summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@mandriva.com>2009-10-15 17:12:03 +0000
committerChristophe Fergeau <cfergeau@mandriva.com>2009-10-15 17:12:03 +0000
commit64f60e96cd8b895cfd908d030d5e6d482b53b98f (patch)
treec3c38c120ff99a6aa547f1bd410bf23e08b19f0e
parent6381a6079098697ddaba5ff6810a2e87658bca26 (diff)
downloadurpmi-64f60e96cd8b895cfd908d030d5e6d482b53b98f.tar
urpmi-64f60e96cd8b895cfd908d030d5e6d482b53b98f.tar.gz
urpmi-64f60e96cd8b895cfd908d030d5e6d482b53b98f.tar.bz2
urpmi-64f60e96cd8b895cfd908d030d5e6d482b53b98f.tar.xz
urpmi-64f60e96cd8b895cfd908d030d5e6d482b53b98f.zip
allow to define the cache directory for RPMs when setting --download-all
-rw-r--r--pod/urpmi.8.pod5
-rw-r--r--urpm.pm21
-rw-r--r--urpm/args.pm3
-rw-r--r--urpm/main_loop.pm7
4 files changed, 23 insertions, 13 deletions
diff --git a/pod/urpmi.8.pod b/pod/urpmi.8.pod
index 287c462e..d4ae0c60 100644
--- a/pod/urpmi.8.pod
+++ b/pod/urpmi.8.pod
@@ -257,12 +257,13 @@ Configure urpmi on the fly from a distrib tree, useful to install a chroot
with the B<--root> option. See the description of the B<--distrib> option
in the C<urpmi.addmedia> manpage.
-=item B<--download-all>
+=item B<--download-all> I<dest-dir>
By default, urpmi will download packages when they are needed. This can be
problematic when connection failures happen during a big upgrade. When this
option is set, urpmi will first download all the needed packages and proceed
-to install them if it managed to download them all.
+to install them if it managed to download them all. You can optionally
+specify a directory where the files should be downloaded (default is /var/cache/urpmi which could be too small to hold all the files).
=item B<--downloader> I<program name>
diff --git a/urpm.pm b/urpm.pm
index ee0fb519..44b1ed16 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -99,15 +99,9 @@ sub prefer_rooted {
-e "$root$file" ? "$root$file" : $file;
}
-sub userdir_prefix {
- my ($_urpm) = @_;
- '/tmp/.urpmi-';
-}
-sub userdir {
- my ($urpm) = @_;
- $< or return;
+sub init_cache_dir {
+ my ($urpm, $dir) = @_;
- my $dir = ($urpm->{urpmi_root} || '') . userdir_prefix($urpm) . $<;
mkdir $dir, 0755; # try to create it
-d $dir && ! -l $dir or $urpm->{fatal}(1, N("fail to create directory %s", $dir));
@@ -118,6 +112,17 @@ sub userdir {
$dir;
}
+sub userdir_prefix {
+ my ($_urpm) = @_;
+ '/tmp/.urpmi-';
+}
+sub userdir {
+ my ($urpm) = @_;
+ $< or return;
+
+ my $dir = ($urpm->{urpmi_root} || '') . userdir_prefix($urpm) . $<;
+ init_cache_dir($$urpm, $dir);
+}
sub ensure_valid_cachedir {
my ($urpm) = @_;
if (my $dir = userdir($urpm)) {
diff --git a/urpm/args.pm b/urpm/args.pm
index d9e26718..e2a0751f 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -130,8 +130,7 @@ my %options_spec = (
'parallel=s' => \$::parallel,
'metalink!' => sub { $urpm->{options}{metalink} = $_[1] },
- 'download-all!' => sub { $urpm->{options}{'download-all'} = $_[1] },
-
+ 'download-all:s' => sub { $urpm->{options}{'download-all'} = $_[1] },
# deprecated in favor of --downloader xxx
wget => sub { $urpm->{options}{downloader} = 'wget' },
curl => sub { $urpm->{options}{downloader} = 'curl' },
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index fdcff529..6c39759c 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -94,10 +94,15 @@ sub download_packages {
join("\n", map { " $_->[0]" } @bad));
}
}
+
(\@error_sources, \@msgs);
}
-if ($urpm->{options}{'download-all'}) {
+if (exists $urpm->{options}{'download-all'}) {
+ if ($urpm->{options}{'download-all'}) {
+ $urpm->{cachedir} = $urpm->{'urpmi-root'}.$urpm->{options}{'download-all'};
+ urpm::init_cache_dir($urpm, $urpm->{cachedir});
+ }
my (undef, $available) = urpm::sys::df("$urpm->{cachedir}/rpms");
if (!$urpm->{options}{ignoresize}) {