rev 12925 - scripts

Modestas Vainius modax-guest at alioth.debian.org
Fri Dec 12 22:44:11 UTC 2008


Author: modax-guest
Date: 2008-12-12 22:44:10 +0000 (Fri, 12 Dec 2008)
New Revision: 12925

Modified:
   scripts/dh_installgen
Log:
debian/not-installed verification support

Modified: scripts/dh_installgen
===================================================================
--- scripts/dh_installgen	2008-12-12 22:39:59 UTC (rev 12924)
+++ scripts/dh_installgen	2008-12-12 22:44:10 UTC (rev 12925)
@@ -736,8 +736,10 @@
                     } else {
                         if ($match eq "inst") {
                             push @autoadd, $miss->stripped_dstpath($self->{srcdir});
+                        } else {
+                            # Otherwise the file was defined as missing on purpose
+                            $miss->{st_miss} = 1;
                         }
-                        # Otherwise the file was defined as missing on purpose
                         $miss->{st_found} = 1;
                     }
                 }
@@ -805,30 +807,39 @@
         my $prevline = "";
 
         # Read. Remove non-matching patterns
-        if (-r $file && !$instgen_opts{VALIDATE}) {
+        if (-r $file) {
             open (DH_INSTALL, "<$file") or main::error("cannot read $file: $!");
-            while ($again || ($_ = <DH_INSTALL>)) {
-                if (defined $p && !m/^#/ && m/(?:^|\s+)\Q$p\E(?:\s+|$)/) {
+            if ($instgen_opts{VALIDATE}) {
+                while (<DH_INSTALL>) {
                     my @set = split;
                     if (! defined $dh{AUTODEST} && @set > 1) {
-                        s/((?:^|\s+)\Q$p\E\s*)(?!$)/ /;
-                    } else {
-                        s/((?:^|\s+)\Q$p\E\s*)/ /;
+                        push @lines, $_;
                     }
-                    if (@set == 1 || @set == 2) {
-                        # Move on
-                        $p = shift @$remove;
+                }
+            } else {
+                while ($again || ($_ = <DH_INSTALL>)) {
+                    if (defined $p && !m/^#/ && m/(?:^|\s+)\Q$p\E(?:\s+|$)/) {
+                        my @set = split;
+                        if (! defined $dh{AUTODEST} && @set > 1) {
+                            s/((?:^|\s+)\Q$p\E\s*)(?!$)/ /;
+                        } else {
+                            s/((?:^|\s+)\Q$p\E\s*)/ /;
+                        }
+                        if (@set == 1 || @set == 2) {
+                            # Move on
+                            $p = shift @$remove;
+                        } else {
+                            # Check for another match
+                            $_ = chomp() . "\n";
+                            $again = 1;
+                            next;
+                        }
                     } else {
-                        # Check for another match
-                        $_ = chomp() . "\n";
-                        $again = 1;
-                        next;
+                        push @lines, $_;
                     }
-                } else {
-                    push @lines, $_;
+                    $again = 0;
+                    $prevline = $_;
                 }
-                $again = 0;
-                $prevline = $_;
             }
             close(DH_INSTALL);
         }
@@ -904,6 +915,24 @@
     }
 }
 
+sub get_not_installed {
+    my $file = shift;
+    $file = "debian/not-installed" unless ($file);
+    if (-r $file) {
+        my %notinstalled;
+        open(NOTINSTALLED, $file) or main::error("Unable to $file for reading");
+        while (<NOTINSTALLED>) {
+            if (m/^\.\/(.*)$/) {
+                $notinstalled{$1} = 0;
+            }
+        }
+        close(NOTINSTALLED);
+        return \%notinstalled;
+    } else {
+        return undef;
+    }
+}
+
 # Initialize some data
 foreach my $package (@{$dh{DOPACKAGES}}) {
     $autoremove{$package} = {};
@@ -1002,6 +1031,34 @@
     }
 }
 
+# Verify against missing on purpose files against debian/not-installed
+if (my $notinstalled = get_not_installed("debian/not-installed")) {
+    my @missing_in_notinstalled;
+    my @excess_in_notinstalled;
+    foreach (@missing) {
+        next unless (exists $_->{st_miss});
+        my $filepath = $_->stripped_dstpath($srcdir);
+        if (!exists $notinstalled->{$filepath}) {
+            push @missing_in_notinstalled, $filepath;
+        } else {
+            $notinstalled->{$filepath} = 1;
+        }
+    }
+    foreach (keys %$notinstalled) {
+        push @excess_in_notinstalled, $_ if ($notinstalled->{$_} == 0);
+    }
+
+    if (@missing_in_notinstalled || @excess_in_notinstalled) {
+        warning "debian/not-installed is out of sync:";
+        map { print STDERR "-", $_, "\n" } sort @excess_in_notinstalled;
+        map { print STDERR "+", $_, "\n" } sort @missing_in_notinstalled;
+
+        if (@missing_in_notinstalled && !($instgen_opts{VALIDATE} or $dh{NO_ACT})) {
+            main::error("Aborting, please update debian/not-installed");
+        }
+    }
+}
+
 foreach my $package (@{$dh{DOPACKAGES}}) {
     # Handle *.install files
     my $file=pkgfile($package, "install");




More information about the pkg-kde-commits mailing list