diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index 4a159a47198..0ad12cb36b2 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -34,6 +34,15 @@ error_func() { exit 2 } +exit_and_cleanup() { + local rval=$1 + + if [ -n "$XBPS_TEMP_MASTERDIR" ]; then + rm -rf "$XBPS_MASTERDIR" + fi + exit ${rval:=0} +} + msg_red() { # error messages in bold/red [ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m" @@ -200,7 +209,7 @@ get_subpkgs() { setup_pkg() { local pkg="$1" cross="$2" - local val _vars f dbgflags + local val _vars f dbgflags _arch [ -z "$pkg" ] && return 1 @@ -322,8 +331,13 @@ setup_pkg() { makejobs="-j$XBPS_MAKEJOBS" fi - if [ -n "$XBPS_BINPKG_EXISTS" -a -f "$XBPS_REPOSITORY/${pkgver}.${XBPS_TARGET_MACHINE}.xbps" ]; then - exit 0 + if [ -n "$noarch" ]; then + _arch="noarch" + else + _arch="$XBPS_TARGET_MACHINE" + fi + if [ -n "$XBPS_BINPKG_EXISTS" -a -f "${XBPS_REPOSITORY}/${pkgver}.${_arch}.xbps" ]; then + exit_and_cleanup fi if [ -z "$XBPS_DEBUG_PKGS" -o "$repository" = "nonfree" ]; then diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh index 628d8b8071e..dbe840ff5dd 100644 --- a/common/xbps-src/shutils/pkgtarget.sh +++ b/common/xbps-src/shutils/pkgtarget.sh @@ -116,12 +116,11 @@ install_pkg() { if [ "$XBPS_TARGET_PKG" = "$sourcepkg" ]; then if [ "$XBPS_TARGET" = "bootstrap" ]; then return 0 - else - # Package built successfully. Exit directly due to nested install_pkg - # and install_pkg_deps functions. - remove_cross_pkg $cross - exit 0 fi + # Package built successfully. Exit directly due to nested install_pkg + # and install_pkg_deps functions. + remove_cross_pkg $cross + exit_and_cleanup fi } diff --git a/xbps-src b/xbps-src index 03dfb4c4c7a..819dd66b60c 100755 --- a/xbps-src +++ b/xbps-src @@ -679,9 +679,4 @@ case "$XBPS_TARGET" in ;; esac -rval=$? - -[ -n "$XBPS_TEMP_MASTERDIR" ] && rm -rf "$XBPS_MASTERDIR" - -# Agur -exit $rval +exit_and_cleanup $?