From fdc9250bca7bfce660758d77af2ffa971bc19ecb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 4 Jan 2015 18:08:09 +0100 Subject: Changing package dependency checks within chroot to work outside as well. --- functions/packages.sh | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'functions') diff --git a/functions/packages.sh b/functions/packages.sh index 4211c0eaa..ebbeb4aa8 100755 --- a/functions/packages.sh +++ b/functions/packages.sh @@ -10,10 +10,11 @@ Check_package () { - FILE="${1}" - PACKAGE="${2}" + CHROOT="${1}" + FILE="${2}" + PACKAGE="${3}" - Check_installed "${FILE}" "${PACKAGE}" + Check_installed "${CHROOT}" "${FILE}" "${PACKAGE}" case "${INSTALL_STATUS}" in 1) @@ -66,38 +67,35 @@ Remove_package () # 2 if package isn't installed and we aren't in an apt managed system Check_installed () { - FILE="${1}" - PACKAGE="${2}" + CHROOT="${1}" + FILE="${2}" + PACKAGE="${3}" - case "${LB_BUILD_WITH_CHROOT}" in - true) + if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] && [ "${CHROOT}" = "chroot" ] + then + if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" + then + INSTALL_STATUS=0 + else + INSTALL_STATUS=1 + fi + else + if which dpkg-query > /dev/null 2>&1 + then if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" then INSTALL_STATUS=0 else INSTALL_STATUS=1 fi - ;; - false) - if which dpkg-query > /dev/null 2>&1 + else + if [ ! -e "${FILE}" ] then - if Chroot chroot "dpkg-query -s ${PACKAGE}" 2> /dev/null | grep -qs "Status: install" - then - INSTALL_STATUS=0 - else - INSTALL_STATUS=1 - fi + INSTALL_STATUS=2 else - FILE="$(echo ${FILE} | sed -e 's|chroot||')" - - if [ ! -e "${FILE}" ] - then - INSTALL_STATUS=2 - else - INSTALL_STATUS=0 - fi + INSTALL_STATUS=0 fi - ;; - esac + fi + fi } -- cgit v1.2.3