diff --git a/check_packages2install b/check_packages2install index 96386410085d4e158320719294db016ae5ee06af..5fd2c5d047553a549c2b4eaff99c42874a9b5d40 100755 --- a/check_packages2install +++ b/check_packages2install @@ -18,6 +18,7 @@ # 2021-05-11 v1.4 <axel.hahn@iml.unibe.ch> added centos8 support # 2021-08-20 v1.5 <martin.gasser@iml.unibe.ch> bug fixing - missing sudo in yum command # 2021-12-16 v1.6 <axel.hahn@iml.unibe.ch> show filtered overview +# 2021-12-17 v1.7 <axel.hahn@iml.unibe.ch> show non matching packages in section "other" # ====================================================================== @@ -60,10 +61,12 @@ function _exec(){ # filter is a param with spaced keywords that will be transformed # to a regex # param1 text if filter keywords (seperated by space) +# param2 text additional grep params; "-v" to invert filtering function _filterPkg(){ local _filter=$( echo $1 | tr " " "|" ) + local _moreparams=$2 - grep -E "^($_filter)" + grep $_moreparams -E "^($_filter)" } # autodetect a package manager using which with @@ -78,7 +81,9 @@ function detectPkgManager(){ } # Debian like Linux +# - Debian 10 # - Debian 11 +# - Ubuntu function pkgApt(){ local sum=$( _exec "sudo apt-get -u upgrade --assume-no" ) @@ -190,12 +195,14 @@ function showFilteredPackages(){ if [ ! -z "$pkgsum" ]; then typeset -i iTotal=$( echo "$pkgsum" | wc -l ) typeset -i iFound=0 + filterAll="" # show filtered view for filterfile in $( ls -1 $0-data/*txt | sort ) do filtername=$( echo $filterfile | rev | cut -f 1 -d "/" | rev | sed "s#.txt\$##g" | sed "s#^[0-9]*_##g" ) filterdata=$( cat ${filterfile} | grep "^[a-zA-Z]" ) + filterAll="$filterAll $filterdata" out=$( echo "$pkgsum" | _filterPkg "${filterdata}" ) typeset -i iCount=$( echo "$out" | grep "." | wc -l ) @@ -213,7 +220,8 @@ function showFilteredPackages(){ if [ $iFound -eq 0 ]; then echo "No package matched a group filter." else - echo "Other packages: $iOther" + echo "--- Other packages: $iOther" + echo "$pkgsum" | _filterPkg "${filterAll}" "-v" fi # total packages