From 7aa7651821eb7b6ac60846ff82c64e870c721544 Mon Sep 17 00:00:00 2001 From: "Fred T. Hamster" Date: Mon, 1 Dec 2025 12:14:23 -0500 Subject: [PATCH] new seek_package script for precise install checks and removed yum case from list_package, which was redundant. and fixed the screensaver setup script to use seek_package, so it's an exact check now. sweet. --- scripts/system/list_packages.sh | 12 ++++---- scripts/system/seek_package.sh | 35 ++++++++++++++++++++++++ scripts/system/start_xwin_screensaver.sh | 10 +++++-- 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 scripts/system/seek_package.sh diff --git a/scripts/system/list_packages.sh b/scripts/system/list_packages.sh index 65840e1b..8fd2af00 100644 --- a/scripts/system/list_packages.sh +++ b/scripts/system/list_packages.sh @@ -23,11 +23,13 @@ if [ ! -z "$rpm_available" ]; then exit $? fi -yum_available="$(whichable yum)" -if [ ! -z "$yum_available" ]; then - yum list | eval $SEEK_PIECE - exit $? -fi +# yum should never be available if rpm was not! +#yum_available="$(whichable yum)" +#if [ ! -z "$yum_available" ]; then +# yum list | eval $SEEK_PIECE +# exit $? +#fi echo "Could not deduce what type of OS this is; missing package listing commands." exit 1 + diff --git a/scripts/system/seek_package.sh b/scripts/system/seek_package.sh new file mode 100644 index 00000000..3a0743c8 --- /dev/null +++ b/scripts/system/seek_package.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" + +if [ -z "$*" ]; then + echo This script requires a package name to find in the installed list of packages. + exit 1 +fi + +if debian_like; then + apt -qq list "$1" 2>/dev/null | grep -q '[installed]' +ret=$? +echo ret from seeking actual is $ret +exit $ret + + exit $? +fi + +rpm_available="$(whichable rpm)" +if [ ! -z "$rpm_available" ]; then + rpm -q --queryformat %{NAME} -p "$1" +#hmmm: this is probably noisy, but we need an rpm system to test on. + exit $? +fi + +# yum should never be available if rpm was not! +#yum_available="$(whichable yum)" +#if [ ! -z "$yum_available" ]; then +# yum list | eval $SEEK_PIECE +# exit $? +#fi + +echo "Could not deduce what type of OS this is; missing package listing commands." +exit 1 + diff --git a/scripts/system/start_xwin_screensaver.sh b/scripts/system/start_xwin_screensaver.sh index 2cb9c40f..1216eabe 100644 --- a/scripts/system/start_xwin_screensaver.sh +++ b/scripts/system/start_xwin_screensaver.sh @@ -17,12 +17,16 @@ fi # tests whether the package name provided as a parameter is already installed on the host. function check_installed() { - bash $FEISTY_MEOW_SCRIPTS/system/list_packages.sh "$1" &>/dev/null + bash $FEISTY_MEOW_SCRIPTS/system/seek_package.sh "$1" &>/dev/null +out=$? +echo out is $out on the seek +return $out + + return $? } # checks whether the provided package is already present, and if not, installs it. -#hmmm: only works with apt based systems currently! -#hmmm: list_packages is an inexact check! it will match xscreensaver-data for xscreensaver as pattern!!! +#hmmm: the below code only works with apt based systems currently! function install_if_missing() { packname="$1"; shift -- 2.34.1