From f916081e1cf3cf8f63d7d2e708353f6a9303401c Mon Sep 17 00:00:00 2001 From: Mathieu Arnold Date: Wed, 11 Nov 2020 13:29:52 +0000 Subject: [PATCH] Add set pipefail in most framework scripts. set pipefail changes the pipeline return status from being the return status of the last command to the last non 0 exit status of any command in the pipeline. This is needed to make sure all the commands in a pipeline did actually return a non 0 status and not only the last one. PR: 250723 Exp-run by: antoine Reviewed by: bapt Approved by: bapt Differential Revision: https://reviews.freebsd.org/D27007 --- Mk/Scripts/check-desktop-entries.sh | 1 + Mk/Scripts/check-stagedir.sh | 1 + Mk/Scripts/check-vulnerable.sh | 1 + Mk/Scripts/check_leftovers.sh | 2 ++ Mk/Scripts/checksum.sh | 1 + Mk/Scripts/create-manifest.sh | 1 + Mk/Scripts/depends-list.sh | 1 + Mk/Scripts/desktop-categories.sh | 1 + Mk/Scripts/dialog4ports.sh | 1 + Mk/Scripts/do-depends.sh | 1 + Mk/Scripts/do-fetch.sh | 1 + Mk/Scripts/do-patch.sh | 1 + Mk/Scripts/do-users-groups.sh | 1 + Mk/Scripts/find-lib.sh | 2 ++ Mk/Scripts/generate-symbols.sh | 2 ++ Mk/Scripts/install-desktop-entries.sh | 1 + Mk/Scripts/makesum.sh | 1 + Mk/Scripts/plist_sub_sed_sort.sh | 2 ++ Mk/Scripts/ports_env.sh | 2 ++ Mk/Scripts/qa.sh | 2 ++ Mk/Scripts/rust-compat11-canary.sh | 1 + Mk/Scripts/smart_makepatch.sh | 2 ++ 22 files changed, 29 insertions(+) diff --git a/Mk/Scripts/check-desktop-entries.sh b/Mk/Scripts/check-desktop-entries.sh index 30025f985916..c1492567c6d3 100644 --- a/Mk/Scripts/check-desktop-entries.sh +++ b/Mk/Scripts/check-desktop-entries.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/check-stagedir.sh b/Mk/Scripts/check-stagedir.sh index 231affabe58a..be06948eceb5 100644 --- a/Mk/Scripts/check-stagedir.sh +++ b/Mk/Scripts/check-stagedir.sh @@ -12,6 +12,7 @@ # c. Files in plist which are owned by dependencies/MTREEs set -e +set -o pipefail . ${SCRIPTSDIR}/functions.sh diff --git a/Mk/Scripts/check-vulnerable.sh b/Mk/Scripts/check-vulnerable.sh index bb85a118f559..2eb9d71b40ce 100644 --- a/Mk/Scripts/check-vulnerable.sh +++ b/Mk/Scripts/check-vulnerable.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/check_leftovers.sh b/Mk/Scripts/check_leftovers.sh index 56203f9a73e9..d5868c66de24 100644 --- a/Mk/Scripts/check_leftovers.sh +++ b/Mk/Scripts/check_leftovers.sh @@ -23,6 +23,8 @@ # The PLIST_SUB feature can be disabled by setting PLIST_SUB_SED= # in environment. +set -o pipefail + [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CHECK_LEFTOVERS}" ] && set -x origin="$1" diff --git a/Mk/Scripts/checksum.sh b/Mk/Scripts/checksum.sh index cde14a831999..7f2f1bc58d9c 100644 --- a/Mk/Scripts/checksum.sh +++ b/Mk/Scripts/checksum.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/create-manifest.sh b/Mk/Scripts/create-manifest.sh index cb924a03839c..3221e21d9d33 100644 --- a/Mk/Scripts/create-manifest.sh +++ b/Mk/Scripts/create-manifest.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/depends-list.sh b/Mk/Scripts/depends-list.sh index 843bedd03958..df7769dfeb41 100644 --- a/Mk/Scripts/depends-list.sh +++ b/Mk/Scripts/depends-list.sh @@ -3,6 +3,7 @@ # $FreeBSD$ set -e +set -o pipefail . ${dp_SCRIPTSDIR}/functions.sh diff --git a/Mk/Scripts/desktop-categories.sh b/Mk/Scripts/desktop-categories.sh index 14d9b9643ac1..4be1290fecd7 100644 --- a/Mk/Scripts/desktop-categories.sh +++ b/Mk/Scripts/desktop-categories.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/dialog4ports.sh b/Mk/Scripts/dialog4ports.sh index 61b855ee44b8..eed3f47099e8 100644 --- a/Mk/Scripts/dialog4ports.sh +++ b/Mk/Scripts/dialog4ports.sh @@ -2,6 +2,7 @@ # $FreeBSD$ # Maintainer: portmgr@FreeBSD.org set -e +set -o pipefail [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DIALOG4PORTS}" ] && set -x diff --git a/Mk/Scripts/do-depends.sh b/Mk/Scripts/do-depends.sh index 2185faebe6dd..11cd1662bd1c 100644 --- a/Mk/Scripts/do-depends.sh +++ b/Mk/Scripts/do-depends.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . ${dp_SCRIPTSDIR}/functions.sh diff --git a/Mk/Scripts/do-fetch.sh b/Mk/Scripts/do-fetch.sh index 7772f3b382bd..272f69029c7e 100644 --- a/Mk/Scripts/do-fetch.sh +++ b/Mk/Scripts/do-fetch.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/do-patch.sh b/Mk/Scripts/do-patch.sh index f880738ea367..ef2a7ce9f64c 100644 --- a/Mk/Scripts/do-patch.sh +++ b/Mk/Scripts/do-patch.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/do-users-groups.sh b/Mk/Scripts/do-users-groups.sh index 95c3d9a4c999..4b558d048bed 100644 --- a/Mk/Scripts/do-users-groups.sh +++ b/Mk/Scripts/do-users-groups.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/find-lib.sh b/Mk/Scripts/find-lib.sh index 3e3c523fe042..e8c925ebac78 100644 --- a/Mk/Scripts/find-lib.sh +++ b/Mk/Scripts/find-lib.sh @@ -2,6 +2,8 @@ # MAINTAINER: portmgr@FreeBSD.org # $FreeBSD$ +set -o pipefail + [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_FIND_LIB}" ] && set -x if [ -z "${LIB_DIRS}" -o -z "${LOCALBASE}" ]; then diff --git a/Mk/Scripts/generate-symbols.sh b/Mk/Scripts/generate-symbols.sh index 4ebb8c87de24..e68c6ccd58e3 100644 --- a/Mk/Scripts/generate-symbols.sh +++ b/Mk/Scripts/generate-symbols.sh @@ -9,6 +9,8 @@ # /usr/local/bin/ssh -> /usr/local/lib/debug/usr/local/bin/ssh.debug LIB_DIR_PREFIX="${LOCALBASE}/lib/debug" +set -o pipefail + msg() { echo "====> $*" } diff --git a/Mk/Scripts/install-desktop-entries.sh b/Mk/Scripts/install-desktop-entries.sh index 5acb4db84799..29da3031267b 100644 --- a/Mk/Scripts/install-desktop-entries.sh +++ b/Mk/Scripts/install-desktop-entries.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/makesum.sh b/Mk/Scripts/makesum.sh index a4230905c647..b9cdb0187a34 100644 --- a/Mk/Scripts/makesum.sh +++ b/Mk/Scripts/makesum.sh @@ -4,6 +4,7 @@ # MAINTAINER: portmgr@FreeBSD.org set -e +set -o pipefail . "${dp_SCRIPTSDIR}/functions.sh" diff --git a/Mk/Scripts/plist_sub_sed_sort.sh b/Mk/Scripts/plist_sub_sed_sort.sh index 3dbab42183ad..45ae72f3bf2d 100644 --- a/Mk/Scripts/plist_sub_sed_sort.sh +++ b/Mk/Scripts/plist_sub_sed_sort.sh @@ -5,6 +5,8 @@ # # PLIST_SUB_SED helper to sort by longest value first. +set -o pipefail + awk '{ while (match($0, /s![^!]*![^!]*!g;/)) { sedp=substr($0, RSTART, RLENGTH) diff --git a/Mk/Scripts/ports_env.sh b/Mk/Scripts/ports_env.sh index 7d1d861bf28e..6adb8d7c50b6 100644 --- a/Mk/Scripts/ports_env.sh +++ b/Mk/Scripts/ports_env.sh @@ -3,6 +3,8 @@ # MAINTAINER: portmgr@FreeBSD.org # $FreeBSD$ +set -o pipefail + if [ -z "${SCRIPTSDIR}" ]; then echo "Must set SCRIPTSDIR" >&2 exit 1 diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh index c1c7f912aca0..aa90f47bd5f6 100644 --- a/Mk/Scripts/qa.sh +++ b/Mk/Scripts/qa.sh @@ -2,6 +2,8 @@ # MAINTAINER: portmgr@FreeBSD.org # $FreeBSD$ +set -o pipefail + if [ -z "${STAGEDIR}" -o -z "${PREFIX}" -o -z "${LOCALBASE}" ]; then echo "STAGEDIR, PREFIX, LOCALBASE required in environment." >&2 exit 1 diff --git a/Mk/Scripts/rust-compat11-canary.sh b/Mk/Scripts/rust-compat11-canary.sh index 90e74bda0cfc..cd307ab4bf4a 100644 --- a/Mk/Scripts/rust-compat11-canary.sh +++ b/Mk/Scripts/rust-compat11-canary.sh @@ -2,6 +2,7 @@ # MAINTAINER: rust@FreeBSD.org # $FreeBSD$ set -eu +set -o pipefail if [ "${OPSYS}" != FreeBSD ] || [ "${OSVERSION}" -lt 1200000 ]; then exit 0 diff --git a/Mk/Scripts/smart_makepatch.sh b/Mk/Scripts/smart_makepatch.sh index 286242ba388e..2d7c56cf9e40 100644 --- a/Mk/Scripts/smart_makepatch.sh +++ b/Mk/Scripts/smart_makepatch.sh @@ -25,6 +25,8 @@ # if those targets modify source files (e.g. with sed). You may also # want to disable EXTRA_PATCHES as well if that is being used. +set -o pipefail + [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_SMART_MAKEPATCH}" ] && set -x if [ -z "${PATCHDIR}" -o -z "${PATCH_WRKSRC}" -o -z "${WRKDIR}" ]; then