ISO shit
This commit is contained in:
@@ -23,4 +23,6 @@ pigz
|
||||
arch-test
|
||||
mksquashfs:squashfs-tools
|
||||
xorriso
|
||||
mformat:mtools
|
||||
grub-mkrescue:grub-common
|
||||
grub-efi-amd64-bin
|
||||
grub-pc-bin
|
||||
@@ -8,14 +8,12 @@ fi
|
||||
ISO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.iso"
|
||||
ISO_TEMP_DIR="${STAGE_WORK_DIR}/iso_temp"
|
||||
|
||||
# Step 1: Generate initramfs.
|
||||
# Because live-boot-initramfs-tools is installed, the generated initrd will
|
||||
# include live-boot hooks that can find and mount the squashfs from the ISO.
|
||||
|
||||
# Replace fstab placeholders so initramfs-tools doesn't warn about unknown fs type.
|
||||
# Step 1: Replace fstab placeholders so initramfs-tools doesn't warn about unknown fs type.
|
||||
sed -i 's/ROOTDEV/LABEL=live-rootfs/g; s/BOOTDEV/LABEL=live-boot/g; s/EFIDEV/LABEL=live-efi/g' \
|
||||
"${ROOTFS_DIR}/etc/fstab"
|
||||
|
||||
# Step 2: Generate initramfs inside the chroot.
|
||||
# live-boot-initramfs-tools is installed so the initrd will include live-boot hooks.
|
||||
on_chroot << EOF
|
||||
update-initramfs -k all -c
|
||||
if [ -x /etc/init.d/fake-hwclock ]; then
|
||||
@@ -28,24 +26,9 @@ if [ -f "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf" ]; then
|
||||
sed -i 's/^MODULES=.*/MODULES=dep/' "${ROOTFS_DIR}/etc/initramfs-tools/initramfs.conf"
|
||||
fi
|
||||
|
||||
# Step 2: Build a standalone GRUB EFI binary inside the chroot.
|
||||
# grub-mkstandalone embeds all required modules so no separate EFI partition is needed.
|
||||
on_chroot << EOF
|
||||
mkdir -p /tmp/grub-standalone
|
||||
grub-mkstandalone \
|
||||
--format=x86_64-efi \
|
||||
--output=/tmp/grub-standalone/bootx64.efi \
|
||||
--modules="part_gpt part_msdos fat iso9660 ext2 normal search \
|
||||
search_fs_uuid search_fs_file search_label all_video \
|
||||
gfxterm gfxterm_background" \
|
||||
--locales="" \
|
||||
--fonts=""
|
||||
EOF
|
||||
|
||||
# Step 3: Assemble ISO directory structure
|
||||
mkdir -p "${ISO_TEMP_DIR}/boot/grub"
|
||||
mkdir -p "${ISO_TEMP_DIR}/live"
|
||||
mkdir -p "${ISO_TEMP_DIR}/EFI/boot"
|
||||
|
||||
# Copy kernel and initrd — find the latest versioned files in /boot
|
||||
VMLINUZ=$(find "${ROOTFS_DIR}/boot" -maxdepth 1 -name "vmlinuz-*" -type f | sort -V | tail -1)
|
||||
@@ -57,22 +40,20 @@ if [ -z "${VMLINUZ}" ] || [ ! -f "${VMLINUZ}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${INITRD}" ] || [ ! -f "${INITRD}" ]; then
|
||||
echo "ERROR: Could not find initrd in ${ROOTFS_DIR}/boot/"
|
||||
ls "${ROOTFS_DIR}/boot/" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "${VMLINUZ}" "${ISO_TEMP_DIR}/boot/vmlinuz"
|
||||
cp "${INITRD}" "${ISO_TEMP_DIR}/boot/initrd.img"
|
||||
|
||||
# Copy GRUB EFI binary from chroot
|
||||
cp "${ROOTFS_DIR}/tmp/grub-standalone/bootx64.efi" "${ISO_TEMP_DIR}/EFI/boot/bootx64.efi"
|
||||
|
||||
# Step 4: Write the live-boot grub.cfg
|
||||
# Step 4: Write the GRUB menu config
|
||||
cat > "${ISO_TEMP_DIR}/boot/grub/grub.cfg" << 'GRUBEOF'
|
||||
set default=0
|
||||
set timeout=5
|
||||
|
||||
insmod part_gpt
|
||||
insmod part_msdos
|
||||
insmod fat
|
||||
insmod iso9660
|
||||
insmod ext2
|
||||
insmod all_video
|
||||
insmod gfxterm
|
||||
|
||||
@@ -99,29 +80,18 @@ mksquashfs "${ROOTFS_DIR}" "${ISO_TEMP_DIR}/live/filesystem.squashfs" \
|
||||
-e tmp \
|
||||
-e run
|
||||
|
||||
# Step 6: Create small EFI FAT image for El Torito EFI boot entry
|
||||
EFI_IMG="${ISO_TEMP_DIR}/efi.img"
|
||||
dd if=/dev/zero of="${EFI_IMG}" bs=1M count=10
|
||||
mkfs.vfat "${EFI_IMG}"
|
||||
mmd -i "${EFI_IMG}" ::/EFI ::/EFI/boot
|
||||
mcopy -i "${EFI_IMG}" "${ISO_TEMP_DIR}/EFI/boot/bootx64.efi" ::/EFI/boot/bootx64.efi
|
||||
|
||||
# Step 7: Build the ISO (UEFI El Torito)
|
||||
xorriso -as mkisofs \
|
||||
-r -J -joliet-long \
|
||||
-eltorito-alt-boot \
|
||||
-e efi.img \
|
||||
-no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-o "${ISO_FILE}" \
|
||||
"${ISO_TEMP_DIR}"
|
||||
# Step 6: Build the ISO with grub-mkrescue (handles BIOS + UEFI automatically)
|
||||
grub-mkrescue \
|
||||
--output="${ISO_FILE}" \
|
||||
"${ISO_TEMP_DIR}" \
|
||||
-- \
|
||||
-V "ChillcraftOS"
|
||||
|
||||
rm -rf "${ISO_TEMP_DIR}"
|
||||
rm -f "${ROOTFS_DIR}/tmp/grub-standalone/bootx64.efi"
|
||||
|
||||
echo "Live ISO created at ${ISO_FILE}"
|
||||
|
||||
# Step 8: Deploy
|
||||
# Step 7: Deploy
|
||||
mkdir -p "${DEPLOY_DIR}"
|
||||
rm -f "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.iso"
|
||||
cp "${ISO_FILE}" "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.iso"
|
||||
|
||||
Reference in New Issue
Block a user