qubes-installer-qubes-os/lorax-templates-qubes/templates/efi.tmpl
Marek Marczykowski-Górecki 2f3063da20
lorax-templates-qubes: break the build if efiboot.img is too big
Break the build instead of producing broken boot image.
2018-09-16 03:40:12 +02:00

70 lines
4.8 KiB
Cheetah

<%page args="configdir, KERNELDIR, efiarch, isolabel, kver"/>
<%
EFIARCH_LOWER=efiarch.lower()
EFIBOOTDIR="EFI/BOOT"
APPLE_EFI_ICON=inroot+"/usr/share/pixmaps/bootloader/fedora.icns"
APPLE_EFI_DISKNAME=inroot+"/usr/share/pixmaps/bootloader/fedora-media.vol"
%>
mkdir ${EFIBOOTDIR}
mkdir ${EFIBOOTDIR}/fonts/
## Install xen.efi directly as BOOTX64.efi, reconsider grub when xen get multiboot2 support
install boot/efi/EFI/*/xen*.efi ${EFIBOOTDIR}/BOOT${efiarch}.efi
## actually make the EFI images
${make_efiboot("images/efiboot.img", include_kernel=True)}
## place fonts on ISO9660, but not in efiboot.img to save space
install boot/efi/EFI/*/fonts/unicode.pf2 ${EFIBOOTDIR}/fonts/
## This is kinda gross, but then... so's EFI.
<%def name="make_efiboot(img, include_kernel=False, disk=False, imgtype='default')">
<%
kdir = EFIBOOTDIR if include_kernel else KERNELDIR
xenconf = "%s/BOOT%s.cfg" % (EFIBOOTDIR, efiarch)
args = "--label=ANACONDA --debug"
scsi_modules = " 3w-9xxx 3w-sas 3w-xxxx BusLogic a100u2w aacraid advansys aic79xx aic7xxx am53c974 arcmsr atp870u bfa bnx2fc csiostor dc395x dmx3191d esas2r esp_scsi fcoe fnic gdth hpsa hptiop hv_storvsc initio ipr ips isci iscsi_boot_sysfs libfc libfcoe libiscsi libosd libsas lpfc megaraid megaraid_mbox megaraid_mm megaraid_sas mpt2sas mpt3sas mvsas mvumi osd pm80xx pmcraid qla1280 qla2xxx qla4xxx raid_class scsi_debug scsi_dh_emc scsi_dh_rdac scsi_transport_fc scsi_transport_iscsi scsi_transport_sas scsi_transport_spi scsi_transport_srp stex sym53c8xx ufshcd virtio_scsi vmw_pvscsi wd719x"
extra_modules = " affs befs coda cuse dlm gfs2 mptfc ncpfs nilfs2 ocfs2 ocfs2_dlm ocfs2_dlmfs ocfs2_nodemanager ocfs2_stack_o2cb ocfs2_stack_user ocfs2_stackglue sctp sysv ubifs ufs"
extra_modules += " 9p cachefiles ceph cramfs fscache minix blocklayoutdriver grace nfs nfsv4 objlayoutdriver romfs btrfs xfs cifs drbd sunrpc sctp mwifiex f2fs reiserfs jfs"
extra_modules += " dns_resolver udp_tunnel ip6_udp_tunnel rfkill cfg80211 virtio virtio_mmio virtio_pci virtio_ring libertas libertas_sdio 9pnet libceph rc-core memstick mspro_block mptbase mptsas mptscsih mptspi rtsx_pci rtsx_usb cb710 mic_bus scif_bus mic_card tifm_core mmc_block mmc_core cb710-mmc mtk-sd rtsx_pci_sdmmc rtsx_usb_sdmmc sdhci-acpi sdhci sdhci-pci sdhci-pltfm sdricoh_cs tifm_sd toshsd ushc via-sdmmc vub300 wbsd mtd_blkdevs mtdblock mtd mdio vxlan libertas libertas_sdio nd_blk nd_btt nd_pmem i82092 pd6729 yenta_socket pps_core ptp"
# The word boundaries are needed to avoid matching squashfs
extra_modules += " \\<hfs\\> hfsplus"
extra_modules += " ib_addr ib_cm ib_core ib_mad ib_sa ib_ucm ib_umad ib_uverbs iw_cm rdma_cm rdma_ucm iw_cxgb3 iw_cxgb4 mlx4_ib ib_mthca iw_nes ib_qib ib_ipoib ib_iser ib_isert ib_srp ib_srpt"
extra_modules += " cxgb3 cxgb4 mlx4_core mlx4_en"
extra_dracut_modules = " multipath modsign crypt shutdown plymouth fcoe fcoe-uefi nfs iscsi ifcfg"
extra_dracut_modules += " btrfs lvm qemu qemu-net systemd-bootchart systemd-networkd virtfs mlx4 rdma cifs livenet network kernel-network-modules"
if disk: args += " --disk"
if imgtype == "apple": args += ' --apple --icon=%s --diskname=%s --product="%s %s"' % (APPLE_EFI_ICON, APPLE_EFI_DISKNAME, product.name, product.version)
%>
%if include_kernel:
copy ${KERNELDIR}/vmlinuz ${EFIBOOTDIR}
runcmd chroot ${inroot} mkdir -p /boot/efi/EFI/qubes
runcmd chroot ${inroot} touch /proc/modules
runcmd chroot ${inroot} dracut --conf /dev/null --confdir /var/empty \
--nomdadmconf --nolvmconf --nofscks --no-early-microcode \
--no-hostonly --xz --install '/.buildstamp' \
--add 'anaconda pollcdrom dmsquash-live' \
--omit="${extra_dracut_modules}" --omit-drivers="${scsi_modules}" --omit-drivers="${extra_modules}" \
/boot/efi/EFI/qubes/initrd-small.img ${kver}
runcmd chroot ${inroot} rm -f /proc/modules
install boot/efi/EFI/qubes/initrd-small.img ${EFIBOOTDIR}/initrd.img
%endif
install ${configdir}/xen-efi.cfg ${xenconf}
replace @KERNELPATH@ /${kdir}/vmlinuz ${xenconf}
%if disk:
replace @ROOT@ inst.stage2=hd:LABEL=ANACONDA ${xenconf}
%else:
replace @ROOT@ 'inst.stage2=hd:LABEL=${isolabel|udev}' ${xenconf}
%endif
runcmd mkefiboot ${args} ${outroot}/${EFIBOOTDIR} ${outroot}/${img}
# place those files to prevent Windows recreating them while writing ISO image
# on Windows (this would break image verification)
runcmd mount ${outroot}/${img} ${outroot}/${EFIBOOTDIR} -o loop
mkdir "${EFIBOOTDIR}/System Volume Information"
install "${configdir}/System Volume Information/*" "${EFIBOOTDIR}/System Volume Information/"
runcmd umount ${outroot}/${img}
# verify if the image is under 32MB (max size of boot image on iso9660)
runcmd sh -x -c '[ $(stat -c %s ${outroot}/${img}) -le 33554432 ]'
</%def>