[dpkg] 153/187: dpkg-gencontrol: Do not update the files list file when printing to STDOUT

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

deki-guest pushed a commit to branch master
in repository dpkg.

commit 2783ac6d21466bb9e448ecbe89c95f8fbafadb92
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Nov 2 01:33:12 2016 +0100

    dpkg-gencontrol: Do not update the files list file when printing to STDOUT
    
    If we are outputting the contents to STDOUT, do not update the
    debian/files file, as we have not generated a control file that will
    allow to build a binary package.
---
 debian/changelog           |  2 ++
 scripts/dpkg-gencontrol.pl | 76 ++++++++++++++++++++++------------------------
 2 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 60dd9b9..513468c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -58,6 +58,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
   * Add new DEB_*_ARCH_ABI and DEB_*_ARCH_LIBC variables to dpkg-architecture
     and architecture.mk Makefile fragment.
   * Do substvar instantiation just once in dpkg-gencontrol.
+  * Fix dpkg-gencontrol to not update the files list file (debian/files)
+    when printing to STDOUT (via -O).
   * Architecture support:
     - Add support for AIX operating system.
     - Add a version pseudo-field to the arch tables.
diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index 7d7386d..dbc6b4f 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -369,52 +369,50 @@ for my $f (keys %remove) {
 
 $fields->apply_substvars($substvars);
 
-if (not $stdout) {
+if ($stdout) {
+    $fields->output(\*STDOUT);
+} else {
     $outputfile //= "$packagebuilddir/DEBIAN/control";
-}
 
-my $sversion = $fields->{'Version'};
-$sversion =~ s/^\d+://;
-$forcefilename //= sprintf('%s_%s_%s.%s', $fields->{'Package'}, $sversion,
-                           $fields->{'Architecture'}, $pkg_type);
-my $section = $fields->{'Section'} || '-';
-my $priority = $fields->{'Priority'} || '-';
-
-# Obtain a lock on debian/control to avoid simultaneous updates
-# of debian/files when parallel building is in use
-my $lockfh;
-my $lockfile = 'debian/control';
-$lockfile = $controlfile if not -e $lockfile;
-
-sysopen($lockfh, $lockfile, O_WRONLY)
-    or syserr(g_('cannot write %s'), $lockfile);
-file_lock($lockfh, $lockfile);
-
-my $dist = Dpkg::Dist::Files->new();
-$dist->load($fileslistfile) if -e $fileslistfile;
-
-foreach my $file ($dist->get_files()) {
-    if (defined $file->{package} &&
-        ($file->{package} eq $fields->{'Package'}) &&
-        ($file->{package_type} eq $pkg_type) &&
-        (debarch_eq($file->{arch}, $fields->{'Architecture'}) ||
-         debarch_eq($file->{arch}, 'all'))) {
-        $dist->del_file($file->{filename});
+    my $sversion = $fields->{'Version'};
+    $sversion =~ s/^\d+://;
+    $forcefilename //= sprintf('%s_%s_%s.%s', $fields->{'Package'}, $sversion,
+                               $fields->{'Architecture'}, $pkg_type);
+    my $section = $fields->{'Section'} || '-';
+    my $priority = $fields->{'Priority'} || '-';
+
+    # Obtain a lock on debian/control to avoid simultaneous updates
+    # of debian/files when parallel building is in use
+    my $lockfh;
+    my $lockfile = 'debian/control';
+    $lockfile = $controlfile if not -e $lockfile;
+
+    sysopen $lockfh, $lockfile, O_WRONLY
+        or syserr(g_('cannot write %s'), $lockfile);
+    file_lock($lockfh, $lockfile);
+
+    my $dist = Dpkg::Dist::Files->new();
+    $dist->load($fileslistfile) if -e $fileslistfile;
+
+    foreach my $file ($dist->get_files()) {
+        if (defined $file->{package} &&
+            ($file->{package} eq $fields->{'Package'}) &&
+            ($file->{package_type} eq $pkg_type) &&
+            (debarch_eq($file->{arch}, $fields->{'Architecture'}) ||
+             debarch_eq($file->{arch}, 'all'))) {
+            $dist->del_file($file->{filename});
+        }
     }
-}
 
-$dist->add_file($forcefilename, $section, $priority);
-$dist->save("$fileslistfile.new");
+    $dist->add_file($forcefilename, $section, $priority);
+    $dist->save("$fileslistfile.new");
 
-rename("$fileslistfile.new", $fileslistfile)
-    or syserr(g_('install new files list file'));
+    rename "$fileslistfile.new", $fileslistfile
+        or syserr(g_('install new files list file'));
 
-# Release the lock
-close($lockfh) or syserr(g_('cannot close %s'), $lockfile);
+    # Release the lock
+    close $lockfh or syserr(g_('cannot close %s'), $lockfile);
 
-if ($stdout) {
-    $fields->output(\*STDOUT);
-} else {
     $fields->save("$outputfile.new");
 
     rename "$outputfile.new", $outputfile

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list