commit 4d089d2c29f0d524f41a7c588febe86256b1606c Author: Andrew Lukoshko Date: Wed Apr 10 12:38:05 2024 +0000 import CentOS redhat-upgrade-tool-0.8.0-9.el6 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd8dbb7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/boom-0.8.tar.gz +SOURCES/redhat-upgrade-tool-0.8.0.tar.gz diff --git a/.redhat-upgrade-tool.metadata b/.redhat-upgrade-tool.metadata new file mode 100644 index 0000000..3057d2f --- /dev/null +++ b/.redhat-upgrade-tool.metadata @@ -0,0 +1,2 @@ +98f6f31efc8e3bc6a8f85ad0c984dfd14cb23116 SOURCES/boom-0.8.tar.gz +2dd00ae1fac32939d8fa440e30f0be44d9aa530f SOURCES/redhat-upgrade-tool-0.8.0.tar.gz diff --git a/SOURCES/0001-Rollbacks-enable-rollbacks-only-on-the-x86_64-arch.patch b/SOURCES/0001-Rollbacks-enable-rollbacks-only-on-the-x86_64-arch.patch new file mode 100644 index 0000000..c1243f7 --- /dev/null +++ b/SOURCES/0001-Rollbacks-enable-rollbacks-only-on-the-x86_64-arch.patch @@ -0,0 +1,26 @@ +From 62687fde687b6e18940272f3d395ee049793a6d0 Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Tue, 11 Sep 2018 12:07:35 +0200 +Subject: [PATCH] Rollbacks: enable rollbacks only on the x86_64 arch + +--- + redhat-upgrade-tool.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/redhat-upgrade-tool.py b/redhat-upgrade-tool.py +index cb34fb7..e82266e 100644 +--- a/redhat-upgrade-tool.py ++++ b/redhat-upgrade-tool.py +@@ -176,6 +176,9 @@ def main(args): + raise SystemExit(1) + + if args.snapshot_root_lv: ++ if platform.machine() != "x86_64": ++ print _("Error: Rollbacks are possible only on the x86_64 architecture.") ++ raise SystemExit(1) + create_cleanup_script() + + if args.system_restore: +-- +2.14.4 + diff --git a/SOURCES/0002-Fix-paths-of-legacy-grub-config-file-on-EFI-system.patch b/SOURCES/0002-Fix-paths-of-legacy-grub-config-file-on-EFI-system.patch new file mode 100644 index 0000000..b35b035 --- /dev/null +++ b/SOURCES/0002-Fix-paths-of-legacy-grub-config-file-on-EFI-system.patch @@ -0,0 +1,52 @@ +From 4ff9d909fa1330cad6f6dfde08795509b3db036d Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Thu, 16 Jul 2020 12:21:00 +0200 +Subject: [PATCH] Fix paths of legacy grub config file on EFI system + +--- + boom-0.8/boom/legacy.py | 2 ++ + redhat_upgrade_tool/__init__.py | 2 ++ + redhat_upgrade_tool/rollback/bootloader.py | 2 ++ + 3 files changed, 6 insertions(+) + +diff --git a/boom-0.8/boom/legacy.py b/boom-0.8/boom/legacy.py +index 0d765d8..bedf219 100644 +--- a/boom-0.8/boom/legacy.py ++++ b/boom-0.8/boom/legacy.py +@@ -36,6 +36,8 @@ BOOM_LEGACY_END_FMT="#--- BOOM_%s_END ---" + #: Constants for legacy boot loaders supported by boom + BOOM_LOADER_GRUB1="grub1" + BOOM_GRUB1_CFG_PATH="grub/grub.conf" ++if not path_exists(path_join("/boot/", BOOM_GRUB1_CFG_PATH)): ++ BOOM_GRUB1_CFG_PATH="efi/EFI/redhat/grub.conf" + + # Module logging configuration + _log = logging.getLogger(__name__) +diff --git a/redhat_upgrade_tool/__init__.py b/redhat_upgrade_tool/__init__.py +index 6976647..1e0b1b3 100644 +--- a/redhat_upgrade_tool/__init__.py ++++ b/redhat_upgrade_tool/__init__.py +@@ -68,5 +68,7 @@ preupgrade_dir = "/root/preupgrade" + preupgrade_script_path = os.path.join(preupgrade_dir, 'preupgrade-scripts') + release_version_file = os.path.join(preupgrade_dir, preupgrade_script_path, 'release_version') + grub_conf_file = "/boot/grub/grub.conf" ++if not os.path.exists(grub_conf_file): ++ grub_conf_file = "/boot/efi/EFI/redhat/grub.conf" + + MIN_AVAIL_BYTES_FOR_BOOT = 50 * 2**20 # 50 MiB +diff --git a/redhat_upgrade_tool/rollback/bootloader.py b/redhat_upgrade_tool/rollback/bootloader.py +index 13d8f18..f0c384a 100644 +--- a/redhat_upgrade_tool/rollback/bootloader.py ++++ b/redhat_upgrade_tool/rollback/bootloader.py +@@ -14,6 +14,8 @@ try: + from redhat_upgrade_tool.util import check_call + except ImportError: + grub_conf_file = "/boot/grub/grub.conf" ++ if not os.path.exists(grub_conf_file): ++ grub_conf_file = "/boot/efi/EFI/redhat/grub.conf" + + def check_call(*popenargs, **kwargs): + retcode = call(*popenargs, **kwargs) +-- +2.25.4 + diff --git a/SOURCES/0003-Fix-grub-conf-paths-during-the-rollback.patch b/SOURCES/0003-Fix-grub-conf-paths-during-the-rollback.patch new file mode 100644 index 0000000..a021add --- /dev/null +++ b/SOURCES/0003-Fix-grub-conf-paths-during-the-rollback.patch @@ -0,0 +1,44 @@ +From 0b9d8cea86f36174f419cd4dfb8df5e1ffd536dc Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Tue, 21 Jul 2020 03:22:11 +0200 +Subject: [PATCH] Fix grub conf paths during the rollback + +--- + redhat_upgrade_tool/rollback/bootloader.py | 20 ++++++++++++++++++-- + 1 file changed, 18 insertions(+), 2 deletions(-) + +diff --git a/redhat_upgrade_tool/rollback/bootloader.py b/redhat_upgrade_tool/rollback/bootloader.py +index f0c384a..aff23f4 100644 +--- a/redhat_upgrade_tool/rollback/bootloader.py ++++ b/redhat_upgrade_tool/rollback/bootloader.py +@@ -13,9 +13,25 @@ try: + from redhat_upgrade_tool import grub_conf_file + from redhat_upgrade_tool.util import check_call + except ImportError: +- grub_conf_file = "/boot/grub/grub.conf" ++ _BIOS_GRUB_CONF_PATH = "/boot/grub/grub.conf" ++ _EFI_GRUB_CONF_PATH = "/boot/efi/EFI/redhat/grub.conf" ++ grub_conf_file = _BIOS_GRUB_CONF_PATH + if not os.path.exists(grub_conf_file): +- grub_conf_file = "/boot/efi/EFI/redhat/grub.conf" ++ grub_conf_file = _EFI_GRUB_CONF_PATH ++ elif os.path.exists(_EFI_GRUB_CONF_PATH): ++ if not os.path.getsize(grub_conf_file): ++ # it can happen that both files (usually on EFI systems) exists, ++ # but the BIOS one is empty in such a case ++ os.remove(grub_conf_file) ++ grub_conf_file = _EFI_GRUB_CONF_PATH ++ elif os.path.exists("/sys/firmware/efi"): ++ # ok, the 'bios' file is not empty ++ # rather move it instead of real remove, as this is weird ++ shutil.move(grub_conf_file, "{}.preupg_rollback_backup".format(grub_conf_file)) ++ grub_conf_file = _EFI_GRUB_CONF_PATH ++ # else: ++ # regarding https://access.redhat.com/solutions/3781221 - we can consider ++ # the system is booted in BIOS mode; do nothing + + def check_call(*popenargs, **kwargs): + retcode = call(*popenargs, **kwargs) +-- +2.25.4 + diff --git a/SOURCES/0004-Fix-detection-of-grub-device-on-UEFI-in-Boom.patch b/SOURCES/0004-Fix-detection-of-grub-device-on-UEFI-in-Boom.patch new file mode 100644 index 0000000..23c7b74 --- /dev/null +++ b/SOURCES/0004-Fix-detection-of-grub-device-on-UEFI-in-Boom.patch @@ -0,0 +1,43 @@ +From 798f911a10b502144ca502d5a9063648f17aaaa0 Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Thu, 30 Jul 2020 16:34:56 +0200 +Subject: [PATCH] Fix detection of grub device on UEFI in Boom + +Previously Boom has not been able to detect the grub1 device because +of used ESP mountpoint on RHEL 6. That results in state the grub +entry with snapshot has not been bootable as the `root` device was +`None`. + +Author: Bryn Reeves +--- + boom-0.8/boom/legacy.py | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/boom-0.8/boom/legacy.py b/boom-0.8/boom/legacy.py +index bedf219..53cf939 100644 +--- a/boom-0.8/boom/legacy.py ++++ b/boom-0.8/boom/legacy.py +@@ -68,10 +68,19 @@ def _get_grub1_device(force=False): + if __grub1_device and not force: + return __grub1_device + ++ # FIX detection of grub device on UEFI on RHEL 6: ++ # the original code cannot detect the device in case of UEFI, because ++ # the ESP mount point is on efi/ . Trimming the 'efi/' prefix doesn't ++ # work as well, as the _loader_map[BOOM_LOADER_GRUB1][2] returns different ++ # device than grub is located in real - e.g. hd(0,0) instead of hd(0,1) ++ # because of that, use the splash.xpm.gz file, which is located on every ++ # x86_64 RHEL 6 system. ++ cfg_path = "grub/splash.xpm.gz" ++ + # The grub1 binary + grub_cmd = "grub" + # The command to issue to discover the /boot device +- find_cmd = "find /%s\n" % _loader_map[BOOM_LOADER_GRUB1][2] ++ find_cmd = "find /%s\n" % cfg_path + # Regular expression matching a valid grub device string + find_rgx = r" \(hd\d+,\d+\)" + +-- +2.25.4 + diff --git a/SOURCES/0005-Fix-detection-of-the-grub-configuration-path.patch b/SOURCES/0005-Fix-detection-of-the-grub-configuration-path.patch new file mode 100644 index 0000000..20c4402 --- /dev/null +++ b/SOURCES/0005-Fix-detection-of-the-grub-configuration-path.patch @@ -0,0 +1,127 @@ +From 58762e6f2bd9a6e42933aafbfc073de28c9918d2 Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Fri, 31 Jul 2020 14:47:57 +0200 +Subject: [PATCH] Fix detection of the grub configuration path + +Previos solution was still buggy. Discussed with the bootloader team, +the solution has been updated for redhat-upgrade-tool (not for boom!). +When the redhat-upgrade-tool is executed, only one configuration file +will remain. +--- + redhat_upgrade_tool/__init__.py | 45 ++++++++++++++++++++-- + redhat_upgrade_tool/rollback/bootloader.py | 43 +++++++++++++-------- + 2 files changed, 69 insertions(+), 19 deletions(-) + +diff --git a/redhat_upgrade_tool/__init__.py b/redhat_upgrade_tool/__init__.py +index 1e0b1b3..9e1fecd 100644 +--- a/redhat_upgrade_tool/__init__.py ++++ b/redhat_upgrade_tool/__init__.py +@@ -67,8 +67,47 @@ rhel_gpgkey_path = 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release' + preupgrade_dir = "/root/preupgrade" + preupgrade_script_path = os.path.join(preupgrade_dir, 'preupgrade-scripts') + release_version_file = os.path.join(preupgrade_dir, preupgrade_script_path, 'release_version') +-grub_conf_file = "/boot/grub/grub.conf" +-if not os.path.exists(grub_conf_file): +- grub_conf_file = "/boot/efi/EFI/redhat/grub.conf" ++ ++def detect_grub_conf(): ++ """ ++ Detect the right path of the grub configuration file and shot the another ++ one if exist. ++ ++ This is really needed. ++ """ ++ _BIOS_GRUB_CONF_PATH = "/boot/grub/grub.conf" ++ _EFI_GRUB_CONF_PATH = "/boot/efi/EFI/redhat/grub.conf" ++ ++ # regarding https://access.redhat.com/solutions/3781221 - this should ++ # be enough for RHEL 6 ++ if os.path.exists("/sys/firmware/efi"): ++ # we should be on EFI ++ grub_conf_file = _EFI_GRUB_CONF_PATH ++ _non_grub_file = _BIOS_GRUB_CONF_PATH ++ else: ++ # we are on BIOS ++ grub_conf_file = _BIOS_GRUB_CONF_PATH ++ _non_grub_file = _EFI_GRUB_CONF_PATH ++ if not os.path.exists(grub_conf_file) or not os.path.getsize(grub_conf_file): ++ # that's fatal error. It shouldn't happened ++ raise Exception( ++ "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) ++ ++ if os.path.exists(_non_grub_file): ++ # it's wrong that both files exist, if it's empty, remove it, ++ # otherwise rename it ++ if not os.path.getsize(_non_grub_file): ++ # Note: this is typical case after IPU 6 -> 7 for EFI ++ # remove the empty file ++ os.remove(_non_grub_file) ++ else: ++ # this is really weird when it happens ++ print "WARNING: Detected two grub configuration files, but only one can exist" ++ print "WARNING: Moving {fname} to {fname}.preupg_rollback_backup".format(fname=_non_grub_file) ++ shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) ++ return grub_conf_file ++ ++ ++grub_conf_file = detect_grub_conf() + + MIN_AVAIL_BYTES_FOR_BOOT = 50 * 2**20 # 50 MiB +diff --git a/redhat_upgrade_tool/rollback/bootloader.py b/redhat_upgrade_tool/rollback/bootloader.py +index aff23f4..2f605ff 100644 +--- a/redhat_upgrade_tool/rollback/bootloader.py ++++ b/redhat_upgrade_tool/rollback/bootloader.py +@@ -15,23 +15,34 @@ try: + except ImportError: + _BIOS_GRUB_CONF_PATH = "/boot/grub/grub.conf" + _EFI_GRUB_CONF_PATH = "/boot/efi/EFI/redhat/grub.conf" +- grub_conf_file = _BIOS_GRUB_CONF_PATH +- if not os.path.exists(grub_conf_file): ++ ++ # regarding https://access.redhat.com/solutions/3781221 - this should ++ # be enough for RHEL 6 ++ if os.path.exists("/sys/firmware/efi"): ++ # we should be on EFI + grub_conf_file = _EFI_GRUB_CONF_PATH +- elif os.path.exists(_EFI_GRUB_CONF_PATH): +- if not os.path.getsize(grub_conf_file): +- # it can happen that both files (usually on EFI systems) exists, +- # but the BIOS one is empty in such a case +- os.remove(grub_conf_file) +- grub_conf_file = _EFI_GRUB_CONF_PATH +- elif os.path.exists("/sys/firmware/efi"): +- # ok, the 'bios' file is not empty +- # rather move it instead of real remove, as this is weird +- shutil.move(grub_conf_file, "{}.preupg_rollback_backup".format(grub_conf_file)) +- grub_conf_file = _EFI_GRUB_CONF_PATH +- # else: +- # regarding https://access.redhat.com/solutions/3781221 - we can consider +- # the system is booted in BIOS mode; do nothing ++ _non_grub_file = _BIOS_GRUB_CONF_PATH ++ else: ++ # we are on BIOS ++ grub_conf_file = _BIOS_GRUB_CONF_PATH ++ _non_grub_file = _EFI_GRUB_CONF_PATH ++ if not os.path.exists(grub_conf_file) or not os.path.getsize(grub_conf_file): ++ # that's fatal error. It shouldn't happened ++ raise Exception( ++ "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) ++ ++ if os.path.exists(_non_grub_file): ++ # it's wrong that both files exist, if it's empty, remove it, ++ # otherwise rename it ++ if not os.path.getsize(_non_grub_file): ++ # Note: this is typical case after IPU 6 -> 7 for EFI ++ # remove the empty file ++ os.remove(_non_grub_file) ++ else: ++ # this is really weird when it happens ++ print "WARNING: Detected two grub configuration files, but only one can exist" ++ print "WARNING: Moving {fname} to {fname}.preupg_rollback_backup".format(fname=_non_grub_file) ++ shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) + + def check_call(*popenargs, **kwargs): + retcode = call(*popenargs, **kwargs) +-- +2.25.4 + diff --git a/SOURCES/0006-Do-not-rename-grub-config-file.patch b/SOURCES/0006-Do-not-rename-grub-config-file.patch new file mode 100644 index 0000000..e67f2e9 --- /dev/null +++ b/SOURCES/0006-Do-not-rename-grub-config-file.patch @@ -0,0 +1,72 @@ +From 464fbb06a2e46b1ac91babf82c3ced6cbc14a405 Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Fri, 31 Jul 2020 15:18:06 +0200 +Subject: [PATCH] Do not rename grub config file + +Update of the previous solution. In case the BIOS and EFI grub conf +files exist, the one that is not expected to be used will not be +renamed, but kept as it is. Instead, we print warnings and update +boom to orient with the same logic as r-u-t. +--- + boom-0.8/boom/legacy.py | 5 ++++- + redhat_upgrade_tool/__init__.py | 7 ++++--- + redhat_upgrade_tool/rollback/bootloader.py | 7 ++++--- + 3 files changed, 12 insertions(+), 7 deletions(-) + +diff --git a/boom-0.8/boom/legacy.py b/boom-0.8/boom/legacy.py +index 53cf939..6d4464b 100644 +--- a/boom-0.8/boom/legacy.py ++++ b/boom-0.8/boom/legacy.py +@@ -36,9 +36,12 @@ BOOM_LEGACY_END_FMT="#--- BOOM_%s_END ---" + #: Constants for legacy boot loaders supported by boom + BOOM_LOADER_GRUB1="grub1" + BOOM_GRUB1_CFG_PATH="grub/grub.conf" +-if not path_exists(path_join("/boot/", BOOM_GRUB1_CFG_PATH)): ++if path_exists("/sys/firmware/efi"): + BOOM_GRUB1_CFG_PATH="efi/EFI/redhat/grub.conf" + ++if not path_exists(path_join("/boot/", BOOM_GRUB1_CFG_PATH)): ++ raise BoomLegacyLoaderError("Could not execute grub1 shell.") ++ + # Module logging configuration + _log = logging.getLogger(__name__) + +diff --git a/redhat_upgrade_tool/__init__.py b/redhat_upgrade_tool/__init__.py +index 9e1fecd..48ef27e 100644 +--- a/redhat_upgrade_tool/__init__.py ++++ b/redhat_upgrade_tool/__init__.py +@@ -102,9 +102,10 @@ def detect_grub_conf(): + os.remove(_non_grub_file) + else: + # this is really weird when it happens +- print "WARNING: Detected two grub configuration files, but only one can exist" +- print "WARNING: Moving {fname} to {fname}.preupg_rollback_backup".format(fname=_non_grub_file) +- shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) ++ print "WARNING: Detected two grub configuration files, but only one should exist" ++ print "WARNIng: Ignoring the {} config file.".format(_non_grub_file) ++ # rather do not move this file... ++ # shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) + return grub_conf_file + + +diff --git a/redhat_upgrade_tool/rollback/bootloader.py b/redhat_upgrade_tool/rollback/bootloader.py +index 2f605ff..bad16d1 100644 +--- a/redhat_upgrade_tool/rollback/bootloader.py ++++ b/redhat_upgrade_tool/rollback/bootloader.py +@@ -40,9 +40,10 @@ except ImportError: + os.remove(_non_grub_file) + else: + # this is really weird when it happens +- print "WARNING: Detected two grub configuration files, but only one can exist" +- print "WARNING: Moving {fname} to {fname}.preupg_rollback_backup".format(fname=_non_grub_file) +- shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) ++ print "WARNING: Detected two grub configuration files, but only one should exist" ++ print "WARNIng: Ignoring the {} config file.".format(_non_grub_file) ++ # rather do not move this file out ++ # shutil.move(_non_grub_file, "{}.preupg_rollback_backup".format(_non_grub_file)) + + def check_call(*popenargs, **kwargs): + retcode = call(*popenargs, **kwargs) +-- +2.25.4 + diff --git a/SOURCES/0007-Rollbacks-ignore-grub-errors-on-non-intel-arches.patch b/SOURCES/0007-Rollbacks-ignore-grub-errors-on-non-intel-arches.patch new file mode 100644 index 0000000..dc261c0 --- /dev/null +++ b/SOURCES/0007-Rollbacks-ignore-grub-errors-on-non-intel-arches.patch @@ -0,0 +1,70 @@ +From 4b9f1f8c5b907c2d4169712a60ccba795274528d Mon Sep 17 00:00:00 2001 +From: Petr Stodulka +Date: Tue, 4 Aug 2020 12:22:11 +0200 +Subject: [PATCH] Rollbacks: ignore grub errors on non-intel arches + +Previous logic around BIOS / EFI bootloader files detection caused +issues on non-intel arches - which are supposed to use different +bootloaders. In this case, set just one of paths for the grub conf +file and do not care about any additional actions (don't do any) on +non-intel arches. +--- + redhat_upgrade_tool/__init__.py | 11 +++++++---- + redhat_upgrade_tool/rollback/bootloader.py | 10 ++++++---- + 2 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/redhat_upgrade_tool/__init__.py b/redhat_upgrade_tool/__init__.py +index 48ef27e..dc36e2d 100644 +--- a/redhat_upgrade_tool/__init__.py ++++ b/redhat_upgrade_tool/__init__.py +@@ -33,6 +33,7 @@ Your pal, + + import logging + import os ++import platform + from .logutils import NullHandler + log = logging.getLogger(__package__) + log.addHandler(NullHandler()) +@@ -89,11 +90,13 @@ def detect_grub_conf(): + grub_conf_file = _BIOS_GRUB_CONF_PATH + _non_grub_file = _EFI_GRUB_CONF_PATH + if not os.path.exists(grub_conf_file) or not os.path.getsize(grub_conf_file): +- # that's fatal error. It shouldn't happened +- raise Exception( +- "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) ++ # this could happen typically on non-intel arch; ignore non-intel arch ++ if platform.machine() == "x86_64": ++ # that's fatal error. It shouldn't happened ++ raise Exception( ++ "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) + +- if os.path.exists(_non_grub_file): ++ if os.path.exists(_non_grub_file) and platform.machine() == "x86_64": + # it's wrong that both files exist, if it's empty, remove it, + # otherwise rename it + if not os.path.getsize(_non_grub_file): +diff --git a/redhat_upgrade_tool/rollback/bootloader.py b/redhat_upgrade_tool/rollback/bootloader.py +index bad16d1..50152e5 100644 +--- a/redhat_upgrade_tool/rollback/bootloader.py ++++ b/redhat_upgrade_tool/rollback/bootloader.py +@@ -27,11 +27,13 @@ except ImportError: + grub_conf_file = _BIOS_GRUB_CONF_PATH + _non_grub_file = _EFI_GRUB_CONF_PATH + if not os.path.exists(grub_conf_file) or not os.path.getsize(grub_conf_file): +- # that's fatal error. It shouldn't happened +- raise Exception( +- "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) ++ # this could happen typically on non-intel arch; ignore non-intel arch ++ if platform.machine() == "x86_64": ++ # that's fatal error. It shouldn't happened ++ raise Exception( ++ "The expected grub configuration file doesn't exist or it is empty: %s" % grub_conf_file) + +- if os.path.exists(_non_grub_file): ++ if os.path.exists(_non_grub_file) and platform.machine() == "x86_64": + # it's wrong that both files exist, if it's empty, remove it, + # otherwise rename it + if not os.path.getsize(_non_grub_file): +-- +2.25.4 + diff --git a/SPECS/redhat-upgrade-tool.spec b/SPECS/redhat-upgrade-tool.spec new file mode 100644 index 0000000..846ed85 --- /dev/null +++ b/SPECS/redhat-upgrade-tool.spec @@ -0,0 +1,501 @@ +%global version_boom 0.8 +%global boom_dir boom-%{version_boom} + +Name: redhat-upgrade-tool +Version: 0.8.0 +Release: 9%{?dist} +Summary: The Red Hat Enterprise Linux Upgrade tool +Epoch: 1 + +License: GPLv2+ +URL: https://github.com/upgrades-migrations/redhat-upgrade-tool +Source0: %{url}/archive/%{name}-%{version}.tar.gz +Source1: boom-%{version_boom}.tar.gz + +Patch0: 0001-Rollbacks-enable-rollbacks-only-on-the-x86_64-arch.patch +Patch1: 0002-Fix-paths-of-legacy-grub-config-file-on-EFI-system.patch +Patch2: 0003-Fix-grub-conf-paths-during-the-rollback.patch +Patch3: 0004-Fix-detection-of-grub-device-on-UEFI-in-Boom.patch +Patch4: 0005-Fix-detection-of-the-grub-configuration-path.patch +Patch5: 0006-Do-not-rename-grub-config-file.patch +Patch6: 0007-Rollbacks-ignore-grub-errors-on-non-intel-arches.patch + +Requires: dbus +Requires: grubby +Requires: python-rhsm +Requires: python-argparse +Requires: preupgrade-assistant >= 2.2.0-1 + +# https://bugzilla.redhat.com/show_bug.cgi?id=1038299 +Requires: yum >= 3.2.29-43 + +BuildRequires: python-libs +BuildRequires: python2-devel +BuildRequires: python-sphinx +BuildRequires: python-setuptools + +BuildArch: noarch + +# GET THEE BEHIND ME, SATAN +Obsoletes: preupgrade + +%description +redhat-upgrade-tool is the Red Hat Enterprise Linux Upgrade tool. + + +%prep +%setup -q -n %{name}-%{version} +%setup -q -T -D -a 1 -n %{name}-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 + + +%build +make PYTHON=%{__python} + +###### boom ####### +pushd %{boom_dir} +CFLAGS="%{optflags}" +%{__python} setup.py %{?py_setup_args} build --executable="%{__python} -s" +popd + + +%install +rm -rf $RPM_BUILD_ROOT +make install PYTHON=%{__python} DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} +# backwards compatibility symlinks, wheee +ln -sf redhat-upgrade-tool $RPM_BUILD_ROOT/%{_bindir}/redhat-upgrade-tool-cli +ln -sf redhat-upgrade-tool.8 $RPM_BUILD_ROOT/%{_mandir}/man8/redhat-upgrade-tool-cli.8 +# updates dir +mkdir -p $RPM_BUILD_ROOT/etc/redhat-upgrade-tool/update.img.d + + +###### boom ####### +pushd %{boom_dir} +%{__python} setup.py %{?py_setup_args} install -O1 --skip-build --root %{buildroot} + +# Install Grub2 integration scripts +mkdir -p ${RPM_BUILD_ROOT}/etc/grub.d +mkdir -p ${RPM_BUILD_ROOT}/etc/default +install -m 755 etc/grub.d/42_boom ${RPM_BUILD_ROOT}/etc/grub.d +install -m 644 etc/default/boom ${RPM_BUILD_ROOT}/etc/default + +# Make configuration directories +find examples -name "*fedora*" -delete +find examples -name "*ubuntu*" -delete +find examples -name "*rhel4*" -delete +find examples -name "*rhel7*" -delete +mkdir -p ${RPM_BUILD_ROOT}/boot/boom/profiles +mkdir -p ${RPM_BUILD_ROOT}/boot/loader/entries +install -d -m 750 ${RPM_BUILD_ROOT}/boot/boom/profiles ${RPM_BUILD_ROOT} +install -d -m 750 ${RPM_BUILD_ROOT}/boot/loader/entries ${RPM_BUILD_ROOT} +install -m 644 examples/profiles/*.profile ${RPM_BUILD_ROOT}/boot/boom/profiles +install -m 644 examples/boom.conf ${RPM_BUILD_ROOT}/boot/boom + +# Automatically enable legacy bootloader support for RHEL6 builds +sed -i 's/enable = False/enable = True/' ${RPM_BUILD_ROOT}/boot/boom/boom.conf + +popd + +# Move the boom utility under libexec as it is not supposed to be used by +# users directly +mv ${RPM_BUILD_ROOT}/%{_bindir}/boom ${RPM_BUILD_ROOT}/%{_libexecdir}/boom + + +%post +if [ ! -e /var/lib/dbus/machine-id ]; then + dbus-uuidgen > /var/lib/dbus/machine-id +fi + + +%files +%{!?_licensedir:%global license %%doc} +%doc README.asciidoc COPYING + +# boom doc files +%license %{boom_dir}/COPYING +%doc %{boom_dir}/README.md +%if 0%{?sphinx_docs} +%doc doc/html/ +%endif # if sphinx_docs + +# systemd stuff +%if 0%{?_unitdir:1} +%{_unitdir}/system-upgrade.target +%{_unitdir}/upgrade-prep.service +%{_unitdir}/upgrade-switch-root.service +%{_unitdir}/upgrade-switch-root.target +%endif +# upgrade prep program +%{_libexecdir}/upgrade-prep.sh +# SysV init replacement +%{_libexecdir}/upgrade-init +# python library +%{python_sitelib}/redhat_upgrade_tool* +# binaries +%{_bindir}/redhat-upgrade-tool +%{_bindir}/redhat-upgrade-tool-cli +# man pages +%{_mandir}/man*/* +# empty config dir +%dir /etc/redhat-upgrade-tool +# empty updates dir +%dir /etc/redhat-upgrade-tool/update.img.d + +# boom +%{python_sitelib}/boom* +%{_libexecdir}/boom +/etc/grub.d/42_boom +%config(noreplace) /etc/default/boom +%config(noreplace) /boot/boom/boom.conf +/boot/* + + + +%changelog +* Fri Jul 31 2020 Petr Stodulka - 1:0.8.0-9 +- do not affect non-intel architectures by the last fix + Resolves: rhbz#1858822 + +* Fri Jul 31 2020 Petr Stodulka - 1:0.8.0-8 +- fix disaster recovery rollbacks on EFI systems + Resolves: rhbz#1858822 + +* Thu Jul 30 2020 Petr Stodulka - 1:0.8.0-7 +- fix of previous fix for the grub1 device detection on EFI systems + Resolves: rhbz#1858822 + +* Thu Jul 30 2020 Petr Stodulka - 1:0.8.0-6 +- fix detection of 'grub1 device' on EFI boot systems, so created snapshot + grub entries are bootable + Resolves: rhbz#1858822 + +* Mon Jul 20 2020 Petr Stodulka - 1:0.8.0-5 +- fix rollbacks on EFI boot + Resolves: rhbz#1858822 + +* Tue Sep 11 2018 Petr Stodulka - 1:0.8.0-4 +- enable rollbacks only on the x86_64 architecture + Related: rhbz#1625999 + +* Thu Sep 06 2018 Petr Stodulka - 1:0.8.0-3 +- remove unneeded boom profiles + Related: rhbz#1625999 + +* Thu Sep 06 2018 Petr Stodulka - 1:0.8.0-2 +- remove dangling symlinks + Related: rhbz#1625999 + +* Thu Sep 06 2018 Petr Stodulka - 1:0.8.0-1 +- Add the rollback capability + Resolves: rhbz#1625999 + +* Tue Jun 12 2018 Michal Bocek - 1:0.7.52-1 +- Add option to disable /boot size check + Resolves: rhbz#1518317 + +* Wed Nov 08 2017 Michal Bocek - 1:0.7.51-1 +- Rebase to 0.7.51 +- Remove dependency on preupgrade-assistant-el6toel7 package +- Fail with proper error message when .treeinfo is not available + Related: rhbz#1486439 +- Check if upgrading to the RHEL version allowed by the Preupgrade Assistant + Resolves: rhbz#1436310 + +* Mon Sep 25 2017 Michal Bocek - 1:0.7.50-1 +- Rebase to 0.7.50 +- Decompress kernel modules (applies to RHEL 7.4+) + Resolves: rhbz#1486962 +- Add rpm dependency of preupgrade-assistant-el6toel7 + +* Fri Jun 16 2017 Michal Bocek - 1:0.7.49-1 +- Rebase to 0.7.49 +- Check for sufficient space in /boot + Resolves: rhbz#1361219 +- Downloading treeinfo if .treeinfo not in repo + Resolves: rhbz#1410949 +- Support for new treeinfo format of RHEL 7.4 repos + Resolves: rhbz#1456809 + +* Wed May 31 2017 Petr Stodulka - 1:0.7.48-2 +- Fix traceback caused by change in treeinfo file + Resolves: rhbz#1283713 + +* Mon Dec 5 2016 Michal Bocek - 1:0.7.48-1 +- Rebase to 0.7.48 +- Support Preupgrade Assistant version 2.2.0 + Resolves: rhbz#1398401 +- Fix usage of HTTPS repo URL with --noverify option + Resolves: rhbz#1398318 + +* Thu Oct 6 2016 Michal Bocek - 1:0.7.47-1 +- Rebase to 0.7.47 +- Fix traceback caused by Unicode characters that appear in raw_input + prompt message during the import of GPG keys. + Related: rhbz#1150029 + +* Wed Sep 7 2016 Michal Bocek - 1:0.7.46-1 +- Rebase to 0.7.46 +- Reverted changes from 0.7.45 regarding "New return codes from + preupgrade-assistant." + Related: rhbz#1371553 + +* Tue Aug 30 2016 Michal Bocek - 1:0.7.45-1 +- Rebase to 0.7.45 +- New return codes from preupgrade-assistant. + Resolves: rhbz#1371553 +- Support include in .repo files. + Resolves: rhbz#1270223 +- Prompt user to accept GPG key import. + Resolves: rhbz#1150029 +- Fix PYCURL ERROR 22 - remove tool cache at the start of the tool. + Resolves: rhbz#1303982 + +* Tue Jul 26 2016 Petr Hracek - 1:0.7.44-2 +- Correct dependency on preupgrade-assistant + Related: rhbz#1356806 + +* Mon Jul 25 2016 Michal Bocek 0.7.44-1 +- Fix tool failure due to AttributeError (check_inplace_risk). + Resolves: rhbz#1356806 + +* Wed Oct 14 2015 David Shea 0.7.43-1 +- Fix the iteration over failed preupgrade scripts (mganisin) + Related: rhbz#1252850 + +* Wed Sep 9 2015 David Shea 0.7.42-1 +- Run all preupgrade scripts and report which failed (phracek) + Resolves: rhbz#1252850 + +* Fri Jul 10 2015 David Shea 0.7.41-1 +- Use the filename to determine the kernel version for new-kernel-pkg. + Resolves: rhbz#1241875 + +* Wed Jul 1 2015 David Shea 0.7.40-1 +- Apply sslnoverify to all setup_downloader calls + Related: rhbz#1169969 + +* Thu Jun 25 2015 David Shea 0.7.39-1 +- Fix traceback for transaction problems with one package + Resolves: rhbz#1220291 + +* Wed Jun 24 2015 David Shea 0.7.38-1 +- Remove the KeyboardInterruptMessage +- Retry raw_input on SIGWINCH + Resolves: rhbz#1106485 +- Do not use losetup for the ISO file name + Related: rhbz#1054048 +- Fix logging in media.py +- Modify yum repo mountpoints before reboot. + Resolves: rhbz#1225092 + +* Tue May 12 2015 David Shea 0.7.37-1 +- Convert bootloader arguments before upgrade (phracek) + Resolves: rhbz#1081047 + +* Wed Apr 8 2015 David Shea 0.7.36-1 +- Add an option to disable SSL certificate verification + Resolves: rhbz#1169969 +- Change the message shown when no upgrade is found. + Resolves: rhbz#1199927 + +* Wed Apr 8 2015 David Shea 0.7.35-1 +- Handle EOFError in raw_input + Resolves: rhbz#1106485 +- Check proper upgrade target version (phracek) + Resolves: rhbz#1199087 +- Add a message on check_release_version_file failures + Related: rhbz#1199087 + +* Fri Feb 13 2015 David Shea 0.7.34-1 +- Run setup_cleanup_post earlier (fkluknav) + Related: rhbz#1187024 + +* Mon Feb 2 2015 David Shea 0.7.33-1 +- Write all command-line options to upgrade.conf (fkluknav) + Resolves: rhbz#1187024 + +* Fri Sep 19 2014 David Shea 0.7.32-1 +- Fix the URLGrabError import + Related: rhbz#1076120 + +* Fri Sep 19 2014 David Shea 0.7.31-1 +- Fix ValueError with --addrepo/--repo REPOID (wwoods) + Related: rhbz#1084985 +- Add a message about invalid repo URLs + Resolves: rhbz#1084985 +- Catch exceptions from early treeinfo parsing + Resolves: (#1076120) + +* Wed Sep 17 2014 David Shea 0.7.30-1 +- Fix the enabled line on disabled yum repos + Related: rhbz#1130686 + +* Fri Sep 12 2014 David Shea 0.7.29-1 +- Disable yum repos with no enabled= line + Resolves: rhbz#1130686 + +* Mon Sep 8 2014 David Shea 0.7.28-1 +- Execute preupgrade-scripts after storing RHEL-7 repos (phracek) + Related: rhbz#1138615 + +* Mon Sep 8 2014 David Shea 0.7.27-1 +- Fix fedup.util.rlistdir + Related: rhbz#1138615 +- Run preupgrade scripts before setting up the upgrade + Resolves: rhbz#1138615 + +* Fri Aug 15 2014 David Shea 0.7.26-1 +- Fix the search for enabled repos to disable. + Related: rhbz#1075486 + +* Mon Aug 4 2014 David Shea 0.7.25-1 +- Add --instrepokey (wwoods) + Related: rhbz#1115532 + Related: rhbz#1123915 +- Automatically add the GPG key to Red Hat repos. + Resolves: rhbz#1123915 +- Revert "fetch/verify .treeinfo.signed if gpgcheck is on" + Related: rhbz#1123915 +- Cleanup repo files added by redhat-upgrade-tool +- Fix a crash if cleaning up without /var/lib/system-upgrade +- Write GPG information to the yum repo files + Resolves: rhbz#1115532 + +* Tue Jul 1 2014 David Shea 0.7.24-1 +- Upgrade repos are enabled by default (phracek) +- Always disable old repos +- Disable repos from RHEL-6 before starting the upgrade. + +* Wed Jun 25 2014 David Shea 0.7.23-1 +- Skip unavailable repos during the postupgrade scripts + Resolves: rhbz#1106401 + +* Wed Jun 4 2014 David Shea 0.7.22-1 +- Use the mkdir_p wrapper instead of os.makedirs + Resolves: rhbz#1104780 + +* Tue Jun 3 2014 David Shea 0.7.21-1 +- Workaround .pem being removed by redhat-upgrade-tool --clean (jdornak) + Related: rhbz#1071902 +- Always create the upgrade.conf directory + Related: rhbz#1070603 +- Copy upgrade.conf to /root/preupgrade + Related: rhbz#1070603 +- Revert "Don't cleanup upgrade.conf for now" + Related: rhbz#1070603 + +* Mon Jun 2 2014 David Shea 0.7.20-1 +- Add net.ifnames=0 to the boot command line + Resolves: rhbz#1089212 + +* Thu May 29 2014 David Shea 0.7.19-1 +- Download RHSM product certificates (jdornak) + Resolves: rhbz#1071902 +- Workaround: Install RHSM product certificates in case that redhat-upgrade-dracut have not installed them. (jdornak) + Resolves: rhbz#1071902 + +* Fri May 23 2014 David Shea 0.7.18-1 +- Fix the arg used with --device (bmr) + Related: rhbz#1083169 + +* Fri May 23 2014 David Shea 0.7.17-1 +- Attempt to bring the network up during upgrade-init + Resolves: rhbz#1089212 + +* Thu May 22 2014 David Shea 0.7.16-1 +- Run realpath on --device arguments. + Resolves: rhbz#1083169 + +* Thu May 22 2014 David Shea 0.7.15-1 +- Add an option --cleanup-post to cleanup packages in post scripts. + Resolves: rhbz#1070603 +- Add a Requires for a sufficiently new yum + Resolves: rhbz#1084165 +- Disable screen blanking + Resolves: rhbz#1070112 +- Clear upgrade.conf before starting + Related: rhbz#1100391 +- Don't cleanup upgrade.conf for now + Related: rhbz#1100391 + +* Tue May 20 2014 David Shea 0.7.14-1 +- Move the repo files to /etc/yum.repos.d + Related: rhbz#1080966 + +* Thu May 8 2014 David Shea 0.7.13-1 +- Move system-upgrade.target.requires mounts into a shell script + Resolves: rhbz#1094193 + +* Fri May 2 2014 David Shea 0.7.12-1 +- Added a check to prevent cross-variant upgrades. + Resolves: rhbz#1070114 + +* Fri Apr 11 2014 David Shea 0.7.11-1 +- Save the repo config files to /var/tmp/system-upgrade/yum.repos.d + Resolves: rhbz#1080966 + +* Thu Apr 3 2014 David Shea 0.7.10-1 +- Revise how preupgrade issues are printed + Related: rhbz#1059447 +- Call preupgrade-assistant API directly (phracek) + Related: rhbz#1059447 + +* Thu Apr 3 2014 David Shea 0.7.9-1 +- Disable plymouth to workaround not reaching sysinit.target + Resolves: rhbz#1060789 +- Handle missing version arguments + Resolves: rhbz#1069836 +- Require --instrepo with --network. + Resolves: rhbz#1070080 +- Fix the reboot command for RHEL 6. + Resolves: rhbz#1070821 + +* Wed Mar 5 2014 David Shea 0.7.8-1 +- Remove the unused systemd requires. + Related: rhbz#1059447 +- Check for preupgrade-assistant risks + Resolves: rhbz#1059447 +- Don't display package problems covered by preupgrade-assistant + Related: rhbz#1059447 +- Revise the preupgrade HIGH risk message. + Related: rhbz#1059447 + +* Wed Feb 26 2014 David Shea 0.7.7-1 +- Remove the output parameter from CalledProcessException + Resolves: rhbz#1054048 + +* Wed Feb 12 2014 David Shea 0.7.6-1 +- Add a generic problem summarizer. + Resolves: rhbz#1040684 +- Fix the dependency problem summary + Related: rhbz#1040684 + +* Tue Jan 28 2014 David Shea 0.7.5-1 +- Replace subprocess backports with the versions from Python 2.7 (dshea) + Resolves: rhbz#1054048 +- Use the output of losetup to find the loop file (dshea) + Related: rhbz#1054048 +- Fix a misnamed variable in device_or_mnt (dshea) + Related: rhbz#1054048 +- fix UnboundLocalError with fedup --device (wwoods) + Related: rhbz#1054048 + +* Mon Dec 2 2013 David Shea 0.7.4-1 +- Remove the URL from Source0 + Related: rhbz#1034906 + +* Tue Nov 26 2013 David Shea 0.7.4-0 +- Fix the kernel and initrd names. (#1031951) +- Remove rhgb quiet from the kernel command line. (#1032038) +- Remove the output parameter from CalledProcessError (#1032038) +- Change the python-devel BuildRequires to python-libs + +* Tue Nov 19 2013 David Shea 0.7.3-0 +- Initial package for RHEL 6 + Resolves: rhbz#1012617