Skip to content
Snippets Groups Projects

add sudo when calling yum

Merged Hahn Axel (hahn) requested to merge 5419-update-check-packages2install into master
4 files
+ 36
26
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -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"
}
Loading