Przeglądaj źródła

Dpkg::Substvars: Always fix up the source version in set_version_substvars

The caller can explicitly pass both versions, but the source version
might still need to be fixed up, for example in case of legacy binNMUs
(when not using the Binary-Only changelog field), whenever the binary
version has been forced through dpkg-gencontrol, then just comparing
if they are equal will not trigger the fix up, which will produce
bogus source versions, affecting the Source field on binary packages.

Instead, always fix up the source version, regardless of the versions
matching or not.

Regression introduced in commit 094d3a7e61e6fc1f5634d880957d18ed70954a60.

Closes: #690823
Guillem Jover 13 lat temu
rodzic
commit
24495ccdaa
3 zmienionych plików z 11 dodań i 3 usunięć
  1. 3 0
      debian/changelog
  2. 3 2
      scripts/Dpkg/Substvars.pm
  3. 5 1
      scripts/t/750_Dpkg_Substvars.t

+ 3 - 0
debian/changelog

@@ -53,6 +53,9 @@ dpkg (1.16.9) UNRELEASED; urgency=low
     match the implementation.
   * Add two missing 3rd person ‘s’ in dpkg-gensymbols(1). Closes: #689863
     Thanks to Paul Menzel <pm.debian@googlemail.com>.
+  * Fix regression on old-style binNMUs for packages that specify an
+    explicit binary version to dpkg-gencontrol, by always fixing up the
+    source version. Closes: #690823
 
   [ Updated programs translations ]
   * Catalan (Guillem Jover).

+ 3 - 2
scripts/Dpkg/Substvars.pm

@@ -195,8 +195,9 @@ sub set_version_substvars {
     # Handle old function signature taking only one argument.
     $binaryversion ||= $sourceversion;
 
-    # Fallback to manually compute the binary version if they are the same.
-    $sourceversion =~ s/\+b[0-9]+$// if $sourceversion eq $binaryversion;
+    # For backwards compatibility on binNMUs that do not use the Binary-Only
+    # field on the changelog, always fix up the source version.
+    $sourceversion =~ s/\+b[0-9]+$//;
 
     $self->{'vars'}{'binary:Version'} = $binaryversion;
     $self->{'vars'}{'source:Version'} = $sourceversion;

+ 5 - 1
scripts/t/750_Dpkg_Substvars.t

@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-use Test::More tests => 29;
+use Test::More tests => 32;
 
 use strict;
 use warnings;
@@ -60,6 +60,10 @@ $s->set_version_substvars("1:2.3.4~5-6.7.8~nmu9", "1:2.3.4~5-6.7.8~nmu9+bin0");
 is($s->get("binary:Version"), "1:2.3.4~5-6.7.8~nmu9+bin0", "binary:Version");
 is($s->get("source:Version"), "1:2.3.4~5-6.7.8~nmu9", "source:Version");
 is($s->get("source:Upstream-Version"), "1:2.3.4~5", "source:Upstream-Version");
+$s->set_version_substvars("2.3.4~5-6.7.8~nmu9+b1", "1:2.3.4~5-6.7.8~nmu9+b1");
+is($s->get("binary:Version"), "1:2.3.4~5-6.7.8~nmu9+b1", "binary:Version");
+is($s->get("source:Version"), "2.3.4~5-6.7.8~nmu9", "source:Version");
+is($s->get("source:Upstream-Version"), "2.3.4~5", "source:Upstream-Version");
 $s->set_version_substvars("1:2.3.4~5-6.7.8~nmu9+b0");
 is($s->get("binary:Version"), "1:2.3.4~5-6.7.8~nmu9+b0", "binary:Version");
 is($s->get("source:Version"), "1:2.3.4~5-6.7.8~nmu9", "source:Version");