diff --git a/README.md b/README.md index 42a6764..fb6c540 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,12 @@ This repository contains utilities for Void Linux: * mkrootfs (The Void Linux rootfs maker for ARM platforms) * mknet (Script to generate netboot tarballs for Void) -#### Dependencies +#### Build Dependencies + * make +#### Dependencies + * Compression type for the initramfs image + * liblz4 (for lz4, xz) (default) * xbps>=0.45 * qemu-user-static binaries (for mkrootfs) diff --git a/dracut/vmklive/copy-initramfs.sh b/dracut/vmklive/copy-initramfs.sh deleted file mode 100644 index ccb2178..0000000 --- a/dracut/vmklive/copy-initramfs.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -# Copy the initramfs back to the new rootfs for proper shutdown. -KVER=$(uname -r) -if [ -x /usr/bin/systemctl ]; then - cp /run/initramfs/live/boot/initrd $NEWROOT/boot/initramfs-${KVER}.img -fi diff --git a/installer.sh.in b/installer.sh.in index f9b311a..c007316 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -577,22 +577,22 @@ set_locale() { } menu_timezone() { - local _tzones="$(cd /usr/share/zoneinfo; find Africa/ America/ Antarctica/ Arctic/ Asia/ Atlantic/ Australia/ Europe/ Indian/ Pacific/ posix/ -type f | sort)" - local _TIMEZONES= + local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific) - for f in ${_tzones}; do - _TIMEZONES="${_TIMEZONES} ${f} -" - done - while true; do - DIALOG --title " Select your timezone " --menu "$MENULABEL" 14 70 14 ${_TIMEZONES} - if [ $? -eq 0 ]; then - set_option TIMEZONE "$(cat $ANSWER)" + local area locations location + while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do + area=$(cat $ANSWER) + read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort) + if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then + location=$(tr ' ' '_' < $ANSWER) + set_option TIMEZONE "$area/$location" TIMEZONE_DONE=1 - break + return 0 else - return + continue fi done + return 1 } set_timezone() { @@ -1342,7 +1342,7 @@ menu_source() { DIALOG --title " Select installation source " \ --menu "$MENULABEL" 8 70 0 \ "Local" "Packages from ISO image" \ - "Network" "Packages from official remote reposity" + "Network" "Base system only, downloaded from official reposity" case "$(cat $ANSWER)" in "Local") src="local";; "Network") src="net"; @@ -1425,7 +1425,7 @@ menu() { esac } -if [ ! -x /bin/dialog ]; then +if ! command -v dialog >/dev/null; then echo "ERROR: missing dialog command, exiting..." exit 1 fi diff --git a/lib.sh.in b/lib.sh.in index c5cc433..a108190 100644 --- a/lib.sh.in +++ b/lib.sh.in @@ -173,6 +173,18 @@ register_binfmt() { _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" QEMU_BIN=qemu-aarch64-static ;; + ppc64le*) + _cpu=ppc64le + _magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00" + _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00" + QEMU_BIN=qemu-ppc64le-static + ;; + ppc64*) + _cpu=ppc64 + _magic="\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15" + _mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" + QEMU_BIN=qemu-ppc64-static + ;; ppc*) _cpu=ppc _magic="\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14" diff --git a/mklive.sh.in b/mklive.sh.in index c568e45..a4dca79 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -155,13 +155,8 @@ generate_initramfs() { copy_dracut_files "$ROOTFS" copy_autoinstaller_files "$ROOTFS" - if [ "$BASE_SYSTEM_PKG" = "base-system-systemd" ]; then - _args="--add systemd" - else - _args="--omit systemd" - fi chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \ - --add-drivers "ahci" --force-add "vmklive autoinstaller" ${_args} "/boot/initrd" $KERNELVERSION + --add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION [ $? -ne 0 ] && die "Failed to generate the initramfs" mv "$ROOTFS"/boot/initrd "$BOOT_DIR" @@ -287,7 +282,7 @@ generate_iso_image() { -no-emul-boot -boot-load-size 4 -boot-info-table \ -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \ -isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \ - -output "$CURDIR/$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image" + -output "$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image" } # @@ -340,9 +335,6 @@ if [ "$(id -u)" -ne 0 ]; then die "Must be run as root, exiting..." fi -readonly CURDIR="$PWD" - - if [ -n "$ROOTDIR" ]; then BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d) else @@ -417,7 +409,7 @@ generate_squashfs print_step "Generating ISO image..." generate_iso_image -hsize=$(du -sh "$CURDIR/$OUTPUT_FILE"|awk '{print $1}') -info_msg "Created $(readlink -f "$CURDIR"/"$OUTPUT_FILE") ($hsize) successfully." +hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}') +info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully." diff --git a/mkplatformfs.sh.in b/mkplatformfs.sh.in index 9692bcd..dfd860c 100644 --- a/mkplatformfs.sh.in +++ b/mkplatformfs.sh.in @@ -61,6 +61,7 @@ Options -C Full path to the XBPS configuration file -r Set XBPS repository (may be set multiple times) -x Use threads to compress the image (dynamic if unset) + -n Do not compress the image, instead print out the rootfs directory -h Show this help -V Show version _EOF @@ -71,8 +72,9 @@ _EOF # ######################################## BASEPKG=base-system +COMPRESSION="y" -while getopts "b:p:k:c:C:r:x:hV" opt; do +while getopts "b:p:k:c:C:r:x:nhV" opt; do case $opt in b) BASEPKG="$OPTARG" ;; p) EXTRA_PKGS="$OPTARG" ;; @@ -81,6 +83,7 @@ while getopts "b:p:k:c:C:r:x:hV" opt; do C) XBPS_CONFFILE="-C $OPTARG" ;; r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG" ;; x) COMPRESSOR_THREADS="$OPTARG" ;; + n) COMPRESSION="n" ;; h) usage; exit 0 ;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;; esac @@ -143,6 +146,10 @@ ROOTFS=$(mktemp -d) || die "failed to create tempdir, exiting..." # Now that we have a directory for the ROOTFS, we can expand the # existing base filesystem into the directory +if [ ! -e "$BASE_TARBALL" ]; then + die "no valid base tarball given, exiting." +fi + info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build." tar xf "$BASE_TARBALL" -C "$ROOTFS" @@ -203,17 +210,31 @@ cleanup_chroot # only for it to be out of date, we remove it now. rm -rf "$ROOTFS/var/cache/*" 2>/dev/null -# Finally we can compress the tarball, the name will include the -# platform and the date on which the tarball was built. -tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz -run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " +# Now we can run the POST_CMD script. This user-supplied script gets the +# $ROOTFS as a parameter. +if [ -n "$POST_CMD" ]; then + info_msg "Running user supllied command: $POST_CMD" + run_cmd $POST_CMD $ROOTFS +fi -# Now that we have the tarball we don't need the rootfs anymore, so we -# can get rid of it. -rm -rf "$ROOTFS" -# Last thing to do before closing out is to let the user know that -# this succeeded. This also ensures that there's something visible -# that the user can look for at the end of the script, which can make -# it easier to see what's going on if something above failed. -info_msg "Successfully created $tarball ($PLATFORM)" +# Compress the tarball or just print out the path? +if [ "$COMPRESSION" = "y" ]; then + # Finally we can compress the tarball, the name will include the + # platform and the date on which the tarball was built. + tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz + run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " + + # Now that we have the tarball we don't need the rootfs anymore, so we + # can get rid of it. + rm -rf "$ROOTFS" + + # Last thing to do before closing out is to let the user know that + # this succeeded. This also ensures that there's something visible + # that the user can look for at the end of the script, which can make + # it easier to see what's going on if something above failed. + info_msg "Successfully created $tarball ($PLATFORM)" +else + # User requested just printing out the path to the rootfs, here it comes. + info_msg "Successfully created rootfs under $ROOTFS" +fi diff --git a/mkrootfs.sh.in b/mkrootfs.sh.in index c0309ec..93b9f94 100644 --- a/mkrootfs.sh.in +++ b/mkrootfs.sh.in @@ -53,11 +53,12 @@ Supported architectures: i686, i686-musl, x86_64, x86_64-musl, armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl aarch64, aarch64-musl, mipsel, mipsel-musl - ppc + ppc, ppc-musl + ppc64le, ppc64le-musl, ppc64, ppc64-musl Options - -b Set an alternative base-system package (defaults to base-system) + -b Set an alternative base-system package (defaults to base-voidstrap) -c Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-) -C Full path to the XBPS configuration file -h Show this help @@ -72,10 +73,14 @@ _EOF # SCRIPT EXECUTION STARTS HERE # ######################################## +# Set the default system package. +SYSPKG="base-voidstrap" + # Boilerplate option parsing. This script supports the bare minimum # needed to build an image. -while getopts "C:c:hr:x:o:V" opt; do +while getopts "b:C:c:hr:x:o:V" opt; do case $opt in + b) SYSPKG="$OPTARG";; C) XBPS_CONFFILE="-C $OPTARG";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";; h) usage; exit 0;; @@ -136,10 +141,10 @@ chmod 755 "$ROOTFS" mount_pseudofs # With everything setup, we can now run the install to load the -# base-voidstrap package into the rootfs. This will not produce a +# system package into the rootfs. This will not produce a # bootable system but will instead produce a base component that can # be quickly expanded to perform other actions on. -run_cmd_target "xbps-install -S $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -y base-voidstrap" +run_cmd_target "xbps-install -S $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -y $SYSPKG" # Enable en_US.UTF-8 locale and generate it into the target ROOTFS. # This is a bit of a hack since some glibc stuff doesn't really work