From 646b696a27fafb92d359018044d02d8337dc84b1 Mon Sep 17 00:00:00 2001 From: Yuriy Kohut Date: Thu, 11 Apr 2024 11:21:02 +0300 Subject: [PATCH] Add CentOS branding with patches: 0008-redhat-upgrade-tool-no-variants.patch 0009-redhat-upgrade-tool-remove-rhsm-downloads.patch --- ...0008-redhat-upgrade-tool-no-variants.patch | 42 ++++++++++++++ ...t-upgrade-tool-remove-rhsm-downloads.patch | 58 +++++++++++++++++++ SPECS/redhat-upgrade-tool.spec | 19 ++++-- 3 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 SOURCES/0008-redhat-upgrade-tool-no-variants.patch create mode 100644 SOURCES/0009-redhat-upgrade-tool-remove-rhsm-downloads.patch diff --git a/SOURCES/0008-redhat-upgrade-tool-no-variants.patch b/SOURCES/0008-redhat-upgrade-tool-no-variants.patch new file mode 100644 index 0000000..84b5165 --- /dev/null +++ b/SOURCES/0008-redhat-upgrade-tool-no-variants.patch @@ -0,0 +1,42 @@ +--- redhat-upgrade-tool.py.orig 2023-12-18 12:27:36.000000000 +0200 ++++ redhat-upgrade-tool.py 2023-12-20 09:08:46.522875724 +0200 +@@ -273,12 +273,10 @@ def main(args): + if args.nogpgcheck: + f._override_sigchecks = True + elif not f.instrepo.gpgcheck: +- # If instrepo is a Red Hat repo, add the gpg key and reload the repos ++ # If instrepo is a CentOS repo, add the gpg key and reload the repos + try: +- key = "product" +- if not f.treeinfo.has_section(key): +- key = "release" +- if f.treeinfo.get(key, 'name') == 'Red Hat Enterprise Linux': ++ key = "general" ++ if f.treeinfo.get(key, 'family') == 'CentOS': + log.info("Reloading repos with GPG key") + args.repos.append(('gpgkey', '%s=%s' % (f.instrepo.name, rhel_gpgkey_path))) + f = setup_downloader(version=args.network, +@@ -534,22 +534,10 @@ def check_preupg_risks(): + + def check_same_variant_upgrade(treeinfo): + distro = platform.linux_distribution()[0] +- if not distro.startswith("Red Hat Enterprise Linux "): ++ if distro not in ("CentOS"): + print _("Invalid distribution: %s") % distro + raise SystemExit(1) + +- from_variant = distro[len('Red Hat Enterprise Linux '):] +- try: +- to_variant = treeinfo.get('general', 'variant') +- except NoOptionError: +- print _("Upgrade repository is not a Red Hat Enterprise Linux repository") +- raise SystemExit(1) +- +- if from_variant != to_variant: +- print _("Upgrade requested from Red Hat Enterprise Linux %s to %s") % (from_variant, to_variant) +- print _("Upgrades between Red Hat Enterprise Linux variants is not supported.") +- raise SystemExit(1) +- + + if __name__ == '__main__': + args = parse_args() diff --git a/SOURCES/0009-redhat-upgrade-tool-remove-rhsm-downloads.patch b/SOURCES/0009-redhat-upgrade-tool-remove-rhsm-downloads.patch new file mode 100644 index 0000000..94761af --- /dev/null +++ b/SOURCES/0009-redhat-upgrade-tool-remove-rhsm-downloads.patch @@ -0,0 +1,58 @@ +--- redhat_upgrade_tool/download.py.orig 2023-12-18 12:27:36.000000000 +0200 ++++ redhat_upgrade_tool/download.py 2023-12-20 09:12:06.435879445 +0200 +@@ -30,7 +30,6 @@ from yum.constants import TS_REMOVE_STAT + from urlgrabber.grabber import URLGrabError + from yum.misc import gpgme + from gzip import GzipFile +-from rhsm.certificate import create_from_pem + + enabled_plugins = ['blacklist', 'whiteout'] + disabled_plugins = ['rpm-warm-cache', 'remove-with-leaves', 'presto', +@@ -339,47 +338,6 @@ class UpgradeDownloader(yum.YumBase): + if updates: + self._checkSignatures(updates, callback) + +- # store RHSM productid certificates +- # (this code is inspired by is taken from subscription_manager.productid) +- used_repos = set([p.repoid for p in updates]) +- for repo in self.repos.listEnabled(): +- # skip repos we have not used to download any package +- if repo.id not in used_repos: +- continue +- +- # skip repos we don't have productid for +- try: +- fn = repo.retrieveMD('productid') +- if fn.endswith('.gz'): +- f = GzipFile(fn) +- else: +- f = open(fn) +- try: +- pem = f.read() +- cert = create_from_pem(pem) +- finally: +- f.close() +- except yum.Errors.RepoMDError, e: +- log.warn("Error loading productid metadata for %s." % repo) +- continue +- except Exception, e: +- log.warn("Error loading productid metadata for %s." % repo) +- log.exception(e) +- continue +- if cert is None: +- continue +- +- product = cert.products[0] +- +- log.debug("product cert: %s repo: %s" % (product.id, repo.id)) +- +- # temporarily use different directory for storing certificates +- packagedir = '/root/preupgrade/productid' +- mkdir_p(packagedir) +- path = os.path.join(packagedir, '%s.pem' % product.id) +- cert.write(path) +- log.info("Downloaded product cert %s: %s %s" % (product.id, product.name, cert.path)) +- + def clean_cache(self, keepfiles): + log.info("checking for unneeded rpms in cache") + # Find all the packages in the caches (not on media though) diff --git a/SPECS/redhat-upgrade-tool.spec b/SPECS/redhat-upgrade-tool.spec index 846ed85..29083f0 100644 --- a/SPECS/redhat-upgrade-tool.spec +++ b/SPECS/redhat-upgrade-tool.spec @@ -3,8 +3,8 @@ Name: redhat-upgrade-tool Version: 0.8.0 -Release: 9%{?dist} -Summary: The Red Hat Enterprise Linux Upgrade tool +Release: 10%{?dist} +Summary: The CentOS Linux Upgrade tool Epoch: 1 License: GPLv2+ @@ -19,10 +19,11 @@ 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 +Patch7: 0008-redhat-upgrade-tool-no-variants.patch +Patch8: 0009-redhat-upgrade-tool-remove-rhsm-downloads.patch Requires: dbus Requires: grubby -Requires: python-rhsm Requires: python-argparse Requires: preupgrade-assistant >= 2.2.0-1 @@ -40,7 +41,7 @@ BuildArch: noarch Obsoletes: preupgrade %description -redhat-upgrade-tool is the Red Hat Enterprise Linux Upgrade tool. +redhat-upgrade-tool is the CentOS Linux Upgrade tool. %prep @@ -53,6 +54,8 @@ redhat-upgrade-tool is the Red Hat Enterprise Linux Upgrade tool. %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p0 +%patch8 -p0 %build @@ -112,6 +115,11 @@ if [ ! -e /var/lib/dbus/machine-id ]; then dbus-uuidgen > /var/lib/dbus/machine-id fi +# CentOS branding +ln -sf redhat-upgrade-tool $RPM_BUILD_ROOT/%{_bindir}/centos-upgrade-tool +ln -sf centos-upgrade-tool $RPM_BUILD_ROOT/%{_bindir}/centos-upgrade-tool-cli +ln -sf redhat-upgrade-tool.8 $RPM_BUILD_ROOT/%{_mandir}/man8/centos-upgrade-tool.8 +ln -sf centos-upgrade-tool.8 $RPM_BUILD_ROOT/%{_mandir}/man8/centos-upgrade-tool-cli.8 %files %{!?_licensedir:%global license %%doc} @@ -158,6 +166,9 @@ fi %changelog +* Thu Apr 11 2024 Yuriy Kohut - 1:0.8.0-10 +- Add CentOS branding with patches: 0008-redhat-upgrade-tool-no-variants.patch, 0009-redhat-upgrade-tool-remove-rhsm-downloads.patch + * Fri Jul 31 2020 Petr Stodulka - 1:0.8.0-9 - do not affect non-intel architectures by the last fix Resolves: rhbz#1858822