diff options
author | Peter Jones <pjones@redhat.com> | 2007-07-18 15:21:51 +0000 |
---|---|---|
committer | Peter Jones <pjones@redhat.com> | 2007-07-18 15:21:51 +0000 |
commit | 2d95cdea6433d617e3edb51a10157452aec2369c (patch) | |
tree | 57cad073f1a0617836aee566192a44d2e6503cdc | |
parent | 8df665208a56ce178629f09fd0782f2df22b319c (diff) | |
download | anaconda-2d95cdea6433d617e3edb51a10157452aec2369c.tar.gz anaconda-2d95cdea6433d617e3edb51a10157452aec2369c.tar.xz anaconda-2d95cdea6433d617e3edb51a10157452aec2369c.zip |
- add support for x86 machines with efi
- add support for gpt on x86
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | fsset.py | 30 | ||||
-rw-r--r-- | iutil.py | 14 | ||||
-rw-r--r-- | partitions.py | 82 |
4 files changed, 116 insertions, 28 deletions
@@ -1,5 +1,23 @@ 2007-07-18 Peter Jones <pjones@redhat.com> + * fsset.py (FATFileSystem.labelDevice): add support for labeling FAT + + * fsset.py (FileSystemSet.getBootDev): make x86 machines using efi + use /boot/efi as their mountpoint. Also mark it bootable in + .setActive() + + * iutil.py (isEfi): add isEfi, which tells you if you're on an EFI + machine. + + * partitions.py (Partitions.getBootableRequest): look for /boot/efi + on x86 machines with efi. Likewise with .getBootableMountpoints() + + * partitions.py (Partitions.sanityCheckAllRequests): fix handling of + gpt and EFI for x86 machines using them. Boot support not yet here, + coming later. + +2007-07-18 Peter Jones <pjones@redhat.com> + * partedUtils.py (DiskSet): - back port (forward port?) reorganization of openDevices() from rhel5 - get rid of clearDevices() @@ -52,7 +52,8 @@ if rhpl.getArch() == "s390": # Many s390 have 2G DASDs, we recomment putting /usr/share on its own DASD defaultMountPoints.insert(4, '/usr/share') -if rhpl.getArch() == "ia64": +if rhpl.getArch() == "ia64" or \ + (rhpl.getArch() in ("i386", "x86_64") and iutil.isEfi()): defaultMountPoints.insert(1, '/boot/efi') else: defaultMountPoints.insert(1, '/boot') @@ -868,6 +869,23 @@ class FATFileSystem(FileSystemType): stderr = "/dev/tty5", searchPath = 1) if rc: raise SystemError + + def labelDevice(self, entry, chroot): + devicePath = entry.device.setupDevice(chroot) + label = labelFactory.createLabel(entry.mountpoint, self.maxLabelChars, + kslabel = entry.label) + + rc = iutil.execWithRedirect("dosfslabel", + [devicePath, label], + stdout = "/dev/tty5", + stderr = "/dev/tty5", + searchPath = 1) + newLabel = iutil.execWithCapture("dosfslabel", [devicePath], + stderr = "/dev/tty5") + newLabel = newLabel.strip() + if label != newLabel: + raise SystemError, "dosfslabel failed on device %s" % (devicePath,) + entry.setLabel(label) fileSystemTypeRegister(FATFileSystem()) @@ -1312,7 +1330,8 @@ MAILADDR root bestprep = entry if bestprep: bootDev = bestprep.device - elif rhpl.getArch() == "ia64": + elif rhpl.getArch() == "ia64" or \ + (rhpl.getArch() in ("i386", "x86_64") and iutil.isEfi()): if mntDict.has_key("/boot/efi"): bootDev = mntDict['/boot/efi'] elif mntDict.has_key("/boot"): @@ -1366,8 +1385,9 @@ MAILADDR root # on ia64, *only* /boot/efi should be marked bootable # similarly, on pseries, we really only want the PReP partition active - if (rhpl.getArch() == "ia64" or iutil.getPPCMachine() == "pSeries" - or iutil.getPPCMachine() == "iSeries") or iutil.getPPCMachine() == "PMac": + if (rhpl.getArch() == "ia64" \ + or (rhpl.getArch() in ("i386", "x86_64") and iutil.isEfi()) \ + or iutil.getPPCMachine() in ("pSeries", "iSeries", "PMac"): part = partedUtils.get_partition_by_name(diskset.disks, bootDev) if part and part.is_flag_available(parted.PARTITION_BOOT): part.set_flag(parted.PARTITION_BOOT, 1) @@ -1377,6 +1397,8 @@ MAILADDR root foundActive = 0 bootPart = None disk = diskset.disks[drive] + if disk.dev.disk_probe().name == "gpt": + continue part = disk.next_partition() while part: if not part.is_active(): @@ -407,6 +407,20 @@ def isMactel(): mactel = False return mactel +efi = None +def isEfi(): + global efi + if efi is not None: + return efi + + # XXX need to make sure efivars is loaded... + if not os.path.exists("/sys/firmware/efi"): + efi = False + else: + efi = True + + return efi + def cpuFeatureFlags(): """Convenience function to get CPU feature flags from /proc/cpuinfo.""" diff --git a/partitions.py b/partitions.py index 1267505aa..b84dd6f36 100644 --- a/partitions.py +++ b/partitions.py @@ -626,7 +626,8 @@ class Partitions: """Return the name of the current 'boot' mount point.""" bootreq = None - if rhpl.getArch() == "ia64": + if rhpl.getArch() == "ia64" or \ + (rhpl.getArch() in ("i386", "x86_64") and iutil.isEfi()): bootreq = self.getRequestByMountPoint("/boot/efi") if bootreq: return [ bootreq ] @@ -699,6 +700,8 @@ class Partitions: if rhpl.getArch() == "ia64": return [ "/boot/efi" ] + if rhpl.getArch() in ("i386", "x86_64") and iutil.isEfi()): + return [ "/boot/efi" ] else: return [ "/boot", "/" ] @@ -797,6 +800,10 @@ class Partitions: boot.extend(self.requests) self.requests = boot + def hasGptLabel(self, diskset, device): + disk = diskset.disks[device] + return disk.type.name == "gpt": + def sanityCheckAllRequests(self, diskset, baseChecks = 0): """Do a sanity check of all of the requests. @@ -823,33 +830,60 @@ class Partitions: "megabytes which is usually too small to " "install %s.") % (productName,)) - if rhpl.getArch() in ("i386", "x86_64") and iutil.isMactel(): - # mactel checks. - bootreqs = self.getBootableRequest() or [] - # FIXME: missing a check to ensure this is gpt. - for br in bootreqs: - dev = br.device - # simplified getDiskPart() for sata only - if dev[-2] in string.digits: - num = dev[-2:] - elif dev[-1] in string.digits: - num = dev[-1] - else: - continue # we should never get here, but you never know... - if int(num) > 4: - print dev, num - errors.append(_("Your boot partition isn't on one of " - "the first four partitions and thus " - "won't be bootable.")) + def getBaseReqs(reqs): + n = 0 + while not reduce(lambda x,y: x and (y.type != REQUEST_RAID), + reqs, True) \ + and len(reqs) > n: + req = reqs[n] + if req.type == REQUEST_RAID: + for id in req.raidmembers: + reqs.append(self.getRequestByID(id)) + del reqs[n] + continue + n += 1 + return reqs + + if rhpl.getArch() in ("i386", "x86_64"): + if iutil.isEfi(): + bootreq = self.getRequestByMountPoint("/boot/efi") + for br in getBaseReqs([bootreq,]): + disk = None + num = None + if br: + (disk, num) = fsset.getDiskPart(br.device) + if not br or br.getActualSize(self, diskset) < 50 or \ + not self.hasGptLabel(diskset, disk): + errors.append(_("You must creat a /boot/efi " + "partition of type FAT and a " + "size of 50 megabytes.")) + else: + # mactel checks. + bootreqs = self.getBootableRequest() or [] + for br in getBaseReqs(bootreqs): + (dev, num) = fsset.getDiskPart(br.device) + + if iutil.isMactel(): + if self.hasGptLabel(diskset, dev) and int(num) > 4: + errors.append( + _("Your boot partition isn't on one of " + "the first four partitions and thus " + "won't be bootable.")) + elif self.hasGptLabel(diskset, dev): + errors.append(_("Your boot partition is on a disk " + "using the GPT partitioning scheme " + "but this machine cannot boot using " + "GPT.")) if rhpl.getArch() == "ia64": bootreq = self.getRequestByMountPoint("/boot/efi") - if not bootreq or bootreq.getActualSize(self, diskset) < 50: - errors.append(_("You must create a /boot/efi partition of " - "type FAT and a size of 50 megabytes.")) + for br in getBaseReqs([bootreq,]): + if not br or br.getActualSize(self, diskset) < 50: + errors.append(_("You must create a /boot/efi partition of " + "type FAT and a size of 50 megabytes.")) if iutil.getPPCMacGen() == "NewWorld": - reqs = self.getBootableRequest() + reqs = getBaseReqs(self.getBootableRequest() or []) found = 0 bestreq = None @@ -869,7 +903,7 @@ class Partitions: if (iutil.getPPCMachine() == "pSeries" or iutil.getPPCMachine() == "iSeries"): - reqs = self.getBootableRequest() + reqs = getBaseReqs(self.getBootableRequest() or []) found = 0 bestreq = None |