[Pkg-javascript-commits] [backbone] 03/05: Extract metadata from images and fonts (not just ignore them) before copyright check. Build-depend on libimage-exiftool-perl, libregexp-assemble-perl, libipc-system-simple-perl and lcdf-typetools.
Jonas Smedegaard
dr at jones.dk
Wed Nov 19 16:43:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master-experimental
in repository backbone.
commit b08d424e203dbeac1e2d025a42c523e7b462556b
Author: Jonas Smedegaard <dr at jones.dk>
Date: Sat May 3 19:12:18 2014 +0200
Extract metadata from images and fonts (not just ignore them) before copyright check. Build-depend on libimage-exiftool-perl, libregexp-assemble-perl, libipc-system-simple-perl and lcdf-typetools.
---
debian/print-metadata.pl | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
debian/rules | 19 ++++++++++++--
2 files changed, 84 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 0aa6532..615864f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -48,8 +48,23 @@ CDBS_RECOMMENDS_$(jspkg) = javascript-common
CDBS_BREAKS_$(nodepkg) = libjs-backbone (<< 0.5.3-3)
CDBS_REPLACES_$(nodepkg) = libjs-backbone (<< 0.5.3-3)
-# Silence images in addition to the default debian files
-DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^docs/images/.*\.(jpg|png)|debian/(changelog|copyright(|_hints|_newhints))$
+# extract metadata from images and fonts 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|jpeg|gif|ttf|otf
+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
DEB_INSTALL_DOCS_ALL += README.md
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list