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

packages2install - fix: count of security packages

parent c5179404
Branches
No related tags found
1 merge request!140packages2install - fix: count of security packages
......@@ -24,7 +24,7 @@
# 2022-06-07 v1.10 <axel.hahn@iml.unibe.ch> fix iPkg2Update on empty package list
# rename package manager functions
# 2022-10-21 v1.11 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> update help
# 2023-08-24 v1.12 <axel.hahn@unibe.ch> update help; rename to getSecurityCount
# ======================================================================
......@@ -238,7 +238,7 @@ else
# generated function names - package manager is prefix
function2install="${pkgmanager}.getPackageList"
_functionExists "${pkgmanager}.getStatusLine" && functionStatus="${pkgmanager}.getStatusLine"
_functionExists "${pkgmanager}.getCriticalList" && functionCritical="${pkgmanager}.getCriticalList"
_functionExists "${pkgmanager}.getCriticalList" && functionSecuritycount="${pkgmanager}.getSecurityCount"
# count of packages ... to install ... critical (centos only)
typeset -i iPkg2Update=0
......@@ -252,8 +252,8 @@ else
test -n "$functionStatus" && statusLabel="[$pkgmanager] $( $functionStatus )"
# custom: get count of critical packages
if [ -n "$functionCritical" ]; then
iPkgCritical=$( $functionCritical "$statusLabel" )
if [ -n "$functionSecuritycount" ]; then
iPkgCritical=$( $functionSecuritycount "$statusLabel" )
ph.perfadd "updates-security" "${iPkgCritical}" 1 1
fi
......
......@@ -13,7 +13,7 @@
# rename functions
# 2022-08-31 v1.2 ah status line depends on os major version
# 2023-07-17 v1.3 ah fix hiding obsolete packages
# 2023-08-24 v1.4 ah update getStatusLine() for centos9
# 2023-08-24 v1.4 ah centos9: update getStatusLine() +
# ===============================================================
......@@ -62,6 +62,7 @@ function yum.getStatusLine(){
local _total; _total=$( echo "${packages2install}" | wc -l )
local _sec; _sec=$( sudo /usr/bin/yum -y --security check-update | grep -v "^Last" | grep -c "." )
# create a status line like in former yum versions
if [ -z "$_sec" ]; then
echo "No packages needed for security; ${_total} packages available"
else
......@@ -79,13 +80,15 @@ function yum.getStatusLine(){
# ---------------------------------------------------------------
# extract count of critical packages
# param string text to extract critical counter from
function yum.getCriticalList(){
function yum.getSecurityCount(){
local summary="$1"
# example outputs:
# I No packages needed for security; 223 packages available
# II 2 package(s) needed for security, out of 237 available
# III No security updates needed, but 61 updates available << centos 8 stream
echo "$summary" | cut -f 1 -d ' ' | sed "s#[^0-9]##g"
# III No security updates needed, but 61 updates available << centos 8 stream
# IV [yum] No packages needed for security; 223 packages available << centos 9
# V [yum] 2 package(s) needed for security, out of 237 available << centos 9
echo "$summary" | cut -f 2 -d ' ' | sed "s#[^0-9]##g"
}
# ---------------------------------------------------------------
......@@ -80,7 +80,7 @@ Each file MUST contain minumum the functions
These functions are optional:
* [packager].getStatusLine - get custom status line (1st line in output)
* [packager].getCriticalList - extract count of critical packages
* [packager].getSecurityCount - extract count of critical packages from status line
### Define groups
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment