Clean rpm db directory of broken symlinks

Related: https://pagure.io/koji/issue/3892
This commit is contained in:
Tomas Kopecek 2023-09-05 13:23:32 +02:00
parent 303c4daeb1
commit a1ad698630

View file

@ -697,9 +697,16 @@ class BuildRoot(object):
'size',
'buildtime')
# Determine db path
dbpath = "%s/var/lib/rpm" % self.rootdir()
if os.path.exists(os.path.join(dbpath, '.migratedb')):
dbpath = "%s/usr/lib/sysimage/rpm" % self.rootdir()
dbpath = "%s/usr/lib/sysimage/rpm" % self.rootdir()
if not os.path.exists(dbpath):
# older variant (<rhel10, <fedora39)
dbpath = "%s/var/lib/rpm" % self.rootdir()
else:
# if new dbpath is used and mock is running older rpm on builder
# _db* symlinks could exist in migrated directory
for f in glob.glob('%s/__db*' % dbpath):
if not os.path.isfile(f):
os.unlink(f)
if not os.path.exists(dbpath):
raise koji.GenericError("Can't get list of installed rpms")
rpm.addMacro("_dbpath", dbpath)