From 7b7d7c13a124a0039d80cf56ed041f91062f658a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 17 Jun 2019 17:38:07 +0200 Subject: [PATCH] xbps-src: exit properly if mktemp(1) fails, not from its subshell. Thanks @huglovefan --- common/chroot-style/proot.sh | 2 +- .../hooks/post-install/04-create-xbps-metadata-scripts.sh | 2 +- common/hooks/pre-pkg/04-generate-runtime-deps.sh | 2 +- common/hooks/pre-pkg/06-shlib-provides.sh | 2 +- common/xbps-src/libexec/build.sh | 2 +- common/xbps-src/shutils/bulk.sh | 2 +- common/xbps-src/shutils/common.sh | 2 +- common/xbps-src/shutils/cross.sh | 6 +++--- common/xbps-src/shutils/pkgtarget.sh | 2 +- common/xbps-src/shutils/show.sh | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/chroot-style/proot.sh b/common/chroot-style/proot.sh index 9bcc3f9520f..5c670ea5da8 100755 --- a/common/chroot-style/proot.sh +++ b/common/chroot-style/proot.sh @@ -18,7 +18,7 @@ if [ -z "$MASTERDIR" -o -z "$DISTDIR" ]; then fi # proot does not properly return the resultcode. Workaround this -RESULT=$(mktemp || exit 1) +RESULT=$(mktemp) || exit 1 PROOT_NO_SECCOMP=1 proot -r $MASTERDIR -w / -b "$RESULT:/.result" -b $DISTDIR:/void-packages \ ${HOSTDIR:+-b $HOSTDIR:/host} -b /proc:/proc -b /dev:/dev \ diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh index 8d3c74dd528..d2a89f66679 100644 --- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh +++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh @@ -12,7 +12,7 @@ _add_trigger() { process_metadata_scripts() { local action="$1" local action_file="$2" - local tmpf=$(mktemp || exit 1) + local tmpf=$(mktemp) || exit 1 local fpattern="s|${PKGDESTDIR}||g;s|^\./$||g;/^$/d" local targets= f= _f= info_files= home= shell= descr= groups= local found= triggers_found= _icondirs= _schemas= _mods= _tmpfiles= diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh index 9edb85ad59b..62077022711 100644 --- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh +++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh @@ -61,7 +61,7 @@ hook() { return 0 fi - depsftmp=$(mktemp || exit 1) + depsftmp=$(mktemp) || exit 1 find ${PKGDESTDIR} -type f -perm -u+w > $depsftmp 2>/dev/null exec 3<&0 # save stdin diff --git a/common/hooks/pre-pkg/06-shlib-provides.sh b/common/hooks/pre-pkg/06-shlib-provides.sh index 44c452a5d9a..cdc94de3bc9 100644 --- a/common/hooks/pre-pkg/06-shlib-provides.sh +++ b/common/hooks/pre-pkg/06-shlib-provides.sh @@ -5,7 +5,7 @@ collect_sonames() { local _destdir="$1" f _soname _fname _pattern local _pattern="^[[:alnum:]]+(.*)+\.so(\.[0-9]+)*$" local _versioned_pattern="^[[:alnum:]]+(.*)+\.so(\.[0-9]+)+$" - local _tmpfile="$(mktemp || exit 1)" + local _tmpfile=$(mktemp) || exit 1 if [ ! -d ${_destdir} ]; then rm -f ${_tmpfile} diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh index 3c6f4d7d1dd..6e89072a442 100755 --- a/common/xbps-src/libexec/build.sh +++ b/common/xbps-src/libexec/build.sh @@ -131,7 +131,7 @@ fi # the bootstrap pkgs from scratch. if [ -z "$CHROOT_READY" -a "$PKGNAME" = "base-files" ]; then msg_normal "Installing $PKGNAME into masterdir...\n" - _log=$(mktemp || exit 1) + _log=$(mktemp) || exit 1 XBPS_ARCH=$XBPS_MACHINE $XBPS_INSTALL_CMD -yf $PKGNAME >${_log} 2>&1 if [ $? -ne 0 ]; then msg_red "Failed to install $PKGNAME into masterdir, see below for errors:\n" diff --git a/common/xbps-src/shutils/bulk.sh b/common/xbps-src/shutils/bulk.sh index ebcd92214c6..73947965282 100644 --- a/common/xbps-src/shutils/bulk.sh +++ b/common/xbps-src/shutils/bulk.sh @@ -30,7 +30,7 @@ bulk_sortdeps() { fi done - tmpf=$(mktemp || exit 1) + tmpf=$(mktemp) || exit 1 # Now make the real dependency graph of all pkgs to build. # Perform a topological sort of all pkgs but only with build dependencies # that are found in previous step. diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index ff823538a08..fea2f952717 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -5,7 +5,7 @@ run_func() { : ${funcname:=$func} - logpipe=$(mktemp -u -p ${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe || exit 1) + logpipe=$(mktemp -u -p ${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe) || exit 1 logfile=${XBPS_STATEDIR}/${pkgname}_${XBPS_CROSS_BUILD}_${funcname}.log msg_normal "${pkgver:-xbps-src}: running ${desc:-${func}} ...\n" diff --git a/common/xbps-src/shutils/cross.sh b/common/xbps-src/shutils/cross.sh index 4aab8b81ded..12c9efa9b49 100644 --- a/common/xbps-src/shutils/cross.sh +++ b/common/xbps-src/shutils/cross.sh @@ -6,7 +6,7 @@ remove_pkg_cross_deps() { cd $XBPS_MASTERDIR || return 1 msg_normal "${pkgver:-xbps-src}: removing autocrossdeps, please wait...\n" - tmplogf=$(mktemp || exit 1) + tmplogf=$(mktemp) || exit 1 if [ -z "$XBPS_REMOVE_XCMD" ]; then source_file $XBPS_CROSSPFDIR/${XBPS_CROSS_BUILD}.sh @@ -37,7 +37,7 @@ prepare_cross_sysroot() { [ $? -eq 0 ] && return 0 msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n" - errlog=$(mktemp || exit 1) + errlog=$(mktemp) || exit 1 $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog rval=$? if [ $rval -ne 0 -a $rval -ne 17 ]; then @@ -71,7 +71,7 @@ install_cross_pkg() { check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1 [ $? -eq 0 ] && return 0 - errlog=$(mktemp || exit 1) + errlog=$(mktemp) || exit 1 msg_normal "Installing $cross cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n" $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog rval=$? diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh index bb2c01149e6..a7be624173e 100644 --- a/common/xbps-src/shutils/pkgtarget.sh +++ b/common/xbps-src/shutils/pkgtarget.sh @@ -48,7 +48,7 @@ remove_pkg_autodeps() { cd $XBPS_MASTERDIR || return 1 msg_normal "${pkgver:-xbps-src}: removing autodeps, please wait...\n" - tmplogf=$(mktemp || exit 1) + tmplogf=$(mktemp) || exit 1 remove_pkg_cross_deps $XBPS_RECONFIGURE_CMD -a >> $tmplogf 2>&1 diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh index 84db717dc36..e2fc956514e 100644 --- a/common/xbps-src/shutils/show.sh +++ b/common/xbps-src/shutils/show.sh @@ -64,7 +64,7 @@ show_pkg_build_depends() { local f x _pkgname _srcpkg _dep found result local _deps="$1" - result=$(mktemp || exit 1) + result=$(mktemp) || exit 1 # build time deps for f in ${_deps}; do