Explorar o código

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.
Guillem Jover %!s(int64=9) %!d(string=hai) anos
pai
achega
2783ac6d21
Modificáronse 2 ficheiros con 39 adicións e 39 borrados
  1. 2 0
      debian/changelog
  2. 37 39
      scripts/dpkg-gencontrol.pl

+ 2 - 0
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.

+ 37 - 39
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