Subject: [PATCH] Add a version number to the collection scripts which should be bumped when incompatible changes are made to them, instead of bumping the lintian lab version number.

From: Raphael Geissert <[email-masked]>
Date: Wed, 4 Mar 2009 22:56:38 -0600

This, if used properly, should let lintian only re-run collection scripts as
needed.

Some collection scripts were fixed as well, so that they remove any possible
left-over. Although those bugs would not only happen with the new system, there
are more chances to become visible.
---
 collection/changelog-file           |    1 +
 collection/changelog-file.desc      |    2 +-
 collection/copyright-file.desc      |    2 +-
 collection/debfiles.desc            |    2 +-
 collection/debian-readme.desc       |    2 +-
 collection/diffstat                 |    2 ++
 collection/diffstat.desc            |    2 +-
 collection/doc-base-files.desc      |    2 +-
 collection/file-info.desc           |    2 +-
 collection/init.d.desc              |    2 +-
 collection/md5sums.desc             |    2 +-
 collection/menu-files.desc          |    2 +-
 collection/objdump-info.desc        |    2 +-
 collection/override-file.desc       |    2 +-
 collection/scripts.desc             |    2 +-
 collection/source-control-file      |    1 +
 collection/source-control-file.desc |    2 +-
 collection/strings.desc             |    2 +-
 frontend/lintian                    |    6 ++++--
 19 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/collection/changelog-file b/collection/changelog-file
