¡Hola! El Tuesday, April 23, 2013 a las 11:29 Niels Thykier escribió: > Hi,
> (Disclaimer: not the maintainer). > Interesting idea and I suspect it will be very useful. Thanks, I appreciate the possitive feedback, even if the never gets accepted. > > - } > > - else { > > + } elsif ($site =~ m%^git://%) { > > + # TODO: check if there is a git command > > + # sanitize $base > > + open(REFS, "git ls-remote $base |"); > Why do you use "2-arg open" here? A "3-arg open" would avoid issues > with quoting. E.g. > open(REFS, '-|', 'git', 'ls-remote', $base) > Also, the return value of open is not checked. So if it fails (e.g. git > is not installed) it will cause a lot of warnings from reading an > "unopened handle". Yeah, you are right. I added those changes to the attached patch, also removed the unneeded message for the recursive search, and added the missing parts to generate the tar.gz file. -- "Whenever possible, steal code." -- Tom Duff Saludos /\/\ /\ >< `/
commit c716721198f9b8f7657a22e90430c3f7205da849 Author: Maximiliano Curia <m...@gnuservers.com.ar> Date: Fri Apr 19 13:00:44 2013 +0200 Basic git:// support diff --git a/scripts/uscan.pl b/scripts/uscan.pl index 1010f7c..b9fb2df 100755 --- a/scripts/uscan.pl +++ b/scripts/uscan.pl @@ -982,8 +982,65 @@ sub process_watchline ($$$$$$) warn "$progname warning: In $watchfile,\n no matching hrefs for watch line\n $line\n"; return 1; } - } - else { + } elsif ($site =~ m%^git://%) { + # TODO: sanitize $base + open(REFS, "-|", 'git', 'ls-remote', $base) || + die "$progname: you must have the git package installed\n" + . "to use git URLs\n"; + my (@refs, $line, $ref, $version); + while (<REFS>) { + chomp; + $line = $_; + foreach my $_pattern (@patterns) { + if ($line =~ + m&^([^[:space:]]+)[[:space:]]+(?:refs\/)?$_pattern$&) { + $ref = $1; $version = $2; + + $version = join(".", map { $_ if defined($_) } + $version); + foreach my $_p (@{$options{'uversionmangle'}}) { + if (! safe_replace(\$version, $_p)) { + warn "$progname: In $watchfile, potentially" + . " unsafe or malformed uversionmangle" + . " pattern:\n '$_p'" + . " found. Skipping watchline\n" + . " $line\n"; + return 1; + } + } + push @refs, [$version, $ref]; + } + } + } + if (@refs) { + if ($verbose) { + print "-- Found the following matching refs:\n"; + foreach my $ref (@refs) { + print " $$ref[1] ($$ref[0])\n"; + } + } + if (defined $download_version) { + my @vrefs = grep { $$_[0] eq $download_version } @refs; + if (@vrefs) { + ($newversion, $newfile) = @{$vrefs[0]}; + } else { + warn "$progname warning: In $watchfile no matching" + . " refs for version $download_version" + . " in watch line\n $line\n"; + return 1; + } + + } else { + @refs = Devscripts::Versort::versort(@refs); + ($newversion, $newfile) = @{$refs[0]}; + } + } else { + warn "$progname warning: In $watchfile,\n" . + " no matching refs for watch line\n" . + " $line\n"; + return 1; + } + } else { # Better be an FTP site if ($site !~ m%^ftp://%) { warn "$progname warning: Unknown protocol in $watchfile, skipping:\n $site\n"; @@ -1124,6 +1181,14 @@ EOF $newfile_base = "$pkg-$newversion.download"; } } + # Default name for git archive + if ($site =~ m%^git://%) { + my $ext = "tar.xz"; + if ($repack) { + $ext = "tar.gz"; + } + $newfile_base = "$pkg-$newversion.$ext"; + } # So what have we got to report now? my $upstream_url; @@ -1200,8 +1265,9 @@ EOF } } } - } - else { + } elsif ($site =~ m%^git://%) { + $upstream_url = "$base $newfile"; + } else { # FTP site $upstream_url = "$base$newfile"; } @@ -1328,8 +1394,25 @@ EOF } return 1; } - } - else { + } elsif ($upstream_url =~ m%^git://%) { + my @cmd = ('git', 'archive', '--format=tar', + "--prefix=$pkg-$newversion/",'--remote'); + my @upstream_ref = split /[[:space:]]+/, $upstream_url, 2; + push @cmd, @upstream_ref; + my (undef, $fname) = tempfile(UNLINK => 1); + spawn(exec => \@cmd, to_file => $fname, wait_child => 1); + if ($repack) { + spawn(exec => ['gzip', '-n', '-9'], + from_file => $fname, + to_file => "$destdir/$newfile_base", + wait_child => 1); + } else { + spawn(exec => ['xz', '-c'], + from_file => $fname, + to_file => "$destdir/$newfile_base", + wait_child => 1); + } + } else { # FTP site if (exists $options{'pasv'}) { $ENV{'FTP_PASSIVE'}=$options{'pasv'};
signature.asc
Description: This is a digitally signed message part.