summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-04-30 17:19:27 -0400
committerChris Lumens <clumens@redhat.com>2009-04-30 17:22:36 -0400
commit9831be217d043fa21cf63b3415c8170c73a8f1fc (patch)
tree1de4ada509dc5d2bcca7dd0bcc82b0d4cf768c9d
parent57352b956a84d723c423e732efad8f9311c0d830 (diff)
downloadanaconda-9831be217d043fa21cf63b3415c8170c73a8f1fc.tar.gz
anaconda-9831be217d043fa21cf63b3415c8170c73a8f1fc.tar.xz
anaconda-9831be217d043fa21cf63b3415c8170c73a8f1fc.zip
Move _resetRpmDb into iutil so we can access it everywhere.
-rw-r--r--iutil.py7
-rw-r--r--packages.py8
-rw-r--r--upgrade.py2
-rw-r--r--yuminstall.py15
4 files changed, 13 insertions, 19 deletions
diff --git a/iutil.py b/iutil.py
index af67c5f7e..eb82b728a 100644
--- a/iutil.py
+++ b/iutil.py
@@ -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 "