53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 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
|
|
|
|
sudo mount --bind /dev "$ROOTFS_PATH/dev"
|
|
sudo mount -t tmpfs run "$ROOTFS_PATH/run" -o mode=0755,nosuid,nodev
|
|
sudo mount -t proc proc "$ROOTFS_PATH/proc" -o nosuid,nodev,noexec
|
|
sudo 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" || sudo umount -lf "$ROOTFS_PATH/dev" || true
|
|
umount "$ROOTFS_PATH/run" || sudo umount -lf "$ROOTFS_PATH/run" || true
|
|
umount "$ROOTFS_PATH/proc" || sudo umount -lf "$ROOTFS_PATH/proc" || true
|
|
umount "$ROOTFS_PATH/sys" || sudo umount -lf "$ROOTFS_PATH/sys" || true
|
|
|
|
# Generate Squashfs image
|
|
|
|
sudo mksquashfs \
|
|
"$ROOTFS_PATH" \
|
|
"$LIVE_BOOT_PATH/live/filesystem.squashfs" \
|
|
-e boot
|
|
|
|
# Copy Kernel to live
|
|
cp "$ROOTFS_PATH/boot"/vmlinuz-* \
|
|
"$LIVE_BOOT_PATH/live/vmlinuz" && \
|
|
cp "$ROOTFS_PATH/boot"/initrd.img-* \
|
|
"$LIVE_BOOT_PATH/live/initrd"
|