This was largely a duplicate of what we do when looking for upgradable roots. Along the way, however, I've gotten rid of the ability to upgrade from one arch to another. We were already saying it was unlikely to work. --- pyanaconda/backend.py | 3 -- pyanaconda/installclass.py | 12 +++++- pyanaconda/storage/__init__.py | 19 ++++++++-- pyanaconda/yuminstall.py | 79 ---------------------------------------- 4 files changed, 26 insertions(+), 87 deletions(-) diff --git a/pyanaconda/backend.py b/pyanaconda/backend.py index 965db8e..ba2b841 100644 --- a/pyanaconda/backend.py +++ b/pyanaconda/backend.py @@ -192,9 +192,6 @@ def doBackendSetup(anaconda): if anaconda.backend.doBackendSetup(anaconda) == DISPATCH_BACK: return DISPATCH_BACK - if anaconda.upgrade: - anaconda.backend.checkSupportedUpgrade(anaconda) - def doPostSelection(anaconda): return anaconda.backend.doPostSelection(anaconda) diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py index 194b8d9..7b2719f 100644 --- a/pyanaconda/installclass.py +++ b/pyanaconda/installclass.py @@ -199,8 +199,16 @@ class BaseInstallClass(object): def productMatches(self, oldprod): pass - def productUpgradable(self, oldprod, oldver): - return self.productMatches(oldprod) and self.versionMatches(oldver) + def productUpgradable(self, arch, oldprod, oldver): + def archesEq(a, b): + import re + + if re.match("i.86", a) and re.match("i.86", b): + return True + else: + return a == b + + return self.productMatches(oldprod) and self.versionMatches(oldver) and archesEq(arch, productArch) def __init__(self): pass diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py index b0411a9..e9ee9c1 100644 --- a/pyanaconda/storage/__init__.py +++ b/pyanaconda/storage/__init__.py @@ -1387,9 +1387,21 @@ class Storage(object): return 0 def getReleaseString(mountpoint): + relArch = None relName = None relVer = None + import rpm + iutil.resetRpmDb(mountpoint) + ts = rpm.TransactionSet(mountpoint) + + # We get the arch from the initscripts package, but the version and name + # must come from reading the release file. + mi = ts.dbMatch('provides', 'initscripts') + for h in mi: + relArch = h['arch'] + break + filename = "%s/etc/redhat-release" % mountpoint if os.access(filename, os.R_OK): with open(filename) as f: @@ -1406,7 +1418,7 @@ def getReleaseString(mountpoint): relName = product relVer = version.split()[0] - return (relName, relVer) + return (relArch, relName, relVer) def findExistingRootDevices(anaconda, upgradeany=False): """ Return a tuple of: @@ -1444,9 +1456,10 @@ def findExistingRootDevices(anaconda, upgradeany=False): continue if os.access(anaconda.rootPath + "/etc/fstab", os.R_OK): - (product, version) = getReleaseString(anaconda.rootPath) + (arch, product, version) = getReleaseString(anaconda.rootPath) + if upgradeany or \ - anaconda.instClass.productUpgradable(product, version): + anaconda.instClass.productUpgradable(arch, product, version): rootDevs.append((device, "%s %s" % (product, version))) else: notUpgradable.append((product, version, device.name)) diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py index 1dac081..55053e9 100644 --- a/pyanaconda/yuminstall.py +++ b/pyanaconda/yuminstall.py @@ -1598,85 +1598,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon # ensure that /etc/mtab is a symlink to /proc/self/mounts anaconda.storage.makeMtab(root=anaconda.rootPath) - def checkSupportedUpgrade(self, anaconda): - if anaconda.dir == DISPATCH_BACK: - return - self._checkUpgradeVersion(anaconda) - self._checkUpgradeArch(anaconda) - - def _checkUpgradeVersion(self, anaconda): - # 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 "Red Hat Enterprise Linux" not in productName: - supportedUpgradeVersion = 1 - - if supportedUpgradeVersion == 0: - rc = anaconda.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: - iutil.resetRpmDb(anaconda.rootPath) - sys.exit(0) - - def _checkUpgradeArch(self, anaconda): - def compareArch(a, b): - 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') - except yum.Errors.PackageSackError: - log.info("no packages named initscripts") - return None - - pkgs = self.ayum.bestPackagesFromList(pkgs) - if len(pkgs) == 0: - log.info("no best package") - return - myarch = pkgs[0].arch - - 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 not compareArch(po.arch, myarch): - rc = anaconda.intf.messageWindow(_("Warning"), - _("The arch of the release of %(productName)s you " - "are upgrading to appears to be %(myarch)s which " - "does not match your previously installed arch of " - "%(arch)s. This is likely to not succeed. Are " - "you sure you wish to continue the upgrade " - "process?") - % {'productName': productName, - 'myarch': myarch, - 'arch': po.arch}, - type="yesno") - if rc == 0: - iutil.resetRpmDb(anaconda.rootPath) - sys.exit(0) - else: - log.warning("upgrade between possibly incompatible " - "arches %s -> %s" %(po.arch, myarch)) - break - def doInstall(self, anaconda): log.info("Preparing to install packages") -- 1.7.4.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list