93 lines
2.7 KiB
Bash
Executable File
93 lines
2.7 KiB
Bash
Executable File
#! /bin/bash
|
|
|
|
set -e
|
|
|
|
source ./info.sh
|
|
|
|
if [[ -z $ROOTFS_PATH ]]
|
|
then
|
|
echo "Error: ROOTFS PATH is not set!"
|
|
exit 1
|
|
fi
|
|
|
|
# Mount
|
|
|
|
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
|
|
|
|
# Setup Chroot scripts
|
|
|
|
cp -rvf ./chroot_scripts "$ROOTFS_PATH/"
|
|
cp -rvf ./hooks "$ROOTFS_PATH/chroot_scripts/"
|
|
cp -rvf ./live-lists "$ROOTFS_PATH/chroot_scripts/"
|
|
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
|
|
|
|
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
|
|
|
|
# Generate Squashfs image
|
|
|
|
mksquashfs \
|
|
"$ROOTFS_PATH" \
|
|
"$LIVE_BOOT_LIVE_PATH/filesystem.squashfs" \
|
|
-noappend \
|
|
-comp xz \
|
|
-b 1M \
|
|
-Xdict-size 1M \
|
|
-Xbcj x86
|
|
|
|
# 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"
|
|
|
|
REFIND_SIZE=$(du -s -B1 ./data/refind | cut -f1)
|
|
LIVE_SIZE=$(du -s -B1 $LIVE_BOOT_LIVE_PATH | cut -f1)
|
|
ISO_SIZE=$(($REFIND_SIZE + $LIVE_SIZE))
|
|
|
|
DD_BOOT_IMAGE="./efiboot.img"
|
|
DD_LIVE_IMAGE="./live.img"
|
|
|
|
# Create Refind Image
|
|
dd if=/dev/zero of="$DD_BOOT_IMAGE" bs=1 count=$REFIND_SIZE
|
|
mkfs.vfat -F 16 "$DD_BOOT_IMAGE"
|
|
for directory in $(find ./data/refind/EFI/ -type d | cut -d'/' -f4-)
|
|
do
|
|
mmd -i "$DD_BOOT_IMAGE" ::"$(echo $directory | tr '[:lower:]' '[:upper:]' | sed 's:/*$::')"
|
|
done
|
|
|
|
for file in $(find ./data/refind/EFI/ -type f)
|
|
do
|
|
mcopy -i "$DD_BOOT_IMAGE" $file ::"$(echo $file | cut -d'/' -f4- | tr '[:lower:]' '[:upper:]')"
|
|
done
|
|
|
|
# Create Live medium image
|
|
dd if=/dev/zero of="$DD_LIVE_IMAGE" bs=1 count=$LIVE_SIZE
|
|
mkfs.ext4 "$DD_LIVE_IMAGE"
|
|
for directory in $(find $LIVE_BOOT_LIVE_PATH -type d | cut -d'/' -f4-)
|
|
do
|
|
mmd -i "$DD_LIVE_IMAGE" ::"$(echo $directory | tr '[:lower:]' '[:upper:]' | sed 's:/*$::')"
|
|
done
|
|
|
|
for file in $(find $LIVE_BOOT_LIVE_PATH -type f)
|
|
do
|
|
mcopy -i "$DD_LIVE_IMAGE" $file ::"$(echo $file | cut -d'/' -f4- | tr '[:lower:]' '[:upper:]')"
|
|
done
|
|
|
|
cat $DD_BOOT_IMAGE $DD_LIVE_IMAGE > "./output/$ISO_IMAGE".iso |