Instead of doing the magic of generating a version string without epoch
and revision and a version string without epoch in
Dpkg::Source::Package, extend Dpkg::Version's as_string function to
support generating that string.
---
 scripts/Dpkg/Source/Package.pm |    6 +-----
 scripts/Dpkg/Version.pm        |   14 +++++++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index 47ea319..e60995d 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -289,11 +289,7 @@ sub get_basename {
         error(_g("source and version are required to compute the source 
basename"));
     }
     my $v = Dpkg::Version->new($f->{'Version'});
-    my $basename = $f->{'Source'} . "_" . $v->version();
-    if ($with_revision and $f->{'Version'} =~ /-/) {
-        $basename .= "-" . $v->revision();
-    }
-    return $basename;
+    return $f->{'Source'} . "_" . $v->as_string(1, !$with_revision);
 }
 
 sub find_original_tarballs {
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
index a113c58..26ee154 100644
--- a/scripts/Dpkg/Version.pm
+++ b/scripts/Dpkg/Version.pm
@@ -21,7 +21,7 @@ package Dpkg::Version;
 use strict;
 use warnings;
 
-our $VERSION = "1.00";
+our $VERSION = "1.01";
 
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
@@ -166,18 +166,22 @@ sub comparison {
     return version_compare_part($a->revision(), $b->revision());
 }
 
-=item "$v", $v->as_string()
+=item "$v", $v->as_string(), $v->as_string($no_epoch), 
$v->as_string($no_epoch, $no_revision)
 
 Returns the string representation of the version number.
 
 =cut
 
 sub as_string {
-    my ($self) = @_;
+    my $self = shift @_;
+    my $no_epoch = shift @_ || '';
+    $no_epoch ||= $self->{no_epoch};
+    my $no_revision = shift @_ || '';
+    $no_revision ||= $self->{no_revision};
     my $str = "";
-    $str .= $self->{epoch} . ":" unless $self->{no_epoch};
+    $str .= $self->{epoch} . ":" unless $no_epoch;
     $str .= $self->{version};
-    $str .= "-" . $self->{revision} unless $self->{no_revision};
+    $str .= "-" . $self->{revision} unless $no_revision;
     return $str;
 }
 
-- 
1.7.10.4



-- 
To UNSUBSCRIBE, email to debian-dpkg-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20130209140331.ga4...@client.brlink.eu

Reply via email to