From 399cb880600f6c827947388088c7124d4590e272 Mon Sep 17 00:00:00 2001 From: Christian Nilsson Date: Wed, 28 Jul 2021 23:57:18 +0200 Subject: [PATCH] PoC RFC Generate (i)PXE files in create-iso for amd64 and friends Copy out needed files from iso to perform iPXE boot from gentoo mirrors Provided as PoC of what is needed for this to be vaild If merged this would resolve NiKiZe/Gentoo-iPXE#2 There is an alternative aproch to extract and generate these files during upload instead Really want to have this in the same target as minimal livecd To test result with qemu localy after build (replace your variables): qemu-system-x86_64 -enable-kvm -M q35 -m 1024 -cpu host -nic user,model=virtio,\ tftp="${BUILD_SRCDIR_BASE}"/builds/default,\ bootfile=install-amd64-minimal-${TIMESTAMP}.ipxe \ -watchdog i6300esb -watchdog-action reset -boot menu=on -usb Signed-off-by: Christian Nilsson --- targets/support/create-iso.sh | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/targets/support/create-iso.sh b/targets/support/create-iso.sh index bcfa20a6..455e553d 100755 --- a/targets/support/create-iso.sh +++ b/targets/support/create-iso.sh @@ -271,6 +271,46 @@ case ${clst_hostarch} in echo 'Creating ISO with fingers crossed that you know what you are doing...' run_mkisofs -J -R -l ${mkisofs_zisofs_opts} -V "${clst_iso_volume_id}" -o "${1}" "${clst_target_path}"/ fi + + # Use same kernel, initrd and squashfs to generate PXE bootable files + iso="${1}" + dstpath=${iso%%.iso} + dstname=$(basename ${dstpath}) + kernel=${clst_boot_kernel} + for x in ${clst_boot_kernel} + do + kernel=${x} + done + echo "Copy kernel for use outside iso ${dstpath}.lkrn" + cp -vf "${clst_target_path}/boot/${kernel}" "${dstpath}.lkrn" + echo "Generate combined initrd + squashfs ${dstpath}.igz" + # change dir to get squashfs in current dir for correct cpio creation + pushd "${clst_target_path}" + # combine original initrd with squashfs + # different variants can be used, compression + # the selected combination here gives most responsive boot (avoids several seconds of black screen) + (cat "boot/${kernel}.igz" ; (echo image.${clst_fstype} | cpio -H newc -o)) > "${dstpath}.igz" + popd + + # Generate kernel cmdline for use in iPXE script + if [ -z "${cmdline_opts}" ] + then + check_bootargs + check_filesystem_type + fi + default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot" + ipxename="${dstpath}.ipxe" + echo "Generating iPXE script ${ipxename}" + echo '#!ipxe' > ${ipxename} + echo '# allow for external keymap setting' >> ${ipxename} + echo 'isset ${keymap} || set keymap dokeymap' >> ${ipxename} + echo '# allow for external cmdline options' >> ${ipxename} + echo 'isset ${cmdline} || set cmdline vga=791' >> ${ipxename} + # initrd= on cmdline is needed for efi + echo "kernel ${dstname}.lkrn ${default_append_line/dokeymap/\$\{keymap\}} initrd=${dstname}.igz \${cmdline}" >> ${ipxename} + echo "initrd ${dstname}.igz" >> ${ipxename} + echo 'imgstat' >> ${ipxename} + echo 'boot' >> ${ipxename} ;; esac exit $?