From dbacb3edd62cf3e30a3635c92c5582a7d754bf35 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 10 Sep 2014 15:52:48 -0400 Subject: [PATCH] catalyst-auto: construct tempdir with mktemp rather than pid This way we can sanely use pid namespaces without tempdirs clashing. --- tools/catalyst-auto | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tools/catalyst-auto b/tools/catalyst-auto index 3aa98b2a..ebdb7c7a 100755 --- a/tools/catalyst-auto +++ b/tools/catalyst-auto @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 # First let's get our own mount namespace to avoid leaking crap. if [[ -z ${UNSHARE} ]] ; then @@ -8,8 +10,6 @@ if [[ -z ${UNSHARE} ]] ; then fi unset UNSHARE -PID=$$ - config_file= verbose=0 keep_tmpdir=0 @@ -118,7 +118,7 @@ fi source ${config_file} -TMPDIR=${TMP_PATH:-/tmp}/catalyst-auto.${PID} +TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" catalyst-auto.XXXXXX) DATESTAMP=$(date +%Y%m%d) if [ ${verbose} = 1 ]; then @@ -126,21 +126,11 @@ if [ ${verbose} = 1 ]; then echo "DATESTAMP = ${DATESTAMP}" fi -# Check if tmp directory exists and remove it -if [ -d "${TMPDIR}" ]; then - if ! rm -rf "${TMPDIR}"; then - echo "Couldn't remove stale tmpdir ${TMPDIR}!" - exit 1 - fi +if ! mkdir -p "${TMPDIR}"/{specs,kconfig,log}; then + echo "Couldn't create tempdirs!" + exit 1 fi -for i in ${TMPDIR} ${TMPDIR}/specs ${TMPDIR}/kconfig ${TMPDIR}/log; do - if ! mkdir -p "${i}"; then - echo "Couldn't create dir ${i}!" - exit 1 - fi -done - if ! run_cmd "pre_build" "${TMPDIR}/log/pre_build.log"; then send_email "Catalyst build error - pre_build" "Your pre_build function sucks" "${TMPDIR}/log/pre_build.log" exit 1