@@ -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.
6155usage () {
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
10097done
10198shift $(( OPTIND - 1 ))
10299ROOTFS_TARBALL=" $1 "
103100
104101if [ -z " $ROOTFS_TARBALL " ]; then
105- usage
102+ echo " $PROGNAME : no ROOTFS tarball specified" >&2
103+ usage >&2
104+ exit 1
106105elif [ ! -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
0 commit comments