changed the way how temporary files/directories will be created:
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 22 Jan 2006 12:24:25 +0000 (12:24 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 22 Jan 2006 12:24:25 +0000 (12:24 +0000)
* mktemp will now be called with the '-t' parameter and sometimes with
  '-p'
* absolutes paths (e.g. '/tmp') were removed from the templates
* with this changes, it is now possible to override the location of
  the temporary files by setting $TMPDIR. This should add a way to
  solve problems like debootstrap on non-executable tmp-directories
  (http://savannah.nongnu.org/bugs/?func=detailitem&item_id=15447)

These changes require that 'mktemp' understands the following switches:

* '-t'  ... Generate a path rooted in a temporary directory.
* '-d'  ... Make a directory instead of a file.
* '-p' ...  Use the specified directory as a prefix when generating
            the temporary filename.

Because 'mktemp' from Debian Woody's 'debianutils_1.16.2woody1'
supports these features every recent Linux distribution should do it
also.

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2263 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/functions
util-vserver/scripts/pkgmgmt
util-vserver/scripts/start-vservers
util-vserver/scripts/util-vserver-vars.pathsubst
util-vserver/scripts/vserver-build.rpm
util-vserver/scripts/vserver.functions
util-vserver/scripts/vserver.start

index 8255487..69e57f0 100644 (file)
@@ -242,7 +242,7 @@ _VS_LOCKS=''
 ## Usage: lock <lockfile> [<timeout>]
 function lock
 {
-    local tmp=$($_MKTEMP /tmp/vserver-lock.XXXXXX)
+    local tmp=$($_MKTEMP vserver-lock.XXXXXX)
     $_RM -f $tmp
     $_MKFIFO -m600 $tmp
 
@@ -969,7 +969,7 @@ function vshelper.doDestroy
 function vshelper.initSync
 {
     local _vis_tmpdir
-    _vis_tmpdir=$($_MKTEMPDIR /tmp/vserver-stop.XXXXXX) || {
+    _vis_tmpdir=$($_MKTEMPDIR vserver-stop.XXXXXX) || {
        warning $"Failed to generate temporary directory for vshelper sync"
        return 1
     }
index 397eca2..04ddd42 100755 (executable)
@@ -94,7 +94,7 @@ function _substFile()
     
     $_CHROOT_SH testfile "$file" || return 0
 
-    local tmp=$($_MKTEMP /tmp/pkgmgmt_subst.XXXXXX)
+    local tmp=$($_MKTEMP pkgmgmt_subst.XXXXXX)
     trap "$_RM -f $tmp" EXIT
 
     $_CHROOT_SH cat "$file" | \
@@ -113,7 +113,7 @@ function _hashAuto()
 
     $_CHROOT_SH testfile "$file" || return 0
     
-    local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
+    local tmp=$($_MKTEMP apt.conf.XXXXXX)
     trap "$_RM -f $tmp" EXIT
 
     $_CHROOT_SH cat "$file" | \
@@ -130,7 +130,7 @@ function _unhashAuto()
     test -e "$1" || return 0
 
     local hash=$2
-    local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
+    local tmp=$($_MKTEMP apt.conf.XXXXXX)
     trap "$_RM -f $tmp" EXIT
 
     $_SED -e "s|^$hash$hash\(.*@autogenerated@\)|\1|" "$1" >$tmp
@@ -350,7 +350,7 @@ Can not continue; use '--force' to override this check"
     if test -n "$is_internalize"; then
        :
     else
-       tmpdir=$($_MKTEMPDIR /var/tmp/pgmgmt.XXXXXX)
+       tmpdir=$($_MKTEMPDIR -p /var/tmp pkgmgmt.XXXXXX)
        trap "$_RM -rf $tmpdir" EXIT
        pushd "$vdir" >/dev/null
        $_EXEC_CD /var/lib $_MV rpm $tmpdir/
index 9e0c4ae..6728437 100755 (executable)
@@ -134,9 +134,9 @@ while test $i -gt 0; do
     unset vservers[$i]
 done
 
-makedir=$($_MKTEMPDIR /tmp/vserver-init.XXXXXX)
-okfile=$($_MKTEMP     /tmp/vserver-init.XXXXXX)
-passedfile=$($_MKTEMP /tmp/vserver-init.XXXXXX)
+makedir=$($_MKTEMPDIR vserver-init.XXXXXX)
+okfile=$($_MKTEMP     vserver-init.XXXXXX)
+passedfile=$($_MKTEMP vserver-init.XXXXXX)
 trap "$_RM -rf $makedir $resultfile $passedfile" EXIT
 
 test_cmd=false
index ee43c1d..4ea7698 100644 (file)
@@ -110,7 +110,7 @@ _LN="@LN@"
 _LN_S="$_LN -s"
 _MKDIR="@MKDIR@"
 _MKFIFO="@MKFIFO@"
-_MKTEMP="@MKTEMP@"
+_MKTEMP="@MKTEMP@ -t"
 _MKTEMPDIR="$_MKTEMP -d"
 _MODPROBE="@MODPROBE@"
 _MOUNT="@MOUNT@"
index 33fc3f9..3de83de 100644 (file)
@@ -85,8 +85,8 @@ setup_writeInitialFstab
 # when basedir is a non-local location, rpm will download it into the
 # current directory. Therefore, create and go into a temporay directory
 # before doing the operations.
-tmpdir=$($_MKTEMPDIR /var/tmp/vserver-build.rpm.XXXXXX)
-manifest=$($_MKTEMP /tmp/vserver-build.rpm.manifest.XXXXXX)
+tmpdir=$($_MKTEMPDIR -p /var/tmp vserver-build.rpm.XXXXXX)
+manifest=$($_MKTEMP vserver-build.rpm.manifest.XXXXXX)
 trap "rm -rf $tmpdir $manifest" EXIT
 cd "$tmpdir"                   
 
index 8d0f010..09c6ee3 100644 (file)
@@ -809,7 +809,7 @@ function initWait
 {
     if $_VSERVER_INFO - FEATURE vwait; then
        local _is_tmpdir
-       _is_tmpdir=$($_MKTEMPDIR /tmp/vwaitstat.XXXXXX)
+       _is_tmpdir=$($_MKTEMPDIR vwaitstat.XXXXXX)
 
        (
            $_VWAIT --timeout "$VSHELPER_SYNC_TIMEOUT" \
index 35b5446..7890c13 100644 (file)
@@ -141,7 +141,7 @@ if $_VSERVER_INFO - FEATURE migrate; then
     "${INITCMD_START[@]}"
 else
     if test -n "$_IS_FAKEINIT"; then
-       startsync_pipe=$($_MKTEMP /tmp/vserver-start.XXXXXX)
+       startsync_pipe=$($_MKTEMP vserver-start.XXXXXX)
        $_RM -f "$startsync_pipe"
        $_MKFIFO -m600 "$startsync_pipe"        ## safe, since mkfifo does not follow symlinks
     fi