[devscripts] 01/01: licensecheck: warn if scanned file is not a text file (Closes: #791756)
dod at debian.org
dod at debian.org
Thu Jul 9 17:32:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
dod pushed a commit to branch master
in repository devscripts.
commit 3a80a0cf68a5cd05bf583260fc7054200404d9b7
Author: Dominique Dumont <dod at debian.org>
Date: Thu Jul 9 19:32:23 2015 +0200
licensecheck: warn if scanned file is not a text file (Closes: #791756)
---
scripts/licensecheck.pl | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/licensecheck.pl b/scripts/licensecheck.pl
index c991a62..7ed9075 100755
--- a/scripts/licensecheck.pl
+++ b/scripts/licensecheck.pl
@@ -321,13 +321,15 @@ while (@files) {
my $license = '';
# Encode::Guess does not work well, use good old file command to get file encoding
- my $mime = `file -bi $file`;
+ my $mime = `file --brief --mime --dereference $file`;
my $charset ;
- if ($mime =~ /charset=([\w-]+)/) {
- $charset = $1;
+ if ($mime =~ m!text/\w+; charset=([\w-]+)!) {
+ $charset = $1;
}
else {
- die "can't find charset of $file\n";
+ chomp $mime;
+ warn "$0 warning: cannot parse file '$file' with mime type '$mime'\n";
+ next;
}
open (my $F, '<' ,$file) or die "Unable to access $file\n";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list