*.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=
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 <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
@ -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))

View File

@ -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] <rootfs-tarball>
cat <<-EOH
Usage: $PROGNAME [options] <platformfs-tarball>
The <rootfs-tarball> 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 <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
-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
Accepted size suffixes: KiB, MiB, GiB, TiB, EiB.
Resulting image will have 2 partitions, /boot and /.
_EOF
exit 0
The <platformfs-tarball> 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

View File

@ -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 <xbps-arch> Set XBPS_ARCH (do not use it unless you know what it is)
-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
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<version> Install a custom Linux version on ISO image (linux meta-package if unset).
-K Do not remove builddir.
To generate a more complete live ISO image, use build-x86-images.sh.
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
OPTIONS
-a <arch> Set XBPS_ARCH in the ISO image
-b <system-pkg> Set an alternative base package (default: base-system)
-r <repo> Use this XBPS repository. May be specified multiple times
-c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
-k <keymap> Default keymap to use (default: us)
-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() {
@ -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))

View File

@ -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))

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
# these down the road in later scripts.
usage() {
cat <<_EOF
Usage: $PROGNAME [options] <platform> <base-tarball>
cat <<-EOH
Usage: $PROGNAME [options] <platform> <rootfs-tarball>
Supported platforms: i686, x86_64, GCP,
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>)
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
-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
-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))

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
# 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,
Generate a Void Linux ROOTFS tarball for the specified architecture.
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
mipsel, mipsel-musl,
ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl
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>)
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
-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
-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