Use case is to create images using livemedia-creator where we wont be running on the target platform, this could be for a arm system, or could be used to make efi bootable media on a non efi system, or any other use case where we need to override anacondas detection of the running system.
Signed-off-by: Dennis Gilmore dennis@ausil.us --- anaconda | 4 ++++ pyanaconda/flags.py | 1 + pyanaconda/iutil.py | 3 +++ 3 files changed, 8 insertions(+)
diff --git a/anaconda b/anaconda index fc679c9..c37dd72 100755 --- a/anaconda +++ b/anaconda @@ -222,6 +222,7 @@ def parseOptions(argv=None, cmdline=None): op.add_option("--kickstart", dest="ksfile") op.add_option("--rescue", dest="rescue", action="store_true", default=False) op.add_option("--targetarch", "rpmarch", dest="targetArch", type="string") + op.add_option("--targetplatform", "platform", dest="targetPlatform", type="string")
op.add_option("-m", "--method", dest="method", default=None) op.add_option("--repo", dest="method", default=None) @@ -803,6 +804,9 @@ if __name__ == "__main__": if opts.targetArch: flags.targetarch = opts.targetArch
+ if opts.targetPlatform: + flags.platform = opts.targetPlatform + # set flags flags.dmraid = opts.dmraid flags.mpath = opts.mpath diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py index 92584fd..7a18043 100644 --- a/pyanaconda/flags.py +++ b/pyanaconda/flags.py @@ -58,6 +58,7 @@ class Flags(object): self.targetarch = None self.useIPv4 = True self.useIPv6 = True + self.platform = None self.preexisting_x11 = False self.noverifyssl = False self.imageInstall = False diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index ed6d098..aef4cc6 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -627,6 +627,9 @@ def getARMMachine(): if not isARM(): return 0
+ if flags.platform: + return flags.platform + armMachine = os.uname()[2].rpartition('.' )[2]
if armMachine.startswith('arm'):
Signed-off-by: Dennis Gilmore dennis@ausil.us --- pyanaconda/yuminstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py index 63d077d..9ac780b 100644 --- a/pyanaconda/yuminstall.py +++ b/pyanaconda/yuminstall.py @@ -1467,7 +1467,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
if not foundkernel and iutil.isARM(): if anaconda.platform.armMachine is not None: - selectKernel("kernel-" + anaconda.platform.armMachine) + selectKernel("kernel-%s" % anaconda.platform.armMachine) foundkernel = True
if not foundkernel:
Signed-off-by: Dennis Gilmore dennis@ausil.us --- pyanaconda/platform.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 1611797..05a496f 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -348,6 +348,32 @@ class ARM(Platform): def armMachine(self): return self._armMachine
+class omapARM(ARM): + _bootloaderClass = bootloader.UBOOTuEnv + _boot_stage1_format_types = ["vfat"] + _boot_stage1_device_types = ["partition"] + _boot_stage1_mountpoints = ["/boot/uboot"] + _boot_mbr_description = N_("Master Boot Record") + _boot_descriptions = {"disk": _boot_mbr_description, + "partition": Platform._boot_partition_description} + + def setDefaultPartitioning(self): + from storage.partspec import PartSpec + ret = Platform.setDefaultPartitioning(self) + ret.append(PartSpec(mountpoint="/boot/uboot", fstype="vfat", size=20, + maxSize=20, + grow=True, weight=self.weight(fstype="vfat"))) + return ret + + def weight(self, fstype=None, mountpoint=None): + score = Platform.weight(self, fstype=fstype, mountpoint=mountpoint) + if score: + return score + elif fstype == "vfat" and mountpoint == "/boot/uboot": + return 6000 + else: + return 0 + def getPlatform(anaconda): """Check the architecture of the system and return an instance of a Platform subclass to match. If the architecture could not be determined, @@ -375,6 +401,11 @@ def getPlatform(anaconda): elif iutil.isX86(): return X86(anaconda) elif iutil.isARM(): - return ARM(anaconda) + armMachine = iutil.getARMMachine() + + if (armMachine == "omap" ): + return omapARM(anaconda) + else: + return ARM(anaconda) else: raise SystemError, "Could not determine system architecture."
--- pyanaconda/bootloader.py | 118 +++++++++++++++++++++++++++++++++++++++++++++++ pyanaconda/platform.py | 11 +++-- 2 files changed, 125 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index ea4de5e..173b45b 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -2295,6 +2295,124 @@ class SILO(YabootSILOBase): if rc: raise BootLoaderError("bootloader install failed")
+class UBOOTBase(BootLoader): + + # + # configuration + # + + @property + def config_dir(self): + if self.stage2_device.format.mountpoint == "/boot/uboot/": + return "/boot/uboot" + else: + return "/boot" + + @property + def config_file(self): + return "%s/%s" % (self.config_dir, self._config_file) + + +class UBOOT(UBOOTBase): + name = "UBOOT" + _config_file = "boot.scr.in" + packages = ['uboot-tools'] + stage2_format_types = ["ext3", "ext2", "vfat"] + can_dual_boot = False + def write_config_header(self, config): + header = ("# boot.scr.in generated by anaconda\n\n" + "#boot=%(stage1dev)s\n" + % {"stage1dev": self.stage1_device.path}) + config.write(header) + + def write_config_images(self, config): + for image in self.images: + + + args = Arguments() + armMachine = iutil.getARMMachine() + + dtb_addr = "" + dtb_line = "" + load_method = "ext2load" + disk_info = "0:1" + + if armMachine in ["highbank"]: + storage_type = "scsi" + elif armMachine in ["tegra", "kirkwood"]: + storage_type = "usb" + elif armMachine in ["imx"]: + storage_type = "" + disk_info = "" + load_method = "${loadcmd}" + else: + storage_type = "sata" + + if image.initrd: + if armMachine in ["highbank"]: + initrd_addr = "${ramdisk_addr_r}" + elif armMachine in ["imx"]: + initrd_addr = "${ramdiskaddr}" + elif armMachine in ["tegra"]: + initrd_addr = "0x4400000" + else: + initrd_addr = "0x81600000" + + initrd_line = "%s %s %s %s %s/uInitrd" % (load_method, + storage_type, disk_info, + initrd_addr, self.boot_prefix) + else: + initrd_line = "" + initrd_addr = "-" + + if armMachine in ["highbank"]: + kernel_addr = "${kernel_addr_r}" + dtb_addr = "${fdt_addr_r}" + elif armMachine in ["imx"]: + kernel_addr = "${kerneladdr}" + elif armMachine in ["tegra"]: + kernel_addr = "0x4080000" + else: + kernel_addr = "0x80300000" + + kernel_line = "%s %s %s %s %s/uImage" % (load_method, + storage_type, disk_info, + kernel_addr, self.boot_prefix) + + root_device_spec = self.storage.rootDevice.fstabSpec + args.update("ro", "root=%s" % root_device_spec) + + args.update(self.boot_args) + log.info("bootloader.py: used boot args: %s " % args) + + stanza = ("\nsetenv bootargs %(root_device)s rootwait %(args)s\n" + "%(kernel_line)s" + "%(initrd_line)s" + "%(dtb_line)s" + "bootm %(kernel_addr)s %(initrd_addr)s %(dtb_addr)s" + "\n\n" + % {"kernel_line": kernel_line, "initrd_line": initrd_line, + "dtb_line": dtb_line, "kernel_addr": kernel_addr, + "initrd_addr": initrd_addr, "dtb_addr": dtb_addr, + "root_device": root_device, "args": args}) + config.write(stanza) + + # + # installation + # + def write_config(self): + super(UBOOT, self).write_config() + + + def install(self): + args = ["-A", "arm", "-T", "script", "-C none", "-n", "%s boot script" % productName, "-d", self.config_file, "/boot/boot.scr"] + rc = iutil.execWithRedirect("mkimage", args, + stdout="/dev/tty5", stderr="/dev/tty5", + root=ROOT_PATH) + + if rc: + raise BootLoaderError("bootloader install failed") +
# anaconda-specific functions
diff --git a/pyanaconda/platform.py b/pyanaconda/platform.py index 05a496f..6a962ea 100644 --- a/pyanaconda/platform.py +++ b/pyanaconda/platform.py @@ -336,20 +336,23 @@ class Sparc(Platform):
class ARM(Platform): _armMachine = iutil.getARMMachine() - _bootloaderClass = bootloader.GRUB2 - _boot_stage1_device_types = ["disk"] + _bootloaderClass = bootloader.UBOOT + _disklabel_types = ["msdos"] + _boot_stage1_format_types = ["ext3","vfat"] + _boot_stage1_device_types = ["partition"] + _boot_stage1_mountpoints = ["/boot"] _boot_mbr_description = N_("Master Boot Record") _boot_descriptions = {"disk": _boot_mbr_description, "partition": Platform._boot_partition_description}
- _disklabel_types = ["msdos"] + _non_linux_format_types = ["vfat"]
@property def armMachine(self): return self._armMachine
class omapARM(ARM): - _bootloaderClass = bootloader.UBOOTuEnv + _bootloaderClass = bootloader.UBOOTBase _boot_stage1_format_types = ["vfat"] _boot_stage1_device_types = ["partition"] _boot_stage1_mountpoints = ["/boot/uboot"]
anaconda-patches@lists.fedorahosted.org