* 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
## 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
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
}
$_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" | \
$_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" | \
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
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/
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
_LN_S="$_LN -s"
_MKDIR="@MKDIR@"
_MKFIFO="@MKFIFO@"
-_MKTEMP="@MKTEMP@"
+_MKTEMP="@MKTEMP@ -t"
_MKTEMPDIR="$_MKTEMP -d"
_MODPROBE="@MODPROBE@"
_MOUNT="@MOUNT@"
# 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"
{
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" \
"${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