Skip to content

Instantly share code, notes, and snippets.

@XIIIVI
Last active June 12, 2020 12:54
Show Gist options
  • Save XIIIVI/27a691f08b7e358443fa83f10f793747 to your computer and use it in GitHub Desktop.
Save XIIIVI/27a691f08b7e358443fa83f10f793747 to your computer and use it in GitHub Desktop.
#
# check_installed_packages
#
check_installed_packages(){
local PACKAGE_LIST=("$@") # Rebuild the array with rest of arguments
for index in "${PACKAGE_LIST[@]}";
do
TEST_COUNT=$((TEST_COUNT + 1))
IS_INSTALLED=$(awk '/Package:/ {print $2}' ${MNT_DIR}/var/lib/dpkg/status | grep -x ${index} || true)
if [ -z "${IS_INSTALLED}" ]
then
test_failed "The package ${index} is missing"
else
test_succeeded "The package ${index} has been found"
fi
done
}
#
# check_missing_packages
#
check_missing_packages(){
local PACKAGE_LIST=("$@") # Rebuild the array with rest of arguments
for index in "${PACKAGE_LIST[@]}";
do
TEST_COUNT=$((TEST_COUNT + 1))
IS_INSTALLED=$(awk '/Package:/ {print $2}' ${MNT_DIR}/var/lib/dpkg/status | grep -x ${index} || true)
if [ -z "${IS_INSTALLED}" ]
then
test_succeeded "The package ${index} is missing"
else
test_failed "The package ${index} has been found"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment