Skip to content
Snippets Groups Projects
Commit 6cd526a7 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

rename package manager functions

parent 42f9adf3
No related branches found
No related tags found
1 merge request!20add sudo when calling yum
...@@ -9,27 +9,27 @@ ...@@ -9,27 +9,27 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# ah <axel.hahn@iml.unibe.ch> # ah <axel.hahn@iml.unibe.ch>
# 2022-06-03 v1.0 ah first version # 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 # command to list of updates
function aptGetUpdates(){ function apt.getUpdates(){
sudo apt-get -u upgrade --assume-no sudo apt-get -u upgrade --assume-no
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
# extract list of packages 2 install # extract list of packages 2 install
# global string packagemanOut output of update lister command # global string packagemanOut output of update lister command
function aptPackages(){ function apt.getPackageList(){
# detect number of line containing "The following packages will be upgraded:" # detect number of line containing "The following packages will be upgraded:"
typeset -i local iStart typeset -i local iStart
iStart=$( echo "$packagemanOut" | grep -n '^The following packages will be upgraded:' | cut -f 1 -d ':' ) iStart=$( echo "$packagemanOut" | grep -n '^The following packages will be upgraded:' | cut -f 1 -d ':' )
if [ $iStart -eq 0 ]; then if [ $iStart -gt 0 ]; then
echo "Nothing to install"
else
# show packages = text starting with 2 spaces below start line # show packages = text starting with 2 spaces below start line
# packages are delimited with space -> replace with new line # packages are delimited with space -> replace with new line
echo "$packagemanOut" | sed -n $iStart,\$p | grep "^\ \ " | sed "s#^\ \ ##g" | tr " " "\n" echo "$packagemanOut" | sed -n $iStart,\$p | grep "^\ \ " | sed "s#^\ \ ##g" | tr " " "\n"
...@@ -39,7 +39,7 @@ function aptPackages(){ ...@@ -39,7 +39,7 @@ function aptPackages(){
# --------------------------------------------------------------- # ---------------------------------------------------------------
# get status line on apt based systems (debian, ubuntu) # get status line on apt based systems (debian, ubuntu)
# global string packagemanOut output of update lister command # global string packagemanOut output of update lister command
function aptStatus(){ function apt.getStatusLine(){
echo "$packagemanOut" | grep "upgraded.*installed" echo "$packagemanOut" | grep "upgraded.*installed"
} }
......
...@@ -9,18 +9,19 @@ ...@@ -9,18 +9,19 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# ah <axel.hahn@iml.unibe.ch> # ah <axel.hahn@iml.unibe.ch>
# 2022-06-03 v1.0 ah first version # 2022-06-03 v1.0 ah first version
# 2022-06-07 v1.1 ah rename functions
# =============================================================== # ===============================================================
# --------------------------------------------------------------- # ---------------------------------------------------------------
# command to list of updates # command to list of updates
function pamacGetUpdates(){ function pamac.GetUpdates(){
pamac checkupdates pamac checkupdates
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
# extract list of packages 2 install # extract list of packages 2 install
# global string packagemanOut output of update lister command # global string packagemanOut output of update lister command
function pamacPackages(){ function pamac.getPackageList(){
echo "$packagemanOut" | grep -- '->' echo "$packagemanOut" | grep -- '->'
} }
......
...@@ -9,19 +9,21 @@ ...@@ -9,19 +9,21 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# ah <axel.hahn@iml.unibe.ch> # ah <axel.hahn@iml.unibe.ch>
# 2022-06-03 v1.0 ah first version # 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 # command to list of updates
function yumGetUpdates(){ function yum.GetUpdates(){
sudo /usr/bin/yum -y check-update sudo /usr/bin/yum -y check-update
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
# extract list of packages 2 install # extract list of packages 2 install
# global string packagemanOut output of update lister command # global string packagemanOut output of update lister command
function yumPackages(){ function yum.getPackageList(){
local iStart=3 local iStart=3
# detect number of line containing "Obsoleting Packages" # detect number of line containing "Obsoleting Packages"
typeset -i iEnd=$( echo "$packagemanOut" | grep -n '^Obsoleting Packages' | cut -f 1 -d ':' )-1 typeset -i iEnd=$( echo "$packagemanOut" | grep -n '^Obsoleting Packages' | cut -f 1 -d ':' )-1
...@@ -34,16 +36,16 @@ function yumPackages(){ ...@@ -34,16 +36,16 @@ function yumPackages(){
# --------------------------------------------------------------- # ---------------------------------------------------------------
# get custom status # get custom status
function yumStatus(){ function yum.getStatusLine(){
if ! sudo /usr/bin/yum --bugfix check-update 2>&1 | grep security; then 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 fi
} }
# --------------------------------------------------------------- # ---------------------------------------------------------------
# extract count of critical packages # extract count of critical packages
# param string text to extract critical counter from # param string text to extract critical counter from
function yumCritical(){ function yum.getCriticalList(){
local summary="$1" local summary="$1"
# example outputs: # example outputs:
# I No packages needed for security; 223 packages available # I No packages needed for security; 223 packages available
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment