summaryrefslogtreecommitdiff
path: root/iso/mkiso.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-01-19 15:48:55 +0000
committerdavidovski <david@davidovski.xyz>2023-01-19 15:48:55 +0000
commitee1692eaf63404cadafabb407c709a2d2f5c071b (patch)
treef29831c1926386df85a0b261c9cd5d5e43111730 /iso/mkiso.sh
parent96509011d0cd432ecdf4d6ece555d970e281f6a5 (diff)
Fix bootstrap umounting efiv1.7.7
Diffstat (limited to 'iso/mkiso.sh')
-rwxr-xr-xiso/mkiso.sh114
1 files changed, 92 insertions, 22 deletions
diff --git a/iso/mkiso.sh b/iso/mkiso.sh
index 855c9dd..84a9782 100755
--- a/iso/mkiso.sh
+++ b/iso/mkiso.sh
@@ -1,20 +1,31 @@
#!/bin/sh
ISO_NAME="xilinux-$(date -u +%Y%m%d)"
-ISO_LABEL="xilinux"
+ISO_LABEL="XILINUX"
PUBLISHER="davidovski"
SYSLINUX_VER=6.04-pre1
-XI_ARGS=""
+XI_ARGS="-yq"
-chroot=/tmp/chroot
-isoroot=/tmp/iso
-iso_pkgs="linux linux-firmware base dracut grub mksh xipkg squashfs-tools lvm2 cryptsetup networkmanager stty xitui neofetch"
+WORKDIR=/tmp/xiiso
+
+chroot=$WORKDIR/chroot
+isoroot=$WORKDIR/iso
+iso_pkgs="linux linux-firmware base dracut grub mksh xipkg squashfs-tools lvm2 cryptsetup networkmanager stty xitui neofetch vim nano gnupg dosfstools"
+
+cmdline="splash console=tty0 console=ttyS0,9600 root=live:CDLABEL=$ISO_LABEL rd.live.dir=/ rd.live.squashimg=filesystem.squashfs rd.live.debug=1 quiet"
+
+grub_mod="all_video disk part_gpt part_msdos linux normal configfile search search_label efi_gop fat iso9660 cat echo ls test true help gzio"
+
+mkdir -p $WORKDIR
create_basesystem () {
xi $XI_ARGS sync
xi $XI_ARGS -r "$chroot" bootstrap
xi $XI_ARGS -r "$chroot" install "$iso_pkgs"
+}
+
+configure_system() {
cat > $chroot/etc/resolv.conf << EOF
nameserver 80.80.80.80
@@ -34,13 +45,18 @@ EOF
cat > $chroot/etc/conf.d/agetty << EOF
agetty_options="--autologin root --noclear"
EOF
+
+ xichroot $chroot rc-update add networkmanager
}
build_initramfs () {
kernel_version=$(ls $chroot/usr/lib/modules | tail -1)
+ export kernel_version
+
mkdir -p "$chroot"/var/tmp
xichroot "$chroot" dracut --nomdadmconf --nolvmconf --xz --add dmsquash-live --add bash --add convertfs --add pollcdrom --force --kver $kernel_version
+
}
create_isoroot() {
@@ -54,40 +70,94 @@ create_isoroot() {
install_syslinux () {
curl https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/$(echo $SYSLINUX_VER | cut -d'-' -f1)/syslinux-$SYSLINUX_VER.tar.xz > syslinux-$SYSLINUX_VER.tar.xz
- tar -C /tmp -xf syslinux-$SYSLINUX_VER.tar.xz
+ tar -C $WORKDIR -xf syslinux-$SYSLINUX_VER.tar.xz
#cp syslinux-$SYSLINUX_VER
- cp /tmp/syslinux-$SYSLINUX_VER/bios/core/isolinux.bin $isoroot/isolinux/isolinux.bin
- cp /tmp/syslinux-$SYSLINUX_VER/bios/com32/elflink/ldlinux/ldlinux.c32 $isoroot/isolinux/ldlinux.c32
-}
+ cp $WORKDIR/syslinux-$SYSLINUX_VER/bios/core/isolinux.bin $isoroot/isolinux/isolinux.bin
+ cp $WORKDIR/syslinux-$SYSLINUX_VER/bios/com32/elflink/ldlinux/ldlinux.c32 $isoroot/isolinux/ldlinux.c32
-build_iso () {
cat > $isoroot/isolinux/isolinux.cfg << EOF
default 1
label 1
kernel /vmlinuz
- append initrd=/initrd.img splash console=tty0 console=ttyS0,9600 root=live:CDLABEL=xilinux rd.live.dir=/ rd.live.squashimg=filesystem.squashfs rd.live.debug=1 quiet
+ append initrd=/initrd.img $cmdline
+EOF
+}
+
+build_grub_efi () {
+ mkdir -p $isoroot/boot/grub
+ cat > $isoroot/boot/grub/grub.cfg << EOF
+ set timeout_style=hidden
+ set timeout=0
+ menuentry "XiLinux" {
+ linux /vmlinuz $cmdline
+ initrd /initrd.img
+ }
+EOF
+ cksum=$(md5sum $isoroot/boot/grub/grub.cfg | cut -d' ' -f1)
+
+ mkdir -p $isoroot/efi/boot
+
+ cat > $WORKDIR/grub_early.$cksum.cfg << EOF
+ search --no-floppy --set=root --label "$ISO_LABEL"
+ set prefix=(\$root)/boot/grub
EOF
- mksquashfs $chroot $isoroot/filesystem.squashfs -noappend -no-progress -e "/proc/*" -e "/dev/*" -e "/sys/*"
- genisoimage -r -V "$ISO_LABEL" -cache-inodes -J -l \
- -allow-limited-size -udf \
- -b isolinux/isolinux.bin -c isolinux/boot.cat \
- -no-emul-boot -boot-load-size 4 -boot-info-table \
- -p "$PUBLISHER <xi@davidovski.xyz>" \
- -A "$ISO_LABEL" -o "$ISO_NAME.iso" $isoroot
+ grub-mkimage \
+ --config="$WORKDIR/grub_early.$cksum.cfg" \
+ --prefix="/boot/grub" \
+ --output="$isoroot/efi/boot/bootx64.efi" \
+ --format="x86_64-efi" \
+ --compression="xz" \
+ $grub_mod
+
+ mformat -i $isoroot/boot/grub/efi.img -C -f 1440 -N 0 ::
+ mcopy -i $isoroot/boot/grub/efi.img -s $isoroot/efi ::
+}
+
+build_iso () {
+ mksquashfs $chroot $isoroot/filesystem.squashfs -noappend -no-progress -e "/proc/*" -e "/dev/*" -e "/sys/*"
+ xorrisofs -output ${ISO_NAME}.iso \
+ -joliet \
+ -rational-rock \
+ -sysid LINUX \
+ -volid "$ISO_LABEL" \
+ -eltorito-boot isolinux/isolinux.bin \
+ -eltorito-catalog isolinux/boot.cat \
+ -no-emul-boot \
+ -boot-load-size 4 \
+ -boot-info-table \
+ -eltorito-alt-boot \
+ -e boot/grub/efi.img \
+ -no-emul-boot \
+ -isohybrid-gpt-basdat \
+ -follow-links \
+ $isoroot
+
+
+ printf "ISO written to $ISO_NAME.iso\n"
}
[ "$#" = 0 ] && {
+ steps="
create_basesystem
+ configure_system
build_initramfs
create_isoroot
- install_syslinux
+ install_syslinux
+ build_grub_efi
build_iso
+ "
} || {
- for task in $*; do
- $task
- done
+ steps="$*"
}
+
+for step in $steps; do
+ $step || {
+ printf "%s\n" "${RED}An error occured!"
+ exit 1
+ }
+done
+