2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-19 08:52:20 +00:00

Reset the rpm database path macro on any error

The _dbpath macro set for fingerprinting an image is process global. It
was only removed after a successful query, so an error left it set and
later fingerprinting in the same process, which fancy_chroot does on
every command, read the wrong database.
This commit is contained in:
Markus Hilger
2026-11-01 18:09:37 +01:00
parent 8b4445e675
commit 0e824ec529
+12 -10
View File
@@ -1511,16 +1511,18 @@ def fingerprint_host_el(args, hostpath='/'):
import rpm
if dbpath:
rpm.addMacro('_dbpath', dbpath)
ts = rpm.TransactionSet(hostpath)
rpms = ts.dbMatch('provides', 'system-release')
for inf in rpms:
if 'el8' not in inf.release and 'el7' not in inf.release and 'el9' not in inf.release and 'el10' not in inf.release:
continue
osname = inf.name
version = inf.version
release = inf.release
if dbpath:
rpm.delMacro('_dbpath')
try:
ts = rpm.TransactionSet(hostpath)
rpms = ts.dbMatch('provides', 'system-release')
for inf in rpms:
if 'el8' not in inf.release and 'el7' not in inf.release and 'el9' not in inf.release and 'el10' not in inf.release:
continue
osname = inf.name
version = inf.version
release = inf.release
finally:
if dbpath:
rpm.delMacro('_dbpath')
except ImportError:
try:
rpmcmd = ['rpm', '--root', hostpath]