*.sh: clean up help output

This commit is contained in:
classabbyamp 2023-10-02 16:37:32 -04:00 committed by classabbyamp
parent 787ddeb9e1
commit 65b9796340
6 changed files with 147 additions and 122 deletions

View File

@ -11,8 +11,28 @@ TRIPLET=
REPO= REPO=
DATE=$(date -u +%Y%m%d) DATE=$(date -u +%Y%m%d)
help() { usage() {
echo "$PROGNAME: [-a arch] [-b base|enlightenment|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-d date] [-t arch-date-variant] [-r repo]" >&2 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 <arch> Set XBPS_ARCH in the image
-b <variant> One of base, enlightenment, xfce, mate, cinnamon, gnome, kde,
lxde, or lxqt (default: base). May be specified multiple times
to build multiple variants
-d <date> Override the datestamp on the generated image (YYYYMMDD format)
-t <arch-date-variant>
Equivalent to setting -a, -b, and -d
-r <repo> 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 while getopts "a:b:d:t:hr:V" opt; do
@ -20,11 +40,11 @@ case $opt in
a) ARCH="$OPTARG";; a) ARCH="$OPTARG";;
b) IMAGES="$OPTARG";; b) IMAGES="$OPTARG";;
d) DATE="$OPTARG";; d) DATE="$OPTARG";;
h) help; exit 0;;
r) REPO="-r $OPTARG $REPO";; r) REPO="-r $OPTARG $REPO";;
t) TRIPLET="$OPTARG";; t) TRIPLET="$OPTARG";;
V) version; exit 0;; V) version; exit 0;;
*) help; exit 1;; h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -52,41 +52,37 @@ cleanup() {
[ -d "$ROOTFS" ] && rmdir "$ROOTFS" [ -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() { usage() {
cat <<_EOF cat <<-EOH
Usage: $PROGNAME [options] <rootfs-tarball> Usage: $PROGNAME [options] <platformfs-tarball>
The <rootfs-tarball> argument expects a tarball generated by void-mkrootfs. Generates a filesystem image suitable for writing with dd from a PLATFORMFS
The platform is guessed automatically by its name. 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 <fstype> /boot filesystem type (default: vfat)
-B <bsize> /boot filesystem size (default: 64MiB)
-r <fstype> / filesystem type (default: ext4)
-s <totalsize> Total image size (default: 2GiB)
-o <output> Image filename (default: guessed automatically)
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
OPTIONS Accepted size suffixes: KiB, MiB, GiB, TiB, EiB.
-b <fstype> Set /boot filesystem type (defaults to FAT)
-B <bsize> Set /boot filesystem size (defaults to 64MiB)
-r <fstype> Set / filesystem type (defaults to EXT4)
-s <totalsize> Set total image size (defaults to 2GB)
-o <output> Set image filename (guessed automatically)
-x <num> Use <num> threads to compress the image (dynamic if unset)
-h Show this help
-V Show version
Resulting image will have 2 partitions, /boot and /. The <platformfs-tarball> argument expects a tarball generated by mkplatformfs.sh.
_EOF The platform is guessed automatically by its name.
exit 0 EOH
} }
# ######################################## # ########################################
# SCRIPT EXECUTION STARTS HERE # 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 case $opt in
b) BOOT_FSTYPE="$OPTARG";; b) BOOT_FSTYPE="$OPTARG";;
B) BOOT_FSSIZE="$OPTARG";; B) BOOT_FSSIZE="$OPTARG";;
@ -95,14 +91,17 @@ while getopts "b:B:o:r:s:x:h:V" opt; do
s) IMGSIZE="$OPTARG";; s) IMGSIZE="$OPTARG";;
x) COMPRESSOR_THREADS="$OPTARG" ;; x) COMPRESSOR_THREADS="$OPTARG" ;;
V) version; exit 0;; V) version; exit 0;;
*) usage;; h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
ROOTFS_TARBALL="$1" ROOTFS_TARBALL="$1"
if [ -z "$ROOTFS_TARBALL" ]; then if [ -z "$ROOTFS_TARBALL" ]; then
usage echo "$PROGNAME: no ROOTFS tarball specified" >&2
usage >&2
exit 1
elif [ ! -r "$ROOTFS_TARBALL" ]; then elif [ ! -r "$ROOTFS_TARBALL" ]; then
# In rare cases the tarball can wind up owned by the wrong user. # In rare cases the tarball can wind up owned by the wrong user.
# This leads to confusing failures if execution is allowed to # This leads to confusing failures if execution is allowed to

