diff options
author | dlehman <dlehman> | 2007-02-22 00:06:15 +0000 |
---|---|---|
committer | dlehman <dlehman> | 2007-02-22 00:06:15 +0000 |
commit | 2c5edecc9801488063b93da903cc98f02be7135d (patch) | |
tree | f135f77f7dea2199b358c6f2a891e5ca96088a79 | |
parent | 27c231de0fe23d95150e9baa6639e9d258dbc677 (diff) | |
download | anaconda-2c5edecc9801488063b93da903cc98f02be7135d.tar.gz anaconda-2c5edecc9801488063b93da903cc98f02be7135d.tar.xz anaconda-2c5edecc9801488063b93da903cc98f02be7135d.zip |
* partedUtils.py (openDevices): don't relabel disks that contain
protected partitions (#220331)
* autopart.py (doClearPartAction): clear all non-protected partitions
from disks that contain a protected partition IFF initAll is set
* partedUtils.py (hasProtectedPartitions): new method to check if a
drive contains protected partitions
* packages.py (writeRegKey): method to write out regkey
* dispatch.py: add writeregkey step
* installclass.py (BaseInstallClass): add regkey fields and step
* instdata.py: include regkey settings in anaconda-ks.cfg
* packages.py (regKeyScreen): allow access to regkey screen while
moving backwards (#219361)
* installclasses/rhel.py: add support for real regkeys (via instnum)
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | autopart.py | 4 | ||||
-rw-r--r-- | dispatch.py | 2 | ||||
-rw-r--r-- | installclass.py | 9 | ||||
-rw-r--r-- | installclasses/rhel.py | 139 | ||||
-rw-r--r-- | instdata.py | 5 | ||||
-rw-r--r-- | packages.py | 77 | ||||
-rw-r--r-- | partedUtils.py | 22 |
8 files changed, 225 insertions, 57 deletions
@@ -1,3 +1,27 @@ +2007-02-21 Dave Lehman <dlehman@redhat.com> + + * partedUtils.py (openDevices): don't relabel disks that contain + protected partitions (#220331) + + * autopart.py (doClearPartAction): clear all non-protected partitions + from disks that contain a protected partition IFF initAll is set + + * partedUtils.py (hasProtectedPartitions): new method to check if a + drive contains protected partitions + + * packages.py (writeRegKey): method to write out regkey + + * dispatch.py: add writeregkey step + + * installclass.py (BaseInstallClass): add regkey fields and step + + * instdata.py: include regkey settings in anaconda-ks.cfg + + * packages.py (regKeyScreen): allow access to regkey screen while + moving backwards (#219361) + + * installclasses/rhel.py: add support for real regkeys (via instnum) + 2007-02-21 Chris Lumens <clumens@redhat.com> * anaconda.spec: Bump version. diff --git a/autopart.py b/autopart.py index d527efdb6..02ba29479 100644 --- a/autopart.py +++ b/autopart.py @@ -1072,6 +1072,7 @@ def doPartitioning(diskset, requests, doRefresh = 1): def doClearPartAction(anaconda, partitions, diskset): type = partitions.autoClearPartType cleardrives = partitions.autoClearPartDrives + initAll = partitions.reinitializeDisks if type == CLEARPART_TYPE_LINUX: linuxOnly = 1 @@ -1107,7 +1108,10 @@ def doClearPartAction(anaconda, partitions, diskset): # 3) there's not fsystem but the numeric id of partition is native # 4) the ptable doesn't support numeric ids, but it appears to be # a RAID or LVM device (#107319) + # 5) the drive contains protected partitions and initAll is set if ((linuxOnly == 0) or (ptype and ptype.isLinuxNativeFS()) or + (initAll and + partedUtils.hasProtectedPartitions(drive, anaconda)) or (not ptype and partedUtils.isLinuxNativeByNumtype(part.native_type)) or ((part.native_type == -1) and # the ptable doesn't have types diff --git a/dispatch.py b/dispatch.py index e96565fbb..07f1adbd4 100644 --- a/dispatch.py +++ b/dispatch.py @@ -27,6 +27,7 @@ from packages import betaNagScreen from packages import setupTimezone from packages import setFileCons from packages import regKeyScreen +from packages import writeRegKey from partitioning import partitionObjectsInitialize from partitioning import partitioningComplete from bootloader import writeBootloader, bootloaderSetupChoices @@ -105,6 +106,7 @@ installSteps = [ ("instbootloader", writeBootloader, ), ("writexconfig", writeXConfiguration, ), ("writeksconfig", writeKSConfiguration, ), + ("writeregkey", writeRegKey, ), ("setfilecon", setFileCons, ), ("copylogs", copyAnacondaLogs, ), ("methodcomplete", doMethodComplete, ), diff --git a/installclass.py b/installclass.py index 11776991a..f5aaa5685 100644 --- a/installclass.py +++ b/installclass.py @@ -67,6 +67,14 @@ class BaseInstallClass: # we can use a different install data class installDataClass = InstallData + # install key related bits + skipkeytext = None + instkeyname = None + allowinstkeyskip = True + instkeydesc = None + installkey = None + skipkey = False + def _get_description(self): return _(self._description) % self._descriptionFields description = property(_get_description) @@ -151,6 +159,7 @@ class BaseInstallClass: "postscripts", "writexconfig", "writeksconfig", + "writeregkey", "methodcomplete", "copylogs", "setfilecon", diff --git a/installclasses/rhel.py b/installclasses/rhel.py index 75c560e72..260148893 100644 --- a/installclasses/rhel.py +++ b/installclasses/rhel.py @@ -2,9 +2,14 @@ from installclass import BaseInstallClass import rhpl from rhpl.translate import N_ from constants import * +from flags import flags import os import iutil import types +try: + import instnum +except ImportError: + instnum = None import logging log = logging.getLogger("anaconda") @@ -21,18 +26,47 @@ class InstallClass(BaseInstallClass): _descriptionFields = (productName,) sortPriority = 10000 allowExtraRepos = False - if not productName.startswith("Red Hat Enterprise"): + if 0: # not productName.startswith("Red Hat Enterprise"): hidden = 1 - tasks = [(N_("Office and Productivity"), ["graphics", "office", "games", "sound-and-video"]), - (N_("Software Development"), ["development-libs", "development-tools", "gnome-software-development", "x-software-development"],), - (N_("Web server"), ["web-server"])] + taskMap = {'client' : [(N_("Office"), ["office"]), + (N_("Multimedia"), ["graphics", + "sound-and-video"])], + 'server' : [(N_("Software Development"), + ["development-libs", "development-tools", + "gnome-software-development", + "x-software-development"],), + (N_("Web server"), ["web-server"])], + 'workstation' : [(N_("Software Development"), + ["development-libs", "development-tools", + "gnome-software-development", + "x-software-development"],)], + 'vt' : [(N_("Virtualization"), ["virtualization"])], + 'cluster' : [(N_("Clustering"), ["clustering"])], + 'clusterstorage': [(N_("Storage Clustering"), + ["cluster-storage"])] + } + + instkeyname = N_("Installation Number") + instkeydesc = N_("To install the full set of supported packages included " + "in your subscription, please enter your Installation " + "Number") + skipkeytext = N_("If you're unable to locate the Installation Number, " + "consult http://www.redhat.com/apps/support/in.html.\n\n" + "If you skip:\n" + "* You may not get access to the full set of " + "packages included in your subscription.\n" + "* It may result in an unsupported/uncertified " + "installation of Red Hat Enterprise Linux.\n" + "* You will not get software and security updates " + "for packages not included in your subscription.") + def setInstallData(self, anaconda): BaseInstallClass.setInstallData(self, anaconda) - if not anaconda.isKickstart: - BaseInstallClass.setDefaultPartitioning(self, anaconda.id.partitions, + BaseInstallClass.setDefaultPartitioning(self, + anaconda.id.partitions, CLEARPART_TYPE_LINUX) def setGroupSelection(self, anaconda): @@ -49,51 +83,79 @@ class InstallClass(BaseInstallClass): def getPackagePaths(self, uri): rc = {} for (name, path) in self.repopaths.items(): - if type(uri) == types.ListType: - lst = [] + if not type(uri) == types.ListType: + uri = [uri,] + if not type(path) == types.ListType: + path = [path,] - for i in uri: - lst.append("%s/%s" % (i, path)) + lst = [] + for i in uri: + for p in path: + lst.append("%s/%s" % (i, p)) - rc[name] = lst - else: - rc[name] = "%s/%s" %(uri, path) + rc[name] = lst + + log.info("package paths is %s" %(rc,)) return rc - def handleRegKey(self, key, intf): -# if key is None or len(key) == 0: -# intf.messageWindow(_("Registration Key Required"), -# _("A registration key is required to " -# "install %s. Please contact your support " -# "representative if you did not receive a " -# "key with your product." %(productName,)), -# type = "ok", custom_icon="error") -# raise NoKeyError - - # simple and stupid for now... if C is in the key, add Clustering - # if V is in the key, add Virtualization. etc - if productPath == "Server" and rhpl.getArch() in ("i386", "x86_64", "ia64"): + def handleRegKey(self, key, intf, interactive = True): + self.repopaths = { "base": "%s" %(productPath,) } + self.tasks = self.taskMap[productPath.lower()] + self.installkey = key + + try: + inum = instnum.InstNum(key) + except Exception, e: + if True or not BETANAG: # disable hack keys for non-beta + # make sure the log is consistent + log.info("repopaths is %s" %(self.repopaths,)) + raise + else: + inum = None + + if inum is not None: + # make sure the base products match + if inum.get_product_string().lower() != productPath.lower(): + raise ValueError, "Installation number incompatible with media" + + for name, path in inum.get_repos_dict().items(): + # virt is only supported on i386/x86_64. so, let's nuke it + # from our repo list on other arches unless you boot with + # 'linux debug' + if name.lower() == "virt" and ( \ + rhpl.getArch() not in ("x86_64","i386") + and not flags.debug): + continue + self.repopaths[name.lower()] = path + log.info("Adding %s repo" % (name,)) + + else: + key = key.upper() + # simple and stupid for now... if C is in the key, add Clustering + # if V is in the key, add Virtualization. etc if key.find("C") != -1: self.repopaths["cluster"] = "Cluster" log.info("Adding Cluster option") if key.find("S") != -1: - self.repopaths["cs"] = "ClusterStorage" + self.repopaths["clusterstorage"] = "ClusterStorage" log.info("Adding ClusterStorage option") - - if productPath == "Client": -# if key.find("D") != -1: -# self.repopaths["desktop"] = "Desktop" -# log.info("Adding Desktop option") if key.find("W") != -1: - self.repopaths["desktop"] = "Workstation" + self.repopaths["workstation"] = "Workstation" log.info("Adding Workstation option") - - if rhpl.getArch() in ("i386", "x86_64", "ia64"): if key.find("V") != -1: self.repopaths["virt"] = "VT" log.info("Adding Virtualization option") - self.regkey = key + for repo in self.repopaths.values(): + if not self.taskMap.has_key(repo.lower()): + continue + + for task in self.taskMap[repo.lower()]: + if task not in self.tasks: + self.tasks.append(task) + self.tasks.sort() + + log.info("repopaths is %s" %(self.repopaths,)) def getMethod(self, methodstr): return BaseInstallClass.getMethod(self, methodstr) @@ -105,4 +167,7 @@ class InstallClass(BaseInstallClass): BaseInstallClass.__init__(self, expert) self.repopaths = { "base": "%s" %(productPath,) } - self.regkey = None + + # minimally set up tasks in case no key is provided + self.tasks = self.taskMap[productPath.lower()] + diff --git a/instdata.py b/instdata.py index 91ca81ad5..56d939405 100644 --- a/instdata.py +++ b/instdata.py @@ -227,6 +227,11 @@ class InstallData: f.write("nfs --server=%s --dir=%s\n" % (srv, dir)) break + if self.instClass.skipkey: + f.write("key --skip\n") + elif self.instClass.installkey: + f.write("key %s\n" %(self.instClass.installkey,)) + self.instLanguage.writeKS(f) if not self.isHeadless: self.keyboard.writeKS(f) diff --git a/packages.py b/packages.py index 0838f176a..623834c1e 100644 --- a/packages.py +++ b/packages.py @@ -53,6 +53,12 @@ def firstbootConfiguration(anaconda): return +def writeRegKey(anaconda): + if anaconda.id.instClass.installkey and os.path.exists(anaconda.rootPath + "/etc/sysconfig/rhn"): + f = open(anaconda.rootPath + "/etc/sysconfig/rhn/install-num", "w+") + f.write("%s\n" %(anaconda.id.instClass.installkey,)) + f.close() + os.chmod(anaconda.rootPath + "/etc/sysconfig/rhn/install-num", 0600) def writeKSConfiguration(anaconda): log.info("Writing autokickstart file") @@ -233,28 +239,61 @@ def recreateInitrd (kernelTag, instRoot): searchPath = 1, root = instRoot) def regKeyScreen(anaconda): - if anaconda.dir == DISPATCH_BACK: - return DISPATCH_NOOP - - while 1: - if anaconda.id.instClass.regkeydesc is None: - desc = _("Please enter the registration key for your version of %s.") %(productName,) - else: - desc = anaconda.id.instClass.regkeydesc - - rc = anaconda.intf.entryWindow(_("Enter Registration Key"), - desc, _("Key:")) - + def checkRegKey(anaconda, key, quiet=0): + rc = True try: - anaconda.id.instClass.handleRegKey(rc, anaconda.intf) + anaconda.id.instClass.handleRegKey(key, anaconda.intf, + not anaconda.isKickstart) except Exception, e: - log.info("exception handling regkey: %s" %(e,)) + if not quiet: + log.info("exception handling installation key: %s" %(e,)) + + (type, value, tb) = sys.exc_info() + list = traceback.format_exception(type, value, tb) + for l in list: + log.debug(l) + anaconda.intf.messageWindow(_("Invalid Key"), + _("The key you entered is invalid."), + type="warning") + rc = False + + return rc + + key = anaconda.id.instClass.installkey or "" + + # handle existing key if we're headed forward + if key and not anaconda.id.instClass.skipkey and \ + anaconda.dir == DISPATCH_FORWARD and checkRegKey(anaconda, key): + return DISPATCH_FORWARD + + # if we're backing up we should allow them to reconsider skipping the key + if anaconda.dir == DISPATCH_BACK and anaconda.id.instClass.skipkey: + anaconda.id.instClass.skipkey = False + + while not anaconda.id.instClass.skipkey: + rc = anaconda.intf.getInstallKey(anaconda, key) + if rc is None and anaconda.dispatch.canGoBack(): + return DISPATCH_BACK + elif rc is None: continue - break - - # FIXME: currently, we only allow this screen to ever be hit _once_ - anaconda.dispatch.skipStep("regkey", permanent = 1) - return + elif rc == SKIP_KEY: + if anaconda.id.instClass.skipkeytext: + rc = anaconda.intf.messageWindow(_("Skip"), + _(anaconda.id.instClass.skipkeytext), + type="custom", custom_icon="question", + custom_buttons=[_("_Back"), _("_Skip")]) + if not rc: + continue + # unset the key and associated data + checkRegKey(anaconda, None, quiet=1) + anaconda.id.instClass.skipkey = True + break + + key = rc + if checkRegKey(anaconda, key): + break + + return DISPATCH_FORWARD def betaNagScreen(anaconda): publicBetas = { "Red Hat Linux": "Red Hat Linux Public Beta", diff --git a/partedUtils.py b/partedUtils.py index 8d8791a60..cd0a4a106 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -352,6 +352,25 @@ def checkDiskLabel(disk, intf): else: return 1 +def hasProtectedPartitions(drive, anaconda): + rc = False + if anaconda is None: + return rc + + try: + for protected in anaconda.method.protectedPartitions(): + if protected.startswith(drive): + part = protected[len(drive):] + if part[0] == "p": + part = part[1:] + if part.isdigit(): + rc = True + break + except: + pass + + return rc + # attempt to associate a parted filesystem type on a partition that # didn't probe as one type or another. def validateFsType(part): @@ -1041,7 +1060,8 @@ class DiskSet: continue if initAll and ((clearDevs is None) or (len(clearDevs) == 0) \ - or (drive in clearDevs)) and not flags.test: + or (drive in clearDevs)) and not flags.test \ + and not hasProtectedPartitions(drive, self.anaconda): if rhpl.getArch() == "s390" and drive[:4] == "dasd": if self.dasdFmt(drive): DiskSet.skippedDisks.append(drive) |