From 12885a6d43b81dfe3c1f4d0ca976e7cd58772c91 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Tue, 22 Nov 2022 16:13:14 -1000 Subject: [PATCH 1/2] Add support for PhotonOS --- tasks/available_updates_linux.sh | 2 +- tasks/cache_remove_linux.sh | 2 +- tasks/cache_update_linux.sh | 2 +- tasks/reboot_required_linux.sh | 2 +- tasks/update_linux.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/available_updates_linux.sh b/tasks/available_updates_linux.sh index 0b05b18..c26c1a5 100644 --- a/tasks/available_updates_linux.sh +++ b/tasks/available_updates_linux.sh @@ -5,7 +5,7 @@ source "${PT__installdir}/patching/files/bash/os_test.sh" case $OS_RELEASE in ################################################################################ - RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX) + RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON) # RedHat variant source "${PT__installdir}/patching/files/bash/available_updates_rh.sh" ;; diff --git a/tasks/cache_remove_linux.sh b/tasks/cache_remove_linux.sh index 06f646e..1ef4c51 100644 --- a/tasks/cache_remove_linux.sh +++ b/tasks/cache_remove_linux.sh @@ -5,7 +5,7 @@ source "${PT__installdir}/patching/files/bash/os_test.sh" case $OS_RELEASE in ################################################################################ - RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX) + RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON) # RedHat variant # clean yum cache OUTPUT=$(yum clean all 2>&1) diff --git a/tasks/cache_update_linux.sh b/tasks/cache_update_linux.sh index b087ceb..0f1b839 100644 --- a/tasks/cache_update_linux.sh +++ b/tasks/cache_update_linux.sh @@ -11,7 +11,7 @@ source "${PT__installdir}/patching/files/bash/os_test.sh" case $OS_RELEASE in ################################################################################ - RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX) + RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON) # RedHat variant # update yum cache OUTPUT=$(yum clean expire-cache 2>&1) diff --git a/tasks/reboot_required_linux.sh b/tasks/reboot_required_linux.sh index 12538b6..a474c0c 100644 --- a/tasks/reboot_required_linux.sh +++ b/tasks/reboot_required_linux.sh @@ -8,7 +8,7 @@ export REBOOT_REQUIRED="false" case $OS_RELEASE in ################################################################################ - RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX) + RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON) # RedHat variant source "${PT__installdir}/patching/files/bash/reboot_required_rh.sh" ;; diff --git a/tasks/update_linux.sh b/tasks/update_linux.sh index ce0c7ff..8a5de8c 100644 --- a/tasks/update_linux.sh +++ b/tasks/update_linux.sh @@ -24,7 +24,7 @@ STATUS=0 case $OS_RELEASE in ################################################################################ - RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX) + RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON) # RedHat variant source "${PT__installdir}/patching/files/bash/update_rh.sh" STATUS=$? From 6187ea6787baaf3fb651c8183151752970a0b7fd Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Wed, 23 Nov 2022 07:29:03 -1000 Subject: [PATCH 2/2] Fix output form tdnf tdnf(1) formats outdated packages lines in an unexpected way where a line like ``` sudo.x86_64 1.9.5-2.ph4 photon-updates ``` has this representation: ``` 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 20 20 70 68 6f 74 6f 6e 2d 75 70 64 61 74 65 73 | photon-updates| 0d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |. | 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 2e | 1.| 39 2e 35 2d 32 2e 70 68 34 0d 73 75 64 6f 2e 78 |9.5-2.ph4.sudo.x| 38 36 5f 36 34 0a |86_64.| ``` while the code expect this: ``` 73 75 64 6f 2e 78 38 36 5f 36 34 20 20 20 20 20 |sudo.x86_64 | 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 20 20 20 20 20 20 20 20 20 20 20 20 20 31 2e 39 | 1.9| 2e 35 2d 32 2e 70 68 34 20 20 20 20 20 20 20 20 |.5-2.ph4 | 20 20 70 68 6f 74 6f 6e 2d 75 70 64 61 74 65 73 | photon-updates| 0a |.| ``` that is: ``` photon-updates 1.9.5-2.ph4 sudo.x86_64 ``` Add an awk script that fix the output when it contains carriage returns. --- files/bash/available_updates_rh.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/files/bash/available_updates_rh.sh b/files/bash/available_updates_rh.sh index 97a46b0..df3ab7c 100755 --- a/files/bash/available_updates_rh.sh +++ b/files/bash/available_updates_rh.sh @@ -6,7 +6,13 @@ # Security: kernel-3.14.2-200.fc20.x86_64 is the currently running version # --- # We need to filter those out as they screw up the package listing -PKGS=$(yum -q check-update 2>/dev/null | egrep -v "is broken|^Security:|^Loaded plugins" | awk '/^[[:alnum:]]/ {print $0}' | sort) +# +# Also the PhotonOS version of tdnf generates lines by printing spaces, the +# repository, a carriage return, (less) spaces, the version, a carriage return, +# the package name and a line feed. The human output is unchanged but this +# confuse the rest of the tooling, so "fix" the output to have the expected +# format. +PKGS=$(yum -q check-update 2>/dev/null | egrep -v "is broken|^Security:|^Loaded plugins" | awk '{ split($0, r, "\x0d"); res = r[1]; for (f in r) { keep = substr(res, 1 + length(r[f])); res = r[f] keep }; print res }' | grep -e '^[[:alnum:]]' | sort) cat <