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

[SCM] Debian package checker branch, master, updated. 2.5.1-27-g8b9cc6b



The following commit has been merged in the master branch:
commit 8b9cc6b10674a952d7942f286f4156017fdb281b
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Jul 1 10:26:31 2011 +0200

    Added check for lengths of filenames in packages

diff --git a/checks/filename-length b/checks/filename-length
new file mode 100644
index 0000000..0cff5b7
--- /dev/null
+++ b/checks/filename-length
@@ -0,0 +1,93 @@
+# filename-length -- lintian check script -*- perl -*-
+
+# Copyright (C) 2011 Niels Thykier <niels@thykier.net>
+#
+# 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 2 of the License, 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, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::filename_length;
+use strict;
+use warnings;
+
+use Lintian::Tags qw(tag);
+
+use constant FILENAME_LENGTH_LIMIT => 80;
+
+# We could derive this from data/fields/architectures, but that
+# contains things like kopensolaris-sparc64 and kfreebsd-sparc64,
+# neither of which Debian offically supports.
+use constant LONGEST_ARCHITECTURE => length 'kfreebsd-amd64';
+
+sub run {
+
+my $pkg = shift;
+my $type = shift;
+my $info = shift;
+my $proc = shift;
+# pkg_version(_arch)?.type
+# - here we pay for length of "name_version"
+my $len = length($pkg) + length($proc->pkg_version) + 1;
+my $extra;
+
+if ($type eq 'binary' || $type eq 'source'){
+    # Here we add length .deb / .dsc (in both cases +4)
+    $len += 4;
+} else {
+    # .udeb, thats a +5
+    $len += 5;
+}
+
+if ($type ne 'source') {
+    # non-src pkgs have architecture as well
+    if ($proc->pkg_arch ne 'all'){
+        my $real = $len + 1 + length($proc->pkg_arch);
+        $len  += 1 + LONGEST_ARCHITECTURE;
+        $extra = "$real ($len)";
+    } else {
+        # _all has length 4
+        $len += 4;
+    }
+}
+$extra = $len unless defined $extra;
+
+tag 'package-has-long-file-name', "$extra > ". FILENAME_LENGTH_LIMIT
+    if $len > FILENAME_LENGTH_LIMIT;
+
+return if $type ne 'source';
+
+# Reset to work with elements of the dsc file.
+$len = 0;
+
+foreach my $entry (split m/\n/o, $info->field('files')){
+    my $filename;
+    my $flen;
+    $entry =~ s/^\s++//o;
+    next unless $entry;
+    (undef, undef, $filename) = split m/\s++/o, $entry;
+    next unless $filename;
+    $flen = length($filename);
+    $len = $flen if ($flen > $len);
+}
+
+if ($len > FILENAME_LENGTH_LIMIT){
+    tag 'source-package-component-has-long-file-name', "$len > " . FILENAME_LENGTH_LIMIT;
+}
+
+
+}
+
+1;
+
diff --git a/checks/filename-length.desc b/checks/filename-length.desc
new file mode 100644
index 0000000..97686d6
--- /dev/null
+++ b/checks/filename-length.desc
@@ -0,0 +1,33 @@
+Check-Script: filename-length
+Author: Niels Thykier <niels@thykier.net>
+Abbrev: flen
+Type: source, binary, udeb
+Needs-info: fields
+Info: This script checks for long package file names
+
+Tag: package-has-long-file-name
+Severity: normal
+Certainty: certain
+Info: The package has a very long package name.  This may complicate
+ shipping the package on some media such as CDs, where the filename
+ length may be limited.
+ .
+ For architecture dependent package names, the number in the brackets
+ represents the filename length on of the package on the architecture
+ with the longest name known to Lintian.
+ .
+ The tag is emitted based on the longest architecture rather than the
+ current architecture.
+Ref: http://lists.debian.org/debian-devel/2011/03/msg00943.html
+
+Tag: source-package-component-has-long-file-name
+Severity: normal
+Certainty: certain
+Info: The source package has a component with a very long filename.
+ This may complicate shipping the package on some media such as CDs,
+ where the filename length may be limited.
+ .
+ Note for architecture dependent packages, this will tag will be
+ triggered for the longest architecture known.
+Ref: http://lists.debian.org/debian-devel/2011/03/msg00943.html
+
diff --git a/debian/changelog b/debian/changelog
index 3685061..5a3c411 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,10 @@
 lintian (2.5.2) UNRELEASED; urgency=low
 
