From e60eb854e654008f4bc4ec79c18ced8d86730ca1 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 10 Apr 2014 11:58:06 +0200 Subject: [PATCH] xbps-src: move check_installed_pkg() to build_dependencies.sh. --- common/xbps-src/shutils/build_dependencies.sh | 31 +++++++++++++++++-- common/xbps-src/shutils/common.sh | 28 ----------------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh index 6040aa8114a..55d7ac491e6 100644 --- a/common/xbps-src/shutils/build_dependencies.sh +++ b/common/xbps-src/shutils/build_dependencies.sh @@ -69,6 +69,33 @@ check_pkgdep_matched() { return 1 } +# +# Returns 0 if pkgpattern in $1 is installed and greater than current +# installed package, otherwise 1. +# +check_installed_pkg() { + local pkg="$1" cross="$2" uhelper= pkgn= iver= + + [ -z "$pkg" ] && return 2 + + pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg})" + [ -z "$pkgn" ] && return 2 + + if [ -n "$cross" ]; then + uhelper="$XBPS_UHELPER_XCMD" + else + uhelper="$XBPS_UHELPER_CMD" + fi + + iver="$($uhelper version $pkgn)" + if [ $? -eq 0 -a -n "$iver" ]; then + $XBPS_CMPVER_CMD "${pkgn}-${iver}" "${pkg}" + [ $? -eq 0 -o $? -eq 1 ] && return 0 + fi + + return 1 +} + # # Installs all dependencies required by a package. # @@ -201,7 +228,7 @@ install_pkg_deps() { ${XBPS_UHELPER_CMD} pkgmatch "$pkgver" "$i" if [ $? -eq 0 ]; then setup_pkg $XBPS_TARGET_PKG - msg_error_nochroot "$pkgver: required host dependency '$i' cannot be resolved!\n" + msg_error "$pkgver: required host dependency '$i' cannot be resolved!\n" fi install_pkg full setup_pkg $XBPS_TARGET_PKG $XBPS_CROSS_BUILD @@ -218,7 +245,7 @@ install_pkg_deps() { $XBPS_UHELPER_CMD pkgmatch "$pkgver" "$i" if [ $? -eq 0 ]; then setup_pkg $XBPS_TARGET_PKG $cross - msg_error_nochroot "$pkgver: required target dependency '$i' cannot be resolved!\n" + msg_error "$pkgver: required target dependency '$i' cannot be resolved!\n" fi install_pkg full $cross setup_pkg $XBPS_TARGET_PKG $XBPS_CROSS_BUILD diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh index 8d6a5e11f2b..d4adba7256d 100644 --- a/common/xbps-src/shutils/common.sh +++ b/common/xbps-src/shutils/common.sh @@ -454,7 +454,6 @@ _remove_pkg_cross_deps() { rm -f $tmplogf } - remove_pkg_autodeps() { local rval= tmplogf= @@ -537,30 +536,3 @@ remove_cross_pkg() { msg_error "failed to remove cross-${XBPS_CROSS_TRIPLET} (error $rval)\n" fi } - -# -# Returns 0 if pkgpattern in $1 is installed and greater than current -# installed package, otherwise 1. -# -check_installed_pkg() { - local pkg="$1" cross="$2" uhelper= pkgn= iver= - - [ -z "$pkg" ] && return 2 - - pkgn="$($XBPS_UHELPER_CMD getpkgname ${pkg})" - [ -z "$pkgn" ] && return 2 - - if [ -n "$cross" ]; then - uhelper="$XBPS_UHELPER_XCMD" - else - uhelper="$XBPS_UHELPER_CMD" - fi - - iver="$($uhelper version $pkgn)" - if [ $? -eq 0 -a -n "$iver" ]; then - $XBPS_CMPVER_CMD "${pkgn}-${iver}" "${pkg}" - [ $? -eq 0 -o $? -eq 1 ] && return 0 - fi - - return 1 -}