hide memtest for efi

This commit is contained in:
betcher_ 2021-10-04 15:51:51 +03:00
parent 6bdbe1a325
commit ec8f55017c

View file

@ -1,5 +1,5 @@
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 9447640..961e65f 100644
index 9447640..02d0d04 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -234,8 +234,7 @@ class LiveImageCreatorBase(LoopImageCreator):
@ -12,7 +12,7 @@ index 9447640..961e65f 100644
"""Configure the image so that it's bootable."""
self._configure_bootloader(self.__ensure_isodir())
self._generate_efiboot(self.__ensure_isodir())
@@ -379,16 +378,13 @@ class x86LiveImageCreator(LiveImageCreatorBase):
@@ -379,16 +378,14 @@ class x86LiveImageCreator(LiveImageCreatorBase):
self._efiarch = None
def _get_xorrisofs_options(self, isodir):
@ -26,17 +26,18 @@ index 9447640..961e65f 100644
- 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"]
+ shim = "BOOT%s.EFI" % (self.efiarch,)
+ options = [ '-no-emul-boot', '-boot-load-size', '4', '-hide',
+ 'boot.catalog', '-boot-info-table', '-b', 'eltorito.img',
+ '--grub2-mbr', '/usr/lib/grub/i386-pc/boot_hybrid.img',
+ '--grub2-boot-info', isodir + '/eltorito.img',
+ '-append_partition', '2', '0xef', './efi.img',
+ '-eltorito-alt-boot', '--efi-boot', 'EFI/BOOT/BOOTx64.EFI' ]
+ '-eltorito-alt-boot', '--efi-boot', 'EFI/BOOT/' + shim ]
+
options += ["-rational-rock", "-joliet", "-volid", self.fslabel]
return options
@@ -398,61 +394,94 @@ class x86LiveImageCreator(LiveImageCreatorBase):
@@ -398,61 +395,104 @@ class x86LiveImageCreator(LiveImageCreatorBase):
def _get_isolinux_stanzas(self, isodir):
return ""
@ -96,23 +97,25 @@ index 9447640..961e65f 100644
+ def _generate_grub2_bootimg(self, isodir):
+ """generate grub2 boot images"""
+
+ def __locales_cfg(self, isodir):
+ 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
+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"
+ lang=$2
+ lang_utf="${2}.UTF-8"
+ export lang
+ export lang_utf
+ configfile ${prefix}/grub.cfg
+}
+done
+
+""" % locales_str
+""" % (timeout, locales_str)
+ with open(isodir + '/EFI/BOOT/lang.cfg', 'w') as f:
+ print(cfg, file=f)
+
@ -122,7 +125,15 @@ index 9447640..961e65f 100644
+ 'search', 'search_fs_uuid', 'search_fs_file', 'true',
+ 'iso9660', 'search_label', 'gfxterm', 'gfxmenu',
+ 'fat', 'ext2', 'ntfs', 'cat', 'echo', 'ls', 'png',
+ 'reboot' ]
+ 'reboot', 'all_video', 'boot' ]
+# '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 /EFI/BOOT/grub.cfg root', file=f)
@ -141,9 +152,9 @@ index 9447640..961e65f 100644
+ if bootis == 'efi':
+ print('==> generating grub2 image for efi boot')
+ cmdlist=['grub2-mkimage', '-p', '/grub2', '-c', './grub.cfg',
+ '-O', 'x86_64-efi' ,'-o', isodir + '/EFI/BOOT/grubx64.efi',
+ '-O', 'x86_64-efi' ,'-o', isodir + f'/EFI/BOOT/grub{self._efiarch.lower()}.efi',
+ '--compression=xz']
+ cmdlist.extend(['efi_gop', 'efi_uga', 'efifwsetup' ])
+ cmdlist.extend(['efi_gop', 'efi_uga', 'efifwsetup', 'efinet', 'lsefi' ])
+ cmdlist.extend(modlist)
+ else:
+ print('==> generating grub2 image eltorito')
@ -160,7 +171,7 @@ index 9447640..961e65f 100644
+ os.makedirs(isodir + '/EFI/BOOT/', exist_ok=True)
+ __grub_boot_img(self, 'bios')
+ __grub_boot_img(self, 'efi')
+ __locales_cfg(self, isodir)
+ __locales_cfg(self, isodir, self._timeout)
+ os.mkdir('img_mount_point')
+
+ open('efi.img', "w").truncate(1000 * 5000)
@ -169,7 +180,7 @@ index 9447640..961e65f 100644
+ 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 + '/EFI/BOOT/grubx64.efi', 'img_mount_point/EFI/BOOT/grubx64.efi')
+ 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')
@ -185,7 +196,7 @@ index 9447640..961e65f 100644
isDracut = False
if os.path.exists(self._instroot + "/usr/bin/dracut"):
@@ -461,17 +490,17 @@ class x86LiveImageCreator(LiveImageCreatorBase):
@@ -461,17 +501,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",
@ -206,7 +217,7 @@ index 9447640..961e65f 100644
is_xen = True
return (is_xen, isDracut)
@@ -488,209 +517,28 @@ class x86LiveImageCreator(LiveImageCreatorBase):
@@ -488,209 +528,28 @@ class x86LiveImageCreator(LiveImageCreatorBase):
return False
@ -425,13 +436,29 @@ index 9447640..961e65f 100644
@property
def efiarch(self):
if not self._efiarch:
@@ -716,13 +564,16 @@ menu end
@@ -700,8 +559,13 @@ menu end
# "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"}
- self._efiarch = efiarch[dnf.rpm.basearch(hawkey.detect_arch())]
+ 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:
+ efiarch = {"i386": "IA32", "x86_64": "x64"}
+ self._efiarch = efiarch[dnf.rpm.basearch(hawkey.detect_arch())]
return self._efiarch
def __copy_efi_files(self, isodir):
@@ -716,13 +580,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),
+ # ("/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),
@ -443,22 +470,27 @@ index 9447640..961e65f 100644
for src, dest, required in files:
src_glob = glob.glob(self._instroot+src)
if not src_glob:
@@ -736,28 +587,73 @@ menu end
@@ -736,28 +603,73 @@ menu end
def __get_basic_efi_config(self, **args):
return """
-set default="1"
+set default="0"
function load_video {
insmod efi_gop
insmod efi_uga
-function load_video {
- insmod efi_gop
- insmod efi_uga
- insmod video_bochs
- insmod video_cirrus
- insmod all_video
}
-}
+#function load_video {
+# insmod efi_gop
+# insmod efi_uga
+#}
+#load_video
load_video
-load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
@ -524,7 +556,7 @@ index 9447640..961e65f 100644
""" %args
def __get_efi_image_stanza(self, **args):
@@ -765,11 +661,58 @@ search --no-floppy --set=root -l '%(isolabel)s'
@@ -765,11 +677,58 @@ search --no-floppy --set=root -l '%(isolabel)s'
args["rootlabel"] = "live:LABEL=%(fslabel)s" % args
else:
args["rootlabel"] = "CDLABEL=%(fslabel)s" % args
@ -533,7 +565,7 @@ index 9447640..961e65f 100644
- 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 systemd.setenv=LC_ALL=$lang_utf
+ 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..."
@ -586,7 +618,7 @@ index 9447640..961e65f 100644
def __get_efi_image_stanzas(self, isodir, name):
# FIXME: this only supports one kernel right now...
@@ -783,32 +726,71 @@ search --no-floppy --set=root -l '%(isolabel)s'
@@ -783,32 +742,73 @@ search --no-floppy --set=root -l '%(isolabel)s'
# we don't support xen kernels
if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
continue
@ -624,17 +656,20 @@ index 9447640..961e65f 100644
- 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 += """menuentry "$pcmemtest" {
+ cfg += """if test "$bootis" != 'UEFI:' ; then
+menuentry "$pcmemtest" {
+ echo "$loading ${pcmemtest}..."
+ set gfxpayload=640x400,800x600,1024x768
+ linux /pcmemtest
+}
+fi
+"""
+
+ cfg += """if test "$bootis" == 'UEFI:' ; then
@ -642,8 +677,7 @@ index 9447640..961e65f 100644
+ fwsetup
+}
+fi
- cfg+= """}
+
+menuentry "$backToMain" {
+ configfile ${prefix}/grub.cfg
+}
@ -669,7 +703,7 @@ index 9447640..961e65f 100644
if self.__copy_efi_files(isodir):
shutil.rmtree(isodir + "/EFI")
logging.warning("Failed to copy EFI files, no EFI Support will be included.")
@@ -828,17 +810,13 @@ submenu 'Troubleshooting -->' {
@@ -828,17 +828,13 @@ submenu 'Troubleshooting -->' {
isodir + "/EFI/BOOT/BOOT.EFI")
def _generate_efiboot(self, isodir):
@ -691,7 +725,7 @@ index 9447640..961e65f 100644
class ppcLiveImageCreator(LiveImageCreatorBase):
def _get_xorrisofs_options(self, isodir):
@@ -962,15 +940,15 @@ timeout=%(timeout)d
@@ -962,15 +958,15 @@ timeout=%(timeout)d
default=linux
image=/ppc/ppc64/vmlinuz
@ -714,7 +748,7 @@ index 9447640..961e65f 100644
""" % args
f = open(isodir + "/etc/yaboot.conf", "w")
@@ -1103,8 +1081,10 @@ class aarch64LiveImageCreator(LiveImageCreatorBase):
@@ -1103,8 +1099,10 @@ class aarch64LiveImageCreator(LiveImageCreatorBase):
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),
@ -725,7 +759,7 @@ index 9447640..961e65f 100644
for src, dest, required in files:
src_glob = glob.glob(self._instroot+src)
if not src_glob:
@@ -1117,36 +1097,47 @@ class aarch64LiveImageCreator(LiveImageCreatorBase):
@@ -1117,36 +1115,47 @@ class aarch64LiveImageCreator(LiveImageCreatorBase):
return fail
def __get_basic_efi_config(self, **args):
@ -781,7 +815,7 @@ index 9447640..961e65f 100644
}
""" %args
@@ -1164,22 +1155,20 @@ search --no-floppy --set=root -l '%(isolabel)s'
@@ -1164,22 +1173,20 @@ search --no-floppy --set=root -l '%(isolabel)s'
cfg += self.__get_efi_image_stanza(fslabel = self.fslabel,
liveargs = kernel_options,
long = "Start " + self.product,