diff --git a/build-x86-images.sh b/build-x86-images.sh index bbf7c26..8b64a07 100755 --- a/build-x86-images.sh +++ b/build-x86-images.sh @@ -11,8 +11,28 @@ TRIPLET= REPO= DATE=$(date -u +%Y%m%d) -help() { - echo "$PROGNAME: [-a arch] [-b base|enlightenment|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-d date] [-t arch-date-variant] [-r repo]" >&2 +usage() { + cat <<-EOH + Usage: $PROGNAME [options ...] [-- mklive options ...] + + Wrapper script around mklive.sh for several standard flavors of live images. + Adds void-installer and other helpful utilities to the generated images. + + OPTIONS + -a Set XBPS_ARCH in the image + -b One of base, enlightenment, xfce, mate, cinnamon, gnome, kde, + lxde, or lxqt (default: base). May be specified multiple times + to build multiple variants + -d Override the datestamp on the generated image (YYYYMMDD format) + -t + Equivalent to setting -a, -b, and -d + -r Use this XBPS repository. May be specified multiple times + -h Show this help and exit + -V Show version and exit + + Other options can be passed directly to mklive.sh by specifying them after the --. + See mklive.sh -h for more details. + EOH } while getopts "a:b:d:t:hr:V" opt; do @@ -20,11 +40,11 @@ case $opt in a) ARCH="$OPTARG";; b) IMAGES="$OPTARG";; d) DATE="$OPTARG";; - h) help; exit 0;; r) REPO="-r $OPTARG $REPO";; t) TRIPLET="$OPTARG";; V) version; exit 0;; - *) help; exit 1;; + h) usage; exit 0;; + *) usage >&2; exit 1;; esac done shift $((OPTIND - 1)) diff --git a/mkimage.sh b/mkimage.sh index bb784e1..5c64fe6 100755 --- a/mkimage.sh +++ b/mkimage.sh @@ -52,41 +52,37 @@ cleanup() { [ -d "$ROOTFS" ] && rmdir "$ROOTFS" } - -# This script is designed to take in a complete platformfs and spit -# out an image that is suitable for writing with dd. The image is -# configurable in terms of the filesystem layout, but not in terms of -# the installed system itself. Customization to the installed system -# should be made during the mkplatformfs step. usage() { - cat <<_EOF -Usage: $PROGNAME [options] + cat <<-EOH + Usage: $PROGNAME [options] -The argument expects a tarball generated by void-mkrootfs. -The platform is guessed automatically by its name. + Generates a filesystem image suitable for writing with dd from a PLATFORMFS + tarball generated by mkplatformfs.sh. The filesystem layout is configurable, + but customization of the installed system should be done when generating the + PLATFORMFS. The resulting image will have 2 partitions, /boot and /. -Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB. + OPTIONS + -b /boot filesystem type (default: vfat) + -B /boot filesystem size (default: 64MiB) + -r / filesystem type (default: ext4) + -s Total image size (default: 2GiB) + -o Image filename (default: guessed automatically) + -x Number of threads to use for image compression (default: dynamic) + -h Show this help and exit + -V Show version and exit -OPTIONS - -b Set /boot filesystem type (defaults to FAT) - -B Set /boot filesystem size (defaults to 64MiB) - -r Set / filesystem type (defaults to EXT4) - -s Set total image size (defaults to 2GB) - -o Set image filename (guessed automatically) - -x Use threads to compress the image (dynamic if unset) - -h Show this help - -V Show version + Accepted size suffixes: KiB, MiB, GiB, TiB, EiB. -Resulting image will have 2 partitions, /boot and /. -_EOF - exit 0 + The argument expects a tarball generated by mkplatformfs.sh. + The platform is guessed automatically by its name. + EOH } # ######################################## # SCRIPT EXECUTION STARTS HERE # ######################################## -while getopts "b:B:o:r:s:x:h:V" opt; do +while getopts "b:B:o:r:s:x:hV" opt; do case $opt in b) BOOT_FSTYPE="$OPTARG";; B) BOOT_FSSIZE="$OPTARG";; @@ -95,14 +91,17 @@ while getopts "b:B:o:r:s:x:h:V" opt; do s) IMGSIZE="$OPTARG";; x) COMPRESSOR_THREADS="$OPTARG" ;; V) version; exit 0;; - *) usage;; + h) usage; exit 0;; + *) usage >&2; exit 1;; esac done shift $((OPTIND - 1)) ROOTFS_TARBALL="$1" if [ -z "$ROOTFS_TARBALL" ]; then - usage + echo "$PROGNAME: no ROOTFS tarball specified" >&2 + usage >&2 + exit 1 elif [ ! -r "$ROOTFS_TARBALL" ]; then # In rare cases the tarball can wind up owned by the wrong user. # This leads to confusing failures if execution is allowed to diff --git a/mklive.sh b/mklive.sh index a83bbae..a1d4a5c 100755 --- a/mklive.sh +++ b/mklive.sh @@ -1,7 +1,5 @@ #!/bin/bash # -# vim: set ts=4 sw=4 et: -# #- # Copyright (c) 2009-2015 Juan Romero Pardines. # All rights reserved. @@ -65,33 +63,35 @@ error_out() { } usage() { - cat <<_EOF -Usage: $PROGNAME [options] + cat <<-EOH + Usage: $PROGNAME [options] -Options: - -a Set XBPS_ARCH (do not use it unless you know what it is) - -b Set an alternative base-system package (defaults to base-system). - -r Use this XBPS repository (may be specified multiple times). - -c Use this XBPS cache directory (a subdirectory of current -directory if unset). - -k Default keymap to use (us if unset) - -l Default locale to use (en_US.UTF-8 if unset). - -i Compression type for the initramfs image (xz if unset). - -s Compression type for the squashfs image (xz if unset) - -o Output file name for the ISO image (auto if unset). - -p "pkg pkgN ..." Install additional packages into the ISO image. - -I Include directory structure under given path into rootfs - -S "service serviceN ..." Services to enable + Generates a basic live ISO image of Void Linux. This ISO image can be written + to a CD/DVD-ROM or any USB stick. - -C "cmdline args" Add additional kernel command line arguments. - -T "title" Modify the bootloader title. - -v linux Install a custom Linux version on ISO image (linux meta-package if unset). - -K Do not remove builddir. - -The $PROGNAME script generates a live image of the Void Linux distribution. -This ISO image can be written to a CD/DVD-ROM or any USB stick. -_EOF - exit 1 + To generate a more complete live ISO image, use build-x86-images.sh. + + OPTIONS + -a Set XBPS_ARCH in the ISO image + -b Set an alternative base package (default: base-system) + -r Use this XBPS repository. May be specified multiple times + -c Use this XBPS cache directory (default: ./xbps-cachedir-) + -k Default keymap to use (default: us) + -l Default locale to use (default: en_US.UTF-8) + -i + Compression type for the initramfs image (default: xz) + -s Compression type for the squashfs image (default: xz) + -o Output file name for the ISO image (default: automatic) + -p " ..." Install additional packages in the ISO image + -I Include directory structure under given path in the ROOTFS + -S " ..." Enable services in the ISO image + -C " ..." Add additional kernel command line arguments + -T Modify the bootloader title (default: Void Linux) + -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage) + -K Do not remove builddir + -h Show this help and exit + -V Show version and exit + EOH } copy_void_keys() { @@ -321,7 +321,8 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:Vh" opt; do T) BOOT_TITLE="$OPTARG";; v) LINUX_VERSION="$OPTARG";; V) version; exit 0;; - *) usage;; + h) usage; exit 0;; + *) usage >&2; exit 1;; esac done shift $((OPTIND - 1)) diff --git a/mknet.sh b/mknet.sh index 8932b38..3d85896 100755 --- a/mknet.sh +++ b/mknet.sh @@ -1,7 +1,5 @@ #!/bin/sh # -# vim: set ts=4 sw=4 et: -# #- # Copyright (c) 2009-2015 Juan Romero Pardines. # All rights reserved. @@ -51,33 +49,33 @@ bailout() { } usage() { - cat <<_EOF -Usage: $PROGNAME [options] <rootfs> + cat <<-EOH + Usage: $PROGNAME [options] <rootfs-tarball> -Options: - -r <repo-url> Use this XBPS repository (may be specified multiple times). - -c <cachedir> Use this XBPS cache directory. - -i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset). - -o <file> Output file name for the netboot tarball (auto if unset). - -K <kernelpkg> Use <kernelpkg> instead of 'linux' to build the image. + Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs. - -k <keymap> Console keymap to set (us if unset) - -l <locale> Locale to set (en_US.UTF-8 if unset) - - -C "cmdline args" Add additional kernel command line arguments. - -T "title" Modify the bootloader title. - -S "splash image" Set a custom splash image for the bootloader - -The $PROGNAME script generates a network-bootable tarball of Void Linux -_EOF - exit 1 + OPTIONS + -r <repo> Use this XBPS repository. May be specified multiple times + -c <cachedir> Use this XBPS cache directory (default: ) + -i <lz4|gzip|bzip2|xz> + Compression type for the initramfs image (default: xz) + -o <file> Output file name for the netboot tarball (default: automatic) + -K linux<version> Install a custom Linux version on ISO image (default: linux metapackage) + -k <keymap> Default keymap to use (default: us) + -l <locale> Default locale to use (default: en_US.UTF-8) + -C "<arg> ..." Add additional kernel command line arguments + -T <title> Modify the bootloader title (default: Void Linux) + -S <image> Set a custom splash image for the bootloader (default: data/splash.png) + -h Show this help and exit + -V Show version and exit + EOH } # ######################################## # SCRIPT EXECUTION STARTS HERE # ######################################## -while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do +while getopts "r:c:C:T:K:i:o:k:l:S:Vh" opt; do case $opt in r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";; @@ -88,9 +86,10 @@ while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do l) LOCALE="$OPTARG";; C) BOOT_CMDLINE="$OPTARG";; T) BOOT_TITLE="$OPTARG";; - S) SPLASH_IMAGE="OPTARG";; + S) SPLASH_IMAGE="$OPTARG";; V) version; exit 0;; - *) usage;; + h) usage; exit 0;; + *) usage >&2; exit 1;; esac done shift $((OPTIND - 1)) diff --git a/mkplatformfs.sh b/mkplatformfs.sh index 6e14299..f56177a 100755 --- a/mkplatformfs.sh +++ b/mkplatformfs.sh @@ -45,26 +45,29 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP # in the script, and it makes it easier to consume the contents of # these down the road in later scripts. usage() { - cat <<_EOF -Usage: $PROGNAME [options] <platform> <base-tarball> + cat <<-EOH + Usage: $PROGNAME [options] <platform> <rootfs-tarball> + + Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS + generated by mkrootfs.sh. -Supported platforms: i686, x86_64, GCP, - rpi-armv6l, rpi-armv7l, rpi-aarch64, - pinebookpro, pinephone, rock64 - -Options - -b <syspkg> Set an alternative base-system package (defaults to base-system) - -p <pkgs> Additional packages to install into the rootfs (separated by blanks) - -k <cmd> Call "cmd <ROOTFSPATH>" after building the rootfs - -c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>) - -C <file> Full path to the XBPS configuration file - -r <repo> Set XBPS repository (may be set multiple times) - -x <num> Use <num> threads to compress the image (dynamic if unset) - -o <file> Filename to write the PLATFORMFS archive to - -n Do not compress the image, instead print out the rootfs directory - -h Show this help - -V Show version -_EOF + Supported platforms: i686, x86_64, GCP, + rpi-armv6l, rpi-armv7l, rpi-aarch64, + pinebookpro, pinephone, rock64 + + OPTIONS + -b <system-pkg> Set an alternative base-system package (default: base-system) + -c <cachedir> Set the XBPS cache directory (default: ./xbps-cachedir-<arch>) + -C <file> Full path to the XBPS configuration file + -k <cmd> Call '<cmd> <ROOTFSPATH>' after building the ROOTFS + -n Do not compress the image, instead print out the ROOTFS directory + -o <file> Filename to write the PLATFORMFS archive to (default: automatic) + -p "<pkg> ..." Additional packages to install into the ROOTFS + -r <repo> Use this XBPS repository. May be specified multiple times + -x <num> Number of threads to use for image compression (default: dynamic) + -h Show this help and exit + -V Show version and exit + EOH } # ######################################## @@ -86,7 +89,8 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do o) FILENAME="$OPTARG" ;; n) COMPRESSION="n" ;; V) version; exit 0;; - *) usage; exit 0 ;; + h) usage; exit 0 ;; + *) usage >&2; exit 1 ;; esac done shift $((OPTIND - 1)) diff --git a/mkrootfs.sh b/mkrootfs.sh index 8e77e4f..b689ba8 100755 --- a/mkrootfs.sh +++ b/mkrootfs.sh @@ -46,27 +46,28 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP # in the script, and it makes it easier to consume the contents of # these down the road in later scripts. usage() { - cat <<_EOF -Usage: $PROGNAME [options] <arch> + cat <<-EOH + Usage: $PROGNAME [options] <arch> -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-musl - ppc64le, ppc64le-musl, ppc64, ppc64-musl + Generate a Void Linux ROOTFS tarball for the specified architecture. - -Options - -b <syspkg> Set an alternative base-system package (defaults to base-voidstrap) - -c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>) - -C <file> Full path to the XBPS configuration file - -h Show this help - -r <repo> Set XBPS repository (may be set multiple times) - -x <num> Use <num> threads to compress the image (dynamic if unset) - -o <file> Filename to write the ROOTFS archive to - -V Show version -_EOF + 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-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl + + OPTIONS + -b <system-pkg> Set an alternative base-system package (default: base-voidstrap) + -c <cachedir> Set XBPS cache directory (default: ./xbps-cachedir-<arch>) + -C <file> Full path to the XBPS configuration file + -r <repo> Use this XBPS repository. May be specified multiple times + -o <file> Filename to write the ROOTFS to (default: automatic) + -x <num> Number of threads to use for image compression (default: dynamic) + -h Show this help and exit + -V Show version and exit + EOH } # ######################################## @@ -87,7 +88,8 @@ while getopts "b:C:c:hr:x:o:V" opt; do x) COMPRESSOR_THREADS="$OPTARG" ;; o) FILENAME="$OPTARG" ;; V) version; exit 0;; - *) usage; exit 0;; + h) usage; exit 0;; + *) usage >&2; exit 1;; esac done shift $((OPTIND - 1)) @@ -111,7 +113,7 @@ check_tools # script will work without knowing what we're trying to build for. if [ -z "$XBPS_TARGET_ARCH" ]; then echo "$PROGNAME: arch was not set!" - usage; exit 1 + usage >&2; exit 1 fi # We need to operate on a tempdir, if this fails to create, it is