From 287e604a8f53e569d355b1b6c75f6736f4927281 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 27 Jun 2014 14:43:12 +0200 Subject: [PATCH] mkimage: use /var/tmp by default instead of /tmp Additionally, this can be overridden by setting the TMPDIR variable, like this was already the case for the generic `mkimage.sh` script. As explained in #6456, the rationale to use `/var/tmp` instead of `/tmp` is that `/tmp` is often a small tmpfs filesystem with more restricted rights. Docker-DCO-1.1-Signed-off-by: Vincent Bernat (github: vincentbernat) --- contrib/mkimage-alpine.sh | 4 ++-- contrib/mkimage-arch.sh | 2 +- contrib/mkimage-busybox.sh | 2 +- contrib/mkimage-crux.sh | 6 +++--- contrib/mkimage-debootstrap.sh | 2 +- contrib/mkimage-rinse.sh | 2 +- contrib/mkimage-unittest.sh | 2 +- contrib/mkimage.sh | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/mkimage-alpine.sh b/contrib/mkimage-alpine.sh index 7444ffafb9..0bf328efa9 100755 --- a/contrib/mkimage-alpine.sh +++ b/contrib/mkimage-alpine.sh @@ -13,8 +13,8 @@ usage() { } tmp() { - TMP=$(mktemp -d /tmp/alpine-docker-XXXXXXXXXX) - ROOTFS=$(mktemp -d /tmp/alpine-docker-rootfs-XXXXXXXXXX) + TMP=$(mktemp -d ${TMPDIR:-/var/tmp}/alpine-docker-XXXXXXXXXX) + ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/alpine-docker-rootfs-XXXXXXXXXX) trap "rm -rf $TMP $ROOTFS" EXIT TERM INT } diff --git a/contrib/mkimage-arch.sh b/contrib/mkimage-arch.sh index dc21067473..27c6ac6a3e 100755 --- a/contrib/mkimage-arch.sh +++ b/contrib/mkimage-arch.sh @@ -14,7 +14,7 @@ hash expect &>/dev/null || { exit 1 } -ROOTFS=$(mktemp -d /tmp/rootfs-archlinux-XXXXXXXXXX) +ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-archlinux-XXXXXXXXXX) chmod 755 $ROOTFS # packages to ignore for space savings diff --git a/contrib/mkimage-busybox.sh b/contrib/mkimage-busybox.sh index cbaa567834..b11a6bb265 100755 --- a/contrib/mkimage-busybox.sh +++ b/contrib/mkimage-busybox.sh @@ -14,7 +14,7 @@ BUSYBOX=$(which busybox) } set -e -ROOTFS=/tmp/rootfs-busybox-$$-$RANDOM +ROOTFS=${TMPDIR:-/var/tmp}/rootfs-busybox-$$-$RANDOM mkdir $ROOTFS cd $ROOTFS diff --git a/contrib/mkimage-crux.sh b/contrib/mkimage-crux.sh index 074c334bba..3f0bdcae3c 100755 --- a/contrib/mkimage-crux.sh +++ b/contrib/mkimage-crux.sh @@ -14,9 +14,9 @@ die () { ISO=${1} -ROOTFS=$(mktemp -d /tmp/rootfs-crux-XXXXXXXXXX) -CRUX=$(mktemp -d /tmp/crux-XXXXXXXXXX) -TMP=$(mktemp -d /tmp/XXXXXXXXXX) +ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-crux-XXXXXXXXXX) +CRUX=$(mktemp -d ${TMPDIR:-/var/tmp}/crux-XXXXXXXXXX) +TMP=$(mktemp -d ${TMPDIR:-/var/tmp}/XXXXXXXXXX) VERSION=$(basename --suffix=.iso $ISO | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') diff --git a/contrib/mkimage-debootstrap.sh b/contrib/mkimage-debootstrap.sh index 808f393549..0a3df140db 100755 --- a/contrib/mkimage-debootstrap.sh +++ b/contrib/mkimage-debootstrap.sh @@ -118,7 +118,7 @@ fi # will be filled in later, if [ -z "$skipDetection" ] lsbDist='' -target="/tmp/docker-rootfs-debootstrap-$suite-$$-$RANDOM" +target="${TMPDIR:-/var/tmp}/docker-rootfs-debootstrap-$suite-$$-$RANDOM" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" returnTo="$(pwd -P)" diff --git a/contrib/mkimage-rinse.sh b/contrib/mkimage-rinse.sh index 0692ae1794..69a8bc8fe6 100755 --- a/contrib/mkimage-rinse.sh +++ b/contrib/mkimage-rinse.sh @@ -39,7 +39,7 @@ if [ ! "$repo" ] || [ ! "$distro" ]; then exit 1 fi -target="/tmp/docker-rootfs-rinse-$distro-$$-$RANDOM" +target="${TMPDIR:-/var/tmp}/docker-rootfs-rinse-$distro-$$-$RANDOM" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" returnTo="$(pwd -P)" diff --git a/contrib/mkimage-unittest.sh b/contrib/mkimage-unittest.sh index a33f238845..feebb17b0e 100755 --- a/contrib/mkimage-unittest.sh +++ b/contrib/mkimage-unittest.sh @@ -15,7 +15,7 @@ SOCAT=$(which socat) shopt -s extglob set -ex -ROOTFS=`mktemp -d /tmp/rootfs-busybox.XXXXXXXXXX` +ROOTFS=`mktemp -d ${TMPDIR:-/var/tmp}/rootfs-busybox.XXXXXXXXXX` trap "rm -rf $ROOTFS" INT QUIT TERM cd $ROOTFS diff --git a/contrib/mkimage.sh b/contrib/mkimage.sh index 522e9a2840..803d1627df 100755 --- a/contrib/mkimage.sh +++ b/contrib/mkimage.sh @@ -50,7 +50,7 @@ fi delDir= if [ -z "$dir" ]; then - dir="$(mktemp -d ${TMPDIR:-/tmp}/docker-mkimage.XXXXXXXXXX)" + dir="$(mktemp -d ${TMPDIR:-/var/tmp}/docker-mkimage.XXXXXXXXXX)" delDir=1 fi