summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-04 14:17:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-04 14:17:16 +0000
commit55208824334294d60c0cda65e0f245f8831a6ace (patch)
tree6298d63e9d6b328f745ba59348030d40fd8f2b1a /urpm.pm
parent542aa55f7bee301752370c9a51e9af2490c6a781 (diff)
downloadurpmi-55208824334294d60c0cda65e0f245f8831a6ace.tar
urpmi-55208824334294d60c0cda65e0f245f8831a6ace.tar.gz
urpmi-55208824334294d60c0cda65e0f245f8831a6ace.tar.bz2
urpmi-55208824334294d60c0cda65e0f245f8831a6ace.tar.xz
urpmi-55208824334294d60c0cda65e0f245f8831a6ace.zip
much nicer userdir() functions:
- userdir() does not modify $urpm->{cachedir} anymore, if you must ensure $urpm->{cachedir} to be modified, use ensure_valid_cachedir() - valid_cachedir() gives you a valid cachedir (works for root or simple-user), but does not modify $urpm->{cachedir}
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/urpm.pm b/urpm.pm
index f0ac28f6..4982bc09 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -111,13 +111,22 @@ sub userdir {
-d $dir && ! -l $dir or $urpm->{fatal}(1, N("fail to create directory %s", $dir));
-o $dir && -w $dir or $urpm->{fatal}(1, N("invalid owner for directory %s", $dir));
- $urpm->{cachedir} = $dir;
-
mkdir "$dir/partial";
mkdir "$dir/rpms";
$dir;
}
+sub ensure_valid_cachedir {
+ my ($urpm) = @_;
+ if (my $dir = userdir($urpm)) {
+ $urpm->{cachedir} = $dir;
+ }
+ -w "$urpm->{cachedir}/partial" or $urpm->{fatal}(1, N("Can not download packages into %s", "$urpm->{cachedir}/partial"));
+}
+sub valid_cachedir {
+ my ($urpm) = @_;
+ userdir($urpm) || $urpm->{cachedir};
+}
sub is_temporary_file {
my ($urpm, $f) = @_;