diff options
author | Paul Nasrat <pnasrat@redhat.com> | 2006-02-22 21:27:13 +0000 |
---|---|---|
committer | Paul Nasrat <pnasrat@redhat.com> | 2006-02-22 21:27:13 +0000 |
commit | cd4dfc67498a8f19387f309c09ed539b9d126ca8 (patch) | |
tree | be9bccc7c73cdf000a0ab3fc2d5bd7174e2ce8fa | |
parent | d7725c6270780a2805f62ccc59eb0e96ef913b99 (diff) | |
download | anaconda-cd4dfc67498a8f19387f309c09ed539b9d126ca8.tar.gz anaconda-cd4dfc67498a8f19387f309c09ed539b9d126ca8.tar.xz anaconda-cd4dfc67498a8f19387f309c09ed539b9d126ca8.zip |
Improved upgrade support
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | backend.py | 2 | ||||
-rw-r--r-- | upgrade.py | 344 | ||||
-rw-r--r-- | yuminstall.py | 54 |
4 files changed, 62 insertions, 344 deletions
@@ -1,3 +1,9 @@ +2006-02-22 Paul Nasrat <pnasrat@redhat.com> + + * backend.py: Call upgrade check + * yuminstall.py: Check version and packages to upgrade + * upgrade.py: Remove unused code. + 2006-02-22 Jeremy Katz <katzj@redhat.com> * isys/isys.py (hardDriveDict): Remove ide raid checking diff --git a/backend.py b/backend.py index 34672e6c1..29900895d 100644 --- a/backend.py +++ b/backend.py @@ -146,6 +146,8 @@ class AnacondaBackend: def doRepoSetup(backend, intf, id, instPath): backend.doInitialSetup(id, instPath) backend.doRepoSetup(intf, instPath) + if id.upgrade: + backend.checkSupportedUpgrade(intf, instPath) def doPostSelection(backend, intf, id, instPath): backend.doPostSelection(intf, id, instPath) diff --git a/upgrade.py b/upgrade.py index f822acbe4..aa5651bd5 100644 --- a/upgrade.py +++ b/upgrade.py @@ -339,348 +339,4 @@ def upgradeMountFilesystems(intf, rootInfo, oldfsset, instPath): oldfsset.turnOnSwap(instPath, upgrading=True) oldfsset.mkDevRoot(instPath) -# move the old pre-convert db back in case of problems -def resetRpmdb(olddb, instPath): - if olddb is not None: - iutil.rmrf(instPath + "/var/lib/rpm") - os.rename (olddb, instPath + "/var/lib/rpm") - -rebuildTime = None - -def upgradeFindPackages(intf, method, id, instPath, dir): - if dir == DISPATCH_BACK: - return - return - # if we've been through here once for this root, then short-circuit - if ((id.upgradeInfoFound is not None) and - (id.upgradeInfoFound == id.upgradeRoot)): - log.info("already found packages to upgrade for %s" %(id.upgradeRoot,)) - return - else: - id.upgradeInfoFound = id.upgradeRoot - - win = intf.waitWindow(_("Finding"), - _("Finding packages to upgrade...")) - - # now, set the system clock so the timestamps will be right: - if flags.setupFilesystems: - iutil.setClock(instPath) - - # 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) and - not os.access(instPath + "/var/lib/rpm/Packages", os.R_OK)): - win.pop() - intf.messageWindow(_("Error"), - _("The installation program is unable to upgrade " - "systems with a pre-rpm 4.x database. " - "Please install the errata rpm packages " - "for your release as described in the release " - "notes and then run the upgrade procedure.")) - sys.exit(0) - - else: - id.dbpath = None - - try: - import findpackageset - - # FIXME: make sure that the rpmdb doesn't have stale locks :/ - for file in ["__db.001", "__db.002", "__db.003"]: - try: - os.unlink("%s/var/lib/rpm/%s" %(instPath, file)) - except: - log.error("failed to unlink /var/lib/rpm/%s" %(file,)) - - packages = findpackageset.findpackageset(id.grpset.hdrlist.hdlist, - instPath) - except rpm.error: - if id.dbpath is not None: - resetRpmdb(id.dbpath, instPath) - win.pop() - intf.messageWindow(_("Error"), - _("An error occurred when finding the packages to " - "upgrade.")) - sys.exit(0) - - # unselect all packages - # turn on the packages in the upgrade set - # open up the database to check dependencies and currently - # installed packages - # make sure we have an arch match. (#87655) - # FIXME: bash wasn't good enough (#129677). let's try initscripts -# mi = ts.dbMatch('name', 'initscripts') -# myarch = id.grpset.hdrlist["initscripts"][rpm.RPMTAG_ARCH] -# for h in mi: -# if h[rpm.RPMTAG_ARCH] != myarch: -# rc = intf.messageWindow(_("Warning"), -# _("The arch of the release of %s you " -# "are upgrading to appears to be %s " -# "which does not match your previously " -# "installed arch of %s. This is likely " -# "to not succeed. Are you sure you " -# "wish to continue the upgrade process?") -# %(productName, h[rpm.RPMTAG_ARCH], myarch), -# type="yesno") -# if rc == 0: -# try: -# resetRpmdb(id.dbpath, instPath) -# except Exception, e: -# log.critical("error returning rpmdb to old state: %s" %(e,)) -# pass -# sys.exit(0) -# else: -# log.warning("upgrade between possibly incompatible " -# "arches %s -> %s" %(h[rpm.RPMTAG_ARCH], myarch)) -# - # I'm going to try to keep this message as politically correct - # as possible. I think the Ximian GNOME is a very pretty desktop - # and the hackers there do an extraordinary amount of work on - # them. But it throws a huge wrench in our upgrade process. We - # just want to warn our users that there are packages on the system - # that might get messed up during the upgrade process. Nothing - # personal, guys. - msw -# if h[rpm.RPMTAG_NAME] == "XFree86" or h[rpm.RPMTAG_NAME] == "xorg-x11": -# hasX = 1 -# if h[rpm.RPMTAG_NAME] == "nautilus": -# hasFileManager = 1 -# if h[rpm.RPMTAG_NAME] == "kdebase": -# hasFileManager = 1 -# if h[rpm.RPMTAG_NAME] == "gmc": -# hasFileManager = 1 -# - - # Figure out current version for upgrade nag and for determining weird - # upgrade cases - supportedUpgradeVersion = -1 - mi = ts.dbMatch('provides', 'redhat-release') - for h in mi: - if h[rpm.RPMTAG_EPOCH] is None: - epoch = None - else: - epoch = str(h[rpm.RPMTAG_EPOCH]) - - if supportedUpgradeVersion <= 0: - val = rpm.labelCompare((None, '3', '1'), - (epoch, h[rpm.RPMTAG_VERSION], - h[rpm.RPMTAG_RELEASE])) - if val > 0: - supportedUpgradeVersion = 0 - else: - supportedUpgradeVersion = 1 - break - - if productName.find("Red Hat Enterprise Linux") == -1: - supportedUpgradeVersion = 1 - - if supportedUpgradeVersion == 0: - rc = intf.messageWindow(_("Warning"), - _("You appear to be upgrading from a system " - "which is too old to upgrade to this " - "version of %s. Are you sure you wish to " - "continue the upgrade " - "process?") %(productName,), - type = "yesno") - if rc == 0: - try: - resetRpmdb(id.dbpath, instPath) - except Exception, e: - log.critical("error returning rpmdb to old state: %s" %(e,)) - pass - sys.exit(0) - - - # during upgrade, make sure that we only install %lang colored files - # for the languages selected to be supported. - langs = '' - if os.access(instPath + "/etc/sysconfig/i18n", os.R_OK): - f = open(instPath + "/etc/sysconfig/i18n", 'r') - for line in f.readlines(): - line = string.strip(line) - parts = string.split(line, '=') - if len(parts) < 2: - continue - if string.strip(parts[0]) == 'SUPPORTED': - langs = parts[1] - if len(langs) > 0: - if langs[0] == '"' and langs[-1:] == '"': - langs = langs[1:-1] - break - del f -## if langs: -## rpm.addMacro("_install_langs", langs) - - # check the installed system to see if the packages just - # are not newer in this release. - if hasX and not hasFileManager: - for name in ("nautilus", "kdebase", "gmc"): - try: - h = ts.dbMatch('name', name).next() - except StopIteration: - continue - if h is not None: - hasFileManager = 1 - break - - # make sure the boot loader being used is being installed. - # FIXME: generalize so that specific bits aren't needed - if iutil.getArch() == "i386" and id.bootloader.useGrub(): - log.info("Upgrade: User selected to use GRUB for bootloader") - if id.grpset.hdrlist.has_key("grub") and not id.grpset.hdrlist["grub"].isSelected(): - log.info("Upgrade: grub is not currently selected to be upgraded") - h = None - try: - h = ts.dbMatch('name', 'grub').next() - except StopIteration: - pass - if h is None: - text = ("Upgrade: GRUB is not already installed on the " - "system, selecting GRUB") - id.upgradeDeps ="%s%s\n" % (id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist["grub"].select() - - h = None - try: - h = ts.dbMatch('name', 'gnome-core').next() - except StopIteration: - pass - if h is not None: - log.info("Upgrade: gnome-core was on the system. Upgrading to GNOME 2") - upgraded = [] - for pkg in ("gnome-terminal", "gnome-desktop", "gnome-session", - "gnome-panel", "metacity", "file-roller", "yelp", - "nautilus"): - if id.grpset.hdrlist.has_key(pkg) and not id.grpset.hdrlist[pkg].isSelected(): - id.grpset.hdrlist[pkg].select() - upgraded.append(pkg) - - text = ("Upgrade: gnome-core is on the system. Selecting packages " - "to upgrade to GNOME2: %s" %(str(upgraded),)) - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - - # if they have up2date-gnome, they probably want the applet now too - # since it works in both gnome and kde - if (id.grpset.hdrlist.has_key("rhn-applet") - and not id.grpset.hdrlist["rhn-applet"].isSelected()): - log.info("Upgrade: rhn-applet is not currently selected to be upgraded") - h = None - try: - h = ts.dbMatch('name', 'up2date-gnome').next() - except StopIteration: - pass - - if h is not None: - hdr = None - try: - hdr = ts.dbMatch('name', 'rhn-applet').next() - except StopIteration: - pass - if hdr is None: - text = ("Upgrade: up2date-gnome is on the " - "system, but rhn-applet isn't. Selecting " - "rhn-applet to be installed") - id.upgradeDeps = "%s%s\n" % (id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist["rhn-applet"].select() - - # and since xterm is now split out from XFree86 (#98254) - if (id.grpset.hdrlist.has_key("xterm") and - not id.grpset.hdrlist["xterm"].isSelected()): - h = None - try: - h = ts.dbMatch('name', 'XFree86').next() - except StopIteration: - pass - if h is not None: - text = ("Upgrade: XFree86 was on the system. Pulling in xterm " - "for upgrade.") - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist["xterm"].select() - - # input methods all changed. hooray! - imupg = ( ("ami", "iiimf-le-hangul"), - ("kinput2-canna-wnn6", "iiimf-le-canna"), - ("miniChinput", "iiimf-le-chinput"), - ("xcin", "iiimf-le-xcin") ) - iiimf = 0 - for (old, new) in imupg: - mi = ts.dbMatch("name", old) - if (mi.count() > 0 and id.grpset.hdrlist.has_key(new) and - not id.grpset.hdrlist[new].isSelected()): - text = "Upgrade: %s was on the system. Pulling in %s" %(old, new) - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist[new].select() - iiimf = 1 - if iiimf: - imupg = ( ("iiimf-gnome-im-switcher", "control-center"), - ("iiimf-gnome-im-switcher", "gnome-panel"), - ("iiimf-gtk", "gtk2"), - ("system-switch-im", "gtk2"), - ("iiimf-x", "xorg-x11"), - ("iiimf-x", "XFree86")) - for (new, old) in imupg: - mi = ts.dbMatch("name", old) - if (not id.grpset.hdrlist.has_key(new) or - id.grpset.hdrlist[new].isSelected()): - continue - if (mi.count() > 0 or - id.grpset.hdrlist.has_key(old) and - id.grpset.hdrlist[old].isSelected()): - text = "Upgrade: Need iiimf base package %s" %(new,) - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist[new].select() - - # firefox replaces mozilla/netscape (#137244) - if (id.grpset.hdrlist.has_key("firefox") and - not id.grpset.hdrlist["firefox"].isSelected()): - found = 0 - for p in ("mozilla", "netscape-navigator", "netscape-communicator"): - mi = ts.dbMatch("name", p) - found += mi.count() - if found > 0: - text = "Upgrade: Found a graphical browser. Pulling in firefox" - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - log.info(text) - id.grpset.hdrlist["firefox"].select() - - # now some upgrade removal black list checking... there are things that - # if they were installed in the past, we want to remove them because - # they'll screw up the upgrade otherwise - for pkg in upgrade_remove_blacklist: - pkgarch = None - pkgnames = None - if len(pkg) == 1: - pkgname = pkg[0] - elif len(pkg) == 2: - pkgname, pkgarch = pkg - if pkgname is None: - continue - - mi = ts.dbMatch('name', pkgname) - for h in mi: - if h is not None: - if pkgarch is None: - text = ("Upgrade: %s is on the system but will cause " - "problems with the upgrade transaction. Removing." %(pkg,)) - log.warning(text) - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - id.upgradeRemove.append(pkgname) - break - else: - if h['arch'] == pkgarch: - text = ("Upgrade: %s.%s is on the system but will " - "cause problems with the upgrade transaction. " - "Removing." %(pkgname,pkgarch)) - log.warning(text) - id.upgradeDeps = "%s%s\n" %(id.upgradeDeps, text) - id.upgradeRemove.append(mi.instance()) - - #XXX: backend dep checking - - win.pop() - diff --git a/yuminstall.py b/yuminstall.py index fc0159d5e..20994bd3a 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -27,6 +27,7 @@ from yum.Errors import RepoError, YumBaseError from repomd.mdErrors import PackageSackError from installmethod import FileCopyException from backend import AnacondaBackend +from product import productName from sortedtransaction import SplitMediaTransactionData from genheader import * from constants import * @@ -760,6 +761,7 @@ class YumBackend(AnacondaBackend): if id.getUpgrade(): from upgrade import upgrade_remove_blacklist + self.upgradeFindPackages() for pkg in upgrade_remove_blacklist: pkgarch = None pkgnames = None @@ -885,6 +887,41 @@ class YumBackend(AnacondaBackend): f.write(id.fsset.mtab()) f.close() + def checkSupportedUpgrade(self, intf, instPath): + # Figure out current version for upgrade nag and for determining weird + # upgrade cases + supportedUpgradeVersion = -1 + for pkgtup in self.ayum.rpmdb.whatProvides('redhat-release', None, None): + n, a, e, v, r = pkgtup + if supportedUpgradeVersion <= 0: + val = rpmUtils.miscutils.compareEVR((None, '3', '1'), + (e, v,r)) + if val > 0: + supportedUpgradeVersion = 0 + else: + supportedUpgradeVersion = 1 + break + + if productName.find("Red Hat Enterprise Linux") == -1: + supportedUpgradeVersion = 1 + + if supportedUpgradeVersion == 0: + rc = intf.messageWindow(_("Warning"), + _("You appear to be upgrading from a system " + "which is too old to upgrade to this " + "version of %s. Are you sure you wish to " + "continue the upgrade " + "process?") %(productName,), + type = "yesno") + if rc == 0: + for rpmfile in ["__db.000", "__db.001", "__db.002", "__db.003"]: + try: + os.unlink("%s/var/lib/rpm/%s" %(instPath, rpmfile)) + except: + log.info("error %s removing file: /var/lib/rpm/%s" %(e,rpmfile)) + pass + sys.exit(0) + def doInstall(self, intf, id, instPath): log.info("Preparing to install packages") if flags.test: @@ -1033,6 +1070,23 @@ class YumBackend(AnacondaBackend): else: log.debug("no such package %s" %(pkg,)) + def upgradeFindPackages(self): + # check the installed system to see if the packages just + # are not newer in this release. + # Dictionary of newer package to tuple of old packages + packageMap = { "firefox": ("mozilla", "netscape-navigator", "netscape-communicator") } + + for new, oldtup in packageMap.iteritems(): + if self.ayum.isPackageInstalled(new): + continue + found = 0 + for p in oldtup: + if self.ayum.rpmdb.installed(name=p): + found = 1 + break + if found > 0: + self.selectPackage(new) + def writePackagesKS(self, f): packages = [] |