From af8d91a5072a2b87aec72b97a5f160be9a8f9958 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 1 Nov 2026 12:55:20 +0100 Subject: [PATCH] Find the rpm database of an EL image of another generation EL9 and older keep the rpm database in /var/lib/rpm, EL10 moved it to /usr/lib/sysimage/rpm. fingerprint_host_el opened the image with the default path of the host, so on an EL10 server an EL9 image was not recognized (and an empty database was created in it). pack then wrote no profile.yaml and no addons link, and import refused the image. Use /var/lib/rpm when it is a real directory in the image. In EL10 it is a relative link, so the default of the host still applies. --- imgutil/imgutil | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/imgutil/imgutil b/imgutil/imgutil index 0bf73230..bb6bc28e 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -1499,8 +1499,18 @@ def fingerprint_host_el(args, hostpath='/'): release = '' if hostpath[0] != '/': hostpath = os.path.join(os.getcwd(), hostpath) + # EL9 and older keep the rpm database in /var/lib/rpm, EL10 moved it to + # /usr/lib/sysimage/rpm and links the old path there. The default of the + # host only finds the database of an image of the same generation. + dbpath = os.path.join(hostpath, 'var/lib/rpm') + if os.path.isdir(dbpath) and not os.path.islink(dbpath): + dbpath = '/var/lib/rpm' + else: + dbpath = None try: import rpm + if dbpath: + rpm.addMacro('_dbpath', dbpath) ts = rpm.TransactionSet(hostpath) rpms = ts.dbMatch('provides', 'system-release') for inf in rpms: @@ -1509,9 +1519,14 @@ def fingerprint_host_el(args, hostpath='/'): osname = inf.name version = inf.version release = inf.release + if dbpath: + rpm.delMacro('_dbpath') except ImportError: try: - rver = subprocess.check_output('rpm --root {0} -q --whatprovides system-release'.format(hostpath).split()) + rpmcmd = ['rpm', '--root', hostpath] + if dbpath: + rpmcmd.extend(['--dbpath', dbpath]) + rver = subprocess.check_output(rpmcmd + ['-q', '--whatprovides', 'system-release']) if not isinstance(rver, str): rver = rver.decode('utf8') for infline in subprocess.check_output('rpm -qi {0}'.format(rver).split()).decode('utf8').split('\n'):