View File

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
# #
# vim: set ts=4 sw=4 et:
#
#- #-
# Copyright (c) 2009-2015 Juan Romero Pardines. # Copyright (c) 2009-2015 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
@ -65,33 +63,35 @@ error_out() {
} }
usage() { usage() {
cat <<_EOF cat <<-EOH
Usage: $PROGNAME [options] Usage: $PROGNAME [options]
Options: Generates a basic live ISO image of Void Linux. This ISO image can be written
-a <xbps-arch> Set XBPS_ARCH (do not use it unless you know what it is) to a CD/DVD-ROM or any USB stick.
-b <system-pkg> Set an alternative base-system package (defaults to base-system).
-r <repo-url> Use this XBPS repository (may be specified multiple times).
-c <cachedir> Use this XBPS cache directory (a subdirectory of current
directory if unset).
-k <keymap> Default keymap to use (us if unset)
-l <locale> Default locale to use (en_US.UTF-8 if unset).
-i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset).
-s <gzip|lzo|xz> Compression type for the squashfs image (xz if unset)
-o <file> Output file name for the ISO image (auto if unset).
-p "pkg pkgN ..." Install additional packages into the ISO image.
-I <includedir> Include directory structure under given path into rootfs
-S "service serviceN ..." Services to enable
-C "cmdline args" Add additional kernel command line arguments. To generate a more complete live ISO image, use build-x86-images.sh.
-T "title" Modify the bootloader title.
-v linux<version> Install a custom Linux version on ISO image (linux meta-package if unset). OPTIONS
-K Do not remove builddir. -a <arch> Set XBPS_ARCH in the ISO image
-b <system-pkg> Set an alternative base package (default: base-system)
The $PROGNAME script generates a live image of the Void Linux distribution. -r <repo> Use this XBPS repository. May be specified multiple times
This ISO image can be written to a CD/DVD-ROM or any USB stick. -c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
_EOF -k <keymap> Default keymap to use (default: us)
exit 1 -l <locale> Default locale to use (default: en_US.UTF-8)
-i <lz4|gzip|bzip2|xz>
Compression type for the initramfs image (default: xz)
-s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)
-o <file> Output file name for the ISO image (default: automatic)
-p "<pkg> ..." Install additional packages in the ISO image
-I <includedir> Include directory structure under given path in the ROOTFS
-S "<service> ..." Enable services in the ISO image
-C "<arg> ..." Add additional kernel command line arguments
-T <title> 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() { 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";; T) BOOT_TITLE="$OPTARG";;
v) LINUX_VERSION="$OPTARG";; v) LINUX_VERSION="$OPTARG";;
V) version; exit 0;; V) version; exit 0;;
*) usage;; h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -1,7 +1,5 @@
#!/bin/sh #!/bin/sh
# #
# vim: set ts=4 sw=4 et:
#
#- #-
# Copyright (c) 2009-2015 Juan Romero Pardines. # Copyright (c) 2009-2015 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
@ -51,33 +49,33 @@ bailout() {
} }
usage() { usage() {
cat <<_EOF cat <<-EOH
Usage: $PROGNAME [options] <rootfs> Usage: $PROGNAME [options] <rootfs-tarball>
Options: Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs.
-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.
-k <keymap> Console keymap to set (us if unset) OPTIONS
-l <locale> Locale to set (en_US.UTF-8 if unset) -r <repo> Use this XBPS repository. May be specified multiple times
-c <cachedir> Use this XBPS cache directory (default: )
-C "cmdline args" Add additional kernel command line arguments. -i <lz4|gzip|bzip2|xz>
-T "title" Modify the bootloader title. Compression type for the initramfs image (default: xz)
-S "splash image" Set a custom splash image for the bootloader -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)
The $PROGNAME script generates a network-bootable tarball of Void Linux -k <keymap> Default keymap to use (default: us)
_EOF -l <locale> Default locale to use (default: en_US.UTF-8)
exit 1 -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 # 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 case $opt in
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";; r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
c) XBPS_CACHEDIR="--cachedir=$OPTARG";; 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";; l) LOCALE="$OPTARG";;
C) BOOT_CMDLINE="$OPTARG";; C) BOOT_CMDLINE="$OPTARG";;
T) BOOT_TITLE="$OPTARG";; T) BOOT_TITLE="$OPTARG";;
S) SPLASH_IMAGE="OPTARG";; S) SPLASH_IMAGE="$OPTARG";;
V) version; exit 0;; V) version; exit 0;;
*) usage;; h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -45,26 +45,29 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP
# in the script, and it makes it easier to consume the contents of # in the script, and it makes it easier to consume the contents of
# these down the road in later scripts. # these down the road in later scripts.
usage() { usage() {
cat <<_EOF cat <<-EOH
Usage: $PROGNAME [options] <platform> <base-tarball> 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, Supported platforms: i686, x86_64, GCP,
rpi-armv6l, rpi-armv7l, rpi-aarch64, rpi-armv6l, rpi-armv7l, rpi-aarch64,
pinebookpro, pinephone, rock64 pinebookpro, pinephone, rock64
Options OPTIONS
-b <syspkg> Set an alternative base-system package (defaults to base-system) -b <system-pkg> Set an alternative base-system package (default: base-system)
-p <pkgs> Additional packages to install into the rootfs (separated by blanks) -c <cachedir> Set the XBPS cache directory (default: ./xbps-cachedir-<arch>)
-k <cmd> Call "cmd <ROOTFSPATH>" after building the rootfs -C <file> Full path to the XBPS configuration file
-c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>) -k <cmd> Call '<cmd> <ROOTFSPATH>' after building the ROOTFS
-C <file> Full path to the XBPS configuration file -n Do not compress the image, instead print out the ROOTFS directory
-r <repo> Set XBPS repository (may be set multiple times) -o <file> Filename to write the PLATFORMFS archive to (default: automatic)
-x <num> Use <num> threads to compress the image (dynamic if unset) -p "<pkg> ..." Additional packages to install into the ROOTFS
-o <file> Filename to write the PLATFORMFS archive to -r <repo> Use this XBPS repository. May be specified multiple times
-n Do not compress the image, instead print out the rootfs directory -x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help -h Show this help and exit
-V Show version -V Show version and exit
_EOF EOH
} }
# ######################################## # ########################################
@ -86,7 +89,8 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do
o) FILENAME="$OPTARG" ;; o) FILENAME="$OPTARG" ;;
n) COMPRESSION="n" ;; n) COMPRESSION="n" ;;
V) version; exit 0;; V) version; exit 0;;
*) usage; exit 0 ;; h) usage; exit 0 ;;
*) usage >&2; exit 1 ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -46,27 +46,28 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP
# in the script, and it makes it easier to consume the contents of # in the script, and it makes it easier to consume the contents of
# these down the road in later scripts. # these down the road in later scripts.
usage() { usage() {
cat <<_EOF cat <<-EOH
Usage: $PROGNAME [options] <arch> Usage: $PROGNAME [options] <arch>
Supported architectures: i686, i686-musl, x86_64, x86_64-musl, Generate a Void Linux ROOTFS tarball for the specified architecture.
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
aarch64, aarch64-musl,
mipsel, mipsel-musl
ppc, ppc-musl
ppc64le, ppc64le-musl, ppc64, ppc64-musl
Supported architectures:
Options i686, i686-musl, x86_64, x86_64-musl,
-b <syspkg> Set an alternative base-system package (defaults to base-voidstrap) armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
-c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>) aarch64, aarch64-musl,
-C <file> Full path to the XBPS configuration file mipsel, mipsel-musl,
-h Show this help ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl
-r <repo> Set XBPS repository (may be set multiple times)
-x <num> Use <num> threads to compress the image (dynamic if unset) OPTIONS
-o <file> Filename to write the ROOTFS archive to -b <system-pkg> Set an alternative base-system package (default: base-voidstrap)
-V Show version -c <cachedir> Set XBPS cache directory (default: ./xbps-cachedir-<arch>)
_EOF -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" ;; x) COMPRESSOR_THREADS="$OPTARG" ;;
o) FILENAME="$OPTARG" ;; o) FILENAME="$OPTARG" ;;
V) version; exit 0;; V) version; exit 0;;
*) usage; exit 0;; h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -111,7 +113,7 @@ check_tools
# script will work without knowing what we're trying to build for. # script will work without knowing what we're trying to build for.
if [ -z "$XBPS_TARGET_ARCH" ]; then if [ -z "$XBPS_TARGET_ARCH" ]; then
echo "$PROGNAME: arch was not set!" echo "$PROGNAME: arch was not set!"
usage; exit 1 usage >&2; exit 1
fi fi
# We need to operate on a tempdir, if this fails to create, it is # We need to operate on a tempdir, if this fails to create, it is