[ciderwebmail] 01/02: Extract metadata from images for copyright check (instead of skipping them).

Jonas Smedegaard dr at jones.dk
Wed Oct 22 23:03:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch experimental
in repository ciderwebmail.

commit 1f92de173b073bc194ef44ae5a3b3145cac2928c
Author: Jonas Smedegaard <dr at jones.dk>
Date:   Thu Oct 23 00:59:36 2014 +0200

    Extract metadata from images for copyright check (instead of skipping them).
---
 debian/print-metadata.pl | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
 debian/rules             | 21 +++++++++++++--
 2 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/debian/print-metadata.pl b/debian/print-metadata.pl
new file mode 100644
index 0000000..7bd3ba0
--- /dev/null
+++ b/debian/print-metadata.pl
@@ -0,0 +1,67 @@
+#! /usr/bin/perl
+
+# Copyright © 2014 Jonas Smedegaard <dr at jones.dk>
+# Description: Extract copyright/licensing metadata from binary files
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+use IPC::System::Simple;
+use autodie qw(:all);
+use feature 'say';
+use Regexp::Assemble;
+use Image::ExifTool qw(:Public);
+
+BEGIN { $Image::ExifTool::configFile = '' }
+
+my $exifTool = new Image::ExifTool;
+
+my $dispatch = {
+	'.*\.(png|jpg|jpeg|gif|icc)' => sub {
+		my ( $infile, $outfile ) = @_;
+		my $info = $exifTool->ImageInfo($infile, '*Name*', '*Copyright*');
+		open(my $fh, ">>", $outfile);
+		foreach (sort keys %$info) {
+#			print $fh "$_: $$info{$_}\n";
+			my $tagdesc = $exifTool->GetDescription($_);
+			print $fh "$tagdesc: $$info{$_}\n";
+		}
+	},
+	'.*\.(ttf|otf)' => sub {
+		my ( $infile, $outfile ) = @_;
+		system 'sh', '-c',
+			"otfinfo -i '$infile' | egrep 'Copyright|Licens' > '$outfile'";
+	},
+};
+
+my $re = Regexp::Assemble->new( track => 1 )->add( keys %$dispatch );
+
+while( <> ) {
+	chomp;
+	if( $re->match($_) ) {
+		my $infile = $re->mvar(0);
+		my $outfile = "$infile.metadata_dump";
+		if ( -e $outfile ) {
+			say STDERR "ERROR: dumpfile exist: $outfile";
+			say STDERR "       remove or put aside and try again";
+			exit 1;
+		}
+		$dispatch->{ $re->matched }( $infile, $outfile );
+	}
+	else {
+		last if /q/;
+		print "\tignored\n";
+	}
+}
diff --git a/debian/rules b/debian/rules
index b6062e0..1372632 100755
--- a/debian/rules
+++ b/debian/rules
@@ -82,8 +82,25 @@ CDBS_DEPENDS_$(pkg) = $(deps), $(depends)
 CDBS_RECOMMENDS_$(pkg) = $(deps-recommend), $(recommends)
 CDBS_SUGGESTS_$(pkg) = $(suggests)
 
-# silence graphics files (in addition to defaults)
-DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(root/(static/(images/.*|favicon\.ico)|locale/.*\.mo)|debian/(changelog|copyright(|_hints|_newhints)))$
+# copyright check
+#  * extract metadata from images
+#  * skip favicons and gettext MO files
+CDBS_BUILD_DEPENDS +=, libimage-exiftool-perl, libregexp-assemble-perl
+CDBS_BUILD_DEPENDS +=, libipc-system-simple-perl, lcdf-typetools
+local_inspection_regex = png|jpg|jpeg|gif|ttf|otf
+DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^((.*/)?[^/]+\.($(local_inspection_regex)|ico|mo)|debian/(changelog|copyright(|_hints|_newhints)))$$
+debian/stamp-copyright-check: debian/stamp-extract-copyright
+debian/stamp-extract-copyright:
+	find * -type f -regextype posix-extended \
+		-regex '.*\.($(local_inspection_regex))' \
+		-print0 | perl -0 debian/print-metadata.pl
+	touch $@
+pre-build:: clean-extracted-copyright-during-build
+clean-extracted-copyright-during-build: debian/stamp-copyright-check
+	find -type f -name '*.metadata_dump' -delete
+clean::
+	find -type f -name '*.metadata_dump' -delete
+	rm -f debian/stamp-extract-copyright
 
 DEB_INSTALL_EXAMPLES_$(pkg) = ciderwebmail.yml script/update_schema.sh
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/ciderwebmail.git



More information about the Pkg-perl-cvs-commits mailing list