From 0661263dd877dccbffe94132fb9eff477e28dcf0 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Mon, 21 Jan 2019 13:15:11 +0000 Subject: [PATCH] buildsystem: restore set -e fail-on-error behaviour --- config/functions | 28 +++++++++++++------------- packages/sysutils/e2fsprogs/package.mk | 2 +- scripts/build | 26 +++++++++++++++--------- scripts/create_addon | 4 +++- scripts/install | 4 ++-- scripts/unpack | 12 ++++++----- 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/config/functions b/config/functions index 4221465174..0d8d532e62 100644 --- a/config/functions +++ b/config/functions @@ -805,22 +805,18 @@ find_dir_path() { find_path -d "$1" "$2" } -# p1: name of potential function to execute if it exists -# return 0 if function executed, 1 if not, die if error +# p1: name of function to test for +# return 0 if function exists, 1 if not +pkg_call_exists() { + [ "$(type -t ${1})" = "function" ] && return 0 || return 1 +} + +# p1: name of function to execute unconditionally +# testing the exit code value of this function is likely to break set -e fail-on-error behaviour pkg_call() { [ -n "${PKG_NAME}" ] || die "$(print_color CLR_ERROR "FAILURE: Cannot call ${1} package function when package is not known!")" - if [ "$(type -t ${1})" = "function" ]; then - ${1} || die "$(print_color CLR_ERROR "FAILURE: ${1} for package ${PKG_NAME} did not succeed!")" - else - return 1 - fi -} - -# p1: name of potential function to execute if it exists -# return 0 if function executed or not, or die if error -pkg_call_optional() { - pkg_call ${1} || return 0 + ${1} } unset_functions() { @@ -922,7 +918,11 @@ source_package() { # Late variable binding - allow the package to now evaluate any variables # that we may have initialised after sourcing the package, typically # PKG_BUILD etc. - [ -n "${PKG_NAME}" ] && pkg_call_optional configure_package || true + if [ -n "${PKG_NAME}" ]; then + if pkg_call_exists configure_package; then + pkg_call configure_package + fi + fi } diff --git a/packages/sysutils/e2fsprogs/package.mk b/packages/sysutils/e2fsprogs/package.mk index 0daafc5b05..65ba2b8c66 100644 --- a/packages/sysutils/e2fsprogs/package.mk +++ b/packages/sysutils/e2fsprogs/package.mk @@ -48,7 +48,7 @@ pre_configure_target() { } pre_configure_init() { - pkg_call pre_configure_target || die "pre_configure_target not found" + pkg_call pre_configure_target PKG_CONFIGURE_OPTS_INIT="$PKG_CONFIGURE_OPTS_TARGET" } diff --git a/scripts/build b/scripts/build index 9032474dd3..1d240b2a12 100755 --- a/scripts/build +++ b/scripts/build @@ -205,7 +205,7 @@ if [ "$PKG_TOOLCHAIN" = "autotools" ]; then fi # include build template and build -pkg_call_optional pre_build_$TARGET +pkg_call_exists pre_build_$TARGET && pkg_call pre_build_$TARGET # ensure $PKG_BUILD is there. (installer? PKG_URL="") if [ ! -d "$PKG_BUILD" ] ; then @@ -228,9 +228,11 @@ if [ -f "$PKG_CONFIGURE_SCRIPT" -o -f "$PKG_CMAKE_SCRIPT" -o -f "$PKG_MESON_SCRI fi # configure -pkg_call_optional pre_configure_$TARGET +pkg_call_exists pre_configure_$TARGET && pkg_call pre_configure_$TARGET -if ! pkg_call configure_$TARGET; then +if pkg_call_exists configure_$TARGET; then + pkg_call configure_$TARGET +else case "$PKG_TOOLCHAIN:$TARGET" in # meson builds "meson:target") @@ -310,12 +312,14 @@ if ! pkg_call configure_$TARGET; then esac fi -pkg_call_optional post_configure_$TARGET +pkg_call_exists post_configure_$TARGET && pkg_call post_configure_$TARGET # make -pkg_call_optional pre_make_$TARGET +pkg_call_exists pre_make_$TARGET && pkg_call pre_make_$TARGET -if ! pkg_call make_$TARGET; then +if pkg_call_exists make_$TARGET; then + pkg_call make_$TARGET +else case "$PKG_TOOLCHAIN:$TARGET" in # ninja based builds "meson:target"|"cmake:target"|"ninja:target") @@ -355,12 +359,14 @@ if ! pkg_call make_$TARGET; then esac fi -pkg_call_optional post_make_$TARGET +pkg_call_exists post_make_$TARGET && pkg_call post_make_$TARGET # make install -pkg_call_optional pre_makeinstall_$TARGET +pkg_call_exists pre_makeinstall_$TARGET && pkg_call pre_makeinstall_$TARGET -if ! pkg_call makeinstall_$TARGET; then +if pkg_call_exists makeinstall_$TARGET; then + pkg_call makeinstall_$TARGET +else case "$PKG_TOOLCHAIN:$TARGET" in # ninja based builds "meson:target"|"cmake:target") @@ -394,7 +400,7 @@ if ! pkg_call makeinstall_$TARGET; then esac fi -pkg_call_optional post_makeinstall_$TARGET +pkg_call_exists post_makeinstall_$TARGET && pkg_call post_makeinstall_$TARGET if [ "$TARGET" = "target" -o "$TARGET" = "init" ]; then if [ -d $INSTALL ]; then diff --git a/scripts/create_addon b/scripts/create_addon index 1644793967..64588696d7 100755 --- a/scripts/create_addon +++ b/scripts/create_addon @@ -208,7 +208,9 @@ build_addon() { rm -rf $ADDON_BUILD # install addon parts - if ! pkg_call addon; then + if pkg_call_exists addon; then + pkg_call addon + else install_binary_addon $PKG_ADDON_ID fi diff --git a/scripts/install b/scripts/install index d9e0bfa35a..cb8521ce49 100755 --- a/scripts/install +++ b/scripts/install @@ -123,7 +123,7 @@ fi # install if [ "$TARGET" = target ] ; then - pkg_call_optional pre_install + pkg_call_exists pre_install && pkg_call pre_install fi if [ "$TARGET" = "target" -a -d $PKG_BUILD/.install_pkg ]; then @@ -133,7 +133,7 @@ elif [ "$TARGET" = "init" -a -d $PKG_BUILD/.install_init ]; then fi if [ "$TARGET" = target ] ; then - pkg_call_optional post_install + pkg_call_exists post_install && pkg_call post_install fi touch $STAMP diff --git a/scripts/unpack b/scripts/unpack index 3dce2c42d2..5da8a4ff77 100755 --- a/scripts/unpack +++ b/scripts/unpack @@ -44,9 +44,11 @@ fi if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then build_msg "CLR_UNPACK" "UNPACK" "${1}" "indent" - pkg_call_optional pre_unpack + pkg_call_exists pre_unpack && pkg_call pre_unpack - if ! pkg_call unpack; then + if pkg_call_exists unpack; then + pkg_call unpack + else if [ -n "$PKG_URL" ]; then $SCRIPTS/extract $1 $BUILD fi @@ -69,10 +71,10 @@ if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then mkdir -p "${PKG_BUILD}" fi - pkg_call_optional post_unpack + pkg_call_exists post_unpack && pkg_call post_unpack if [ "${PKG_SKIP_PATCHES}" != "yes" ]; then - pkg_call_optional pre_patch + pkg_call_exists pre_patch && pkg_call pre_patch if [ "$TARGET_ARCH" = "x86_64" ]; then PATCH_ARCH="x86" @@ -141,7 +143,7 @@ if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then fi done - pkg_call_optional post_patch + pkg_call_exists post_patch && pkg_call post_patch fi if [ ! "$PKG_NAME" = "configtools" ] ; then