[devscripts] 02/02: debsnap: Allow specifying version ranges with --first/--last options
James McCoy
jamessan at debian.org
Sat Mar 5 02:17:32 UTC 2016
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit 9c35a4987d4d83b67c825307aeba3397a820c117
Author: James McCoy <jamessan at debian.org>
Date: Fri Mar 4 21:16:22 2016 -0500
debsnap: Allow specifying version ranges with --first/--last options
Closes: #675867
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 2 ++
scripts/debsnap.1 | 12 ++++++++++++
scripts/debsnap.pl | 51 +++++++++++++++++++++++++++++++++++++++++----------
3 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index ecf3b6b..c18490b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,8 @@ devscripts (2.16.2) UNRELEASED; urgency=medium
* debsnap:
+ Only make the destination directory if there is something to download.
(Closes: #816022)
+ + Add --first & --last options to define a range of versions to download.
+ Based on a patch by Ivo De Decker. (Closes: #675867)
* uscan:
+ Fix typo in dirversionmangle help. (Closes: #816231)
* grep-excuses:
diff --git a/scripts/debsnap.1 b/scripts/debsnap.1
index c54b0d9..217c1ac 100644
--- a/scripts/debsnap.1
+++ b/scripts/debsnap.1
@@ -55,6 +55,18 @@ This can be given multiple times in order to download binary packages for
multiple architectures.
.TP
+.B \-\-first
+Specify the minimum version of a package which will be downloaded. Any
+versions which compare larger than this, according to \fBdpkg\fP, will be
+considered for download. May be used in combination with \fB\-\-last\fP.
+
+.TP
+.B \-\-last
+Specify the maximum version of a package which will be downloaded. Any package
+versions which compare less than this, according to \fBdpkg\fP, will be
+considered for download. May be used in combination with \fB\-\-first\fP.
+
+.TP
.BR \-h ", " \-\-help
Show a summary of these options.
diff --git a/scripts/debsnap.pl b/scripts/debsnap.pl
index 6ebd8b2..50749fb 100755
--- a/scripts/debsnap.pl
+++ b/scripts/debsnap.pl
@@ -47,7 +47,9 @@ my %config_vars = ();
my %opt = (architecture => []);
my $package = '';
-my $pkgversion = '';
+my $pkgversion;
+my $firstversion;
+my $lastversion;
my $warnings = 0;
sub fatal($);
@@ -187,13 +189,34 @@ sub verbose($)
print "$msg" if $opt{verbose};
}
+sub keep_version($)
+{
+ my $version = shift;
+ if (defined $pkgversion) {
+ return version_compare_relation($pkgversion, REL_EQ, $version);
+ }
+ if (defined $firstversion) {
+ if ($firstversion > $version) {
+ verbose "skip version $version: older than first";
+ return 0;
+ }
+ }
+ if (defined $lastversion) {
+ if ($lastversion < $version) {
+ verbose "skip version $version: newer than last";
+ return 0;
+ }
+ }
+ return 1;
+}
+
###
# Main program
###
read_conf(@ARGV);
Getopt::Long::Configure('gnu_compat');
Getopt::Long::Configure('no_ignore_case');
-GetOptions(\%opt, 'verbose|v', 'destdir|d=s', 'force|f', 'help|h', 'version', 'binary', 'architecture|a=s@') || usage(1);
+GetOptions(\%opt, 'verbose|v', 'destdir|d=s', 'force|f', 'help|h', 'version', 'first=s', 'last=s', 'binary', 'architecture|a=s@') || usage(1);
usage(0) if $opt{help};
usage(1) unless @ARGV;
@@ -201,7 +224,17 @@ $package = shift;
if (@ARGV) {
my $version = shift;
$pkgversion = Dpkg::Version->new($version, check => 1);
- fatal "Invalid version '$version'" unless $pkgversion;
+ fatal "Invalid version '$version'" unless $pkgversion->is_valid;
+}
+
+if (defined $opt{first}) {
+ $firstversion = Dpkg::Version->new($opt{first}, check => 1);
+ fatal "Invalid version '$opt{first}'" unless $firstversion->is_valid();
+}
+
+if (defined $opt{last}) {
+ $lastversion = Dpkg::Version->new($opt{last}, check => 1);
+ fatal "Invalid version '$opt{last}'" unless $lastversion->is_valid();
}
$package eq '' && usage(1);
@@ -238,13 +271,11 @@ unless ($json_text && @{$json_text->{result}}) {
}
my @versions = @{$json_text->{result}};
-if ($pkgversion) {
- @versions = $opt{binary} ? grep { !($_->{binary_version} <=> $pkgversion) } @versions
- : grep { !($_->{version} <=> $pkgversion) } @versions;
- unless (@versions) {
- warn "$progname: No matching versions found for $package\n";
- $warnings++;
- }
+ at versions = $opt{binary} ? grep { keep_version($_->{binary_version}) } @versions
+ : grep { keep_version($_->{version}) } @versions;
+unless (@versions) {
+ warn "$progname: No matching versions found for $package\n";
+ $warnings++;
}
if ($opt{binary}) {
foreach my $version (@versions) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list