-
Notifications
You must be signed in to change notification settings - Fork 0
/
package
executable file
·74 lines (53 loc) · 1.48 KB
/
package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash -eu
readonly SCRIPT_NAME="$(basename "$0")"
readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"
source "$SCRIPT_DIR"/lib/package.sh
usage() {
die <<EOM
Usage:
$SCRIPT_NAME [OPTION]... MACHINE PROFILE MEDIA
$SCRIPT_NAME [OPTION]... MACHINE.PROFILE.img
Builds an Gentoo image for a host named MACHINE using settings from
profiles/PROFILE.* and storing the result the MEDIA file.
The second form uses the MEDIA filename as template for the needed parameters.
Options:
-h print this help message
-w wipe MEDIA
-q log messages in scripting mode
Environment variables:
WIPE same as -w
QUIET same as -q
For further environment variables that can customize the packaging process,
see '$(realpath --relative-to="$(pwd)" $SCRIPT_DIR)/install -h'.
Sample invocation:
sudo -E $0 gentoo.rpi4.img
EOM
}
while getopts :hwq OPTION; do
case $OPTION in
h) usage ;;
w) WIPE=true ;;
q) QUIET=true ;;
\?) usage ;;
esac
done
shift $((OPTIND-1))
if (( $# == 1 )); then
MEDIA="$1"
parse-media-name
elif (( $# == 3 )); then
MACHINE="$1"
PROFILE="$2"
MEDIA="$3"
else
usage
fi
[ -n "$MACHINE" ] || die "MACHINE parameter cannot be empty"
[ -n "$PROFILE" ] || die "PROFILE parameter cannot be empty"
[ -n "$MEDIA" ] || die "MEDIA parameter cannot be empty"
[ -f profiles/"$PROFILE".sh ] || die "unsupported profile '$PROFILE'"
cd "$(dirname "$0")"
package
${QUIET:-false} || cat <<EOM
Created $MEDIA.
EOM