The following commit has been merged in the master branch:
commit ac6f5240b6e34310d244f608631e69e57a64c9c6
Author: James Vega <[email protected]>
Date:   Wed May 4 22:49:07 2011 -0400

    dget: Improve wget()'s handling of file/copy URIs.
    
    + Allow relative paths for file/copy URIs.
    + Follow symlinks when copying/hard linking files from a local cache.
      (Closes: #515852)
    + Call system() with a list of arguments to prevent shell interpolation of
      the command.
    
    Signed-off-by: James Vega <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index 0782975..f82e7cb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,13 @@ devscripts (2.10.73) UNRELEASED; urgency=low
     + Add -M option to use debian/control's Maintainer information.  Thanks to
       Modestas Vainius for the patch.  (Closes: #560900)
     + Update recognized Ubuntu releases (- jaunty/karmic, + oneiric).
+  * dget: Improve wget()'s handling of file/copy URIs.  Thanks to Adam
+    Borowski for the suggestions.
+    + Allow relative paths for file/copy URIs.
+    + Follow symlinks when copying/hard linking files from a local cache.
+      (Closes: #515852)
+    + Call system() with a list of arguments to prevent shell interpolation of
+      the command.
 
   [ Benjamin Drung ]
   * Add myself to uploaders.
diff --git a/scripts/dget.pl b/scripts/dget.pl
index 7fafb3d..23e4c05 100755
--- a/scripts/dget.pl
+++ b/scripts/dget.pl
@@ -27,6 +27,7 @@
 # Later modifications: see debian/changelog
 
 use strict;
+use Cwd qw(abs_path);
 use IO::Dir;
 use IO::File;
 use Digest::MD5;
@@ -103,9 +104,14 @@ sub wget {
     my ($file, $url) = @_;
 
     # schemes not supported by all backends
-    if ($url =~ m!^(file|copy)://(/.+)!) {
-       if ($1 eq "copy" or not link($2, $file)) {
-           system "cp -a $2 $file";
+    if ($url =~ m!^(file|copy):(.+)!) {
+       my $path = abs_path($2);
+       unless ($path) {
+           warn "$progname: unable to resolve full path for $2: $!\n";
+           return 1;
+       }
+       if ($1 eq "copy" or not link($path, $file)) {
+           system 'cp', '-aL', $path, $file;
            return $? >> 8;
        }
        return;
@@ -175,7 +181,7 @@ sub get_file {
                    print "$progname: using $path/$file (hardlink)\n" unless 
$opt->{'quiet'};
                } else {
                    print "$progname: using $path/$file (copy)\n" unless 
$opt->{'quiet'};
-                   system "cp -a $path/$file $file";
+                   system 'cp', '-aL', "$path/$file", $file;
                }
                last;
            }
@@ -193,8 +199,9 @@ sub get_file {
 
     # try apt-get if it is still not there
     if (not -e $file and $file =~ 
m!^([a-z0-9.+-]{2,})_[^/]+\.(?:diff\.gz|tar\.gz)$!) {
-       my $cmd = "apt-get source --print-uris $1";
-       my $apt = new IO::File("$cmd |") or die "$cmd: $!";
+       my @cmd = ('apt-get', 'source', '--print-uris', $1);
+       my $cmd = join ' ', @cmd;
+       open(my $apt, '-|', @cmd) or die "$cmd: $!";
        while(<$apt>) {
            if (/'(\S+)'\s+\S+\s+\d+\s+([\da-f]+)/i and $2 eq $md5sum) {
                if (wget($file, $1)) {

-- 
Git repository for devscripts


-- 
To unsubscribe, send mail to [email protected].

Reply via email to