diff options
Diffstat (limited to 'mklive.sh.in')
-rw-r--r-- | mklive.sh.in | 152 |
1 files changed, 80 insertions, 72 deletions
diff --git a/mklive.sh.in b/mklive.sh.in index c16495e..9e31155 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -88,48 +88,6 @@ and follow the on-screen instructions. Thanks for trying Void Linux. _EOF } -write_default_isolinux_conf() { - local kver="$1" - - if [ -r "$SPLASH_IMAGE" ]; then - BACKGROUND="MENU BACKGROUND $(basename $SPLASH_IMAGE)" - fi - - cat >> "$ISOLINUX_CFG" << _EOF -UI vesamenu.c32 -PROMPT 0 -TIMEOUT 100 -ONTIMEOUT linux - -MENU TABMSG Press ENTER to boot or TAB to edit a menu entry -MENU AUTOBOOT BIOS default device boot in # second{,s}... -$BACKGROUND -MENU WIDTH 78 -MENU MARGIN 1 -MENU ROWS 4 -MENU VSHIFT 2 -MENU TIMEOUTROW 8 -MENU TABMSGROW 2 -MENU CMDLINEROW 11 -MENU HELPMSGROW 16 -MENU HELPMSGENDROW 29 - -MENU COLOR title * #FF5255FF * -MENU COLOR border * #00000000 #00000000 none -MENU COLOR sel * #ffffffff #FF5255FF * - -LABEL linux -MENU LABEL Boot Void GNU/Linux ${kver} ($(uname -m)) -KERNEL vmlinuz -APPEND initrd=initrd.lz root=live:CDLABEL=VoidLinux-live-$(uname -m)-${kver} \ - rootfstype=auto ro liveimg rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 \ - vconsole.keymap=${KEYMAP} vconsole.unicode=1 locale.LANG=${LOCALE} -LABEL c -MENU LABEL Boot first HD found by BIOS -LOCALBOOT 0x80 -_EOF -} - write_conf_file() { cat > "$1" <<_EOF # *-*- sh -*-* @@ -171,7 +129,6 @@ Options: -k version Kernel version to use. -o outfile Output file name for the ISO image. -s splash Splash image file for isolinux. - -v volname ISO Volume name. _EOF exit 1 } @@ -179,14 +136,13 @@ _EOF # # main() # -while getopts "C:c:k:o:s:v:h" opt; do +while getopts "C:c:k:o:s:h" opt; do case $opt in C) CONFIG_FILE="$OPTARG";; c) COMPRESSTYPE="$OPTARG";; k) KERNELVERSION="$OPTARG";; o) OUTPUT_FILE="$OPTARG";; s) SPLASH_IMAGE="$OPTARG";; - v) ISO_VOLUME="$OPTARG";; h) usage;; esac done @@ -205,12 +161,15 @@ if [ -z "$OUTPUT_FILE" ]; then fi LOGFILE="$(mktemp -t vmklive-XXXXXXXXXX.log)" -if [ -z "$ISO_VOLUME" ]; then - ISO_VOLUME="VoidLinux-live-$(uname -m)-${KERNELVERSION}" -fi if [ -z "$SYSLINUX_DATADIR" ]; then SYSLINUX_DATADIR=/usr/share/syslinux fi +if [ -z "$GRUB_DATADIR" ]; then + GRUB_DATADIR=/usr/share/grub +fi +if [ -z "$MKLIVE_DATADIR" ]; then + MKLIVE_DATADIR=/usr/share/void-mklive +fi if [ -z "$SPLASH_IMAGE" ]; then SPLASH_IMAGE=/usr/share/void-artwork/splash.png fi @@ -251,10 +210,13 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi +ISO_VOLUME="VOID_LIVE" BUILDDIR=$(mktemp --tmpdir=$HOME -d) || exit 1 BUILDDIR=$(readlink -f $BUILDDIR) ROOTFS="$BUILDDIR/rootfs" -ISOLINUX_DIR="$BUILDDIR/isolinux" +BOOT_DIR="$BUILDDIR/boot" +ISOLINUX_DIR="$BOOT_DIR/isolinux" +GRUB_DIR="$BOOT_DIR/grub" ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" # @@ -270,8 +232,7 @@ fi # Mount pseudofs in the target rootfs. # mount_pseudofs -mkdir -p "$ROOTFS/tmp" -mkdir -p "$ISOLINUX_DIR" +mkdir -p "$ROOTFS/tmp" "$ISOLINUX_DIR" "$GRUB_DIR" XBPS_ARGS="-r $ROOTFS -y" if [ -n "$REPOSITORY_CACHE" ]; then @@ -284,7 +245,7 @@ case $XBPS_VERSION in esac info_msg "Redirecting stdout/stderr to $LOGFILE ..." -info_msg "[1/9] Installing packages into the rootfs..." +info_msg "[1/10] Installing packages into the rootfs..." for f in ${PACKAGE_LIST}; do info_msg " $f" done @@ -307,22 +268,22 @@ ${XBPS_BIN_CMD} -r "$ROOTFS" list > \ # # Prepare /etc/motd. # -info_msg "[2/9] Creating /etc/motd..." +info_msg "[2/10] Creating /etc/motd..." mkdir -p "$ROOTFS"/etc write_etc_motd # # Create the initramfs with XZ compression. # -info_msg "[3/9] Creating initramfs image ($COMPRESSTYPE)..." +info_msg "[3/10] Creating initramfs image ($COMPRESSTYPE)..." dracut --no-hostonly --add "dmsquash-live vmklive" --${COMPRESSTYPE} \ - "${ISOLINUX_DIR}/initrd.lz" ${KERNELVERSION} 2>/dev/null || error_out + "${BOOT_DIR}/initrd.lz" ${KERNELVERSION} 2>/dev/null || error_out # # Copy the linux image to the target directory. # -info_msg "[4/9] Copying kernel image/modules..." -cp -f /boot/vmlinuz-${KERNELVERSION} "${ISOLINUX_DIR}/vmlinuz" || error_out $? +info_msg "[4/10] Copying kernel image/modules..." +cp -f /boot/vmlinuz-${KERNELVERSION} "${BOOT_DIR}/vmlinuz" || error_out $? mkdir -p "$ROOTFS/lib/modules" cp -a /lib/modules/${KERNELVERSION} "$ROOTFS/lib/modules" || error_out $? @@ -404,20 +365,60 @@ install -Dm755 /bin/mount "$ROOTFS/bin/mount" || error_out $? umount_pseudofs # -# Copy required isolinux files in the target rootfs. +# Prepare isolinux files in the target rootfs. # -info_msg "[5/9] Copying isolinux files..." -cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" -cp -f $SYSLINUX_DATADIR/vesamenu.c32 "$ISOLINUX_DIR" -write_default_isolinux_conf ${KERNELVERSION} +info_msg "[5/10] Preparing isolinux support for BIOS..." +cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" || error_out $? +cp -f $SYSLINUX_DATADIR/vesamenu.c32 "$ISOLINUX_DIR" || error_out $? +cp -f $MKLIVE_DATADIR/isolinux.cfg.in \ + "$ISOLINUX_DIR"/isolinux.cfg || error_out $? + if [ -f "$SPLASH_IMAGE" ]; then - cp -f $SPLASH_IMAGE "$ISOLINUX_DIR" + cp -f $SPLASH_IMAGE "$ISOLINUX_DIR" || error_out $? fi +sed -i -e "s|@@SPLASHIMAGE@@|$(basename $SPLASH_IMAGE)|" \ + -e "s|@@KERNVER@@|${KERNELVERSION}|" \ + -e "s|@@KEYMAP@@|${KEYMAP}|" \ + -e "s|@@LOCALE@@|${LOCALE}|" $ISOLINUX_DIR/isolinux.cfg + +# +# Prepare grub files for EFI. +# +info_msg "[6/10] Preparing GRUB support for EFI..." +cp -f $MKLIVE_DATADIR/grub.cfg $GRUB_DIR || error_out $? +cp -f $MKLIVE_DATADIR/grub_void.cfg.in $GRUB_DIR/grub_void.cfg || error_out $? +sed -i -e "s|@@SPLASHIMAGE@@|$(basename $SPLASH_IMAGE)|" \ + -e "s|@@KERNVER@@|${KERNELVERSION}|" \ + -e "s|@@KEYMAP@@|${KEYMAP}|" \ + -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_void.cfg +mkdir -p $GRUB_DIR/fonts $GRUB_DIR/locale || error_out $? +cp -f $GRUB_DATADIR/unicode.pf2 $GRUB_DIR/fonts || error_out $? +cp -f /boot/grub/locale/* $GRUB_DIR/locale || error_out $? + +# Create EFI vfat image. +dd if=/dev/zero of=$GRUB_DIR/efiboot.img bs=1024 count=4096 \ + 2>&1 | cat >>$LOGFILE || error_out $? +mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" \ + 2>&1 | cat >>$LOGFILE || error_out $? + +GRUB_EFI_TMPDIR="$(mktemp --tmpdir=$HOME -d)" +LOOP_DEVICE="$(losetup --show --find ${GRUB_DIR}/efiboot.img)" +mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" \ + 2>&1 | cat >>$LOGFILE || error_out $? + +mkdir -p "${GRUB_EFI_TMPDIR}/EFI/boot/" || error_out $? +cd "$BUILDDIR" || error_out $? +grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi" --format="x86_64-efi" \ + --compression="xz" --output="${GRUB_EFI_TMPDIR}/EFI/boot/bootx64.efi" \ + "boot/grub/grub.cfg" 2>&1 | cat >>$LOGFILE || error_out $? +umount "$GRUB_EFI_TMPDIR" || error_out $? +losetup --detach "${LOOP_DEVICE}" || error_out $? +rm -rf $GRUB_EFI_TMPDIR || error_out $? # # Prepare the squashed rootfs image. # -info_msg "[6/9] Creating squashfs image ($COMPRESSTYPE) from rootfs..." +info_msg "[7/10] Creating squashfs image ($COMPRESSTYPE) from rootfs..." # Find out required size for the rootfs and create an ext3fs image off it. ROOTFS_SIZE=$(du -sk "$ROOTFS"|awk '{print $1}') mkdir -p "$BUILDDIR/tmp/LiveOS" @@ -435,19 +436,26 @@ mksquashfs "$BUILDDIR/tmp" "$BUILDDIR/LiveOS/squashfs.img" \ -comp ${COMPRESSTYPE} 2>&1 | cat >> $LOGFILE || error_out chmod 444 "$BUILDDIR/LiveOS/squashfs.img" || error_out $? -info_msg "[7/9] Removing rootfs directory..." +info_msg "[8/9] Removing rootfs directory..." rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp" || error_out $? # # Prepare the ISO image. # -info_msg "[8/9] Building ISO image..." -mkisofs -J -r -V "$ISO_VOLUME" -b isolinux/isolinux.bin \ - -c isolinux/boot.cat -no-emul-boot \ - -boot-load-size 4 -boot-info-table \ - -o "$OUTPUT_FILE" "$BUILDDIR" 2>&1 | cat >>$LOGFILE || error_out $? - -info_msg "[9/9] Removing build directory..." +info_msg "[9/10] Building ISO image..." +xorriso -as mkisofs \ + -iso-level 3 -rock -joliet \ + -max-iso9660-filenames -omit-period \ + -omit-version-number -relaxed-filenames -allow-lowercase \ + -volid "VOID_LIVE" \ + -eltorito-boot boot/isolinux/isolinux.bin \ + -eltorito-catalog boot/isolinux/boot.cat \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + -eltorito-alt-boot --efi-boot boot/grub/efiboot.img -no-emul-boot \ + -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \ + -output "$OUTPUT_FILE" "$BUILDDIR" 2>&1 | cat >>$LOGFILE || error_out $? + +info_msg "[10/10] Removing build directory..." rm -rf "$BUILDDIR" || error_out $? hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}') |