index 4e3b03d..49d5f8e 100755
--- a/collection/changelog-file
+++ b/collection/changelog-file
@@ -93,6 +93,7 @@ if (not defined $chl) {
 
 # Extract NEWS.Debian files as well, with similar precautious.  Ignore any
 # symlinks to other packages here; in that case, we just won't check the file.
+unlink('NEWS.Debian');
 my $news = "unpacked/usr/share/doc/$pkg/NEWS.Debian.gz";
 if (-f $news) {
     if (-l $news) {
diff --git a/collection/changelog-file.desc b/collection/changelog-file.desc
index bdb47b6..66af738 100644
--- a/collection/changelog-file.desc
+++ b/collection/changelog-file.desc
@@ -5,5 +5,5 @@ Info: This script copies the <tt>changelog</tt> file and
  directory.
 Type: binary
 Unpack-Level: 2
-Output: changelog
+Version: 1
 Order: 1
diff --git a/collection/copyright-file.desc b/collection/copyright-file.desc
index 7e6ae2a..47ed372 100644
--- a/collection/copyright-file.desc
+++ b/collection/copyright-file.desc
@@ -4,5 +4,5 @@ Info: This script copies the "copyright" file of a package into the
  lintian directory.
 Type: binary
 Unpack-Level: 2
-Output: copyright
+Version: 1
 Order: 1
diff --git a/collection/debfiles.desc b/collection/debfiles.desc
index 0caf69b..316b542 100644
--- a/collection/debfiles.desc
+++ b/collection/debfiles.desc
@@ -4,5 +4,5 @@ Info: This script collects files shipped in the source of the
  package.
 Type: source
 Unpack-Level: 2
-Output: debfiles
+Version: 1
 Order: 1
diff --git a/collection/debian-readme.desc b/collection/debian-readme.desc
index bf92191..af28493 100644
--- a/collection/debian-readme.desc
+++ b/collection/debian-readme.desc
@@ -3,5 +3,5 @@ Author: Richard Braakman <[email-masked]>
 Info: This script copies the 'README.Debian' file of a package into the lintian directory.
 Type: binary
 Unpack-Level: 2
-Output: README.Debian
+Version: 1
 Order: 1
diff --git a/collection/diffstat b/collection/diffstat
index 9d07ef3..9fe66ae 100755
--- a/collection/diffstat
+++ b/collection/diffstat
@@ -39,6 +39,8 @@ open (V, '<', "fields/version") or fail("cannot open fields/version: $!");
 my $ver = <V>; chomp $ver;
 close V;
 
+unlink('debian-patch');
+
 $ver =~ s/^\d://; #Remove epoch for this
 
 my $diff_file = "${pkg}_${ver}.diff.gz";
diff --git a/collection/diffstat.desc b/collection/diffstat.desc
index 2a6ad70..d250dbe 100644
--- a/collection/diffstat.desc
+++ b/collection/diffstat.desc
@@ -4,5 +4,5 @@ Info: This script extracts the Debian diff of a source package, and runs
  diffstat on it, leaving the result in the diffstat output file
 Type: source
 Unpack-Level: 1
-Output: diffstat
+Version: 1
 Order: 1
diff --git a/collection/doc-base-files.desc b/collection/doc-base-files.desc
index fbe5d7e..71fabca 100644
--- a/collection/doc-base-files.desc
+++ b/collection/doc-base-files.desc
@@ -4,5 +4,5 @@ Info: This script copies the contents of /usr/share/doc-base into the
  lintian doc-base/ directory.
 Type: binary
 Unpack-Level: 2
-Output: doc-base
+Version: 1
 Order: 1
diff --git a/collection/file-info.desc b/collection/file-info.desc
index cbe68e6..08e513e 100644
--- a/collection/file-info.desc
+++ b/collection/file-info.desc
@@ -3,5 +3,5 @@ Author: Richard Braakman <[email-masked]>
 Info: This script runs the "file" command over all files of any kind of package.
 Type: binary, udeb, source
 Unpack-Level: 2
-Output: file-info
+Version: 1
 Order: 1
diff --git a/collection/init.d.desc b/collection/init.d.desc
index 1901cda..ccc4c6c 100644
--- a/collection/init.d.desc
+++ b/collection/init.d.desc
@@ -4,5 +4,5 @@ Info: This script copies the "etc/init.d" directory into the lintian
  directory.
 Type: binary
 Unpack-Level: 2
-Output: init.d
+Version: 1
 Order: 1
diff --git a/collection/md5sums.desc b/collection/md5sums.desc
index 74f0fa8..4e5e52f 100644
--- a/collection/md5sums.desc
+++ b/collection/md5sums.desc
@@ -3,5 +3,5 @@ Author: Richard Braakman <[email-masked]>
 Info: This script runs the "md5sums" over all files in a binary package.
 Type: binary, udeb
 Unpack-Level: 2
-Output: md5sums
+Version: 1
 Order: 1
diff --git a/collection/menu-files.desc b/collection/menu-files.desc
index 2f87589..33dbed0 100644
--- a/collection/menu-files.desc
+++ b/collection/menu-files.desc
@@ -3,5 +3,5 @@ Author: Richard Braakman <[email-masked]>
 Info: This script copies the contents of /usr/lib/menu into the lintian menu/ directory.
 Type: binary
 Unpack-Level: 2
-Output: menu
+Version: 1
 Order: 1
diff --git a/collection/objdump-info.desc b/collection/objdump-info.desc
index e25ef50..c0b7321 100644
--- a/collection/objdump-info.desc
+++ b/collection/objdump-info.desc
@@ -4,6 +4,6 @@ Info: This script runs "objdump" over all binaries and object files of a
  binary package.
 Type: binary, udeb
 Unpack-Level: 2
-Output: objdump-info
+Version: 1
 Order: 2
 Needs-Info: file-info
diff --git a/collection/override-file.desc b/collection/override-file.desc
index 722a3be..ff1e744 100644
--- a/collection/override-file.desc
+++ b/collection/override-file.desc
@@ -4,5 +4,5 @@ Info: This script copies the "override" file of a package into the lintian
  directory.
 Type: binary, udeb, source
 Unpack-Level: 2
-Output: override
+Version: 1
 Order: 1
diff --git a/collection/scripts.desc b/collection/scripts.desc
index e5771ec..3469335 100644
--- a/collection/scripts.desc
+++ b/collection/scripts.desc
@@ -7,5 +7,5 @@ Info: This script scans a binary package for scripts that start with #! and
  because linux only looks at the first word when executing a script.
 Type: binary, udeb
 Unpack-Level: 2
-Output: scripts
+Version: 1
 Order: 1
diff --git a/collection/source-control-file b/collection/source-control-file
index 42d36ab..c98d18b 100755
--- a/collection/source-control-file
+++ b/collection/source-control-file
@@ -34,6 +34,7 @@ use Util;
 my @control_data = read_dpkg_control("debfiles/control");
 shift @control_data; # we don't need the source information
 
+delete_dir('control');
 mkdir "control", 0777  or fail( "can't create dir control: $!" );
 
 foreach (@control_data) {
diff --git a/collection/source-control-file.desc b/collection/source-control-file.desc
index f6c881d..a8127d2 100644
--- a/collection/source-control-file.desc
+++ b/collection/source-control-file.desc
@@ -3,6 +3,6 @@ Author: Frank Lichtenheld <[email-masked]>
 Info: Collects information about binary packages from debian/control in source packages
 Type: source
 Unpack-Level: 1
-Output: control
+Version: 1
 Order: 2
 Needs-Info: debfiles
diff --git a/collection/strings.desc b/collection/strings.desc
index e0f68ef..12f36d9 100644
--- a/collection/strings.desc
+++ b/collection/strings.desc
@@ -4,6 +4,6 @@ Info: This script runs the "strings" command over all files of a binary
  package.
 Type: binary, udeb
 Unpack-Level: 2
-Output: elf-index
+Version: 1
 Order: 2
 Needs-Info: file-info
diff --git a/frontend/lintian b/frontend/lintian
index 7505b1b..d9c70b8 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1088,8 +1088,8 @@ for my $f (readdir COLLDIR) {
     $p->{'type'} = "$s$b$u";
 
     set_value($f,$p,'unpack-level',$secs[0],1);
-    set_value($f,$p,'output',$secs[0],1);
     set_value($f,$p,'order',$secs[0],1);
+    set_value($f,$p,'version',$secs[0],1);
 
     if (exists $secs[0]->{'needs-info'} && defined $secs[0]->{'needs-info'}) {
 	for (split(/\s*,\s*/o,$secs[0]->{'needs-info'})) {
@@ -1439,7 +1439,8 @@ foreach my $pkg_info ($schedule->get_all) {
 	    next unless ($ci->{'type'} =~ m/$type/);
 
 	    # info already available?
-	    next if (-e "$base/$ci->{'output'}");
+	    next if (-l "$base/.${coll}$ci->{'version'}");
+	    system('sh', '-c', 'rm -f '."'$base'/.${coll}*");
 
 	    # unpack to desired unpack level (if necessary)
 	    $act_unpack_level = unpack_pkg($type,$base,$file,$act_unpack_level,$ci->{'unpack-level'});
@@ -1467,6 +1468,7 @@ foreach my $pkg_info ($schedule->get_all) {
 		$exit_code = 2;
 		next PACKAGE;
 	    }
+	    symlink $$, ".${coll}$ci->{'version'}";
 	}
     }