On 04/30/2009 02:02 PM, Chris Lumens wrote: > --- Seems like it should be broken into two commits, but otherwise fine. > iutil.py | 7 +++++++ > packages.py | 8 +------- > upgrade.py | 2 +- > yuminstall.py | 24 ++++++++++++------------ > 4 files changed, 21 insertions(+), 20 deletions(-) > > diff --git a/iutil.py b/iutil.py > index af67c5f..eb82b72 100644 > --- a/iutil.py > +++ b/iutil.py > @@ -20,6 +20,7 @@ > # Author(s): Erik Troan <ewt@xxxxxxxxxx> > # > > +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 275c7c7..739cc90 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 c00c9c6..e5844e8 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 b16d7c6..0e7a4da 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,10 +1507,17 @@ 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): > + def compareArch(a, b): > + import re > + if re.match("i.86", a) and re.match("i.86", b): > + return True > + else: > + return a == b > + > # get the arch of the initscripts package > try: > pkgs = self.ayum.pkgSack.returnNewestByName('initscripts') > @@ -1534,7 +1534,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon > log.info("initscripts is arch: %s" %(myarch,)) > for po in self.ayum.rpmdb.getProvides('initscripts'): > log.info("po.arch is arch: %s" %(po.arch,)) > - if po.arch != myarch: > + if not compareArch(po.arch, myarch): > rc = anaconda.intf.messageWindow(_("Warning"), > _("The arch of the release of %s you " > "are upgrading to appears to be %s " > @@ -1545,7 +1545,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 " -- Peter Sanity's just a one trick pony anyway. You only get one trick -- rational thinking -- but when you're good and crazy, the sky's the limit! -- The Tick _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list