From 6cd526a7dc0c076942d7972cafc228af61ab7668 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Tue, 7 Jun 2022 10:03:17 +0200 Subject: [PATCH] rename package manager functions --- check_packages2install-pkgmanager/apt.sh | 12 ++++++------ check_packages2install-pkgmanager/pamac.sh | 5 +++-- check_packages2install-pkgmanager/yum.sh | 12 +++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/check_packages2install-pkgmanager/apt.sh b/check_packages2install-pkgmanager/apt.sh index b650f38..877722d 100644 --- a/check_packages2install-pkgmanager/apt.sh +++ b/check_packages2install-pkgmanager/apt.sh @@ -9,27 +9,27 @@ # --------------------------------------------------------------- # ah <axel.hahn@iml.unibe.ch> # 2022-06-03 v1.0 ah first version +# 2022-06-07 v1.1 ah remove text "Nothing to install" +# rename functions # =============================================================== # --------------------------------------------------------------- # command to list of updates -function aptGetUpdates(){ +function apt.getUpdates(){ sudo apt-get -u upgrade --assume-no } # --------------------------------------------------------------- # extract list of packages 2 install # global string packagemanOut output of update lister command -function aptPackages(){ +function apt.getPackageList(){ # detect number of line containing "The following packages will be upgraded:" typeset -i local iStart iStart=$( echo "$packagemanOut" | grep -n '^The following packages will be upgraded:' | cut -f 1 -d ':' ) - if [ $iStart -eq 0 ]; then - echo "Nothing to install" - else + if [ $iStart -gt 0 ]; then # show packages = text starting with 2 spaces below start line # packages are delimited with space -> replace with new line echo "$packagemanOut" | sed -n $iStart,\$p | grep "^\ \ " | sed "s#^\ \ ##g" | tr " " "\n" @@ -39,7 +39,7 @@ function aptPackages(){ # --------------------------------------------------------------- # get status line on apt based systems (debian, ubuntu) # global string packagemanOut output of update lister command -function aptStatus(){ +function apt.getStatusLine(){ echo "$packagemanOut" | grep "upgraded.*installed" } diff --git a/check_packages2install-pkgmanager/pamac.sh b/check_packages2install-pkgmanager/pamac.sh index 279b073..b5f039f 100644 --- a/check_packages2install-pkgmanager/pamac.sh +++ b/check_packages2install-pkgmanager/pamac.sh @@ -9,18 +9,19 @@ # --------------------------------------------------------------- # ah <axel.hahn@iml.unibe.ch> # 2022-06-03 v1.0 ah first version +# 2022-06-07 v1.1 ah rename functions # =============================================================== # --------------------------------------------------------------- # command to list of updates -function pamacGetUpdates(){ +function pamac.GetUpdates(){ pamac checkupdates } # --------------------------------------------------------------- # extract list of packages 2 install # global string packagemanOut output of update lister command -function pamacPackages(){ +function pamac.getPackageList(){ echo "$packagemanOut" | grep -- '->' } diff --git a/check_packages2install-pkgmanager/yum.sh b/check_packages2install-pkgmanager/yum.sh index 735f8e0..829abe6 100644 --- a/check_packages2install-pkgmanager/yum.sh +++ b/check_packages2install-pkgmanager/yum.sh @@ -9,19 +9,21 @@ # --------------------------------------------------------------- # ah <axel.hahn@iml.unibe.ch> # 2022-06-03 v1.0 ah first version +# 2022-06-07 v1.1 ah add sudo for yum --bugfix check-update +# rename functions # =============================================================== # --------------------------------------------------------------- # command to list of updates -function yumGetUpdates(){ +function yum.GetUpdates(){ sudo /usr/bin/yum -y check-update } # --------------------------------------------------------------- # extract list of packages 2 install # global string packagemanOut output of update lister command -function yumPackages(){ +function yum.getPackageList(){ local iStart=3 # detect number of line containing "Obsoleting Packages" typeset -i iEnd=$( echo "$packagemanOut" | grep -n '^Obsoleting Packages' | cut -f 1 -d ':' )-1 @@ -34,16 +36,16 @@ function yumPackages(){ # --------------------------------------------------------------- # get custom status -function yumStatus(){ +function yum.getStatusLine(){ if ! sudo /usr/bin/yum --bugfix check-update 2>&1 | grep security; then - echo "Ooops - no output from [/usr/bin/yum --bugfix check-update]" + echo "Ooops - no output from [sudo /usr/bin/yum --bugfix check-update]" fi } # --------------------------------------------------------------- # extract count of critical packages # param string text to extract critical counter from -function yumCritical(){ +function yum.getCriticalList(){ local summary="$1" # example outputs: # I No packages needed for security; 223 packages available -- GitLab