#!/bin/bash CWD=$(pwd) SOURCE=/run/initramfs/memory TEMP=/tmp REGEX='^$' if [ "$1" = "-e" ]; then REGEX="$2" shift shift fi TARGET="$(readlink -f "$1")" if [ "$TARGET" = "" ]; then echo "" echo "Generate MiniOS ISO image, adding specified modules" echo "Regular expression is used to exclude any existing path or file with -e regex" echo "" echo "Usage:" echo " $0 [[ -e regex ]] target.iso [[module.sb]] [[module.sb]] ..." echo "" echo "Examples:" echo " # to create MiniOS iso without chromium.sb module:" echo " $0 -e 'chromium' minios_without_chromium.iso" echo "" echo " # to create MiniOS text-mode core only:" echo " $0 -e 'firmware|xorg|desktop|apps|chromium' minios_textmode.iso" exit 1 fi if [ -e "$SOURCE/data/boot/syslinux/isolinux.bin" ]; then MINIOS=$SOURCE/data fi if [ "$MINIOS" = "" ]; then echo "Cannot find boot/isolinux.bin in MiniOS data" >&2 exit 2 fi VER=2021 DATE=$(date +%Y-%m-%d-%H-%M) DIR=$MINIOS ; ISO=$TEMP/minios_$DATE.iso [ -n "$1" ] && ISO="$1" B="-b boot/syslinux/isolinux.bin -c boot/syslinux/boot.cat" C="-no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot" if [ -x "$(which xorriso 2> /dev/null)" ]; then M="xorriso -as mkisofs -isohybrid-mbr $DIR/boot/syslinux/isohdpfx.bin" D=" -isohybrid-gpt-basdat -e" elif [ -x "$(which genisoimage 2> /dev/null)" ]; then M=genisoimage ; D="-efi-boot" else M=mkisofs ; D="-eltorito-platform 0xEF -eltorito-boot" fi E="EFI/boot/efiboot.img -no-emul-boot" VER="MiniOS $VER" if ! $M -hide-rr-moved -f -r -J -l -V "$VER" -A "$VER" \ $B $C $D $E -o $ISO $DIR ; then exit 1 fi echo ">>> $ISO created" # xorriso has hybridization built-in if [ "$(echo $M | cut -d" " -f1)" != "xorriso" ]; then if [ -x "$(which isohybrid 2> /dev/null)" ]; then isohybrid -uefi $ISO else echo ">>> No isohybrid to hybridize this ISO" fi fi exit 0