diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-02-05 22:21:33 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-02-05 22:21:33 +0000 |
commit | 3fa72a8b50e233a1afdb714197a68c319e67d9fe (patch) | |
tree | 1e8e1f42ea39603496181035c475fa8bb9c6862d | |
parent | 97bf42e57ae82a73e2874e4f033e689eb293c063 (diff) | |
download | anaconda-3fa72a8b50e233a1afdb714197a68c319e67d9fe.tar.gz anaconda-3fa72a8b50e233a1afdb714197a68c319e67d9fe.tar.xz anaconda-3fa72a8b50e233a1afdb714197a68c319e67d9fe.zip |
use new -r argument for convertdb1
do save and restore of the old rpmdb correctly for pre-rpm4 upgrades so that
people might have a chance of not being completely hosed if the upgrade fails.
-rw-r--r-- | packages.py | 21 | ||||
-rw-r--r-- | upgrade.py | 35 |
2 files changed, 24 insertions, 32 deletions
diff --git a/packages.py b/packages.py index 08299178e..6d1118693 100644 --- a/packages.py +++ b/packages.py @@ -1045,26 +1045,9 @@ def doPostInstall(method, id, intf, instPath): w.set(4) if upgrade and id.dbpath is not None: - # move the rebuilt db into place. + # remove the old rpmdb try: - iutil.rmrf (instPath + "/var/lib/rpm.rpmsave") - except OSError: - pass - try: - os.rename (instPath + "/var/lib/rpm", - instPath + "/var/lib/rpm.rpmsave") - except OSError: - # XXX hack..., if the above move failed, we'll just stash it in - # a (hopefully) unique location. (#50339) - os.rename (instPath + "/var/lib/rpm", - instPath + "/var/lib/rpm.rpmsave-%s" % - (str(int(time.time())),)) - os.rename (instPath + id.dbpath, - instPath + "/var/lib/rpm") - - # XXX - rpm 4.0.2 %post braindeadness support - try: - os.unlink (instPath + "/etc/rpm/macros.db1") + iutil.rmrf (id.dbpath) except OSError: pass diff --git a/upgrade.py b/upgrade.py index b643202b4..6549109f1 100644 --- a/upgrade.py +++ b/upgrade.py @@ -22,6 +22,7 @@ import sys import os.path import partedUtils import string +import shutil import lvm from flags import flags from fsset import * @@ -311,6 +312,11 @@ def upgradeMountFilesystems(intf, rootInfo, oldfsset, instPath): if flags.setupFilesystems: oldfsset.turnOnSwap(instPath) +# move the old pre-convert db back in case of problems +def resetRpmdb(olddb): + iutil.rmrf(instPath + "/var/lib/rpm") + os.rename (olddb, instPath + "/var/lib/rpm") + rebuildTime = None def upgradeFindPackages(intf, method, id, instPath, dir): @@ -338,12 +344,13 @@ def upgradeFindPackages(intf, method, id, instPath, dir): # we should only have to rebuild for upgrades of pre rpm 4.0.x systems # according to jbj - if os.access(instPath + "/var/lib/rpm/packages.rpm", os.R_OK): - id.dbpath = None - rebuildpath = None + if (os.access(instPath + "/var/lib/rpm/packages.rpm", os.R_OK) and + not os.access(instPath + "/var/lib/rpm/Packages", os.R_OK)): + id.dbpath = "%s/var/lib/rpm-%s" %(instPath, rebuildTime) + shutil.copytree("%s/var/lib/rpm" %(instPath,), id.dbpath) args = [ "/usr/libexec/convertdb1", - instPath + "/var/lib/rpm/packages.rpm" ] + "-r", instPath, "/var/lib/rpm/packages.rpm" ] rc = iutil.execWithRedirect(args[0], args, stdout = "/dev/tty5", stderr = "/dev/tty5") @@ -356,7 +363,6 @@ def upgradeFindPackages(intf, method, id, instPath, dir): sys.exit(0) else: id.dbpath = None - rebuildpath = None try: import findpackageset @@ -370,8 +376,8 @@ def upgradeFindPackages(intf, method, id, instPath, dir): packages = findpackageset.findpackageset(id.hdList.hdlist, instPath) except rpm.error: - if rebuildpath is not None: - iutil.rmrf(rebuildpath) + if id.dbpath is not None: + resetRpmdb(id.dbpath) win.pop() intf.messageWindow(_("Error"), _("An error occurred when finding the packages to " @@ -440,8 +446,9 @@ def upgradeFindPackages(intf, method, id, instPath, dir): type="yesno") if rc == 0: try: - iutil.rmrf(rebuildpath) - except: + resetRpmdb(id.dbpath) + except Exception, e: + logMessage("error returning rpmdb to old state: %s" %(e,)) pass sys.exit(0) @@ -456,8 +463,9 @@ def upgradeFindPackages(intf, method, id, instPath, dir): type="yesno") if rc == 0: try: - iutil.rmrf(rebuildpath) - except: + resetRpmdb(id.dbpath) + except Exception, e: + logMessage("error returning rpmdb to old state: %s" %(e,)) pass sys.exit(0) @@ -496,8 +504,9 @@ def upgradeFindPackages(intf, method, id, instPath, dir): type="yesno") if rc == 0: try: - iutil.rmrf(rebuildpath) - except: + resetRpmdb(id.dbpath) + except Exception, e: + logMessage("error returning rpmdb to old state: %s" %(e,)) pass sys.exit(0) |