From e8f54cd09cd4ee9eb0322db38054ef0663006091 Mon Sep 17 00:00:00 2001 From: msivak Date: Fri, 26 Oct 2007 08:51:25 +0000 Subject: Inform user about the arch mismatch and offer to upgrade rpm platform Bug #217132 2007-10-26 Martin Sivak * backend.py (doRepoSetup): Update the platform file if necessary * dispatch.py: Add new step for detecting platform upgrade * flags.py (Flags): Add flag for controlling the rpm platform update * iutil.py (writeRpmPlatform): Now controlled by the updateRpmPlatform flag * upgrade.py: Add isUpgradingArch, queryUpgradeArch and add the upgradearchitecture step (#217132) --- ChangeLog | 14 ++++++++++++++ backend.py | 1 + dispatch.py | 3 ++- flags.py | 1 + iutil.py | 2 +- upgrade.py | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78395a5e5..7e12610c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-10-26 Martin Sivak + + * backend.py (doRepoSetup): Update the platform file if necessary + + * dispatch.py: Add new step for detecting platform upgrade + + * flags.py (Flags): Add flag for controlling the rpm platform update + + * iutil.py (writeRpmPlatform): Now controlled by the updateRpmPlatform + flag + + * upgrade.py: Add isUpgradingArch, queryUpgradeArch and add the + upgradearchitecture step (#217132) + 2007-10-26 Martin Sivak * partedUtils.py (DiskSet): Do not ask for partition table init when in diff --git a/backend.py b/backend.py index 1335f4067..9ec560b20 100644 --- a/backend.py +++ b/backend.py @@ -184,6 +184,7 @@ def doRepoSetup(anaconda): return DISPATCH_BACK if anaconda.id.upgrade: anaconda.backend.checkSupportedUpgrade(anaconda) + iutil.writeRpmPlatform(anaconda.rootPath) def doPostSelection(anaconda): return anaconda.backend.doPostSelection(anaconda) diff --git a/dispatch.py b/dispatch.py index de3ebe9ef..3fe8a614f 100644 --- a/dispatch.py +++ b/dispatch.py @@ -32,7 +32,7 @@ from partitioning import partitionObjectsInitialize from partitioning import partitioningComplete from bootloader import writeBootloader, bootloaderSetupChoices from flags import flags -from upgrade import upgradeMountFilesystems +from upgrade import upgradeMountFilesystems, queryUpgradeArch from upgrade import upgradeSwapSuggestion, upgradeMigrateFind from upgrade import findRootParts, queryUpgradeContinue from network import networkDeviceCheck @@ -73,6 +73,7 @@ installSteps = [ ("autopartitionexecute", doAutoPartition, ), ("partition", ), ("upgrademount", upgradeMountFilesystems, ), + ("upgradearchitecture", queryUpgradeArch, ), ("upgradecontinue", queryUpgradeContinue, ), ("upgradeswapsuggestion", upgradeSwapSuggestion, ), ("addswap", ), diff --git a/flags.py b/flags.py index 9582faa43..0797d0d4c 100644 --- a/flags.py +++ b/flags.py @@ -71,6 +71,7 @@ class Flags: self.__dict__['flags']['selinux'] = SELINUX_DEFAULT self.__dict__['flags']['debug'] = 0 self.__dict__['flags']['targetarch'] = None + self.__dict__['flags']['updateRpmPlatform'] = False self.__dict__['flags']['cmdline'] = self.createCmdlineDict() self.__dict__['flags']['useIPv4'] = True self.__dict__['flags']['useIPv6'] = True diff --git a/iutil.py b/iutil.py index cfce3e417..926b0c612 100644 --- a/iutil.py +++ b/iutil.py @@ -496,7 +496,7 @@ def writeRpmPlatform(root="/"): if flags.test: return - if os.access("%s/etc/rpm/platform" %(root,), os.R_OK): + if not flags.updateRpmPlatform and os.access("%s/etc/rpm/platform" %(root,), os.R_OK): return if not os.access("%s/etc/rpm" %(root,), os.X_OK): os.mkdir("%s/etc/rpm" %(root,)) diff --git a/upgrade.py b/upgrade.py index ff71bec12..f35a9e0c3 100644 --- a/upgrade.py +++ b/upgrade.py @@ -52,6 +52,39 @@ if rhpl.getArch() == "ppc": if rhpl.getArch() == "x86_64": upgrade_remove_blacklist.extend( [("perl","i386")] ) +def isUpgradingArch(anaconda): + """anaconda -> (bool, oldarch) + Check if the upgrade should change architecture of instalation""" + + rpmplatform = open(anaconda.rootPath+"/etc/rpm/platform").readline().strip() + rpmarch = rpmplatform[:rpmplatform.index("-")] + + return rhpl.arch.canonArch!=rpmarch, rpmarch + + +def queryUpgradeArch(anaconda): + archupgrade, oldrpmarch = isUpgradingArch(anaconda) #Check if we are to upgrade the architecture of previous product + + if anaconda.dir == DISPATCH_FORWARD or not archupgrade: + return DISPATCH_FORWARD + + rc = anaconda.intf.messageWindow(_("Proceed with upgrade?"), + _("You have choosen the upgrade for %s " + "architecture, but the installed system " + "is for %s architecture. " + "\n\n" % (rhpl.arch.canonArch, oldrpmarch,)) + + _("Would you like to upgrade " + " the installed system to the %s architecture?" % (rhpl.arch.canonArch,)), + type="custom", custom_icon=["error","error"], + custom_buttons=[_("_Exit installer"), _("_Continue")]) + + if rc == 0: + sys.exit(0) + + flags.updateRpmPlatform = True + + return DISPATCH_FORWARD + def queryUpgradeContinue(anaconda): if anaconda.dir == DISPATCH_FORWARD: return @@ -389,6 +422,7 @@ def setSteps(anaconda): "upgrademount", "upgrademigfind", "upgrademigratefs", + "upgradearchitecture", "upgradecontinue", "reposetup", "upgbootloader", -- cgit