livecd-tools/grub2-everywhere.diff
Mikhail Novosyolov 08ea0e4312 Remove odd cmdline
Anaconda prints a warning that "lang" is depreceated and suggests to use "inst.lang" which is already used.
Nobody else parses "lang".
2022-10-31 12:15:43 +03:00

1501 lines
61 KiB
Diff

diff --git a/imgcreate/live.py b/imgcreate/live.py
index 9447640..aa28c43 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -48,7 +48,7 @@ class LiveImageCreatorBase(LoopImageCreator):
def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp",
title="Linux", product="Linux", useplugins=False, cacheonly=False,
- docleanup=True):
+ docleanup=True, build_id=None, isotype='mbr2'):
"""Initialise a LiveImageCreator instance.
This method takes the same arguments as LoopImageCreator.__init__().
@@ -87,7 +87,8 @@ class LiveImageCreatorBase(LoopImageCreator):
self.title = title
self.product = product
-
+ self.build_id = build_id
+ self.isotype = isotype
#
# Hooks for subclasses
#
@@ -234,8 +235,7 @@ class LiveImageCreatorBase(LoopImageCreator):
# XXX-BCL: does this need --label?
subprocess.call(["mkefiboot", isodir + "/EFI/BOOT",
isodir + "/isolinux/efiboot.img"])
-
- def _create_bootconfig(self):
+ def _create_bootconfig(self):
"""Configure the image so that it's bootable."""
self._configure_bootloader(self.__ensure_isodir())
self._generate_efiboot(self.__ensure_isodir())
@@ -319,7 +319,23 @@ class LiveImageCreatorBase(LoopImageCreator):
args.extend(self._get_xorrisofs_options(isodir))
args.append(isodir)
-
+
+ print('create: ' + isodir + '/mkiso')
+ prev = ''
+ with open(isodir + '/mkiso', 'w') as f:
+ print('#!/bin/bash', file=f)
+ for arg in args:
+ if prev == '-output':
+ print(self.name + ".iso \\", file=f)
+ elif prev == self.name:
+ print('.', file=f)
+ else:
+ print(arg + ' \\', file=f)
+ prev = str(arg)
+
+ print(' ', file=f)
+ os.chmod(isodir + '/mkiso', stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
+
if subprocess.call(args) != 0:
raise CreatorError("ISO creation failed!")
@@ -379,17 +395,31 @@ class x86LiveImageCreator(LiveImageCreatorBase):
self._efiarch = None
def _get_xorrisofs_options(self, isodir):
- options = ["-eltorito-boot", "isolinux/isolinux.bin",
- "-no-emul-boot", "-boot-info-table", "-boot-load-size", "4",
- "-eltorito-catalog", "isolinux/boot.cat",
- "-isohybrid-mbr", "/usr/share/syslinux/isohdpfx.bin"]
- if os.path.exists(os.path.join(isodir, "isolinux/efiboot.img")):
- options += ["-eltorito-alt-boot", "-e", "isolinux/efiboot.img",
- "-no-emul-boot", "-isohybrid-gpt-basdat"]
- if os.path.exists(os.path.join(isodir, "isolinux/macboot.img")):
- options += ["-eltorito-alt-boot", "-e", "isolinux/macboot.img",
- "-no-emul-boot", "-isohybrid-gpt-hfsplus"]
- options += ["-rational-rock", "-joliet", "-volid", self.fslabel]
+ print('Iso type: ' + self.isotype)
+ # shim = "BOOT%s.EFI" % (self.efiarch,)
+ if self.isotype != 'efionly':
+ options = [ '-b', 'eltorito.img',
+ '-no-emul-boot', '-boot-load-size', '4',
+ '-boot-info-table', '-partition_offset', '16',
+ '--boot-catalog-hide',
+ '--grub2-mbr', '/usr/lib/grub/i386-pc/boot_hybrid.img',
+ '--grub2-boot-info' ]
+ else:
+ options = ["-eltorito-alt-boot", "-e", "/efi.img",
+ '--no-emul-boot', '-isohybrid-gpt-basdat' ]
+
+ if self.isotype == 'mbr2':
+ options += [ '-iso_mbr_part_type', '0x83',
+ '-append_partition', '2', '0xef', './efi.img',
+ '-eltorito-alt-boot', '-e', '/efi.img', "-no-emul-boot" ]
+ elif self.isotype == 'gpt2':
+ options += [ '-iso_mbr_part_type', '0x83',
+ '-append_partition', '2', '0xef', './efi.img', '-appended_part_as_gpt',
+ '-eltorito-alt-boot', '-e', '/efi.img', "-no-emul-boot", "-no-pad" ]
+ elif self.isotype == 'mbr1':
+ options += [ '-iso_mbr_part_type', '0xef', '-eltorito-alt-boot', '-e', '/efi.img', "-no-emul-boot" ]
+
+ options += [ "-rational-rock", "-joliet", "-volid", self.fslabel ]
return options
def _get_required_packages(self):
@@ -398,61 +428,109 @@ class x86LiveImageCreator(LiveImageCreatorBase):
def _get_isolinux_stanzas(self, isodir):
return ""
- def __find_syslinux_menu(self):
- for menu in ("vesamenu.c32", "menu.c32"):
- for dir in ("/usr/lib/syslinux/", "/usr/share/syslinux/"):
- if os.path.isfile(self._instroot + dir + menu):
- return menu
-
- raise CreatorError("syslinux not installed : "
- "no suitable *menu.c32 found")
-
- def __find_syslinux_mboot(self):
- #
- # We only need the mboot module if we have any xen hypervisors
- #
- if not glob.glob(self._instroot + "/boot/xen.gz*"):
- return None
-
- return "mboot.c32"
-
- def __copy_syslinux_files(self, isodir, menu, mboot = None):
- files = ["isolinux.bin", "ldlinux.c32", "libcom32.c32", "libutil.c32", menu]
- if mboot:
- files += [mboot]
-
- for f in files:
- if os.path.exists(self._instroot + "/usr/lib/syslinux/" + f):
- path = self._instroot + "/usr/lib/syslinux/" + f
- elif os.path.exists(self._instroot + "/usr/share/syslinux/" + f):
- path = self._instroot + "/usr/share/syslinux/" + f
- if not os.path.isfile(path):
- raise CreatorError("syslinux not installed : "
- "%s not found" % path)
-
- shutil.copy(path, isodir + "/isolinux/")
-
- def __copy_syslinux_background(self, isodest):
- background_path = self._instroot + \
- "/usr/share/anaconda/boot/syslinux-vesa-splash.jpg"
-
- if not os.path.exists(background_path):
- # fallback to F13 location
- background_path = self._instroot + \
- "/usr/lib/anaconda-runtime/syslinux-vesa-splash.jpg"
-
- if not os.path.exists(background_path):
- return False
-
- shutil.copyfile(background_path, isodest)
-
- return True
-
- def __copy_kernel_and_initramfs(self, isodir, version, index):
- bootdir = self._instroot + "/boot"
-
+ def _generate_grub2_bootimg(self, isodir):
+ """generate grub2 boot images"""
+
+ def __locales_cfg(self, isodir, timeout):
+ locales_str = self.__set_locales(isodir)
+ cfg = """insmod regexp
+firstTime=no
+default=1
+timeout=%s
+export firstTime
+for langstr in en_US=English %s ; do
+ regexp -s 2:langname -s 1:langcode '(.*)=(.*)' "$langstr"
+ menuentry "${langname}" "$langcode" {
+ lang=$2
+ lang_utf="${2}.UTF-8"
+ export lang
+ export lang_utf
+ configfile ${prefix}/grub.cfg
+}
+done
+
+""" % (timeout, locales_str)
+ with open(isodir + '/EFI/BOOT/lang.cfg', 'w') as f:
+ print(cfg, file=f)
+
+ def __grub_boot_img(self, bootis):
+ modlist=['part_msdos', 'part_gpt', 'regexp', 'gettext',
+ 'linux', 'loopback', 'normal', 'configfile', 'test',
+ 'search', 'search_fs_uuid', 'search_fs_file', 'true',
+ 'iso9660', 'search_label', 'gfxterm', 'gfxmenu',
+ 'fat', 'ext2', 'ntfs', 'cat', 'echo', 'ls', 'png',
+ 'reboot', 'all_video', 'boot', 'chain', 'gzio', 'loadenv' ]
+# 'chain', 'cryptodisk',
+# 'gcry_rijndael', 'gcry_rsa', 'gcry_serpent', 'gcry_sha256',
+# 'gcry_twofish', 'gcry_whirlpool', 'gfxterm_background',
+# 'gfxterm_menu', 'gzio', 'halt', 'hfsplus', 'iso9660',
+# 'jpeg', 'loadenv', 'loopback', 'linux', 'luks',
+# 'lvm', 'mdraid09', 'mdraid1x', 'minicmd', 'part_apple',
+# 'password_pbkdf2', 'probe', 'serial', 'sleep',
+# 'squash4', 'tftp', 'video']
+
+ with open('./grub.cfg', 'w') as f:
+ print('search.file /ROSA-LIVE.sgn root', file=f)
+ print('prefix=($root)/EFI/BOOT', file=f)
+ if bootis == 'efi':
+ print('bootis=UEFI:', file=f)
+ else:
+ print('bootis=""', file=f)
+ print('lang=en_US', file=f)
+ print('export lang', file=f)
+ print('export root', file=f)
+ print('export prefix', file=f)
+ print('export bootis', file=f)
+ print('configfile /EFI/BOOT/grub.cfg', file=f)
+
+ if bootis == 'efi':
+ print('==> generating grub2 image for efi boot')
+ cmdlist=['grub2-mkimage', '-p', '/grub2', '-c', './grub.cfg',
+ '-O', 'x86_64-efi' ,'-o', isodir + f'/EFI/BOOT/grub{self._efiarch.lower()}.efi',
+ '--compression=xz']
+ cmdlist.extend(['efi_gop', 'efi_uga', 'efifwsetup', 'efinet', 'lsefi' ])
+ cmdlist.extend(modlist)
+ else:
+ print('==> generating grub2 image eltorito')
+ cmdlist=['grub2-mkimage', '-p', '/grub2', '-c', './grub.cfg',
+ '-O', 'i386-pc-eltorito', '-o', isodir + '/eltorito.img',
+ '--compression=xz']
+ cmdlist.extend(['biosdisk', 'vbe'])
+ cmdlist.extend(modlist)
+ ecode = subprocess.call(cmdlist)
+ if ecode != 0:
+ print(f'Generating grub2 image for {bootis} - Failed')
+
+ #os.mkdir(isodir + '/grub2/')
+ os.makedirs(isodir + '/EFI/BOOT/', exist_ok=True)
+ __grub_boot_img(self, 'bios')
+ __grub_boot_img(self, 'efi')
+ __locales_cfg(self, isodir, self._timeout)
+ os.mkdir('img_mount_point')
+
+ open('efi.img', "w").truncate(1000 * 5000)
+ # zero is a 'False' for python
+ if not subprocess.call(['mkfs.vfat', '-n', 'ROSA', 'efi.img']):
+ if not subprocess.call(['mount', '-o', 'loop', 'efi.img', 'img_mount_point']):
+ os.makedirs('img_mount_point/EFI/BOOT')
+ shim = "BOOT%s.EFI" % (self.efiarch,)
+ shutil.copyfile(isodir + f'/EFI/BOOT/grub{self._efiarch.lower()}.efi', f'img_mount_point/EFI/BOOT/grub{self._efiarch.lower()}.efi')
+ shutil.copyfile(isodir + '/EFI/BOOT/' + shim, 'img_mount_point/EFI/BOOT/' + shim )
+ else:
+ print('Error. Can not mount image')
+ subprocess.call(['umount', 'img_mount_point'])
+ else:
+ print('Error. Can not format image')
+
+ shutil.copyfile('efi.img', isodir + '/efi.img' )
+
+ # marker to find gub2 $root
+ with open(isodir + '/ROSA-LIVE.sgn', 'w') as f:
+ print('File - marker to find grub2 $root.', file=f)
+
+ def __copy_kernel_and_initramfs(self, isodir, version, index, bootdir):
shutil.copyfile(bootdir + "/vmlinuz-" + version,
- isodir + "/isolinux/vmlinuz" + index)
+ isodir + "/vmlinuz" + index)
isDracut = False
if os.path.exists(self._instroot + "/usr/bin/dracut"):
@@ -461,17 +539,17 @@ class x86LiveImageCreator(LiveImageCreatorBase):
# FIXME: Implement a better check for how the initramfs is named...
if os.path.exists(bootdir + "/initramfs-" + version + ".img"):
shutil.copyfile(bootdir + "/initramfs-" + version + ".img",
- isodir + "/isolinux/initrd" + index + ".img")
+ isodir + "/initrd" + index + ".img")
elif os.path.exists(bootdir + "/initrd-" + version + ".img"):
shutil.copyfile(bootdir + "/initrd-" + version + ".img",
- isodir + "/isolinux/initrd" + index + ".img")
+ isodir + "/initrd" + index + ".img")
elif not self.base_on:
logging.error("No initramfs or initrd found for %s" % (version,))
is_xen = False
if os.path.exists(bootdir + "/xen.gz-" + version[:-3]):
shutil.copyfile(bootdir + "/xen.gz-" + version[:-3],
- isodir + "/isolinux/xen" + index + ".gz")
+ isodir + "/xen" + index + ".gz")
is_xen = True
return (is_xen, isDracut)
@@ -488,222 +566,503 @@ class x86LiveImageCreator(LiveImageCreatorBase):
return False
- def __get_basic_syslinux_config(self, **args):
- return """
-default %(menu)s
-timeout %(timeout)d
-menu background %(background)s
-menu autoboot Starting %(title)s in # second{,s}. Press any key to interrupt.
-
-menu clear
-menu title %(title)s
-menu vshift 8
-menu rows 18
-menu margin 8
-#menu hidden
-menu helpmsgrow 15
-menu tabmsgrow 13
-
-menu color border * #00000000 #00000000 none
-menu color sel 0 #ffffffff #00000000 none
-menu color title 0 #ff7ba3d0 #00000000 none
-menu color tabmsg 0 #ff3a6496 #00000000 none
-menu color unsel 0 #84b8ffff #00000000 none
-menu color hotsel 0 #84b8ffff #00000000 none
-menu color hotkey 0 #ffffffff #00000000 none
-menu color help 0 #ffffffff #00000000 none
-menu color scrollbar 0 #ffffffff #ff355594 none
-menu color timeout 0 #ffffffff #00000000 none
-menu color timeout_msg 0 #ffffffff #00000000 none
-menu color cmdmark 0 #84b8ffff #00000000 none
-menu color cmdline 0 #ffffffff #00000000 none
-
-menu tabmsg Press Tab for full configuration options on menu items.
-menu separator
-""" % args
-
- def __get_image_stanza(self, is_xen, isDracut, **args):
- if isDracut:
- args["rootlabel"] = "live:CDLABEL=%(fslabel)s" % args
- else:
- args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
-
- if not is_xen:
- template = """label %(short)s
- menu label %(long)s
- kernel vmlinuz%(index)s
- append initrd=initrd%(index)s.img root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s
-"""
- else:
- template = """label %(short)s
- menu label %(long)s
- kernel mboot.c32
- append xen%(index)s.gz --- vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s --- initrd%(index)s.img
-"""
- if args.get("help"):
- template += """ text help
- %(help)s
- endtext
-"""
- return template % args
- def __get_image_stanzas(self, isodir):
+ def __get_kernel_initrd(self, isodir):
+ bootdir = self._instroot + "/boot"
kernels = self._get_kernel_versions()
kernel_options = self._get_kernel_options()
checkisomd5 = self._has_checkisomd5()
-
- # Stanzas for insertion into the config template
- linux = []
- basic = []
- check = []
-
- index = "0"
+ index="0"
for kernel, version in ((k,v) for k in kernels for v in kernels[k]):
- (is_xen, isDracut) = self.__copy_kernel_and_initramfs(isodir, version, index)
- if index == "0":
- self._isDracut = isDracut
+ (is_xen, isDracut) = self.__copy_kernel_and_initramfs(isodir, version, index, bootdir)
+ index = str(int(index) + 1)
+ if os.path.exists(bootdir + "/pcmemtest"):
+ shutil.copyfile(bootdir + "/pcmemtest",
+ isodir + "/pcmemtest")
+ else:
+ print('pcmemtest not found')
- default = self.__is_default_kernel(kernel, kernels)
- if default:
- long = self.product
- elif kernel.startswith(b"kernel-"):
- long = "%s (%s)" % (self.product, kernel[7:])
+ def __get_local_stanza(self, isodir):
+ return """label local
+ menu label Boot from ^local drive
+ localboot 0xffff
+"""
+ @property
+ def efiarch(self):
+ if not self._efiarch:
+ # for most things, we want them named boot$efiarch
+ # Note that AA64 and IA32 are in uppercase but x64 is in lowercase
+ # according to the UEFI specification
+ # "Unified Extensible Firmware Interface (UEFI) Specification, Version 2.7 Errata A, August 2017"
+ # https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf
+ # 3.5.1.1 Removable Media Boot Behavior, Table 14. UEFI Image Types, page 159
+ if glob.glob(self._instroot + '/boot/efi/EFI/*/shimx64.efi'):
+ self._efiarch = 'x64'
+ elif glob.glob(self._instroot + '/boot/efi/EFI/*/shimia32.efi'):
+ self._efiarch = 'IA32'
else:
- long = "%s (%s)" % (self.product, kernel)
+ efiarch = {"i386": "IA32", "x86_64": "x64"}
+ self._efiarch = efiarch[dnf.rpm.basearch(hawkey.detect_arch())]
+ return self._efiarch
- # tell dracut not to ask for LUKS passwords or activate mdraid sets
- if isDracut:
- kern_opts = kernel_options + " rd.luks=0 rd.md=0 rd.dm=0"
+ def __copy_efi_files(self, isodir):
+ """ Copy the efi files into /EFI/BOOT/
+ If any of them are missing, return False.
+ requires:
+ shimx64.efi
+ gcdx64.efi
+ fonts/unicode.pf2
+ """
+ fail = False
+ files = [("/boot/efi/EFI/*/shim%s.efi" % (self.efiarch.lower(),), "/EFI/BOOT/BOOT%s.EFI" % (self.efiarch,), True),
+ # XXX grubcd.efi probably should contain EFI arch in its name to make 32 bit EFI possible on x86_64 (?)
+ # Or will 32 bit shim be able to load 64 bit grub?
+ # efi bootloader is generated now
+ # ("/usr/share/grub2-efi/grubcd.efi", "/EFI/BOOT/grub%s.efi" % (self.efiarch.lower(),), True),
+ ("/boot/efi/EFI/*/shimia32.efi", "/EFI/BOOT/BOOTIA32.EFI", False),
+ # XXX gcdia32.efi does not exist yet in ROSA
+ ("/boot/efi/EFI/*/gcdia32.efi", "/EFI/BOOT/grubia32.efi", False),
+ ("/boot/grub2/fonts/unicode.pf2", "/EFI/BOOT/fonts/", True),
+ ("/boot/grub2/themes/rosa/*", "/EFI/BOOT/themes/rosa/", True),
+ ]
+ makedirs(isodir+"/EFI/BOOT/fonts/")
+ makedirs(isodir+"/EFI/BOOT/themes/rosa/")
+ for src, dest, required in files:
+ src_glob = glob.glob(self._instroot+src)
+ if not src_glob:
+ if required:
+ logging.error("Missing EFI file (%s)" % (src,))
+ fail = True
else:
- kern_opts = kernel_options
+ for src_file in src_glob:
+ shutil.copy(src_file, isodir+dest)
+ return fail
- linux.append(self.__get_image_stanza(is_xen, isDracut,
- fslabel = self.fslabel,
- isofstype = "auto",
- liveargs = kern_opts,
- long = "^Start " + long,
- short = "linux" + index,
- extra = "",
- help = "",
- index = index))
-
- if default:
- linux[-1] += " menu default\n"
-
- basic.append(self.__get_image_stanza(is_xen, isDracut,
- fslabel = self.fslabel,
- isofstype = "auto",
- liveargs = kern_opts,
- long = "Start " + long + " in ^basic graphics mode.",
- short = "basic" + index,
- extra = "nomodeset",
- help = "Try this option out if you're having trouble starting.",
- index = index))
+ def __get_basic_efi_config(self, **args):
+ return """
+set default="0"
- if checkisomd5:
- check.append(self.__get_image_stanza(is_xen, isDracut,
- fslabel = self.fslabel,
- isofstype = "auto",
- liveargs = kern_opts,
- long = "^Test this media & start " + long,
- short = "check" + index,
- extra = "rd.live.check",
- help = "",
- index = index))
- else:
- check.append(None)
+set gfxpayload=keep
+insmod gzio
+insmod part_gpt
+insmod part_msdos
+insmod ext2
+insmod iso9660
+
+set gfxmode=1024x768,1024x600,800x600,640x480
+insmod gfxterm
+
+set localedir ${prefix}/locale
+insmod gettext
+
+set OS=$"ROSA linux"
+set start=$"Start"
+set startInstall=$"Start & install"
+set basicMode=$"in basic graphics mode"
+set consoleMode=$"in console mode"
+set rebootToEfi=$"Reboot to EFI firmware setup"
+set reboot=$"Reboot"
+set testMedia=$"Test this media & start"
+set installer=$"Install"
+set troubleshooting=$"Troubleshooting"
+set backToMain=$"Back to main menu"
+set loading=$"Loading"
+set backToLang=$"Back to lang menu"
+set pcmemtest=$"Checking RAM"
+set bootFromHdd=$"Boot instaled OS"
+
+export OS
+export start
+export startInstall
+export basicMode
+export consoleMode
+export rebootToEfi
+export reboot
+export testMedia
+export installer
+export additional
+export backToMain
+export loading
+export backToLang
+export pcmemtest
+export bootFromHdd
+
+terminal_output gfxterm
+insmod gfxmenu
+loadfont /EFI/BOOT/themes/rosa/dejavu_sans_bold_14.pf2
+loadfont /EFI/BOOT/themes/rosa/dejavu_sans_mono_11.pf2
+loadfont /EFI/BOOT/themes/rosa/terminal_font_11.pf2
+insmod png
+set theme=/EFI/BOOT/themes/rosa/theme.txt
+export theme
+background_image -m stretch /EFI/BOOT/themes/rosa/terminal_background.png
+if test $firstTime != no ; then
+ configfile ${prefix}/lang.cfg
+fi
+set timeout=%(timeout)d
- index = str(int(index) + 1)
+search --no-floppy --set=root -l '%(isolabel)s'
+
+""" %args
- return (linux, basic, check)
+ def __get_efi_image_stanza(self, **args):
+ if self._isDracut:
+ args["rootlabel"] = "live:LABEL=%(fslabel)s" % args
+ else:
+ args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
+ return """menuentry "%(long)s" --class rosa --class gnu-linux --class gnu --class os {
+ linux /vmlinuz%(index)s root=%(rootlabel)s %(liveargs)s %(extra)s \
+ inst.lang=$lang_utf locale.LANG=$lang_utf locale.LANGUAGE=$lang_utf
+ echo "$loading /vmlinuz%(index)s..."
+ initrd /initrd%(index)s.img
+ echo "$loading /initrd%(index)s.img..."
+}
+""" %args
+ def __set_locales(self, isodir):
+ os.mkdir(isodir + '/EFI/BOOT/locale')
+ if os.path.exists('/usr/share/livecd-tools/grub2/locales'):
+ for po in os.listdir('/usr/share/livecd-tools/grub2/locales'):
+ print('Processing: ' + po)
+ if po.endswith('.po'):
+ lng = po.split( '_' )[0]
+ mo = '/usr/share/locale/' + lng + '/LC_MESSAGES/grub.mo'
+ if os.path.exists(mo):
+ subprocess.call( [ 'msgunfmt', mo, '-o', lng + '.po' ])
+ if subprocess.call( [ 'msgcat', lng + '.po',
+ '/usr/share/livecd-tools/grub2/locales/' + po,
+ '-o', isodir + "/EFI/BOOT/locale/" + po ] ):
+ print(f"Msgcat for {po} & {lng}.po file - Failed")
+ else:
+ shutil.copy('/usr/share/livecd-tools/grub2/locales/' + po,
+ isodir + "/EFI/BOOT/locale/" + po)
+ else:
+ shutil.copy('/usr/share/livecd-tools/grub2/locales/' + po,
+ isodir + "/EFI/BOOT/locale/" + po)
+ for po in os.listdir(isodir + '/EFI/BOOT/locale'):
+ if po.endswith('.po'):
+ # zero is a 'False' for python
+ if not subprocess.call(['msgfmt', isodir +
+ '/EFI/BOOT/locale/' + po, '-o',
+ isodir + '/EFI/BOOT/locale/'
+ + po.replace('.po', '.mo') ]):
+ os.remove(isodir + '/EFI/BOOT/locale/' + po)
+ else:
+ print(f"Msgfmt for {po} file - Failed")
+ avaliable_locales = list(map(lambda locale: locale.split('.')[0],
+ os.listdir(isodir + '/EFI/BOOT/locale')))
+ known_locales = [ "ru_RU=Русский", "it_IT=italiano",
+ "de_DE=Deutsch ", "fr_FR=Français",
+ "pt_PT=Português", "es_ES=Español" ]
+ locales_str = ''
+ for l in known_locales:
+ for a in avaliable_locales:
+ if l.startswith(a):
+ locales_str += l + ' '
+ print('found locales: ' + locales_str)
+ return locales_str
+ else:
+ return False
- def __get_memtest_stanza(self, isodir):
- memtest = glob.glob(self._instroot + "/boot/memtest86*")
- if not memtest:
- return ""
+ def __get_efi_image_stanzas(self, isodir, name):
+ # FIXME: this only supports one kernel right now...
- shutil.copyfile(memtest[0], isodir + "/isolinux/memtest")
+ kernel_options = self._get_kernel_options()
+ checkisomd5 = self._has_checkisomd5()
+ #if os.path.exists(isodir + '/var/lib/rosa-iso-info'):
+ # with open(isodir + '/var/lib/rosa-iso-info', r) as f:
+ # for string in f:
+ # if string.strip().split('=')[0] == 'BUILD_ID':
+ # BUILD_ID = string.strip().split('=')[1]
+ # break
+
+ if self.build_id != None:
+ efisgn = '/rosa-iso-build_' + self.build_id
+ legacysgn = '/boot/rosa-iso-build_' + self.build_id
+ else:
+ efisgn = '/EFI/rosa/grub.cfg'
+ legacysgn = '/boot/grub2/themes/rosa/theme.txt'
+
+ cfg ="""if test "$bootis" == 'UEFI:' ; then
+ if search --no-floppy --file %s ; then
+ menuentry "$bootFromHdd" {
+ search --set=root --no-floppy --file %s
+ configfile /EFI/rosa/grub.cfg
+ }
+ fi
+else
+ if search --no-floppy --file %s ; then
+ menuentry "$bootFromHdd" {
+ search --set=root --no-floppy --file %s
+ set prefix=($root)/boot/grub2
+ configfile /boot/grub2/grub.cfg
+ }
+ fi
+fi
+""" % (efisgn, efisgn, legacysgn, legacysgn)
- return """label memtest
- menu label Run a ^memory test.
- text help
- If your system is having issues, an problem with your
- system's memory may be the cause. Use this utility to
- see if the memory is working correctly.
- endtext
- kernel memtest
-"""
+ for index in range(0, 9):
+ # we don't support xen kernels
+ if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
+ continue
- def __get_local_stanza(self, isodir):
- return """label local
- menu label Boot from ^local drive
- localboot 0xffff
-"""
+ if not 'systemd.unit=anaconda.target' in kernel_options:
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$startInstall $bootis $OS (live)",
+ extra = "rhgb splash=silent logo.nologo", index = index)
- def _configure_syslinux_bootloader(self, isodir):
- """configure the boot loader"""
- makedirs(isodir + "/isolinux")
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$installer $bootis $OS",
+ extra = "systemd.unit=anaconda.target ", index = index)
- menu = self.__find_syslinux_menu()
+ cfg += r"""submenu "${troubleshooting}..." --id additional {
+"""
+
+ if checkisomd5:
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$testMedia " + self.product,
+ extra = "rd.live.check",
+ index = index)
- self.__copy_syslinux_files(isodir, menu,
- self.__find_syslinux_mboot())
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$start " + self.product + " $basicMode",
+ extra = "nomodeset plymouth.enable=0 noapic acpi=off loglevel=5 vga=788", index = index)
- background = ""
- if self.__copy_syslinux_background(isodir + "/isolinux/splash.jpg"):
- background = "splash.jpg"
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$installer " + self.product + " $consoleMode",
+ extra = "systemd.unit=anaconda.target inst.text", index = index)
+ if os.path.exists(isodir + '/pcmemtest'):
+ cfg += """if test "$bootis" != 'UEFI:' ; then
+menuentry "$pcmemtest" {
+ echo "$loading ${pcmemtest}..."
+ set gfxpayload=640x400,800x600,1024x768
+ linux /pcmemtest
+}
+fi
+"""
- cfg = self.__get_basic_syslinux_config(menu = menu,
- background = background,
- title = self.title,
- timeout = self._timeout * 10)
- cfg += "menu separator\n"
+ cfg += """if test "$bootis" == 'UEFI:' ; then
+menuentry "$rebootToEfi" {
+ fwsetup
+}
+fi
- linux, basic, check = self.__get_image_stanzas(isodir)
- # Add linux stanzas to main menu
- for s in linux:
- cfg += s
- cfg += "menu separator\n"
+menuentry "$backToMain" {
+ configfile ${prefix}/grub.cfg
+}
- cfg += """menu begin ^Troubleshooting
- menu title Troubleshooting
+}
"""
- # Add basic video and check to submenu
- for b, c in zip(basic, check):
- cfg += b
- if c:
- cfg += c
-
- cfg += self.__get_memtest_stanza(isodir)
- cfg += "menu separator\n"
-
- cfg += self.__get_local_stanza(isodir)
- cfg += self._get_isolinux_stanzas(isodir)
-
- cfg += """menu separator
-label returntomain
- menu label Return to ^main menu.
- menu exit
-menu end
+ cfg += """menuentry "$backToLang" --hotkey 'f2' --id 'lang' {
+ configfile ${prefix}/lang.cfg
+}
"""
- cfgf = open(isodir + "/isolinux/isolinux.cfg", "w")
+ cfg += """menuentry "$reboot" {
+ reboot
+}
+"""
+
+ break
+ return cfg
+
+ def _configure_efi_bootloader(self, isodir):
+ """Set up the configuration for an EFI bootloader"""
+ self.__get_kernel_initrd(isodir)
+ if self.__copy_efi_files(isodir):
+ shutil.rmtree(isodir + "/EFI")
+ logging.warning("Failed to copy EFI files, no EFI Support will be included.")
+ return
+
+ cfg = self.__get_basic_efi_config(isolabel = self.fslabel,
+ timeout = self._timeout)
+ cfg += self.__get_efi_image_stanzas(isodir, self.name)
+
+ cfgf = open(isodir + "/EFI/BOOT/grub.cfg", "w")
cfgf.write(cfg)
cfgf.close()
+ # first gen mactel machines get the bootloader name wrong apparently
+ if dnf.rpm.basearch(hawkey.detect_arch()) == "i386":
+ os.link(isodir + "/EFI/BOOT/BOOT%s.EFI" % (self.efiarch),
+ isodir + "/EFI/BOOT/BOOT.EFI")
+
+ def _generate_efiboot(self, isodir):
+ return True
+
+ def _configure_bootloader(self, isodir):
+ #self._configure_syslinux_bootloader(isodir)
+ self._configure_efi_bootloader(isodir)
+ self._generate_grub2_bootimg(isodir)
+
+class aarch64LiveImageCreator(LiveImageCreatorBase):
+ """ImageCreator for aarch64 machines"""
+ def __init__(self, *args, **kwargs):
+ LiveImageCreatorBase.__init__(self, *args, **kwargs)
+ self._efiarch = None
+
+ def _get_xorrisofs_options(self, isodir):
+ options = ["-eltorito-alt-boot", "-e", '/EFI/BOOT/efi.img',
+ "-no-emul-boot", "-hide-rr-moved"]
+
+ options += ["-rational-rock", "-joliet", "-volid", self.fslabel]
+ return options
+
+ def _get_required_packages(self):
+ return LiveImageCreatorBase._get_required_packages(self)
+
+ def _get_isolinux_stanzas(self, isodir):
+ return ""
+
+ def _generate_grub2_bootimg(self, isodir):
+ """generate grub2 boot images"""
+
+ def __locales_cfg(self, isodir, timeout):
+ locales_str = self.__set_locales(isodir)
+ cfg = """insmod regexp
+firstTime=no
+default=1
+timeout=%s
+export firstTime
+for langstr in en_US=English %s ; do
+ regexp -s 2:langname -s 1:langcode '(.*)=(.*)' "$langstr"
+ menuentry "${langname}" "$langcode" {
+ lang=$2
+ lang_utf="${2}.UTF-8"
+ export lang
+ export lang_utf
+ configfile ${prefix}/grub.cfg
+}
+done
+
+""" % (timeout, locales_str)
+ with open(isodir + '/EFI/BOOT/lang.cfg', 'w') as f:
+ print(cfg, file=f)
+
+ def __grub_boot_img(self, bootis):
+ modlist=['part_msdos', 'part_gpt', 'regexp', 'gettext',
+ 'linux', 'loopback', 'normal', 'configfile', 'test',
+ 'search', 'search_fs_uuid', 'search_fs_file', 'true',
+ 'iso9660', 'search_label', 'gfxterm', 'gfxmenu',
+ 'fat', 'ext2', 'ntfs', 'cat', 'echo', 'ls', 'png',
+ 'reboot', 'all_video', 'boot', 'chain', 'gzio', 'loadenv' ]
+
+ with open('./grub.cfg', 'w') as f:
+ print('search.file /ROSA-LIVE.sgn root', file=f)
+ print('prefix=($root)/EFI/BOOT', file=f)
+ print('lang=en_US', file=f)
+ print('export lang', file=f)
+ print('export root', file=f)
+ print('export prefix', file=f)
+ print('configfile /EFI/BOOT/grub.cfg', file=f)
+
+ print('==> generating grub2 image for efi boot')
+ cmdlist=['grub2-mkimage', '-p', '/grub2', '-c', './grub.cfg',
+ '-O', 'arm64-efi' ,'-o', isodir + f'/EFI/BOOT/grub{self._efiarch.lower()}.efi',
+ '--compression=xz']
+ cmdlist.extend(['efi_gop', 'efifwsetup', 'efinet', 'lsefi' ])
+ cmdlist.extend(modlist)
+ ecode = subprocess.call(cmdlist)
+ if ecode != 0:
+ print(f'Generating efi grub2 image for - Failed')
+
+ #os.mkdir(isodir + '/grub2/')
+ os.makedirs(isodir + '/EFI/BOOT/', exist_ok=True)
+ __grub_boot_img(self, 'efi')
+ __locales_cfg(self, isodir, self._timeout)
+ os.mkdir('img_mount_point')
+
+ open('efi.img', "w").truncate(1000 * 5000)
+ # zero is a 'False' for python
+ if not subprocess.call(['mkfs.vfat', 'efi.img']):
+ if not subprocess.call(['mount', '-o', 'loop', 'efi.img', 'img_mount_point']):
+ os.makedirs('img_mount_point/EFI/BOOT')
+ shim = "BOOT%s.EFI" % (self.efiarch,)
+ shutil.copyfile(isodir + f'/EFI/BOOT/grub{self._efiarch.lower()}.efi', f'img_mount_point/EFI/BOOT/grub{self._efiarch.lower()}.efi')
+ shutil.copyfile(isodir + '/EFI/BOOT/' + shim, 'img_mount_point/EFI/BOOT/' + shim )
+ else:
+ print('Error. Can not mount image')
+ subprocess.call(['umount', 'img_mount_point'])
+ else:
+ print('Error. Can not format image')
+
+ shutil.copyfile( 'efi.img', isodir + '/EFI/BOOT/efi.img')
+
+ with open(isodir + '/ROSA-LIVE.sgn', 'w') as f:
+ print('File - marker to find grub2 $root.', file=f)
+
+ def __copy_kernel_and_initramfs(self, isodir, version, index, bootdir):
+ shutil.copyfile(bootdir + "/vmlinuz-" + version,
+ isodir + "/vmlinuz" + index)
+
+ isDracut = False
+ if os.path.exists(self._instroot + "/usr/bin/dracut"):
+ isDracut = True
+
+ # FIXME: Implement a better check for how the initramfs is named...
+ if os.path.exists(bootdir + "/initramfs-" + version + ".img"):
+ shutil.copyfile(bootdir + "/initramfs-" + version + ".img",
+ isodir + "/initrd" + index + ".img")
+ elif os.path.exists(bootdir + "/initrd-" + version + ".img"):
+ shutil.copyfile(bootdir + "/initrd-" + version + ".img",
+ isodir + "/initrd" + index + ".img")
+ elif not self.base_on:
+ logging.error("No initramfs or initrd found for %s" % (version,))
+
+ is_xen = False
+ if os.path.exists(bootdir + "/xen.gz-" + version[:-3]):
+ shutil.copyfile(bootdir + "/xen.gz-" + version[:-3],
+ isodir + "/xen" + index + ".gz")
+ is_xen = True
+
+ return (is_xen, isDracut)
+
+ def __is_default_kernel(self, kernel, kernels):
+ if len(kernels) == 1:
+ return True
+
+ if kernel == self._default_kernel:
+ return True
+
+ if kernel.startswith(b"kernel-") and kernel[7:] == self._default_kernel:
+ return True
+
+ return False
+
+
+ def __get_kernel_initrd(self, isodir):
+ bootdir = self._instroot + "/boot"
+ kernels = self._get_kernel_versions()
+ kernel_options = self._get_kernel_options()
+ checkisomd5 = self._has_checkisomd5()
+ index="0"
+ for kernel, version in ((k,v) for k in kernels for v in kernels[k]):
+ (is_xen, isDracut) = self.__copy_kernel_and_initramfs(isodir, version, index, bootdir)
+ index = str(int(index) + 1)
+ if os.path.exists(bootdir + "/pcmemtest"):
+ shutil.copyfile(bootdir + "/pcmemtest",
+ isodir + "/pcmemtest")
+ else:
+ print('pcmemtest not found')
+
+
+ def __get_local_stanza(self, isodir):
+ return """label local
+ menu label Boot from ^local drive
+ localboot 0xffff
+"""
@property
def efiarch(self):
if not self._efiarch:
# for most things, we want them named boot$efiarch
- # Note that AA64 and IA32 are in uppercase but x64 is in lowercase
- # according to the UEFI specification
- # "Unified Extensible Firmware Interface (UEFI) Specification, Version 2.7 Errata A, August 2017"
- # https://uefi.org/sites/default/files/resources/UEFI%20Spec%202_7_A%20Sept%206.pdf
- # 3.5.1.1 Removable Media Boot Behavior, Table 14. UEFI Image Types, page 159
- efiarch = {"i386": "IA32", "x86_64": "x64"}
+ efiarch = {"aarch64": "AA64"}
self._efiarch = efiarch[dnf.rpm.basearch(hawkey.detect_arch())]
return self._efiarch
-
+
def __copy_efi_files(self, isodir):
""" Copy the efi files into /EFI/BOOT/
If any of them are missing, return False.
@@ -716,13 +1075,16 @@ menu end
files = [("/boot/efi/EFI/*/shim%s.efi" % (self.efiarch.lower(),), "/EFI/BOOT/BOOT%s.EFI" % (self.efiarch,), True),
# XXX grubcd.efi probably should contain EFI arch in its name to make 32 bit EFI possible on x86_64 (?)
# Or will 32 bit shim be able to load 64 bit grub?
- ("/usr/share/grub2-efi/grubcd.efi", "/EFI/BOOT/grub%s.efi" % (self.efiarch.lower(),), True),
+ # efi bootloader is generated now
+ # ("/usr/share/grub2-efi/grubcd.efi", "/EFI/BOOT/grub%s.efi" % (self.efiarch.lower(),), True),
("/boot/efi/EFI/*/shimia32.efi", "/EFI/BOOT/BOOTIA32.EFI", False),
# XXX gcdia32.efi does not exist yet in ROSA
("/boot/efi/EFI/*/gcdia32.efi", "/EFI/BOOT/grubia32.efi", False),
("/boot/grub2/fonts/unicode.pf2", "/EFI/BOOT/fonts/", True),
+ ("/boot/grub2/themes/rosa/*", "/EFI/BOOT/themes/rosa/", True),
]
makedirs(isodir+"/EFI/BOOT/fonts/")
+ makedirs(isodir+"/EFI/BOOT/themes/rosa/")
for src, dest, required in files:
src_glob = glob.glob(self._instroot+src)
if not src_glob:
@@ -736,28 +1098,69 @@ menu end
def __get_basic_efi_config(self, **args):
return """
-set default="1"
-
-function load_video {
- insmod efi_gop
- insmod efi_uga
- insmod video_bochs
- insmod video_cirrus
- insmod all_video
-}
+set default="0"
-load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
+insmod part_msdos
insmod ext2
-
+insmod iso9660
+
+set gfxmode=1024x768,1024x600,800x600,640x480
+insmod gfxterm
+
+set localedir ${prefix}/locale
+insmod gettext
+
+set OS=$"ROSA linux"
+set start=$"Start"
+set startInstall=$"Start & install"
+set basicMode=$"in basic graphics mode"
+set consoleMode=$"in console mode"
+set rebootToEfi=$"Reboot to EFI firmware setup"
+set reboot=$"Reboot"
+set testMedia=$"Test this media & start"
+set installer=$"Install"
+set troubleshooting=$"Troubleshooting"
+set backToMain=$"Back to main menu"
+set loading=$"Loading"
+set backToLang=$"Back to lang menu"
+set pcmemtest=$"Checking RAM"
+set bootFromHdd=$"Boot instaled OS"
+
+export OS
+export start
+export startInstall
+export basicMode
+export consoleMode
+export rebootToEfi
+export reboot
+export testMedia
+export installer
+export additional
+export backToMain
+export loading
+export backToLang
+export pcmemtest
+export bootFromHdd
+
+terminal_output gfxterm
+insmod gfxmenu
+loadfont /EFI/BOOT/themes/rosa/dejavu_sans_bold_14.pf2
+loadfont /EFI/BOOT/themes/rosa/dejavu_sans_mono_11.pf2
+loadfont /EFI/BOOT/themes/rosa/terminal_font_11.pf2
+insmod png
+set theme=/EFI/BOOT/themes/rosa/theme.txt
+export theme
+background_image -m stretch /EFI/BOOT/themes/rosa/terminal_background.png
+if test $firstTime != no ; then
+ configfile ${prefix}/lang.cfg
+fi
set timeout=%(timeout)d
-### END /etc/grub.d/00_header ###
search --no-floppy --set=root -l '%(isolabel)s'
-### BEGIN /etc/grub.d/10_linux ###
""" %args
def __get_efi_image_stanza(self, **args):
@@ -765,50 +1168,155 @@ search --no-floppy --set=root -l '%(isolabel)s'
args["rootlabel"] = "live:LABEL=%(fslabel)s" % args
else:
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
- return """menuentry '%(long)s' --class fedora --class gnu-linux --class gnu --class os {
- linuxefi /isolinux/vmlinuz%(index)s root=%(rootlabel)s %(liveargs)s %(extra)s
- initrdefi /isolinux/initrd%(index)s.img
+ return """menuentry "%(long)s" --class rosa --class gnu-linux --class gnu --class os {
+ linux /vmlinuz%(index)s root=%(rootlabel)s %(liveargs)s %(extra)s \
+ lang=$lang inst.lang=$lang_utf locale.LANG=$lang_utf locale.LANGUAGE=$lang_utf
+ echo "$loading /vmlinuz%(index)s..."
+ initrd /initrd%(index)s.img
+ echo "$loading /initrd%(index)s.img..."
}
""" %args
+ def __set_locales(self, isodir):
+ os.mkdir(isodir + '/EFI/BOOT/locale')
+ if os.path.exists('/usr/share/livecd-tools/grub2/locales'):
+ for po in os.listdir('/usr/share/livecd-tools/grub2/locales'):
+ print('Processing: ' + po)
+ if po.endswith('.po'):
+ lng = po.split( '_' )[0]
+ mo = '/usr/share/locale/' + lng + '/LC_MESSAGES/grub.mo'
+ if os.path.exists(mo):
+ subprocess.call( [ 'msgunfmt', mo, '-o', lng + '.po' ])
+ if subprocess.call( [ 'msgcat', lng + '.po',
+ '/usr/share/livecd-tools/grub2/locales/' + po,
+ '-o', isodir + "/EFI/BOOT/locale/" + po ] ):
+ print(f"Msgcat for {po} & {lng}.po file - Failed")
+ else:
+ shutil.copy('/usr/share/livecd-tools/grub2/locales/' + po,
+ isodir + "/EFI/BOOT/locale/" + po)
+ else:
+ shutil.copy('/usr/share/livecd-tools/grub2/locales/' + po,
+ isodir + "/EFI/BOOT/locale/" + po)
+ for po in os.listdir(isodir + '/EFI/BOOT/locale'):
+ if po.endswith('.po'):
+ # zero is a 'False' for python
+ if not subprocess.call(['msgfmt', isodir +
+ '/EFI/BOOT/locale/' + po, '-o',
+ isodir + '/EFI/BOOT/locale/'
+ + po.replace('.po', '.mo') ]):
+ os.remove(isodir + '/EFI/BOOT/locale/' + po)
+ else:
+ print(f"Msgfmt for {po} file - Failed")
+ avaliable_locales = list(map(lambda locale: locale.split('.')[0],
+ os.listdir(isodir + '/EFI/BOOT/locale')))
+ known_locales = [ "ru_RU=Русский", "it_IT=italiano",
+ "de_DE=Deutsch ", "fr_FR=Français",
+ "pt_PT=Português", "es_ES=Español" ]
+ locales_str = ''
+ for l in known_locales:
+ for a in avaliable_locales:
+ if l.startswith(a):
+ locales_str += l + ' '
+ print('found locales: ' + locales_str)
+ return locales_str
+ else:
+ return False
def __get_efi_image_stanzas(self, isodir, name):
# FIXME: this only supports one kernel right now...
kernel_options = self._get_kernel_options()
checkisomd5 = self._has_checkisomd5()
-
- cfg = ""
+ #if os.path.exists(isodir + '/var/lib/rosa-iso-info'):
+ # with open(isodir + '/var/lib/rosa-iso-info', r) as f:
+ # for string in f:
+ # if string.strip().split('=')[0] == 'BUILD_ID':
+ # BUILD_ID = string.strip().split('=')[1]
+ # break
+
+ if self.build_id != None:
+ efisgn = '/rosa-iso-build_' + self.build_id
+ else:
+ efisgn = '/EFI/rosa/grub.cfg'
+
+ cfg ="""if search --no-floppy --file %s ; then
+ menuentry "$bootFromHdd" {
+ search --set=root --no-floppy --file %s
+ configfile /EFI/rosa/grub.cfg
+ }
+ fi
+""" % (efisgn, efisgn)
for index in range(0, 9):
# we don't support xen kernels
if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
continue
+
+ if not 'systemd.unit=anaconda.target' in kernel_options:
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$startInstall $OS (live)",
+ extra = "rhgb splash=silent logo.nologo", index = index)
+
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
liveargs = kernel_options,
- long = "Start " + self.product,
- extra = "", index = index)
+ long = "$installer $OS",
+ extra = "systemd.unit=anaconda.target ", index = index)
+
+ cfg += r"""submenu "${troubleshooting}..." --id additional {
+"""
+
if checkisomd5:
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
liveargs = kernel_options,
- long = "Test this media & start " + self.product,
+ long = "$testMedia " + self.product,
extra = "rd.live.check",
- index = index)
- cfg += """
-submenu 'Troubleshooting -->' {
-"""
+ index = index)
+
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
liveargs = kernel_options,
- long = "Start " + self.product + " in basic graphics mode",
- extra = "nomodeset", index = index)
+ long = "$start " + self.product + " $basicMode",
+ extra = "nomodeset plymouth.enable=0 noapic acpi=off loglevel=5 vga=788", index = index)
- cfg+= """}
+ cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
+ liveargs = kernel_options,
+ long = "$installer " + self.product + " $consoleMode",
+ extra = "systemd.unit=anaconda.target inst.text", index = index)
+ if os.path.exists(isodir + '/pcmemtest'):
+ cfg += """if test "$bootis" != 'UEFI:' ; then
+menuentry "$pcmemtest" {
+ echo "$loading ${pcmemtest}..."
+ set gfxpayload=640x400,800x600,1024x768
+ linux /pcmemtest
+}
+fi
+"""
+
+ cfg += """menuentry "$rebootToEfi" {
+ fwsetup
+}
+
+
+menuentry "$backToMain" {
+ configfile ${prefix}/grub.cfg
+}
+
+}
"""
- break
+ cfg += """menuentry "$backToLang" --hotkey 'f2' --id 'lang' {
+ configfile ${prefix}/lang.cfg
+}
+"""
+ cfg += """menuentry "$reboot" {
+ reboot
+}
+"""
+ break
return cfg
def _configure_efi_bootloader(self, isodir):
"""Set up the configuration for an EFI bootloader"""
+ self.__get_kernel_initrd(isodir)
if self.__copy_efi_files(isodir):
shutil.rmtree(isodir + "/EFI")
logging.warning("Failed to copy EFI files, no EFI Support will be included.")
@@ -822,23 +1330,14 @@ submenu 'Troubleshooting -->' {
cfgf.write(cfg)
cfgf.close()
- # first gen mactel machines get the bootloader name wrong apparently
- if dnf.rpm.basearch(hawkey.detect_arch()) == "i386":
- os.link(isodir + "/EFI/BOOT/BOOT%s.EFI" % (self.efiarch),
- isodir + "/EFI/BOOT/BOOT.EFI")
-
+
def _generate_efiboot(self, isodir):
- LiveImageCreatorBase._generate_efiboot(self, isodir)
- # add macboot data
- subprocess.call(["mkefiboot", "-a", isodir + "/EFI/BOOT",
- isodir + "/isolinux/macboot.img", "-l", self.product,
- "-n", "/usr/share/pixmaps/bootloader/fedora-media.vol",
- "-i", "/usr/share/pixmaps/bootloader/fedora.icns",
- "-p", self.product])
+ return True
def _configure_bootloader(self, isodir):
- self._configure_syslinux_bootloader(isodir)
self._configure_efi_bootloader(isodir)
+ self._generate_grub2_bootimg(isodir)
+
class ppcLiveImageCreator(LiveImageCreatorBase):
def _get_xorrisofs_options(self, isodir):
@@ -962,15 +1461,15 @@ timeout=%(timeout)d
default=linux
image=/ppc/ppc64/vmlinuz
- label=linux64
- alias=linux
- initrd=/ppc/ppc64/initrd.img
- read-only
+ label=linux64
+ alias=linux
+ initrd=/ppc/ppc64/initrd.img
+ read-only
image=/ppc/ppc32/vmlinuz
- label=linux32
- initrd=/ppc/ppc32/initrd.img
- read-only
+ label=linux32
+ initrd=/ppc/ppc32/initrd.img
+ read-only
""" % args
f = open(isodir + "/etc/yaboot.conf", "w")
@@ -1033,177 +1532,6 @@ class ppc64LiveImageCreator(ppcLiveImageCreator):
return ["kernel.ppc"] + \
ppcLiveImageCreator._get_excluded_packages(self)
-class aarch64LiveImageCreator(LiveImageCreatorBase):
- """ImageCreator for aarch64 machines"""
- def __init__(self, *args, **kwargs):
- LiveImageCreatorBase.__init__(self, *args, **kwargs)
- self._efiarch = None
-
- def _get_xorrisofs_options(self, isodir):
- options = []
- if os.path.exists(os.path.join(isodir, "isolinux/efiboot.img")):
- options += ["-eltorito-alt-boot", "-e", "isolinux/efiboot.img",
- "-no-emul-boot", "-hide-rr-moved"]
- options += ["-rational-rock", "-joliet", "-volid", self.fslabel]
- return options
-
- def _get_required_packages(self):
- return LiveImageCreatorBase._get_required_packages(self)
-
- def __copy_kernel_and_initramfs(self, isodir, version, index):
- bootdir = self._instroot + "/boot"
- makedirs(isodir + "/LiveOS/")
- shutil.copyfile(bootdir + "/vmlinuz-" + version,
- isodir + "/LiveOS/vmlinuz" + index)
-
- isDracut = False
- if os.path.exists(self._instroot + "/usr/bin/dracut"):
- isDracut = True
-
- # FIXME: Implement a better check for how the initramfs is named...
- if os.path.exists(bootdir + "/initramfs-" + version + ".img"):
- shutil.copyfile(bootdir + "/initramfs-" + version + ".img",
- isodir + "/LiveOS/initrd" + index + ".img")
- elif os.path.exists(bootdir + "/initrd-" + version + ".img"):
- shutil.copyfile(bootdir + "/initrd-" + version + ".img",
- isodir + "/LiveOS/initrd" + index + ".img")
- elif not self.base_on:
- logging.error("No initramfs or initrd found for %s" % (version,))
-
- return isDracut
-
- def __is_default_kernel(self, kernel, kernels):
- if len(kernels) == 1:
- return True
-
- if kernel == self._default_kernel:
- return True
-
- if kernel.startswith(b"kernel-") and kernel[7:] == self._default_kernel:
- return True
-
- return False
-
- def __get_local_stanza(self, isodir):
- return """label local
- menu label Boot from ^local drive
- localboot 0xffff
-"""
-
- @property
- def efiarch(self):
- if not self._efiarch:
- # for most things, we want them named boot$efiarch
- efiarch = {"aarch64": "AA64"}
- self._efiarch = efiarch[dnf.rpm.basearch(hawkey.detect_arch())]
- return self._efiarch
-
- def __copy_efi_files(self, isodir):
- fail = False
- files = [("/boot/efi/EFI/*/shim%s.efi" % (self.efiarch.lower(),), "/EFI/BOOT/BOOT%s.EFI" % (self.efiarch,), True),
- ("/usr/share/grub2-efi/grubcd.efi", "/EFI/BOOT/grub%s.efi" % (self.efiarch.lower(),), True),
- ("/boot/grub2/fonts/unicode.pf2", "/EFI/BOOT/fonts/", True),
- ]
- makedirs(isodir+"/EFI/BOOT/fonts/")
- for src, dest, required in files:
- src_glob = glob.glob(self._instroot+src)
- if not src_glob:
- if required:
- logging.error("Missing EFI file (%s)" % (src,))
- fail = True
- else:
- for src_file in src_glob:
- shutil.copy(src_file, isodir+dest)
- return fail
-
- def __get_basic_efi_config(self, **args):
- return """
-set default="1"
-
-function load_video {
- insmod efi_gop
- insmod efi_uga
- insmod video_bochs
- insmod video_cirrus
- insmod all_video
-}
-
-load_video
-set gfxpayload=keep
-insmod gzio
-insmod part_gpt
-insmod ext2
-
-set timeout=%(timeout)d
-### END /etc/grub.d/00_header ###
-
-search --no-floppy --set=root -l '%(isolabel)s'
-
-### BEGIN /etc/grub.d/10_linux ###
-""" %args
-
- def __get_efi_image_stanza(self, **args):
- args["rootlabel"] = "live:LABEL=%(fslabel)s" % args
- return """menuentry '%(long)s' --class fedora --class gnu-linux --class gnu --class os {
- linux /LiveOS/vmlinuz%(index)s root=%(rootlabel)s %(liveargs)s %(extra)s
- initrd /LiveOS/initrd%(index)s.img
-}
-""" %args
-
-
- def __get_efi_image_stanzas(self, isodir, name):
- # FIXME: this only supports one kernel right now...
- kernels = self._get_kernel_versions()
- kernel_options = self._get_kernel_options()
- checkisomd5 = self._has_checkisomd5()
-
- cfg = ""
- index = "0"
- for kernel, version in ((k,v) for k in kernels for v in kernels[k]):
- self.__copy_kernel_and_initramfs(isodir, version, index)
- cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
- liveargs = kernel_options,
- long = "Start " + self.product,
- extra = "", index = index)
- if checkisomd5:
- cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
- liveargs = kernel_options,
- long = "Test this media & start " + self.product,
- extra = "rd.live.check",
- index = index)
- cfg += """
-submenu 'Troubleshooting -->' {
-"""
- cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
- liveargs = kernel_options,
- long = "Start " + self.product + " in basic graphics mode",
- extra = "nomodeset", index = index)
-
- cfg+= """}
-"""
- break
-
- return cfg
-
- def _configure_efi_bootloader(self, isodir):
- """Set up the configuration for an EFI bootloader"""
- makedirs(isodir + "/isolinux")
- if self.__copy_efi_files(isodir):
- shutil.rmtree(isodir + "/EFI")
- logging.warning("Failed to copy EFI files, no EFI Support will be included.")
- return
-
- cfg = self.__get_basic_efi_config(isolabel = self.fslabel,
- timeout = self._timeout)
- cfg += self.__get_efi_image_stanzas(isodir, self.name)
-
- cfgf = open(isodir + "/EFI/BOOT/grub.cfg", "w")
- cfgf.write(cfg)
- cfgf.close()
-
- def _configure_bootloader(self, isodir):
- self._configure_efi_bootloader(isodir)
-
arch = dnf.rpm.basearch(hawkey.detect_arch())
if arch in ("i386", "x86_64"):
LiveImageCreator = x86LiveImageCreator
diff --git a/tools/livecd-creator b/tools/livecd-creator
index a057887..efaec04 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -50,6 +50,13 @@ def parse_options(args):
help="Title used by syslinux.cfg file"),
imgopt.add_option("", "--product", type="string", dest="product",
help="Product name used in syslinux.cfg boot stanzas and countdown"),
+ imgopt.add_option("", "--build_id", type="string", dest="build_id",
+ help="Build ID", default=None),
+
+ imgopt.add_option("", "--isotype", type="string", dest="isotype",
+ help="ISO Type. <table><number of partitions>. Available:"
+ "gpt2, mbr2, mbr1, efionly", default="mbr2"),
+
# Provided for img-create compatibility
imgopt.add_option("-n", "--name", type="string", dest="fslabel",
help=optparse.SUPPRESS_HELP)
@@ -210,7 +217,9 @@ def main():
useplugins=options.plugins,
title=title, product=product,
cacheonly=options.cacheonly,
- docleanup=not options.nocleanup)
+ docleanup=not options.nocleanup,
+ build_id=options.build_id,
+ isotype=options.isotype)
elif options.image_type == 'image':
creator = imgcreate.LoopImageCreator(ks, name,
fslabel=fslabel,