diff -Nru dpkg-repack-1.36/debian/changelog dpkg-repack-1.37/debian/changelog --- dpkg-repack-1.36/debian/changelog 2011-10-08 04:09:24.000000000 +0000 +++ dpkg-repack-1.37/debian/changelog 2011-12-06 16:21:11.000000000 +0000 @@ -1,3 +1,13 @@ +dpkg-repack (1.37) unstable; urgency=low + + * Fix generation of conffiles list file. For some reason dpkg-query + does not list this file, so it has to be generated when there's a + Conffiles stanza in the package status. Closes: #651165 + * Remove the Conffiles stanza from the generated package's control file; + dpkg ignores it anyway. + + -- Joey Hess Tue, 06 Dec 2011 12:20:13 -0400 + dpkg-repack (1.36) unstable; urgency=low * Fix check for non-installed packages to not misfire on a package that diff -Nru dpkg-repack-1.36/dpkg-repack dpkg-repack-1.37/dpkg-repack --- dpkg-repack-1.36/dpkg-repack 2011-10-08 04:07:33.000000000 +0000 +++ dpkg-repack-1.37/dpkg-repack 2011-12-06 16:18:33.000000000 +0000 @@ -20,7 +20,7 @@ use strict; use File::stat; use vars qw($error_flag $dirty_flag $build_dir $arch $rootdir $packagename - $generate @control_files); + $generate); sub Syntax { print STDERR <$build_dir/DEBIAN/control") || Die "Can't write to $build_dir/DEBIAN/control"; - print CONTROL $control; + + my $control; + my $skip=0; + foreach (@control) { + # Remove the Conffiles stanza + if (/^(\S+):/) { + $skip = lc $1 eq "conffiles"; + } + print CONTROL "$_\n" unless $skip; + } + close CONTROL; SafeSystem "chown","0:0","$build_dir/DEBIAN/control",""; } @@ -134,33 +144,35 @@ # Install all the files in the DEBIAN directory. (Except control file and # file list file.) sub Install_DEBIAN { + my @conffiles=@_; + + my @control_files; + open (Q, "dpkg-query --admindir=$rootdir/var/lib/dpkg --control-path $packagename 2>/dev/null |") || die "dpkg-query failed: $!"; + while (my $fn=) { + chomp $fn; + push @control_files, $fn; + } + close Q; + foreach my $fn (@control_files) { my ($basename)=$fn=~m/^.*\.(.*?)$/; - if ($basename eq 'conffiles') { - # If the conffiles file lists conffiles that are - # not present on the file system, and so were not - # copied to the build tree, dpkg-deb would cmplain - # and abort the build. So check the list of - # conffiles. - open (CONFFILES, $fn) || Die "$fn: $!"; - open (OUT, ">$build_dir/DEBIAN/$basename") || Die "write conffiles: $!"; - while () { - chomp; - if (-e "$build_dir/$_" || -l "$build_dir/$_") { - print OUT "$_\n"; - } - else { - Warn "Skipping missing conffile: $_"; - } - } - close OUT; - close CONFFILES; - SafeSystem "chown","0:0","$build_dir/DEBIAN/$basename", ""; - } - elsif ($basename ne 'list') { + if ($basename ne 'list' && $basename ne 'conffiles') { SafeSystem "cp","-p",$fn,"$build_dir/DEBIAN/$basename",""; } } + + # Conffiles have to be handled specially, because + # dpkg-query --control-path does not list the conffiles file. + # Also, we need to generate one that only control conffiles + # that are still present on the filesystem. + if (@conffiles) { + open (OUT, ">$build_dir/DEBIAN/conffiles") || Die "write conffiles: $!"; + foreach (@conffiles) { + print OUT "$_\n"; + } + close OUT; + SafeSystem "chown","0:0","$build_dir/DEBIAN/conffiles", ""; + } } # This looks at the list of files in this package, and places them @@ -170,7 +182,7 @@ # There are two types of conffiles. Obsolete conffiles should be # skipped, while other conffiles should be included if present. - my @conffiles; + my @conffiles=(); my @obsolete_conffiles; my $in_conffiles=0; foreach my $line (split /\n/,$control) { @@ -256,6 +268,8 @@ SafeSystem "cp","-pd",$fn,"$build_dir/$origfn",""; } } + + return @conffiles; } # Parse parameters. @@ -280,13 +294,6 @@ } foreach $packagename (@ARGV) { - open (Q, "dpkg-query --admindir=$rootdir/var/lib/dpkg --control-path $packagename 2>/dev/null |") || die "dpkg-query failed: $!"; - while (my $fn=) { - chomp $fn; - push @control_files, $fn; - } - close Q; - my $control=Extract_Control(); if (!$control) { Die "Unable to locate $packagename in the package list." } @@ -296,8 +303,8 @@ # Generate the directory tree. Make_Dirs(); - Install_Files($control); - Install_DEBIAN(); + my @conffiles=Install_Files($control); + Install_DEBIAN(@conffiles); Install_Control($control); # Stop here?