Package: devscripts
Version: 2.10.69
Severity: wishlist
File: /usr/bin/debsnap
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I found the attached feature (debsnap just printing what it would
download, without actually downloading it) useful. Please consider
including it in the next release.

Thanks,
Joachim

- -- Package-specific info:

- --- /etc/devscripts.conf ---

- --- ~/.devscripts ---
DEBCHANGE_RELEASE_HEURISTIC=changelog
DEBRELEASE_UPLOADER=dput

- -- System Information:
Debian Release: 6.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.36-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages devscripts depends on:
ii  dpkg-dev                      1.15.8.8   Debian package development tools
ii  libc6                         2.11.2-8   Embedded GNU C Library: Shared lib
ii  perl                          5.10.1-17  Larry Wall's Practical Extraction 

Versions of packages devscripts recommends:
ii  at                 3.1.12-1              Delayed job execution and batch pr
ii  bsd-mailx [mailx]  8.1.2-0.20100314cvs-1 simple mail user agent
ii  bzr                2.3.0~beta3-1         easy to use distributed version co
ii  curl               7.21.2-4              Get a file from an HTTP, HTTPS or 
ii  cvs                1:1.12.13-12          Concurrent Versions System
ii  darcs              2.4.4-3               a distributed, interactive, smart 
ii  dctrl-tools        2.14.5                Command-line tools to process Debi
ii  debian-keyring [de 2010.12.29            GnuPG keys of Debian Developers
ii  dput               0.9.6.1               Debian package upload tool
ii  epiphany-browser [ 2.30.6-1              Intuitive GNOME web browser
ii  equivs             2.0.8                 Circumvent Debian package dependen
ii  fakeroot           1.14.5-1              Gives a fake root environment
ii  galeon [www-browse 2.0.7-2.1+b1          GNOME web browser for advanced use
ii  git [git-core]     1:1.7.2.3-2.2         fast, scalable, distributed revisi
ii  git-core           1:1.7.2.3-2.2         fast, scalable, distributed revisi
ii  gnupg              1.4.10-4              GNU privacy guard - a free PGP rep
ii  iceweasel [www-bro 3.5.16-4              Web browser based on Firefox
ii  libauthen-sasl-per 2.1500-1              Authen::SASL - SASL Authentication
ii  libcrypt-ssleay-pe 0.57-2                Support for https protocol in LWP
ii  libjson-perl       2.27-1                Perl module to parse and convert t
ii  libparse-debcontro 2.005-2               Easy OO parsing of Debian control-
ii  libsoap-lite-perl  0.712-2               Perl implementation of a SOAP clie
ii  libterm-size-perl  0.2-4+b1              Perl extension for retrieving term
ii  libtimedate-perl   1.2000-1              collection of modules to manipulat
ii  liburi-perl        1.56-1                module to manipulate and access UR
ii  libwww-perl        5.837-1               simple and consistent interface to
ii  libyaml-syck-perl  1.17-1                Perl module providing a fast, ligh
ii  lintian            2.4.3                 Debian package checker
ii  lsb-release        3.2-26                Linux Standard Base version report
ii  lynx-cur [www-brow 2.8.8dev.7-1          Text-mode WWW Browser with NLS sup
ii  lzma               4.43-14               Compression method of 7z format in
ii  man-db             2.5.7-8               on-line manual pager
ii  mercurial          1.6.4-1               scalable distributed version contr
ii  openssh-client [ss 1:5.5p1-6             secure shell (SSH) client, for sec
ii  patch              2.6-3                 Apply a diff file to an original
ii  patchutils         0.3.1-2               Utilities to work with patches
ii  sensible-utils     0.0.6                 Utilities for sensible alternative
ii  strace             4.5.20-2              A system call tracer
ii  subversion         1.6.12dfsg-4          Advanced version control system
ii  unzip              6.0-4                 De-archiver for .zip files
ii  w3m [www-browser]  0.5.2-10              WWW browsable pager with excellent
ii  wdiff              0.6.3-1               Compares two files word by word
ii  wget               1.12-2.1              retrieves files from the web
ii  xz-utils           5.0.0-2               XZ-format compression utilities

Versions of packages devscripts suggests:
ii  build-essential               11.5       Informational list of build-essent
pn  cvs-buildpackage              <none>     (no description available)
pn  devscripts-el                 <none>     (no description available)
ii  gnuplot                       4.4.0-1.1  A command-line driven interactive 
ii  libfile-desktopentry-perl     0.04-2     Perl module to handle freedesktop 
ii  libnet-smtp-ssl-perl          1.01-2     SSL support for Net::SMTP
pn  mutt                          <none>     (no description available)
ii  svn-buildpackage              0.8.3      helper programs to maintain Debian
ii  w3m                           0.5.2-10   WWW browsable pager with excellent

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk0xKrEACgkQ9ijrk0dDIGxY+QCfWClZyY9dvrU4hMZCZXwPeLr5
KH4An0553pVZ7dpwQ9HJMdK4cJuQjZtj
=hhNY
-----END PGP SIGNATURE-----
>From 73ff8d20e52a36806604862e69448e1da117e386 Mon Sep 17 00:00:00 2001
From: Joachim Breitner <[email protected]>
Date: Sat, 15 Jan 2011 10:29:57 +0530
Subject: [PATCH] New option --dry-run for debsnap

Option to disable downloading of files, but instead pringing what would
be downloaded.
---
 debian/changelog   |    4 ++++
 scripts/debsnap.1  |   11 ++++++++++-
 scripts/debsnap.pl |   23 ++++++++++++++++++-----
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 53952e1..a526daf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,10 @@ devscripts (2.10.70) UNRELEASED; urgency=low
     --source (DEBCHECKOUT_SOURCE) to control this behavior. (Closes: #535767)
   * Makefiles: Fix parallelization for use with make -j N.
 
+  [ Joachim Breitner ]
+  * New option -n to debsnap: Do now download file, but show what would
+    be downloaded
+
  -- James Vega <[email protected]>  Thu, 02 Dec 2010 20:27:34 -0500
 
 devscripts (2.10.69) unstable; urgency=low
diff --git a/scripts/debsnap.1 b/scripts/debsnap.1
index c7b249f..a0c632c 100644
--- a/scripts/debsnap.1
+++ b/scripts/debsnap.1
@@ -1,5 +1,5 @@
 .\" for manpage-specific macros, see man(7)
-.TH DEBSNAP 1 "July 3, 2010" "Debian devscripts" "DebSnap User Manual"
+.TH DEBSNAP 1 "January 15, 2011" "Debian devscripts" "DebSnap User Manual"
 .SH NAME
 debsnap \- retrieve old snapshots of Debian packages
 
@@ -45,6 +45,11 @@ Report on the \fBdebsnap\fP configuration being used and 
progress during the
 download operation.  Please always use this option when reporting bugs.
 
 .TP
+.BR \-n ", " \-\-dry\-run
+Does not download any files, but prints each URL to be downloaded and the 
filename
+it would be downloaded to, separated by a tabulator character.
+
+.TP
 .BR \-h ", " \-\-help
 Show a summary of these options.
 
@@ -73,6 +78,10 @@ The base url for the snapshots archive.
 
 If unset this defaults to \fIhttp://snapshot.debian.org\fP
 
+.TP
+.B DEBSNAP_DRY_RUN
+Same as the command line option \fB\-\-dry\-run\fP.  Set to "yes" to enable.
+
 .SH EXIT STATUS
 \fBdebsnap\fP will return an exit status of 0 if all operations succeeded,
 1 if a fatal error occurred, and 2 if some packages failed to be downloaded
diff --git a/scripts/debsnap.pl b/scripts/debsnap.pl
index eb4ee46..eb8dabc 100755
--- a/scripts/debsnap.pl
+++ b/scripts/debsnap.pl
@@ -91,6 +91,8 @@ The following options are supported:
                                         Default is ./source-<package name>
     -f, --force                         Force overwriting an existing
                                         destdir
+    -n, --dry-run                       Do not download files, but show what
+                                        would be downloaded where.
 
 Default settings modified by devscripts configuration files or command-line
 options:
@@ -122,6 +124,7 @@ sub read_conf
        'DEBSNAP_VERBOSE' => 'no',
        'DEBSNAP_DESTDIR' => '',
        'DEBSNAP_BASE_URL' => 'http://snapshot.debian.org',
+       'DEBSNAP_DRY_RUN' => 'no',
     );
 
     my %config_default = %config_vars;
@@ -140,8 +143,10 @@ sub read_conf
     @config_vars{keys %config_vars} = split /\n/, $shell_out, -1;
 
     # Check validity
-    $config_vars{'DEBSNAP_VERBOSE'} =~ /^(yes|no)$/
-       or $config_vars{'DEBSNAP_VERBOSE'} = 'no';
+    foreach my $boolean_option (qw/DEBSNAP_VERBOSE DEBSNAP_DRY_RUN/) {
+       $config_vars{$boolean_option} =~ /^(yes|no)$/
+           or $config_vars{$boolean_option} = 'no';
+       }
 
     foreach my $var (sort keys %config_vars) {
        if ($config_vars{$var} ne $config_default{$var}) {
@@ -155,6 +160,7 @@ sub read_conf
     $opt{verbose} = $config_vars{DEBSNAP_VERBOSE} eq 'yes';
     $opt{destdir} = $config_vars{DEBSNAP_DESTDIR};
     $opt{baseurl} = $config_vars{DEBSNAP_BASE_URL};
+    $opt{dry_run} = $config_vars{DEBSNAP_DRY_RUN} eq 'yes';
 }
 
 sub fatal($)
@@ -180,7 +186,8 @@ sub verbose($)
 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') 
|| exit 1;
+GetOptions(\%opt, 'verbose|v', 'destdir|d=s', 'force|f', 'dry_run|n',
+    'help|h', 'version') || exit 1;
 
 usage(0) if $opt{help};
 usage(1) unless @ARGV;
@@ -201,7 +208,9 @@ if (-d $opt{destdir}) {
        fatal "Destination dir $opt{destdir} already exists.\nPlease (re)move 
it first, or use --force to overwrite.";
     }
 }
-make_path($opt{destdir});
+unless ($opt{dry_run}) {
+    make_path($opt{destdir});
+}
 
 my $json_text = fetch_json_page($baseurl);
 unless ($json_text && @{$json_text->{result}}) {
@@ -241,7 +250,11 @@ foreach my $version (@{$json_text->{result}}) {
        $file_name = basename($file_name);
        if (!$fetched{$file_name}) {
            verbose "Getting file $file_name: $file_url";
-           LWP::Simple::getstore($file_url, "$opt{destdir}/$file_name");
+           if ($opt{dry_run}) {
+               printf "%s %s", $file_url, $file_name;
+           } else {
+               LWP::Simple::getstore($file_url, "$opt{destdir}/$file_name");
+           }
        }
        $fetched{$file_name} = 1;
     }
-- 
1.7.2.3

Reply via email to