forked from xen0l/oi-packer
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·87 lines (77 loc) · 1.74 KB
/
build.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# Use the Image Builder to produce a tar file that contains an installed OpenIndiana Hipster
# image. The produced file should be something like:
#
# /rpool/images/output/openindiana-hipster.tar.gz
#
#
set -o xtrace
set -o pipefail
set -o errexit
TOP=$(cd "$(dirname "$0")" && pwd)
. "$TOP/lib/common.sh"
DISTRO=${DISTRO:-openindiana}
BRANCH=${BRANCH:-hipster}
TOP=$(cd "$(dirname "$0")" && pwd)
STRAP_ARGS=()
ALL_ARGS=()
IMAGE_SUFFIX=
while getopts 'BEfs:' c; do
case "$c" in
f)
#
# Use -f to request a full reset from the image builder, thus
# effectively destroying any existing files and starting from a
# freshly installed set of OS files.
#
STRAP_ARGS+=( '--fullreset' )
;;
E)
#
# Enable OmniOS Extra (Additional packages) publisher.
#
ALL_ARGS+=( '-F' 'extra' )
;;
B)
#
# Install software build tools.
#
ALL_ARGS+=( '-F' 'build' )
;;
s)
#
# You can customise the strap image by swapping out the middle
# stage, 02-image. Normally this takes the expensive base OS
# step (01-strap) and adds a few extra packages for
# convenience. If you specify a -s option here, e.g.,
# "-s mine", we will look for, e.g.,
# "hipster-02-image-mine.json" instead of the stock
# "hipster-02-image.json".
#
IMAGE_SUFFIX="-$OPTARG"
;;
\?)
printf 'usage: %s [-f]\n' "$0" >&2
exit 2
;;
esac
done
shift $((OPTIND - 1))
cd "$TOP"
for n in 01-strap "02-image$IMAGE_SUFFIX" 03-archive; do
ARGS=()
if [[ $n == 01-strap ]]; then
ARGS=( "${STRAP_ARGS[@]}" )
fi
banner "$n"
pfexec "image-builder" \
build \
-T "$TOP/templates" \
-d "$DATASET" \
-g "$DISTRO" \
-n "$BRANCH-$n" \
"${ALL_ARGS[@]}" \
"${ARGS[@]}"
done
ls -lh "$MOUNTPOINT/output/$DISTRO-$BRANCH.tar.gz"