From 24495ccdaab2b3c12f441e70a5d54de7d8c27150 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 18 Oct 2012 03:55:32 +0200 Subject: 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 --- scripts/Dpkg/Substvars.pm | 5 +++-- scripts/t/750_Dpkg_Substvars.t | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index a97a31af5..d01f66320 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/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; diff --git a/scripts/t/750_Dpkg_Substvars.t b/scripts/t/750_Dpkg_Substvars.t index 52d6a05de..04f933444 100644 --- a/scripts/t/750_Dpkg_Substvars.t +++ b/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 . -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"); -- cgit v1.2.3