2024-08-01 14:23:17 +02:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
source ./info.sh
|
|
|
|
|
|
|
|
if [[ -z $ROOTFS_PATH ]]
|
|
|
|
then
|
|
|
|
echo "Error: ROOTFS PATH is not set!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Mount
|
|
|
|
|
2024-08-01 14:42:33 +02:00
|
|
|
mount --bind /dev "$ROOTFS_PATH/dev"
|
|
|
|
mount -t tmpfs run "$ROOTFS_PATH/run" -o mode=0755,nosuid,nodev
|
|
|
|
mount -t proc proc "$ROOTFS_PATH/proc" -o nosuid,nodev,noexec
|
|
|
|
mount -t sysfs sys "$ROOTFS_PATH/sys" -o nosuid,nodev,noexec,ro
|
2024-08-01 14:23:17 +02:00
|
|
|
|
|
|
|
# Setup Chroot scripts
|
|
|
|
|
|
|
|
cp -rvf ./chroot_scripts "$ROOTFS_PATH/"
|
|
|
|
cp -rvf ./hooks "$ROOTFS_PATH/chroot_scripts/"
|
2024-08-01 18:16:30 +02:00
|
|
|
cp -rvf ./live-lists "$ROOTFS_PATH/chroot_scripts/"
|
2024-08-01 14:23:17 +02:00
|
|
|
cp -rvf ./pool-lists "$ROOTFS_PATH/chroot_scripts/"
|
|
|
|
cp -rvf ./rem-lists "$ROOTFS_PATH/chroot_scripts/"
|
|
|
|
cp -rvf ./info.sh "$ROOTFS_PATH/chroot_scripts/"
|
|
|
|
|
|
|
|
# Run chroot_script inside ROOTFS
|
|
|
|
|
|
|
|
chroot "$ROOTFS_PATH" bash -c "/chroot_scripts/0-chroot.sh"
|
|
|
|
rm -rfv "$ROOTFS_PATH/chroot_scripts"
|
|
|
|
|
|
|
|
# Unmount
|
|
|
|
|
2024-08-01 14:42:33 +02:00
|
|
|
umount "$ROOTFS_PATH/dev" || umount -lf "$ROOTFS_PATH/dev" || true
|
|
|
|
umount "$ROOTFS_PATH/run" || umount -lf "$ROOTFS_PATH/run" || true
|
|
|
|
umount "$ROOTFS_PATH/proc" || umount -lf "$ROOTFS_PATH/proc" || true
|
|
|
|
umount "$ROOTFS_PATH/sys" || umount -lf "$ROOTFS_PATH/sys" || true
|
2024-08-01 14:23:17 +02:00
|
|
|
|
|
|
|
# Generate Squashfs image
|
|
|
|
|
2024-08-01 14:42:33 +02:00
|
|
|
mksquashfs \
|
2024-08-01 14:23:17 +02:00
|
|
|
"$ROOTFS_PATH" \
|
2024-08-01 18:16:30 +02:00
|
|
|
"$LIVE_BOOT_LIVE_PATH/filesystem.squashfs" \
|
2024-08-01 14:49:39 +02:00
|
|
|
-noappend \
|
|
|
|
-comp xz \
|
|
|
|
-b 1M \
|
|
|
|
-Xdict-size 1M \
|
|
|
|
-Xbcj x86
|
2024-08-01 14:23:17 +02:00
|
|
|
|
2024-08-02 00:24:07 +02:00
|
|
|
# Copy Kernel to live (Disabled, Copy Kernels to refind instead)
|
|
|
|
#cp "$ROOTFS_PATH/boot"/vmlinuz-* \
|
|
|
|
# "$LIVE_BOOT_LIVE_PATH/vmlinuz" && \
|
|
|
|
#cp "$ROOTFS_PATH/boot"/initrd.img-* \
|
|
|
|
# "$LIVE_BOOT_LIVE_PATH/initrd" && \
|
|
|
|
#cp ./data/refind/refind_linux.conf \
|
|
|
|
# "$LIVE_BOOT_LIVE_PATH/refind_linux.conf"
|
2024-08-01 18:05:23 +02:00
|
|
|
|
|
|
|
# Generate bootable EFI Image from refind
|
|
|
|
|
2024-08-02 00:24:07 +02:00
|
|
|
# Copy kernel to refind
|
|
|
|
cp "$ROOTFS_PATH/boot"/vmlinuz-* \
|
|
|
|
"./data/refind/EFI/vmlinuz" && \
|
|
|
|
cp "$ROOTFS_PATH/boot"/initrd.img-* \
|
|
|
|
"./data/refind/EFI/initrd"
|
|
|
|
|
2024-08-03 00:45:59 +02:00
|
|
|
dd if=/dev/zero of="$LIVE_BOOT_PATH/efiboot.img" bs=512 count=$(du -s ./data/refind | cut -f1)
|
2024-08-01 19:05:07 +02:00
|
|
|
mkfs.msdos -F 16 "$LIVE_BOOT_PATH/efiboot.img"
|
|
|
|
for directory in $(find ./data/refind/EFI/ -type d | cut -d'/' -f4-)
|
|
|
|
do
|
2024-08-01 19:27:08 +02:00
|
|
|
mmd -i "$LIVE_BOOT_PATH/efiboot.img" ::"$(echo $directory | tr '[:lower:]' '[:upper:]' | sed 's:/*$::')"
|
2024-08-01 19:05:07 +02:00
|
|
|
done
|
|
|
|
|
2024-08-01 19:35:10 +02:00
|
|
|
for file in $(find ./data/refind/EFI/ -type f)
|
2024-08-01 19:05:07 +02:00
|
|
|
do
|
2024-08-01 19:35:10 +02:00
|
|
|
mcopy -i "$LIVE_BOOT_PATH/efiboot.img" $file ::"$(echo $file | cut -d'/' -f4- | tr '[:lower:]' '[:upper:]')"
|
2024-08-01 19:05:07 +02:00
|
|
|
done
|
2024-08-01 18:05:23 +02:00
|
|
|
|
|
|
|
# Create Bootable UEFI Full Image
|
|
|
|
mkdir -p ./output
|
|
|
|
|
|
|
|
xorriso \
|
|
|
|
-as mkisofs \
|
2024-08-01 20:00:30 +02:00
|
|
|
-iso-level 3 \
|
2024-08-01 18:05:23 +02:00
|
|
|
-V $LIVE_BOOT_VOLUME_NAME \
|
2024-08-01 21:24:38 +02:00
|
|
|
-e --interval:appended_partition_2:all:: \
|
2024-08-01 19:53:07 +02:00
|
|
|
-append_partition 2 0xef "$LIVE_BOOT_PATH/efiboot.img" \
|
|
|
|
-J -joliet-long \
|
2024-08-01 18:05:23 +02:00
|
|
|
-no-emul-boot \
|
2024-08-01 21:24:38 +02:00
|
|
|
-isohybrid-gpt-basdat \
|
2024-08-01 20:15:53 +02:00
|
|
|
-o "./output/$ISO_IMAGE".iso \
|
2024-08-01 18:16:30 +02:00
|
|
|
"$LIVE_BOOT_DATA_PATH"
|
2024-08-01 20:15:53 +02:00
|
|
|
|
|
|
|
# Generate an integrity sum
|
|
|
|
touch "./output/$ISO_IMAGE".md5
|
|
|
|
md5sum "./output/$ISO_IMAGE".iso > "./output/$ISO_IMAGE".md5
|