windvn/path/wdvn-image-iso (copy 1)

88 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# https://gist.github.com/Sirherobrine23/6d680d3027a0b032fb950b1770f03a45
set -e
set -x
DISC_NAME="Linux"
CHROOT="$1"
IMAGE="$2.tmp"
OLDPWD="$(pwd)"
mkdir -p "$IMAGE/casper"
mkdir -p "$IMAGE/isolinux"
# Boot
cp -fv "$CHROOT/boot"/vmlinuz-* "$IMAGE/casper/vmlinuz"
cp -fv "$CHROOT/boot"/initrd.img-* "$IMAGE/casper/initrd"
# ------
#
chroot "$CHROOT" dpkg-query -W --showformat='${Package} ${Version}\n' | tee "$IMAGE/casper/filesystem.manifest"
cp -v "$IMAGE/casper/filesystem.manifest" "$IMAGE/casper/filesystem.manifest-desktop"
sed -i '/ubiquity/d' "$IMAGE/casper/filesystem.manifest-desktop"
sed -i '/casper/d' "$IMAGE/casper/filesystem.manifest-desktop"
sed -i '/discover/d' "$IMAGE/casper/filesystem.manifest-desktop"
sed -i '/laptop-detect/d' "$IMAGE/casper/filesystem.manifest-desktop"
sed -i '/os-prober/d' "$IMAGE/casper/filesystem.manifest-desktop"
# Create read-only
if [ -e "$IMAGE/casper/filesystem.squashfs" ];then
rm -rfv "$IMAGE/casper/filesystem.squashfs"
fi
mksquashfs "$CHROOT" "$IMAGE/casper/filesystem.squashfs"
# squashFS Size
printf $(du -sx --block-size=1 "$CHROOT" | cut -f1) > "$IMAGE/casper/filesystem.size"
# IMAGE DIR
# --------
# README.diskdefines
echo "#define DISKNAME $DISC_NAME
#define TYPE binary
#define TYPEbinary 1
#define ARCH amd64
#define ARCHamd64 1
#define DISKNUM 1
#define DISKNUM1 1
#define TOTALNUM 0
#define TOTALNUM0 1" > "$IMAGE/README.diskdefines"
echo 'UI menu.c32
MENU TITLE Boot Menu
DEFAULT linux
TIMEOUT 600
LABEL linux
MENU LABEL windvn live
MENU DEFAULT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd boot=casper selinux=disabled
LABEL linux
MENU LABEL windvn live (nomodeset)
MENU DEFAULT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd boot=casper selinux=disabled nomodeset
' > "$IMAGE/isolinux/isolinux.cfg"
cp /usr/lib/ISOLINUX/isolinux.bin "$IMAGE/isolinux/"
cp /usr/lib/syslinux/modules/bios/* "$IMAGE/isolinux/"
xorriso \
-as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-volid "$DISC_NAME" \
-output "$2" \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-eltorito-boot \
isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--eltorito-catalog isolinux/isolinux.cat \
"$IMAGE"
# -eltorito-alt-boot \
# -e /EFI/boot/efiboot.img \
# -no-emul-boot \
# -isohybrid-gpt-basdat \
# -append_partition 2 0xef EFI/boot/efiboot.img \
# "$IMAGE"