Package: dpkg-repack
Version: 1.43
Severity: wishlist
Tags: patch

Playing around with dpkg-repack I noticed that even in the case of
packages where there is no modification that'd make it impossible,
dpkg-repack never generates perfect replicas of the original packages.


With the attached patch, dpkg-repack inspects the installed package's
changelog file for a suitable timestamp for SOURCE_DATE_EPOCH and sets
it if appropriate. With --tag=none, this gives byte-perfect replicas of
the packages I've tested it against unless they had local / config /
post-inst modifications.

I'd envision that a --tag=auto feature go well with that (that adds a
version tag if the md5sums indicate that the package changed), but
that's not implemented in the current patch and I don't know if the
md5sums criterion would be sufficient (eg. to see whether file ownership
was changed in postinst).


-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.12.0 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages dpkg-repack depends on:
ii  libdpkg-perl  1.18.24
ii  perl          5.26.0-5

dpkg-repack recommends no packages.

Versions of packages dpkg-repack suggests:
ii  fakeroot  1.21-3.1

-- no debconf information

-- 
To use raw power is to make yourself infinitely vulnerable to greater powers.
  -- Bene Gesserit axiom
From 782b2e9c90fb6f9ab682bb91b179af46a72f605b Mon Sep 17 00:00:00 2001
From: chrysn <chr...@fsfe.org>
Date: Fri, 4 Aug 2017 17:38:30 +0200
Subject: [PATCH] dpkg calls: Respond to error codes

Contributes-To: https://bugs.debian.org/870724
---
 dpkg-repack | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dpkg-repack b/dpkg-repack
index 920f434..6f65499 100755
--- a/dpkg-repack
+++ b/dpkg-repack
@@ -131,9 +131,9 @@ sub Extract_Status {
     my $inst = Dpkg::Control->new(type => CTRL_FILE_STATUS);
 
     open my $fh, '-|', 'dpkg', "--root=$rootdir/", '-s', $pkgname
-        or Die "Unable to locate $pkgname in the package list.";
+        or Die "Failed to fork dpkg.";
     $inst->parse($fh, "dpkg status for $pkgname");
-    close $fh;
+    close $fh or Die "`dpkg -s` failed (status " . ($? >> 8) . ").";
 
     if ($inst->{Status} !~ m/^\S+\s+\S+\s+installed$/) {
         Die "Package $pkgname not fully installed: $inst->{Status}";
@@ -184,12 +184,12 @@ sub Install_DEBIAN {
 
     my @control_files;
     open my $q_fh, '-|', "dpkg-query --admindir=$rootdir/var/lib/dpkg --control-path $inst->{Package} 2>/dev/null"
-        or Die "dpkg-query failed: $!";
+        or Die "Failed to fork dpkg.";
     while (my $fn = <$q_fh>) {
         chomp $fn;
         push @control_files, $fn;
     }
-    close $q_fh;
+    close $q_fh or Die "`dpkg-query` failed (status " . ($? >> 8) . ").";
 
     foreach my $fn (@control_files) {
         my ($basename) = $fn =~ m/^.*\.(.*?)$/;
@@ -233,7 +233,11 @@ sub Install_Files {
     # it runs with English language output.
     my $lc_all = $ENV{LC_ALL};
     $ENV{LC_ALL} = 'C';
-    my @filelist = split /\n/, qx{dpkg --root=$rootdir/ -L $inst->{Package}};
+    my $filelist = qx{dpkg --root=$rootdir/ -L $inst->{Package}:$inst->{Architecture}};
+    if ($? != 0) {
+        Die "`dpkg -L` failed (status " . ($? >> 8) . ").";
+    }
+    my @filelist = split /\n/, $filelist;
     $ENV{LC_ALL} = $lc_all if defined $lc_all; # important to reset it.
 
     # Set up a hash for easy lookups.
-- 
2.13.2

Attachment: signature.asc
Description: PGP signature

Reply via email to