On Tuesday 21 August 2007 18:23:03 Steffen Moeller wrote: > On Tuesday 21 August 2007 17:44:17 Andreas Tille wrote: > > On Tue, 21 Aug 2007, Charles Plessy wrote: > > > # This is useful to download the orig.gz sources before running > > > svn-buildpackage tarballs: > > > [ -d ../tarballs ] || mkdir ../tarballs > > > uscan --force-download > > > mv ../melt* ../tarballs > > > > > > As you can see, code factorisation is not 100 %, but on the other hand, > > > the specific parts are trivial. > > > > Don't you think this is a topic for debian-devel? I'd expect more > > input than from readers of this list. > > The origDir flag should be read by uscan from the debian/.svn directory > which is used by svn-buildpackage. I have to leave now and think of a > respective patch to uscan while I am driving. I changed my mind on that. I just submitted a bug+patch to devscripts that features uscan to add the option --destdir. No bug# yet. I will add a little script wrapping that new version of uscan to the repository in a few instances. Those not feeling like waiting for a new version fo devscripts, please feel free to patch uscan with the patch appended. Steffen -- Dr. Steffen Möller University of Lübeck Institute for Neuro- and Bioinformatics Ratzeburger Allee 160 23538 Lübeck Germany T: +49 451 500 5504 F: +49 451 500 5502 moeller@inb.uni-luebeck.de
--- uscan 2007-08-10 00:36:53.000000000 +0200
+++ uscan.pl 2007-08-21 23:24:52.000000000 +0200
@@ -77,6 +77,7 @@
Report status of packages, but do not download
--debug Dump the downloaded web pages to stdout for debugging
your watch file.
+ --destdir Path of directory to which to download.
--download Report on newer and absent versions, and download (default)
--force-download
Always download the upstream release, even if up to date
@@ -130,7 +131,7 @@
sub version {
print <<"EOF";
-This is $progname, from the Debian devscripts package, version 2.10.7
+This is $progname, from the Debian devscripts package, version ###VERSION###
This code is copyright 1999-2006 by Julian Gilbey, all rights reserved.
Original code by Christoph Lameter.
This program comes with ABSOLUTELY NO WARRANTY.
@@ -145,6 +146,7 @@
# Now start by reading configuration files and then command line
# The next stuff is boilerplate
+my $destdir = "..";
my $download = 1;
my $force_download = 0;
my $report = 0; # report even on up-to-date packages?
@@ -158,7 +160,7 @@
my $dehs_start_output = 0;
my $pkg_report_header = '';
my $timeout = 20;
-my $user_agent_string = 'Debian uscan 2.10.7';
+my $user_agent_string = 'Debian uscan ###VERSION###';
if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
$modified_conf_msg = " (no configuration files read)";
@@ -167,6 +169,7 @@
my @config_files = ('/etc/devscripts.conf', '~/.devscripts');
my %config_vars = (
'USCAN_TIMEOUT' => 20,
+ 'USCAN_DESTDIR' => '..',
'USCAN_DOWNLOAD' => 'yes',
'USCAN_PASV' => 'default',
'USCAN_SYMLINK' => 'symlink',
@@ -191,6 +194,8 @@
@config_vars{keys %config_vars} = split /\n/, $shell_out, -1;
# Check validity
+ $config_vars{'USCAN_DESTDIR'} =~ /^\s*(\S+)\s*$/
+ or $config_vars{'USCAN_DESTDIR'}='..';
$config_vars{'USCAN_DOWNLOAD'} =~ /^(yes|no)$/
or $config_vars{'USCAN_DOWNLOAD'}='yes';
$config_vars{'USCAN_PASV'} =~ /^(yes|no|default)$/
@@ -217,6 +222,8 @@
$modified_conf_msg ||= " (none)\n";
chomp $modified_conf_msg;
+ $destdir = $config_vars{'USCAN_DESTDIR'}
+ if defined $config_vars{'USCAN_DESTDIR'};
$download = $config_vars{'USCAN_DOWNLOAD'} eq 'no' ? 0 : 1;
$passive = $config_vars{'USCAN_PASV'} eq 'yes' ? 1 :
$config_vars{'USCAN_PASV'} eq 'no' ? 0 : 'default';
@@ -232,13 +239,15 @@
# Now read the command line arguments
my $debug = 0;
-my ($opt_h, $opt_v, $opt_download, $opt_force_download, $opt_report, $opt_passive, $opt_symlink);
+my ($opt_h, $opt_v, $opt_destdir, $opt_download, $opt_force_download,
+ $opt_report, $opt_passive, $opt_symlink);
my ($opt_verbose, $opt_ignore, $opt_level, $opt_regex, $opt_noconf);
my ($opt_package, $opt_uversion, $opt_watchfile, $opt_dehs, $opt_timeout);
my $opt_user_agent;
GetOptions("help" => \$opt_h,
"version" => \$opt_v,
+ "destdir=s" => \$opt_destdir,
"download!" => \$opt_download,
"force-download" => \$opt_force_download,
"report" => sub { $opt_download = 0; },
@@ -271,6 +280,7 @@
# Now we can set the other variables according to the command line options
+$destdir = $opt_destdir if defined $opt_destdir;
$download = $opt_download if defined $opt_download;
$force_download = $opt_force_download if defined $opt_force_download;
$report = $opt_report if defined $opt_report;
@@ -1019,18 +1029,22 @@
}
if (defined $pkg_dir) {
- if (-f "../$newfile_base") {
+ if (! -d "$destdir") {
+ print "Package directory '$destdir to store downloaded file is not existing\n";
+ return 1;
+ }
+ if (-f "$destdir/$newfile_base") {
print " => $newfile_base already in package directory\n"
if $verbose or ($download == 0 and ! $dehs);
return 0;
}
- if (-f "../${pkg}_${newversion}.orig.tar.gz") {
- print " => ${pkg}_${newversion}.orig.tar.gz already in package directory\n"
+ if (-f "$destdir/${pkg}_${newversion}.orig.tar.gz") {
+ print " => ${pkg}_${newversion}.orig.tar.gz already in package directory '$destdir'\n"
if $verbose or ($download == 0 and ! $dehs);
return 0;
}
- elsif (-f "../${pkg}_${newversion}.orig.tar.bz2") {
- print " => ${pkg}_${newversion}.orig.tar.bz2 already in package directory\n"
+ elsif (-f "$destdir/${pkg}_${newversion}.orig.tar.bz2") {
+ print " => ${pkg}_${newversion}.orig.tar.bz2 already in package directory '$destdir'\n"
if $verbose or ($download == 0 and ! $dehs);
return 0;
}
@@ -1063,6 +1077,10 @@
return 0 unless $download;
print "-- Downloading updated package $newfile_base\n" if $verbose;
+ if (! -d "$destdir") {
+ print "Package directory '$destdir to store downloaded file is not existing\n";
+ return 1;
+ }
# Download newer package
if ($upstream_url =~ m%^http(s)?://%) {
if (defined($1) and !$haveSSL) {
@@ -1072,7 +1090,7 @@
# Is anything else than "&" required? I doubt it.
print STDERR "$progname debug: requesting URL $upstream_url\n" if $debug;
$request = HTTP::Request->new('GET', $upstream_url);
- $response = $user_agent->request($request, "../$newfile_base");
+ $response = $user_agent->request($request, "$destdir/$newfile_base");
if (! $response->is_success) {
if (defined $pkg_dir) {
warn "$progname warning: In directory $pkg_dir, downloading\n $upstream_url failed: " . $response->status_line . "\n";
@@ -1089,7 +1107,7 @@
}
print STDERR "$progname debug: requesting URL $upstream_url\n" if $debug;
$request = HTTP::Request->new('GET', "$upstream_url");
- $response = $user_agent->request($request, "../$newfile_base");
+ $response = $user_agent->request($request, "$destdir/$newfile_base");
if (exists $options{'pasv'}) {
if (defined $passive) { $ENV{'FTP_PASSIVE'}=$passive; }
else { delete $ENV{'FTP_PASSIVE'}; }
@@ -1105,26 +1123,26 @@
}
if ($newfile_base =~ /\.(tar\.gz|tgz|tar\.bz2|tbz2?)$/) {
- my $filetype = `file ../$newfile_base`;
+ my $filetype = `file $destdir/$newfile_base`;
$filetype =~ s%^\.\./\Q$newfile_base\E: %%;
unless ($filetype =~ /compressed data/) {
- warn "$progname warning: ../$newfile_base does not appear to be a compressed file;\nthe file command says: $filetype\nNot processing this file any further!\n";
+ warn "$progname warning: $destdir/$newfile_base does not appear to be a compressed file;\nthe file command says: $filetype\nNot processing this file any further!\n";
return 1;
}
}
if ($newfile_base =~ /\.(tar\.gz|tgz)$/) {
if ($symlink eq 'symlink') {
- symlink $newfile_base, "../${pkg}_${newversion}.orig.tar.gz";
+ symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.gz";
} elsif ($symlink eq 'rename') {
- move "../$newfile_base", "../${pkg}_${newversion}.orig.tar.gz";
+ move "$destdir/$newfile_base", "$destdir/${pkg}_${newversion}.orig.tar.gz";
}
}
elsif ($newfile_base =~ /\.(tar\.bz2|tbz2?)$/) {
if ($symlink eq 'symlink') {
- symlink $newfile_base, "../${pkg}_${newversion}.orig.tar.bz2";
+ symlink $newfile_base, "$destdir/${pkg}_${newversion}.orig.tar.bz2";
} elsif ($symlink eq 'rename') {
- move "../$newfile_base", "../${pkg}_${newversion}.orig.tar.bz2";
+ move "$destdir/$newfile_base", "$destdir/${pkg}_${newversion}.orig.tar.bz2";
}
}
@@ -1181,14 +1199,14 @@
# Do whatever the user wishes to do
if ($action) {
- my $usefile = "../$newfile_base";
+ my $usefile = "$destdir/$newfile_base";
if ($symlink =~ /^(symlink|rename)$/
and $newfile_base =~ /\.(tar\.gz|tgz)$/) {
- $usefile = "../${pkg}_${newversion}.orig.tar.gz";
+ $usefile = "$destdir/${pkg}_${newversion}.orig.tar.gz";
}
elsif ($symlink =~ /^(symlink|rename)$/
and $newfile_base =~ /\.(tar\.bz2|tbz2)$/) {
- $usefile = "../${pkg}_${newversion}.orig.tar.bz2";
+ $usefile = "$destdir/${pkg}_${newversion}.orig.tar.bz2";
}
# Any symlink requests are already handled by uscan
Attachment:
signature.asc
Description: This is a digitally signed message part.