From de604eab53669f3d4aa6b65c8326a8a402048fe5 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 3 Sep 2004 05:06:37 +0000 Subject: If $TMPDIR is not writable, don't use it --- URPM/Build.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/URPM/Build.pm b/URPM/Build.pm index 0ace0ce..ecb24d1 100644 --- a/URPM/Build.pm +++ b/URPM/Build.pm @@ -2,6 +2,12 @@ package URPM; use strict; +sub _get_tmp_dir () { + my $t = $ENV{TMPDIR}; + $t && -w $t or $t = '/tmp'; + "$t/.build_hdlist"; +} + #- prepare build of an hdlist from a list of files. #- it can be used to start computing depslist. #- parameters are : @@ -16,7 +22,7 @@ sub parse_rpms_build_headers { #- check for mandatory options. if (@{$options{rpms} || []} > 0) { #- build a working directory which will hold rpm headers. - $dir = $options{dir} || ($ENV{TMPDIR} || "/tmp") . "/.build_hdlist"; + $dir = $options{dir} || _get_tmp_dir; $options{clean} and system($ENV{LD_LOADER} ? $ENV{LD_LOADER} : @{[]}, "rm", "-rf", $dir); -d $dir or mkdir $dir, 0755 or die "cannot create directory $dir\n"; @@ -117,7 +123,7 @@ sub parse_headers { my ($urpm, %options) = @_; my ($dir, $start, $id); - $dir = $options{dir} || ($ENV{TMPDIR} || "/tmp") . "/.build_hdlist"; + $dir = $options{dir} || _get_tmp_dir; -d $dir or die "no directory $dir\n"; $start = @{$urpm->{depslist} || []}; @@ -397,7 +403,7 @@ sub build_hdlist { my ($urpm, %options) = @_; my ($dir, $ratio, $split, @idlist); - $dir = $options{dir} || ($ENV{TMPDIR} || "/tmp") . "/.build_hdlist"; + $dir = $options{dir} || _get_tmp_dir; -d $dir or die "no directory $dir\n"; @idlist = @{$options{idlist} || []} > 0 ? @{$options{idlist}} : -- cgit v1.2.1