2
0

version-omit_revision.pl 480 B

12345678910111213141516171819202122
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Dpkg::Version;
  5. my $version;
  6. open(my $fh, '-|', 'dpkg-parsechangelog -S version') or die "Failed to execute dpkg-parsechangelog: $!";
  7. {
  8. local $/;
  9. $version = <$fh>;
  10. }
  11. close $fh;
  12. $version =~ s/\s+$//;
  13. die "No version found or empty output from dpkg-parsechangelog" unless defined $version and $version ne '';
  14. my $v = Dpkg::Version->new($version);
  15. my $vs = $v->as_string(omit_epoch => 1, omit_revision => 1);
  16. print "$vs\n";