Add CentOS branding with patches:

0008-redhat-upgrade-tool-no-variants.patch
0009-redhat-upgrade-tool-remove-rhsm-downloads.patch
This commit is contained in:
Yuriy Kohut 2024-04-11 11:21:02 +03:00
parent 4d089d2c29
commit 646b696a27
3 changed files with 115 additions and 4 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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 <ykohut@almalinux.org> - 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 <pstodulk@redhat.com> - 1:0.8.0-9
- do not affect non-intel architectures by the last fix
Resolves: rhbz#1858822