From c42abbd0f192a5d4a6a58fd901f45d2c06b018b5 Mon Sep 17 00:00:00 2001 From: davidovski Date: Sun, 15 Jan 2023 21:24:17 +0000 Subject: Add installer to iso --- iso/mkiso.sh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 iso/mkiso.sh (limited to 'iso/mkiso.sh') diff --git a/iso/mkiso.sh b/iso/mkiso.sh new file mode 100755 index 0000000..925c52a --- /dev/null +++ b/iso/mkiso.sh @@ -0,0 +1,93 @@ +#!/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 xitui" + +create_basesystem () { + xi $XI_ARGS sync + xi $XI_ARGS -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 + + cp -r ./root $chroot/ + + cat > $chroot/etc/conf.d/agetty << EOF +agetty_options="--autologin root --noclear" +EOF + +} + +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 quiet + +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