2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-20 17:32:21 +00:00

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.
This commit is contained in:
Markus Hilger
2026-11-01 12:55:20 +01:00
parent 89787671cf
commit af8d91a507
+16 -1
View File
@@ -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'):