update pkg_installed function

This commit is contained in:
Patrick Schleizer 2025-01-31 14:33:54 -05:00
parent ac1493fcfc
commit 041caf286b
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -33,13 +33,13 @@ pkg_installed() {
package_name="$1" package_name="$1"
## Cannot use '&>' because it is a bashism. ## Cannot use '&>' because it is a bashism.
dpkg_query_output="$(dpkg-query --show --showformat='${Status}' "$package_name" 2>/dev/null)" || true dpkg_query_output="$(dpkg-query --show --showformat='${Status}' "$package_name" 2>/dev/null)" || true
## dpkg_query_output Exampels: ## dpkg_query_output Examples:
## install ok half-configured ## install ok half-configured
## install ok installed ## install ok installed
requested_action=$(echo "$dpkg_query_output" | awk '{print $1}') requested_action=$(printf '%s' "$dpkg_query_output" | awk '{print $1}')
status=$(echo "$dpkg_query_output" | awk '{print $2}') status=$(printf '%s' "$dpkg_query_output" | awk '{print $2}')
error_state=$(echo "$dpkg_query_output" | awk '{print $3}') error_state=$(printf '%s' "$dpkg_query_output" | awk '{print $3}')
if [ "$requested_action" = 'install' ]; then if [ "$requested_action" = 'install' ]; then
true "$0: INFO: $package_name is installed, ok." true "$0: INFO: $package_name is installed, ok."