From fe1bbc2dcb3494a2160a1bea094f314da0eb3076 Mon Sep 17 00:00:00 2001 From: davidovski Date: Sun, 15 Jan 2023 15:48:34 +0000 Subject: Added working iso building script --- scripts/mkiso.sh | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 scripts/mkiso.sh (limited to 'scripts') diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh new file mode 100755 index 0000000..cc1d4ec --- /dev/null +++ b/scripts/mkiso.sh @@ -0,0 +1,94 @@ +#!/bin/sh + +ISO_NAME="xilinux-$(date -u +%Y%m%d)" +ISO_LABEL="xilinux" +PUBLISHER="davidovski" +SYSLINUX_VER=6.04-pre1 + +XI_ARGS="" + +chroot=/tmp/chroot +isoroot=/tmp/iso +iso_pkgs="linux linux-firmware base dracut grub bash xipkg squashfs-tools lvm2 cryptsetup networkmanager stty" + +create_basesystem () { + mkdir -p "$chroot" + + xi $XI_ARGS sync + [ ! -d "$chroot" ] && xi -r "$chroot" bootstrap + xi $XI_ARGS -r "$chroot" install "$iso_pkgs" + + cat > $chroot/etc/resolv.conf << EOF +nameserver 80.80.80.80 +EOF + + hostname=xilinux + echo xilinux > $chroot/etc/hostname + + cat > $chroot/etc/hosts << EOF +127.0.0.1 localhost +::1 localhost +127.0.1.1 $hostname.local $hostname +EOF + + xichroot $SYSROOT passwd + + xichroot "$chroot" +} + +build_initramfs () { + kernel_version=$(ls $chroot/usr/lib/modules | tail -1) + 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() { + mkdir -p $isoroot/ + cp $chroot/boot/vmlinuz-** $isoroot/vmlinuz + cp $chroot/boot/initramfs-** $isoroot/initrd.img + + mkdir -p $isoroot/isolinux +} + +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 + #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 +} + +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 + + + +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 " \ + -A "$ISO_LABEL" -o "$ISO_NAME.iso" $isoroot +} + + +[ "$#" = 0 ] && { + create_basesystem + build_initramfs + create_isoroot + install_syslinux + build_iso +} || { + for task in $*; do + $task + done +} -- cgit v1.2.1