[SCM] calf/master: Extract metadata from images before copyright check. Build-depend on libimage-exiftool-perl libregexp-assemble-perl libipc-system-simple-perl lcdf-typetools.

js at users.alioth.debian.org js at users.alioth.debian.org
Mon Feb 22 09:44:13 UTC 2016


The following commit has been merged in the master branch:
commit 57521b00214de10abef30102bdf98d6b0cf8c4af
Author: Jonas Smedegaard <dr at jones.dk>
Date:   Sun Sep 14 15:24:26 2014 +0200

    Extract metadata from images before copyright check. Build-depend on libimage-exiftool-perl libregexp-assemble-perl libipc-system-simple-perl lcdf-typetools.

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 dbdf6ad..5fe4f23 100755
--- a/debian/rules
+++ b/debian/rules
@@ -41,6 +41,24 @@ DEB_CONFIGURE_EXTRA_FLAGS += --enable-experimental
 # Avoid useless linking
 LDFLAGS += -Wl,--as-needed
 
+# extract metadata from images before copyright check
+CDBS_BUILD_DEPENDS +=, libimage-exiftool-perl, libregexp-assemble-perl
+CDBS_BUILD_DEPENDS +=, libipc-system-simple-perl, lcdf-typetools
+local_inspection_regex = png|jpg
+DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^((.*/)?[^/]+\.($(local_inspection_regex))|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
+
 # put aside upstream-shipped temp files during build but after copyright-check
 DEB_UPSTREAM_CRUFT_MOVE = calf.desktop configure INSTALL
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list