[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/02: Use Lintian::Data for compressed file extension



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

broucaries-guest pushed a commit to branch master
in repository lintian.

commit db2dab8b714f0b3ab32486ca9994eed969e32e6f
Author: Bastien ROUCARIÈS <roucaries.bastien@gmail.com>
Date:   Sun Dec 22 14:56:08 2013 +0100

    Use Lintian::Data for compressed file extension
    
    Less code more data. Be more consistant about extension.
    
    Signed-off-by: Bastien ROUCARIÈS <roucaries.bastien+debian@gmail.com>
---
 checks/files.pm                       | 26 +++++++++++++++++++++++---
 data/files/compressed-file-extensions |  8 ++++++++
 debian/changelog                      |  1 +
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/checks/files.pm b/checks/files.pm
index a9692e7..c205870 100644
--- a/checks/files.pm
+++ b/checks/files.pm
@@ -37,7 +37,7 @@ my $TRIPLETS = Lintian::Data->new('files/triplets', qr/\s++/);
 my $LOCALE_CODES = Lintian::Data->new('files/locale-codes', qr/\s++/);
 my $INCORRECT_LOCALE_CODES
   = Lintian::Data->new('files/incorrect-locale-codes', qr/\s++/);
-my $MULTIARCH_DIRS= Lintian::Data->new('common/multiarch-dirs', qr/\s++/,
+my $MULTIARCH_DIRS = Lintian::Data->new('common/multiarch-dirs', qr/\s++/,
     sub { return { 'dir' => $_[1], 'match' => qr/\Q$_[1]\E/ } });
 
 my $PRIVACY_BREAKER_WEBSITES
@@ -48,6 +48,26 @@ my $PRIVACY_BREAKER_FRAGMENTS
   = Lintian::Data->new('files/privacy-breaker-fragments',
     qr/\s*\~\~/o,sub { return qr/$_[1]/ism });
 
+my $COMPRESS_FILE_EXTENSIONS
+  = Lintian::Data->new('files/compressed-file-extensions',
+    qr/s++/,sub { return qr/\Q$_[0]\E/ });
+
+# an OR (|) regex of all compressed extension
+my $COMPRESS_FILE_EXTENSIONS_OR_ALL = sub { qr/$_[0]/ }
+  ->(
+    join(
+        '|',
+        map($COMPRESS_FILE_EXTENSIONS->value($_),
+            $COMPRESS_FILE_EXTENSIONS->all)));
+
+# see tag duplicated-compressed-file
+my $DUPLICATED_COMPRESSED_FILE_REGEX
+  = qr/^(.+)\.(?:$COMPRESS_FILE_EXTENSIONS_OR_ALL)$/;
+
+# see tag compressed-symlink-with-wrong-ext
+my $COMPRESSED_SYMLINK_POINTING_TO_COMPRESSED_REGEX
+  = qr/\.($COMPRESS_FILE_EXTENSIONS_OR_ALL)\s*$/;
+
 # A list of known packaged Javascript libraries
 # and the packages providing them
 my @jslibraries = (
@@ -1385,7 +1405,7 @@ sub run {
             }
 
             # --------------- compressed + uncompressed files
-            if ($file =~ m,^(.+)\.(?:gz|bz2|xz|zip)$,) {
+            if ($file =~ $DUPLICATED_COMPRESSED_FILE_REGEX) {
                 tag 'duplicated-compressed-file', $file
                   if $info->file_info($1);
             }
@@ -1658,7 +1678,7 @@ sub run {
             }
           NEXT_LINK:
 
-            if ($link =~ m,\.(gz|[zZ]|bz|bz2|tgz|zip|xz)\s*$,) {
+            if ($link =~ $COMPRESSED_SYMLINK_POINTING_TO_COMPRESSED_REGEX) {
                 # symlink is pointing to a compressed file
 
                 # symlink has correct extension?
diff --git a/data/files/compressed-file-extensions b/data/files/compressed-file-extensions
new file mode 100644
index 0000000..05e8e3a
--- /dev/null
+++ b/data/files/compressed-file-extensions
@@ -0,0 +1,8 @@
+# list of compressed file extension
+# please alpha sort
+bz
+bz2
+gz
+tgz
+z
+Z
diff --git a/debian/changelog b/debian/changelog
index c334e20..ef54f26 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ lintian (2.5.21) UNRELEASED; urgency=medium
 
   * checks/files.{desc.pm}:
     + [BR] Add xz and zip to duplicated-compressed-file regexp.
+    + [BR] Use Lintian::Data for compressed file extension.
 
   * debian/control:
     + [NT] Add relevant relations on libyaml-perl, which is

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: