Просмотр исходного кода

dpkg-genchanges: Fix order of Files field in generated .changes file

Regression introduced in commit e1749d77a44ee1c82c2d047cf9be4b071554832d.

As the code switched to use the list of files to be distributed instead
of the files with checksums, the order changed. Move the code around to
inject the source files first into the distributed files so that we
recover the old behavior, and make it consistent with the Checksums
fields.
Guillem Jover лет назад: 12
Родитель
Сommit
49e2e69055
2 измененных файлов с 75 добавлено и 74 удалено
  1. 2 0
      debian/changelog
  2. 73 74
      scripts/dpkg-genchanges.pl

+ 2 - 0
debian/changelog

@@ -19,6 +19,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     dpkg-architecture and dpkg-vendor.
     dpkg-architecture and dpkg-vendor.
   * Always warn in dpkg-genchanges on missing Section or Priority value,
   * Always warn in dpkg-genchanges on missing Section or Priority value,
     either empty or '-'.
     either empty or '-'.
+  * Fix order of Files field on generated .changes file in dpkg-genchanges.
+    Regression introduced in dpkg 1.17.7.
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 73 - 74
scripts/dpkg-genchanges.pl

@@ -246,7 +246,80 @@ if (defined($prev_changelog) and
         unless $changelog->{'Version'} =~ /~(?:bpo|vola)/;
         unless $changelog->{'Version'} =~ /~(?:bpo|vola)/;
 }
 }
 
 
+# Scan control info of source package
+my $src_fields = $control->get_source();
+foreach (keys %{$src_fields}) {
+    my $v = $src_fields->{$_};
+    if (m/^Source$/) {
+        set_source_package($v);
+    } elsif (m/^Section$|^Priority$/i) {
+        $sourcedefault{$_} = $v;
+    } else {
+        field_transfer_single($src_fields, $fields);
+    }
+}
+
 my $dist = Dpkg::Dist::Files->new();
 my $dist = Dpkg::Dist::Files->new();
+my $origsrcmsg;
+
+if ($include & BUILD_SOURCE) {
+    my $sec = $sourcedefault{'Section'} // '-';
+    my $pri = $sourcedefault{'Priority'} // '-';
+    warning(_g('missing Section for source files')) if $sec eq '-';
+    warning(_g('missing Priority for source files')) if $pri eq '-';
+
+    my $spackage = get_source_package();
+    (my $sversion = $substvars->get('source:Version')) =~ s/^\d+://;
+
+    my $dsc = "${spackage}_${sversion}.dsc";
+    my $dsc_pathname = "$uploadfilesdir/$dsc";
+    my $dsc_fields = Dpkg::Control->new(type => CTRL_PKG_SRC);
+    $dsc_fields->load($dsc_pathname) or error(_g('%s is empty', $dsc_pathname));
+    $checksums->add_from_file($dsc_pathname, key => $dsc);
+    $checksums->add_from_control($dsc_fields, use_files_for_md5 => 1);
+
+    # Compare upstream version to previous upstream version to decide if
+    # the .orig tarballs must be included
+    my $include_tarball;
+    if (defined($prev_changelog)) {
+        my $cur = Dpkg::Version->new($changelog->{'Version'});
+        my $prev = Dpkg::Version->new($prev_changelog->{'Version'});
+        $include_tarball = ($cur->version() ne $prev->version()) ? 1 : 0;
+    } else {
+        # No previous entry means first upload, tarball required
+        $include_tarball = 1;
+    }
+
+    my $ext = compression_get_file_extension_regex();
+    if ((($sourcestyle =~ m/i/ && !$include_tarball) ||
+         $sourcestyle =~ m/d/) &&
+        any { m/\.(?:debian\.tar|diff)\.$ext$/ } $checksums->get_files())
+    {
+        $origsrcmsg = _g('not including original source code in upload');
+        foreach my $f (grep { m/\.orig(-.+)?\.tar\.$ext$/ } $checksums->get_files()) {
+            $checksums->remove_file($f);
+        }
+    } else {
+        if ($sourcestyle =~ m/d/ &&
+            none { m/\.(?:debian\.tar|diff)\.$ext$/ } $checksums->get_files()) {
+            warning(_g('ignoring -sd option for native Debian package'));
+        }
+        $origsrcmsg = _g('including full source code in upload');
+    }
+
+    # Only add attributes for files being distributed.
+    for my $f ($checksums->get_files()) {
+        $dist->add_file($f, $sec, $pri);
+    }
+} elsif ($include == BUILD_ARCH_DEP) {
+    $origsrcmsg = _g('binary-only arch-specific upload ' .
+                     '(source code and arch-indep packages not included)');
+} elsif ($include == BUILD_ARCH_INDEP) {
+    $origsrcmsg = _g('binary-only arch-indep upload ' .
+                     '(source code and arch-specific packages not included)');
+} else {
+    $origsrcmsg = _g('binary-only upload (no source code included)');
+}
 
 
 if ($include & BUILD_BINARY) {
 if ($include & BUILD_BINARY) {
     my $dist_count = 0;
     my $dist_count = 0;
@@ -269,19 +342,6 @@ if ($include & BUILD_BINARY) {
     }
     }
 }
 }
 
 
-# Scan control info of source package
-my $src_fields = $control->get_source();
-foreach (keys %{$src_fields}) {
-    my $v = $src_fields->{$_};
-    if (m/^Source$/) {
-	set_source_package($v);
-    } elsif (m/^Section$|^Priority$/i) {
-	$sourcedefault{$_} = $v;
-    } else {
-        field_transfer_single($src_fields, $fields);
-    }
-}
-
 # Scan control info of all binary packages
 # Scan control info of all binary packages
 foreach my $pkg ($control->get_packages()) {
 foreach my $pkg ($control->get_packages()) {
     my $p = $pkg->{'Package'};
     my $p = $pkg->{'Package'};
@@ -385,67 +445,6 @@ for my $p (keys %p2f) {
     }
     }
 }
 }
 
 
-my $origsrcmsg;
-
-if ($include & BUILD_SOURCE) {
-    my $sec = $sourcedefault{'Section'} // '-';
-    my $pri = $sourcedefault{'Priority'} // '-';
-    warning(_g('missing Section for source files')) if $sec eq '-';
-    warning(_g('missing Priority for source files')) if $pri eq '-';
-
-    my $spackage = get_source_package();
-    (my $sversion = $substvars->get('source:Version')) =~ s/^\d+://;
-
-    my $dsc = "${spackage}_${sversion}.dsc";
-    my $dsc_pathname = "$uploadfilesdir/$dsc";
-    my $dsc_fields = Dpkg::Control->new(type => CTRL_PKG_SRC);
-    $dsc_fields->load($dsc_pathname) or error(_g('%s is empty', $dsc_pathname));
-    $checksums->add_from_file($dsc_pathname, key => $dsc);
-    $checksums->add_from_control($dsc_fields, use_files_for_md5 => 1);
-
-    # Compare upstream version to previous upstream version to decide if
-    # the .orig tarballs must be included
-    my $include_tarball;
-    if (defined($prev_changelog)) {
-	my $cur = Dpkg::Version->new($changelog->{'Version'});
-	my $prev = Dpkg::Version->new($prev_changelog->{'Version'});
-	$include_tarball = ($cur->version() ne $prev->version()) ? 1 : 0;
-    } else {
-	# No previous entry means first upload, tarball required
-	$include_tarball = 1;
-    }
-
-    my $ext = compression_get_file_extension_regex();
-    if ((($sourcestyle =~ m/i/ && !$include_tarball) ||
-	 $sourcestyle =~ m/d/) &&
-	any { m/\.(?:debian\.tar|diff)\.$ext$/ } $checksums->get_files())
-    {
-	$origsrcmsg= _g('not including original source code in upload');
-	foreach my $f (grep { m/\.orig(-.+)?\.tar\.$ext$/ } $checksums->get_files()) {
-	    $checksums->remove_file($f);
-	}
-    } else {
-	if ($sourcestyle =~ m/d/ &&
-	    none { m/\.(?:debian\.tar|diff)\.$ext$/ } $checksums->get_files()) {
-	    warning(_g('ignoring -sd option for native Debian package'));
-	}
-        $origsrcmsg= _g('including full source code in upload');
-    }
-
-    # Only add attributes for files being distributed.
-    for my $f ($checksums->get_files()) {
-        $dist->add_file($f, $sec, $pri);
-    }
-} elsif ($include == BUILD_ARCH_DEP) {
-    $origsrcmsg = _g('binary-only arch-specific upload ' .
-                     '(source code and arch-indep packages not included)');
-} elsif ($include == BUILD_ARCH_INDEP) {
-    $origsrcmsg = _g('binary-only arch-indep upload ' .
-                     '(source code and arch-specific packages not included)');
-} else {
-    $origsrcmsg = _g('binary-only upload (no source code included)');
-}
-
 print { *STDERR } "$Dpkg::PROGNAME: $origsrcmsg\n"
 print { *STDERR } "$Dpkg::PROGNAME: $origsrcmsg\n"
     or syserr(_g('write original source message')) unless $quiet;
     or syserr(_g('write original source message')) unless $quiet;