diff options
-rw-r--r-- | iutil.py | 7 | ||||
-rw-r--r-- | packages.py | 8 | ||||
-rw-r--r-- | upgrade.py | 2 | ||||
-rw-r--r-- | yuminstall.py | 15 |
4 files changed, 13 insertions, 19 deletions
@@ -20,6 +20,7 @@ # Author(s): Erik Troan <ewt@redhat.com> # +import glob import os, string, stat, sys import signal import os.path @@ -914,3 +915,9 @@ def reIPL(anaconda, loader_pid): # or a two-item list with errorMessage and rebootInstr (=> shutdown) return message +def resetRpmDb(rootdir): + for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootdir): + try: + os.unlink(rpmfile) + except Exception, e: + log.debug("error %s removing file: %s" %(e,rpmfile)) diff --git a/packages.py b/packages.py index 33457772d..f59cd7b09 100644 --- a/packages.py +++ b/packages.py @@ -307,13 +307,7 @@ def rpmKernelVersionList(rootPath = "/"): versions = [] - # FIXME: and make sure that the rpmdb doesn't have stale locks :/ - for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootPath): - try: - os.unlink(rpmfile) - except: - log.debug("failed to unlink %s" % rpmfile) - + iutil.resetRpmDb(rootPath) ts = rpm.TransactionSet(rootPath) mi = ts.dbMatch('provides', 'kernel') diff --git a/upgrade.py b/upgrade.py index 730bb4c71..d8cee5a55 100644 --- a/upgrade.py +++ b/upgrade.py @@ -50,7 +50,7 @@ def guessGuestArch(rootdir): """root path -> None|"architecture" Guess the architecture of installed system """ - + iutil.resetRpmDb(rootdir) ts = rpm.ts(rootdir) packages = ["filesystem", "initscripts"] diff --git a/yuminstall.py b/yuminstall.py index b16d7c616..ff6136088 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -1004,7 +1004,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon # clean up rpmdb locks so that kickstart %post scripts aren't # unhappy (#496961) - self._resetRpmDb(anaconda.rootPath) + iutil.resetRpmDb(anaconda.rootPath) def doBackendSetup(self, anaconda): if anaconda.dir == DISPATCH_BACK: @@ -1012,7 +1012,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon if anaconda.id.getUpgrade(): # FIXME: make sure that the rpmdb doesn't have stale locks :/ - self._resetRpmDb(anaconda.rootPath) + iutil.resetRpmDb(anaconda.rootPath) iutil.writeRpmPlatform() self.ayum = AnacondaYum(anaconda) @@ -1480,13 +1480,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon self._checkUpgradeVersion(anaconda) self._checkUpgradeArch(anaconda) - def _resetRpmDb(self, rootPath): - for rpmfile in glob.glob("%s/var/lib/rpm/__db.*" % rootPath): - try: - os.unlink(rpmfile) - except Exception, e: - log.debug("error %s removing file: %s" %(e,rpmfile)) - def _checkUpgradeVersion(self, anaconda): # Figure out current version for upgrade nag and for determining weird # upgrade cases @@ -1514,7 +1507,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon "process?") %(productName,), type = "yesno") if rc == 0: - self._resetRpmDb(anaconda.rootPath) + iutil.resetRpmDb(anaconda.rootPath) sys.exit(0) def _checkUpgradeArch(self, anaconda): @@ -1545,7 +1538,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon %(productName, myarch, po.arch), type="yesno") if rc == 0: - self._resetRpmDb(anaconda.rootPath) + iutil.resetRpmDb(anaconda.rootPath) sys.exit(0) else: log.warning("upgrade between possibly incompatible " |