windvn/path/wdvn-image-iso

73 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-08-10 00:00:49 +00:00
#!/bin/bash
set -e
2022-08-10 16:31:18 +00:00
DISC_NAME="${WDVN_VER:0:3} $WDVN_ARCH $WDVN_DATE"
DISC_NAME="${DISC_NAME:0:32}"
2022-08-10 00:00:49 +00:00
CHROOT="$1"
IMAGE="$2.tmp"
if [ -d "$IMAGE" ]; then
rm -r -f "$IMAGE"
fi
EXIT=0
if [ ! -d "$CHROOT/lib/live/boot" ]; then
echo "ERROR: /lib/live/boot not found within chroot. On your chroot, run 'apt install live-boot'."
EXIT=1
fi
if [ ! -f "$CHROOT/usr/share/initramfs-tools/hooks/live" ]; then
echo "ERROR: /usr/share/initramfs-tools/hooks/live not found within chroot. On your chroot, run 'apt install live-boot-initramfs-tools'."
EXIT=1
fi
2022-08-14 20:00:05 +00:00
if ! command -v mksquashfs &> /dev/null
then
2022-08-15 06:31:02 +00:00
echo "ERROR: mksquashfs not found. Run 'apt install squashfs-tools'."
2022-08-14 20:00:05 +00:00
EXIT=1
fi
2022-08-10 00:00:49 +00:00
if ! command -v xorriso &> /dev/null
then
echo "ERROR: xorriso not found. Run 'apt install xorriso'."
EXIT=1
fi
2022-08-15 06:31:02 +00:00
if ! command -v grub-mkrescue &> /dev/null
then
echo "ERROR: grub-mkrescue not found. Run 'apt install grub-common'."
EXIT=1
fi
2022-08-10 00:00:49 +00:00
if [ -f "$2" ]; then
echo "ERROR: $2 already exists."
EXIT=1
fi
if [ "$EXIT" == "1" ]; then
exit 1
fi
mkdir -p "$IMAGE"
mkdir -p "$IMAGE/live"
2022-08-15 06:31:02 +00:00
mkdir -p "$IMAGE/boot/grub"
2022-08-10 00:00:49 +00:00
cp -fv "$CHROOT/boot"/vmlinuz-* "$IMAGE/live/vmlinuz"
cp -fv "$CHROOT/boot"/initrd.img-* "$IMAGE/live/initrd.img"
mksquashfs "$CHROOT" "$IMAGE/live/filesystem.squashfs"
2022-08-10 16:31:57 +00:00
#mksquashfs -comp zstd -Xcompression-level 22 "$CHROOT" "$IMAGE/live/filesystem.squashfs"
2022-08-10 00:00:49 +00:00
2022-08-15 06:31:02 +00:00
echo "GRUB_TERMINAL=console
2022-08-10 00:00:49 +00:00
2022-08-15 06:31:02 +00:00
menuentry '$WDVN_NAME $WDVN_ARCH $WDVN_VER $WDVN_DATE live' --class gnu-linux --id linux {
insmod all_video
echo "Loading Linux ..."
linux /live/vmlinuz boot=live noautologin quiet
echo "Loading initrd ..."
initrd /live/initrd.img
}
" > "$IMAGE/boot/grub/grub.cfg"
2022-08-10 00:00:49 +00:00
2022-08-15 17:24:02 +00:00
grub-mkrescue -o "$2" "$IMAGE" --volid "$DISC_NAME"
2022-08-10 22:31:56 +00:00
2022-08-15 06:31:02 +00:00
rm -r "$IMAGE"