commit: 2d5c1dc73b2c44200e7bbb0ebb18a46adcc63af1 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Sat Apr 6 18:53:30 2019 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sat Apr 6 18:53:30 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=2d5c1dc7
Fix "Make sure $TMPDIR exists" Previous attempt to ensure $TMPDIR exists introduced a new bug: The used one-line if clause was invalid. Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> gen_cmdline.sh | 6 +++++- genkernel | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gen_cmdline.sh b/gen_cmdline.sh index c5697e2..be04cdb 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -587,8 +587,12 @@ parse_cmdline() { ;; --tempdir=*) TMPDIR="${*#*=}" - [ ! -d "${TMPDIR}" ] && mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!" + if [ ! -d "${TMPDIR}" ] + then + mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!" + fi TEMP=$(mktemp -d -p "${TMPDIR}" gk.XXXXXXXX) + [ -z "${TEMP}" ] && gen_die "mktemp failed!" print_info 2 "TMPDIR: ${TMPDIR}" print_info 2 "TEMP: ${TEMP}" ;; diff --git a/genkernel b/genkernel index 6904ff2..5337833 100755 --- a/genkernel +++ b/genkernel @@ -44,8 +44,13 @@ source ${GK_SHARE}/gen_moddeps.sh || gen_die "Could not read ${GK_SHARE}/gen_mod source ${GK_SHARE}/gen_package.sh || gen_die "Could not read ${GK_SHARE}/gen_package.sh" source ${GK_SHARE}/gen_bootloader.sh || gen_die "Could not read ${GK_SHARE}/gen_bootloader.sh" -[ ! -d "${TMPDIR}" ] && mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!" +if [ ! -d "${TMPDIR}" ] +then + mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!" +fi + TEMP=$(mktemp -d -p "${TMPDIR}" gk.XXXXXXXX) +[ -z "${TEMP}" ] && gen_die "mktemp failed!" trap_cleanup(){ # Call exit code of 1 for failure