From 92a8b24015bce10859ac424c07178f33bba7e3d8 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Thu, 16 Dec 2021 17:05:26 +0100 Subject: [PATCH] packages2install: put filtered view into function --- check_packages2install | 77 +++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/check_packages2install b/check_packages2install index b9717be..24a8964 100755 --- a/check_packages2install +++ b/check_packages2install @@ -180,7 +180,48 @@ function checkYum(){ echo } +# ---------------------------------------------------------------------- + +# show grouped packages by category +# OOPS: uses global vars :-/ +function showFilteredPackages(){ + + # filtered package view + if [ ! -z "$pkgsum" ]; then + typeset -i iTotal=$( echo "$pkgsum" | wc -l ) + typeset -i iFound=0 + + # 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]" ) + + out=$( echo "$pkgsum" | _filterPkg "${filterdata}" ) + typeset -i iCount=$( echo "$out" | grep "." | wc -l ) + + test $iCount -ne 0 && ( + echo --- $( echo "$filtername" | sed "s#MYfilter##g" ): $iCount + echo "$out" | nl; echo + ) + iFound=$iFound+$iCount + done + + # show count of non matching packages + typeset -i iOther=$iTotal-$iFound + if [ $iFound -eq 0 ]; then + echo "No package matched a group filter." + else + echo "Other packages: $iOther" + fi + + # total packages + echo Total packages to install: $iTotal + + fi + +} # ---------------------------------------------------------------------- # main @@ -215,41 +256,7 @@ echo "$pkgstatus" echo showAutoupdate echo - -# filtered package view -if [ ! -z "$pkgsum" ]; then - typeset -i iTotal=$( echo "$pkgsum" | wc -l ) - typeset -i iFound=0 - - # 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]" ) - - out=$( echo "$pkgsum" | _filterPkg "${filterdata}" ) - typeset -i iCount=$( echo "$out" | grep "." | wc -l ) - - test $iCount -ne 0 && ( - echo --- $( echo "$filtername" | sed "s#MYfilter##g" ): $iCount - echo "$out" | nl; echo - ) - iFound=$iFound+$iCount - - done - - # show count of non matching packages - typeset -i iOther=$iTotal-$iFound - if [ $iFound -eq 0 ]; then - echo "No package matched a group filter." - else - echo "Other packages: $iOther" - fi - - # total packages - echo Total packages to install: $iTotal - -fi +showFilteredPackages ph.exit -- GitLab