+  * Summary of tag changes:
+    + Added:
+      - package-has-long-file-name
+      - source-package-component-has-long-file-name
+
   * checks/binaries:
     + [NT] Added lib/${MULTIARCH_DIR} to the list of paths to
       check for public shared libraries.  Thanks to Sven Joachim
@@ -21,6 +26,9 @@ lintian (2.5.2) UNRELEASED; urgency=low
       a Makefile variable is used to choose between dh_python2
       and dh_python3.  Thanks to Leonid Borisenko for the report.
       (Closes: #631662)
+  * checks/filename-length{,.desc}:
+    + [NT] New file that checks the length of the package file
+      names.  (Closes: #631656)
   * checks/files:
     + [NT] Check for embedded copies of the underscore javascript
       library.  Thanks to Jakub Wilk for report and the patch.
diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile
index c8a9b1f..b856c33 100644
--- a/profiles/debian/main.profile
+++ b/profiles/debian/main.profile
@@ -4,8 +4,8 @@ Extends: debian/ftp-master-auto-reject
 Enable-Tags-From-Check: binaries, changelog-file, changes-file, circular-deps, conffiles,
  control-file, control-files, copyright-file, cruft, deb-format, debconf,
  debhelper, debian-readme, debian-source-dir, description, duplicate-files,
- etcfiles, fields, files, huge-usr-share, infofiles, init.d, java, lintian,
- manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems, po-debconf,
- rules, scripts, shared-libs, standards-version, symlinks, version-substvars,
- watch-file
+ etcfiles, fields, filename-length, files, huge-usr-share, infofiles, init.d,
+ java, lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
+ po-debconf, rules, scripts, shared-libs, standards-version, symlinks,
+ version-substvars, watch-file
 
diff --git a/t/tests/filename-length-really-really-really-really-long-package-name/desc b/t/tests/filename-length-really-really-really-really-long-package-name/desc
new file mode 100644
index 0000000..cd6e47b
--- /dev/null
+++ b/t/tests/filename-length-really-really-really-really-long-package-name/desc
@@ -0,0 +1,9 @@
+Testname: filename-length-really-really-really-really-long-package-name
+Sequence: 6000
+Version: 1.0.and.a.really.long.version.too-1
+Type: non-native
+Description: General length of package file names
+Test-For:
+ package-has-long-file-name
+ source-package-component-has-long-file-name
+
diff --git a/t/tests/filename-length-really-really-really-really-long-package-name/tags b/t/tests/filename-length-really-really-really-really-long-package-name/tags
new file mode 100644
index 0000000..1838caa
--- /dev/null
+++ b/t/tests/filename-length-really-really-really-really-long-package-name/tags
@@ -0,0 +1,3 @@
+W: filename-length-really-really-really-really-long-package-name source: package-has-long-file-name 101 > 80
+W: filename-length-really-really-really-really-long-package-name source: source-package-component-has-long-file-name 107 > 80
+W: filename-length-really-really-really-really-long-package-name: package-has-long-file-name 105 > 80
diff --git a/t/tests/filename-length-really-really-really-really-long-package-name/upstream/README b/t/tests/filename-length-really-really-really-really-long-package-name/upstream/README
new file mode 100644
index 0000000..595fc74
--- /dev/null
+++ b/t/tests/filename-length-really-really-really-really-long-package-name/upstream/README
@@ -0,0 +1,2 @@
+"A shallow carrying a coconut?"
+ - Monthy Python and the Holy Grail

-- 
Debian package checker


Reply to: