Skip to content

Commit 65b9796

Browse files
committed
*.sh: clean up help output
1 parent 787ddeb commit 65b9796

6 files changed

Lines changed: 158 additions & 133 deletions

File tree

build-x86-images.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,40 @@ TRIPLET=
1111
REPO=
1212
DATE=$(date -u +%Y%m%d)
1313

14-
help() {
15-
echo "$PROGNAME: [-a arch] [-b base|enlightenment|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-d date] [-t arch-date-variant] [-r repo]" >&2
14+
usage() {
15+
cat <<-EOH
16+
Usage: $PROGNAME [options ...] [-- mklive options ...]
17+
18+
Wrapper script around mklive.sh for several standard flavors of live images.
19+
Adds void-installer and other helpful utilities to the generated images.
20+
21+
OPTIONS
22+
-a <arch> Set XBPS_ARCH in the image
23+
-b <variant> One of base, enlightenment, xfce, mate, cinnamon, gnome, kde,
24+
lxde, or lxqt (default: base). May be specified multiple times
25+
to build multiple variants
26+
-d <date> Override the datestamp on the generated image (YYYYMMDD format)
27+
-t <arch-date-variant>
28+
Equivalent to setting -a, -b, and -d
29+
-r <repo> Use this XBPS repository. May be specified multiple times
30+
-h Show this help and exit
31+
-V Show version and exit
32+
33+
Other options can be passed directly to mklive.sh by specifying them after the --.
34+
See mklive.sh -h for more details.
35+
EOH
1636
}
1737

1838
while getopts "a:b:d:t:hr:V" opt; do
1939
case $opt in
2040
a) ARCH="$OPTARG";;
2141
b) IMAGES="$OPTARG";;
2242
d) DATE="$OPTARG";;
23-
h) help; exit 0;;
2443
r) REPO="-r $OPTARG $REPO";;
2544
t) TRIPLET="$OPTARG";;
2645
V) version; exit 0;;
27-
*) help; exit 1;;
46+
h) usage; exit 0;;
47+
*) usage >&2; exit 1;;
2848
esac
2949
done
3050
shift $((OPTIND - 1))

mkimage.sh

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,37 @@ cleanup() {
5252
[ -d "$ROOTFS" ] && rmdir "$ROOTFS"
5353
}
5454

55-
56-
# This script is designed to take in a complete platformfs and spit
57-
# out an image that is suitable for writing with dd. The image is
58-
# configurable in terms of the filesystem layout, but not in terms of
59-
# the installed system itself. Customization to the installed system
60-
# should be made during the mkplatformfs step.
6155
usage() {
62-
cat <<_EOF
63-
Usage: $PROGNAME [options] <rootfs-tarball>
64-
65-
The <rootfs-tarball> argument expects a tarball generated by void-mkrootfs.
66-
The platform is guessed automatically by its name.
67-
68-
Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB.
69-
70-
OPTIONS
71-
-b <fstype> Set /boot filesystem type (defaults to FAT)
72-
-B <bsize> Set /boot filesystem size (defaults to 64MiB)
73-
-r <fstype> Set / filesystem type (defaults to EXT4)
74-
-s <totalsize> Set total image size (defaults to 2GB)
75-
-o <output> Set image filename (guessed automatically)
76-
-x <num> Use <num> threads to compress the image (dynamic if unset)
77-
-h Show this help
78-
-V Show version
79-
80-
Resulting image will have 2 partitions, /boot and /.
81-
_EOF
82-
exit 0
56+
cat <<-EOH
57+
Usage: $PROGNAME [options] <platformfs-tarball>
58+
59+
Generates a filesystem image suitable for writing with dd from a PLATFORMFS
60+
tarball generated by mkplatformfs.sh. The filesystem layout is configurable,
61+
but customization of the installed system should be done when generating the
62+
PLATFORMFS. The resulting image will have 2 partitions, /boot and /.
63+
64+
OPTIONS
65+
-b <fstype> /boot filesystem type (default: vfat)
66+
-B <bsize> /boot filesystem size (default: 64MiB)
67+
-r <fstype> / filesystem type (default: ext4)
68+
-s <totalsize> Total image size (default: 2GiB)
69+
-o <output> Image filename (default: guessed automatically)
70+
-x <num> Number of threads to use for image compression (default: dynamic)
71+
-h Show this help and exit
72+
-V Show version and exit
73+
74+
Accepted size suffixes: KiB, MiB, GiB, TiB, EiB.
75+
76+
The <platformfs-tarball> argument expects a tarball generated by mkplatformfs.sh.
77+
The platform is guessed automatically by its name.
78+
EOH
8379
}
8480

8581
# ########################################
8682
# SCRIPT EXECUTION STARTS HERE
8783
# ########################################
8884

89-
while getopts "b:B:o:r:s:x:h:V" opt; do
85+
while getopts "b:B:o:r:s:x:hV" opt; do
9086
case $opt in
9187
b) BOOT_FSTYPE="$OPTARG";;
9288
B) BOOT_FSSIZE="$OPTARG";;
@@ -95,14 +91,17 @@ while getopts "b:B:o:r:s:x:h:V" opt; do
9591
s) IMGSIZE="$OPTARG";;
9692
x) COMPRESSOR_THREADS="$OPTARG" ;;
9793
V) version; exit 0;;
98-
*) usage;;
94+
h) usage; exit 0;;
95+
*) usage >&2; exit 1;;
9996
esac
10097
done
10198
shift $((OPTIND - 1))
10299
ROOTFS_TARBALL="$1"
103100

104101
if [ -z "$ROOTFS_TARBALL" ]; then
105-
usage
102+
echo "$PROGNAME: no ROOTFS tarball specified" >&2
103+
usage >&2
104+
exit 1
106105
elif [ ! -r "$ROOTFS_TARBALL" ]; then
107106
# In rare cases the tarball can wind up owned by the wrong user.
108107
# This leads to confusing failures if execution is allowed to

mklive.sh

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22
#
3-
# vim: set ts=4 sw=4 et:
4-
#
53
#-
64
# Copyright (c) 2009-2015 Juan Romero Pardines.
75
# All rights reserved.
@@ -65,33 +63,35 @@ error_out() {
6563
}
6664

6765
usage() {
68-
cat <<_EOF
69-
Usage: $PROGNAME [options]
70-
71-
Options:
72-
-a <xbps-arch> Set XBPS_ARCH (do not use it unless you know what it is)
73-
-b <system-pkg> Set an alternative base-system package (defaults to base-system).
74-
-r <repo-url> Use this XBPS repository (may be specified multiple times).
75-
-c <cachedir> Use this XBPS cache directory (a subdirectory of current
76-
directory if unset).
77-
-k <keymap> Default keymap to use (us if unset)
78-
-l <locale> Default locale to use (en_US.UTF-8 if unset).
79-
-i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset).
80-
-s <gzip|lzo|xz> Compression type for the squashfs image (xz if unset)
81-
-o <file> Output file name for the ISO image (auto if unset).
82-
-p "pkg pkgN ..." Install additional packages into the ISO image.
83-
-I <includedir> Include directory structure under given path into rootfs
84-
-S "service serviceN ..." Services to enable
85-
86-
-C "cmdline args" Add additional kernel command line arguments.
87-
-T "title" Modify the bootloader title.
88-
-v linux<version> Install a custom Linux version on ISO image (linux meta-package if unset).
89-
-K Do not remove builddir.
90-
91-
The $PROGNAME script generates a live image of the Void Linux distribution.
92-
This ISO image can be written to a CD/DVD-ROM or any USB stick.
93-
_EOF
94-
exit 1
66+
cat <<-EOH
67+
Usage: $PROGNAME [options]
68+
69+
Generates a basic live ISO image of Void Linux. This ISO image can be written
70+
to a CD/DVD-ROM or any USB stick.
71+
72+
To generate a more complete live ISO image, use build-x86-images.sh.
73+
74+
OPTIONS
75+
-a <arch> Set XBPS_ARCH in the ISO image
76+
-b <system-pkg> Set an alternative base package (default: base-system)
77+
-r <repo> Use this XBPS repository. May be specified multiple times
78+
-c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
79+
-k <keymap> Default keymap to use (default: us)
80+
-l <locale> Default locale to use (default: en_US.UTF-8)
81+
-i <lz4|gzip|bzip2|xz>
82+
Compression type for the initramfs image (default: xz)
83+
-s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)
84+
-o <file> Output file name for the ISO image (default: automatic)
85+
-p "<pkg> ..." Install additional packages in the ISO image
86+
-I <includedir> Include directory structure under given path in the ROOTFS
87+
-S "<service> ..." Enable services in the ISO image
88+
-C "<arg> ..." Add additional kernel command line arguments
89+
-T <title> Modify the bootloader title (default: Void Linux)
90+
-v linux<version> Install a custom Linux version on ISO image (default: linux metapackage)
91+
-K Do not remove builddir
92+
-h Show this help and exit
93+
-V Show version and exit
94+
EOH
9595
}
9696

9797
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
321321
T) BOOT_TITLE="$OPTARG";;
322322
v) LINUX_VERSION="$OPTARG";;
323323
V) version; exit 0;;
324-
*) usage;;
324+
h) usage; exit 0;;
325+
*) usage >&2; exit 1;;
325326
esac
326327
done
327328
shift $((OPTIND - 1))

mknet.sh

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/sh
22
#
3-
# vim: set ts=4 sw=4 et:
4-
#
53
#-
64
# Copyright (c) 2009-2015 Juan Romero Pardines.
75
# All rights reserved.
@@ -51,33 +49,33 @@ bailout() {
5149
}
5250

5351
usage() {
54-
cat <<_EOF
55-
Usage: $PROGNAME [options] <rootfs>
56-
57-
Options:
58-
-r <repo-url> Use this XBPS repository (may be specified multiple times).
59-
-c <cachedir> Use this XBPS cache directory.
60-
-i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset).
61-
-o <file> Output file name for the netboot tarball (auto if unset).
62-
-K <kernelpkg> Use <kernelpkg> instead of 'linux' to build the image.
63-
64-
-k <keymap> Console keymap to set (us if unset)
65-
-l <locale> Locale to set (en_US.UTF-8 if unset)
66-
67-
-C "cmdline args" Add additional kernel command line arguments.
68-
-T "title" Modify the bootloader title.
69-
-S "splash image" Set a custom splash image for the bootloader
70-
71-
The $PROGNAME script generates a network-bootable tarball of Void Linux
72-
_EOF
73-
exit 1
52+
cat <<-EOH
53+
Usage: $PROGNAME [options] <rootfs-tarball>
54+
55+
Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs.
56+
57+
OPTIONS
58+
-r <repo> Use this XBPS repository. May be specified multiple times
59+
-c <cachedir> Use this XBPS cache directory (default: )
60+
-i <lz4|gzip|bzip2|xz>
61+
Compression type for the initramfs image (default: xz)
62+
-o <file> Output file name for the netboot tarball (default: automatic)
63+
-K linux<version> Install a custom Linux version on ISO image (default: linux metapackage)
64+
-k <keymap> Default keymap to use (default: us)
65+
-l <locale> Default locale to use (default: en_US.UTF-8)
66+
-C "<arg> ..." Add additional kernel command line arguments
67+
-T <title> Modify the bootloader title (default: Void Linux)
68+
-S <image> Set a custom splash image for the bootloader (default: data/splash.png)
69+
-h Show this help and exit
70+
-V Show version and exit
71+
EOH
7472
}
7573

7674
# ########################################
7775
# SCRIPT EXECUTION STARTS HERE
7876
# ########################################
7977

80-
while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do
78+
while getopts "r:c:C:T:K:i:o:k:l:S:Vh" opt; do
8179
case $opt in
8280
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
8381
c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
@@ -88,9 +86,10 @@ while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do
8886
l) LOCALE="$OPTARG";;
8987
C) BOOT_CMDLINE="$OPTARG";;
9088
T) BOOT_TITLE="$OPTARG";;
91-
S) SPLASH_IMAGE="OPTARG";;
89+
S) SPLASH_IMAGE="$OPTARG";;
9290
V) version; exit 0;;
93-
*) usage;;
91+
h) usage; exit 0;;
92+
*) usage >&2; exit 1;;
9493
esac
9594
done
9695
shift $((OPTIND - 1))

mkplatformfs.sh

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,29 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP
4545
# in the script, and it makes it easier to consume the contents of
4646
# these down the road in later scripts.
4747
usage() {
48-
cat <<_EOF
49-
Usage: $PROGNAME [options] <platform> <base-tarball>
50-
51-
Supported platforms: i686, x86_64, GCP,
52-
rpi-armv6l, rpi-armv7l, rpi-aarch64,
53-
pinebookpro, pinephone, rock64
54-
55-
Options
56-
-b <syspkg> Set an alternative base-system package (defaults to base-system)
57-
-p <pkgs> Additional packages to install into the rootfs (separated by blanks)
58-
-k <cmd> Call "cmd <ROOTFSPATH>" after building the rootfs
59-
-c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>)
60-
-C <file> Full path to the XBPS configuration file
61-
-r <repo> Set XBPS repository (may be set multiple times)
62-
-x <num> Use <num> threads to compress the image (dynamic if unset)
63-
-o <file> Filename to write the PLATFORMFS archive to
64-
-n Do not compress the image, instead print out the rootfs directory
65-
-h Show this help
66-
-V Show version
67-
_EOF
48+
cat <<-EOH
49+
Usage: $PROGNAME [options] <platform> <rootfs-tarball>
50+
51+
Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS
52+
generated by mkrootfs.sh.
53+
54+
Supported platforms: i686, x86_64, GCP,
55+
rpi-armv6l, rpi-armv7l, rpi-aarch64,
56+
pinebookpro, pinephone, rock64
57+
58+
OPTIONS
59+
-b <system-pkg> Set an alternative base-system package (default: base-system)
60+
-c <cachedir> Set the XBPS cache directory (default: ./xbps-cachedir-<arch>)
61+
-C <file> Full path to the XBPS configuration file
62+
-k <cmd> Call '<cmd> <ROOTFSPATH>' after building the ROOTFS
63+
-n Do not compress the image, instead print out the ROOTFS directory
64+
-o <file> Filename to write the PLATFORMFS archive to (default: automatic)
65+
-p "<pkg> ..." Additional packages to install into the ROOTFS
66+
-r <repo> Use this XBPS repository. May be specified multiple times
67+
-x <num> Number of threads to use for image compression (default: dynamic)
68+
-h Show this help and exit
69+
-V Show version and exit
70+
EOH
6871
}
6972

7073
# ########################################
@@ -86,7 +89,8 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do
8689
o) FILENAME="$OPTARG" ;;
8790
n) COMPRESSION="n" ;;
8891
V) version; exit 0;;
89-
*) usage; exit 0 ;;
92+
h) usage; exit 0 ;;
93+
*) usage >&2; exit 1 ;;
9094
esac
9195
done
9296
shift $((OPTIND - 1))

0 commit comments

Comments
 (0)