Skip to content

Commit

Permalink
fix module parsing on rhel 8 and similar
Browse files Browse the repository at this point in the history
  • Loading branch information
furlongm committed Jun 19, 2024
1 parent 4a23284 commit 18dcd1a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions client/patchman-client
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,28 @@ get_enabled_modules() {
| grep -v ^Hint \
| awk {'print $1'})

OLDIFS=${IFS}
IFS="
"
for module in ${enabled_modules} ; do
IFS=${OLDIFS}
module_info=$(yum module info ${module})
module_arch=$(echo ${module_info} | grep Architecture | cut -d : -f 2 | awk '{$1=$1};1')
module_repo=$(echo ${module_info} | grep Repo | cut -d : -f 2 | awk '{$1=$1};1')
module_stream=$(echo ${module_info} | grep Stream | cut -d : -f 2 | sed -e 's/ \[.*//g' | awk '{$1=$1};1')
module_version=$(echo ${module_info} | grep Version | cut -d : -f 2 | awk '{$1=$1};1')
module_context=$(echo ${module_info} | grep Context | cut -d : -f 2 | awk '{$1=$1};1')
module_packages=$(echo ${module_info} | sed -n '/Artifacts/,$p' | grep -v Hint | sed -e 's/.* : //g' | grep -v ^$)
modules_info=$(yum module info ${module} | grep -v ^Hint)
unset x
while read -r line ; do
if [ -z "$line" ] ; then
echo -e ${x} | grep -q -E "^Stream.*\[e\]" && break || unset x
else
x="$x$line\n"
fi
done < <(echo -n "${modules_info}")
module_info=$(echo -e ${x})
module_arch=$(echo "${module_info}" | grep ^Architecture | cut -d : -f 2 | awk '{$1=$1};1')
module_repo=$(echo "${module_info}" | grep ^Repo | cut -d : -f 2 | awk '{$1=$1};1')
module_stream=$(echo "${module_info}" | grep ^Stream | cut -d : -f 2 | sed -e 's/ \[.*//g' | awk '{$1=$1};1')
module_version=$(echo "${module_info}" | grep ^Version | cut -d : -f 2 | awk '{$1=$1};1')
module_context=$(echo "${module_info}" | grep ^Context | cut -d : -f 2 | awk '{$1=$1};1')
module_packages=$(echo "${module_info}" | sed -n '/Artifacts/,$p' | sed -e 's/.* *: //g' | grep -v ^$)

OLDIFS=${IFS}
IFS="
"
module_package_str=""
for package in ${module_packages} ; do
module_package_str="${module_package_str} '${package}'"
done
Expand Down

0 comments on commit 18dcd1a

Please sign in to comment.