[SCM] Debian package checker branch, master, updated. 2.5.0-rc3-14-g846e0c0
The following commit has been merged in the master branch:
commit 846e0c07118b87808f91291a5af3a1270f1d3dd9
Author: Niels Thykier <niels@thykier.net>
Date: Mon Apr 25 20:45:04 2011 +0200
Added experimental check for duplicate-files
diff --git a/checks/conffiles b/checks/duplicate-files
similarity index 57%
copy from checks/conffiles
copy to checks/duplicate-files
index b9385f6..696abf3 100644
--- a/checks/conffiles
+++ b/checks/duplicate-files
@@ -1,6 +1,6 @@
-# conffiles -- lintian check script -*- perl -*-
+# duplicate-files -- lintian check script -*- perl -*-
-# Copyright (C) 1998 Christian Schwarz
+# Copyright (C) 2011 Niels Thykier
#
# 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
@@ -18,54 +18,41 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
-package Lintian::conffiles;
+package Lintian::duplicate_files;
use strict;
use warnings;
-use Util;
use Lintian::Tags qw(tag);
+use Util;
sub run {
my $pkg = shift;
my $type = shift;
-
-my $cf = 'control/conffiles';
-
-# conffiles?
-unless (-f $cf) {
- return 0;
-}
-
-my %conffiles = ();
-
-open(IN, '<', $cf) or fail("cannot open $cf for reading: $!");
-while (<IN>) {
- chop;
- next if m/^\s*$/;
-
- unless (m,^/,) {
- tag 'relative-conffile', $_;
- $_ = '/' . $_;
- }
- my $file = $_;
- $file =~ s@^/++@@o;
- $conffiles{$file}++;
-
- if ($conffiles{$file} > 1) {
- tag 'duplicate-conffile', $file;
- }
-
- if (m,^/usr/,) {
- tag 'file-in-usr-marked-as-conffile', $file;
+my $info = shift;
+
+my %hashmap;
+
+foreach my $file (@{ $info->sorted_index }){
+ my $md5 = $info->md5sums->{$file};
+ my $fs;
+ next unless defined $md5;
+ next unless $info->index->{$file}->{type} eq '-';
+ next unless $file =~ m@usr/share/doc/@o;
+ $fs = $hashmap{$md5};
+ unless (defined $fs){
+ $fs = [$file];
+ $hashmap{$md5} = $fs;
} else {
- unless (m,^/etc/,) {
- tag 'non-etc-file-marked-as-conffile', $file;
- }
+ push @$fs, $file;
}
+}
+foreach my $hash (keys %hashmap){
+ my @files = @{ $hashmap{$hash} };
+ next if scalar(@files) < 2;
+ tag 'duplicate-files', sort @files;
}
-close(IN);
}
diff --git a/checks/duplicate-files.desc b/checks/duplicate-files.desc
new file mode 100644
index 0000000..5222eca
--- /dev/null
+++ b/checks/duplicate-files.desc
@@ -0,0 +1,14 @@
+Check-Script: duplicate-files
+Author: Niels Thykier <niels@thykier.net>
+Abbrev: dupf
+Type: binary
+Needs-Info: md5sums, index
+Info: This script checks for duplicate files using checksums
+
+Tag: duplicate-files
+Severity: minor
+Certainty: possible
+Experimental: yes
+Info: The package ships the two (or more) files with the exact same
+ contents.
+
diff --git a/debian/changelog b/debian/changelog
index 6b5ebe2..213c4cc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,12 +2,16 @@ lintian (2.5.0~rc4) UNRELEASED; urgency=low
* Summary of tag changes:
+ Added:
+ - duplicate-files
- format-3.0-but-debian-changes-patch
* checks/copyright-file.desc:
+ [ADB] Correct a spelling mistake ("coypright" -> "copyright") in the
description of copyright-refers-to-deprecated-bsd-license-file; thanks,
Kees Cook. (Closes: #623780)
+ * checks/duplicate-files{,.desc}:
+ + [NT] Added to check for duplicate files in usr/share/doc. Thanks to
+ Axel Beckert for the suggestion. (Closes: #614715)
* checks/patch-systems{,.desc}:
+ [NT] Detect when 3.0 (quilt) packages have a debian-changes-VERSION
patch without a patch header. Thanks to Iain Lane for suggestion
diff --git a/t/tests/duplicate-files/debian/debian/docs b/t/tests/duplicate-files/debian/debian/docs
new file mode 100644
index 0000000..d4894cd
--- /dev/null
+++ b/t/tests/duplicate-files/debian/debian/docs
@@ -0,0 +1,6 @@
+doc-file1
+doc-file2
+doc-file3
+doc-file4
+doccy1
+doccy2
diff --git a/t/tests/duplicate-files/debian/doc-file1 b/t/tests/duplicate-files/debian/doc-file1
new file mode 100644
index 0000000..8bebc6c
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doc-file1
@@ -0,0 +1 @@
+hallo world
diff --git a/t/tests/duplicate-files/debian/doc-file2 b/t/tests/duplicate-files/debian/doc-file2
new file mode 100644
index 0000000..8bebc6c
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doc-file2
@@ -0,0 +1 @@
+hallo world
diff --git a/t/tests/duplicate-files/debian/doc-file3 b/t/tests/duplicate-files/debian/doc-file3
new file mode 100644
index 0000000..8bebc6c
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doc-file3
@@ -0,0 +1 @@
+hallo world
diff --git a/t/tests/duplicate-files/debian/doc-file4 b/t/tests/duplicate-files/debian/doc-file4
new file mode 100644
index 0000000..8bebc6c
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doc-file4
@@ -0,0 +1 @@
+hallo world
diff --git a/t/tests/duplicate-files/debian/doccy1 b/t/tests/duplicate-files/debian/doccy1
new file mode 100644
index 0000000..d732961
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doccy1
@@ -0,0 +1 @@
+Hi Haley
diff --git a/t/tests/duplicate-files/debian/doccy2 b/t/tests/duplicate-files/debian/doccy2
new file mode 100644
index 0000000..d732961
--- /dev/null
+++ b/t/tests/duplicate-files/debian/doccy2
@@ -0,0 +1 @@
+Hi Haley
diff --git a/t/tests/duplicate-files/desc b/t/tests/duplicate-files/desc
new file mode 100644
index 0000000..3a8c92d
--- /dev/null
+++ b/t/tests/duplicate-files/desc
@@ -0,0 +1,5 @@
+Testname: duplicate-files
+Sequence: 6000
+Version: 1.0
+Description: Test for duplicate files
+Test-For:
diff --git a/t/tests/duplicate-files/tags b/t/tests/duplicate-files/tags
new file mode 100644
index 0000000..f9a5773
--- /dev/null
+++ b/t/tests/duplicate-files/tags
@@ -0,0 +1,2 @@
+X: duplicate-files: duplicate-files usr/share/doc/duplicate-files/doc-file1 usr/share/doc/duplicate-files/doc-file2 usr/share/doc/duplicate-files/doc-file3 usr/share/doc/duplicate-files/doc-file4
+X: duplicate-files: duplicate-files usr/share/doc/duplicate-files/doccy1 usr/share/doc/duplicate-files/doccy2
--
Debian package checker
Reply to: