-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild
More file actions
executable file
·199 lines (151 loc) · 5.23 KB
/
build
File metadata and controls
executable file
·199 lines (151 loc) · 5.23 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env bash
set -euo pipefail
# targets which produce releases and deployments, prevents usage of QUICK_BUILD
PRODUCTION_TARGETS="develop|validation|master|release-disk"
# other targets used for development/testing/etc
OTHER_TARGETS="vm|stuck|lab-key|shed-key|test-e2e|all"
ALL_TARGETS="$PRODUCTION_TARGETS|$OTHER_TARGETS"
usage() {
echo "Usage: $0 [--quick] {$ALL_TARGETS}"
exit 1
}
TARGET=""
for arg in "$@"; do
if [[ "$arg" == "--quick" ]]; then
export QUICK_BUILD=1
else
if [[ -z "$TARGET" ]]; then
TARGET="$arg"
else
echo "Too many arguments specified: $@"
usage
fi
fi
done
if [[ -z "$TARGET" ]]; then
usage
fi
if [[ ! -z "${QUICK_BUILD:-}" ]] && [[ "$PRODUCTION_TARGETS" =~ "$TARGET" ]]; then
echo "Error: QUICK_BUILD mode not allowed for target '$TARGET', aborting."
echo " Remove --quick and/or make sure QUICK_BUILD env var is unset"
exit 11
fi
# Allow unfree packages, required for zerotier using a BSL 1.1 licence
# See https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package%3F
export NIXPKGS_ALLOW_UNFREE=1
if [ "$TARGET" == "vm" ]; then
(set -x; nix-build \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildLive false \
--arg buildDisk false)
echo -e "
Run ./result/bin/run-in-vm to start a VM.
QEMU Shortcuts:
- Grab/release cursor: ctrl-alt-g
- Quit: ctrl-alt-q
PlayOS shortcuts:
- Toggle controller: ctrl-shift-f12
You can switch virtual consoles in the guest via QEMU monitor (ctrl-alt-2), sending a key combination via 'sendkey <key-comb>, and returning to QEMU display (ctrl-alt-1).
- Status console: ctrl-alt-f8
- Graphical system: ctrl-alt-f7
"
elif [ "$TARGET" == "develop" ]; then
scripts/info-branch-commit
scripts/confirm-or-abort
(set -x; nix-build \
--arg updateCert ./pki/develop/cert.pem \
--arg updateUrl https://dist.dividat.com/releases/playos/develop/ \
--arg deployUrl s3://dist.dividat.ch/releases/playos/develop/ \
--arg kioskUrl https://dev-play.dividat.com/ \
--arg watchdogUrls '["https://dev-play.dividat.com/" "https://dev-api.dividat.com"]' \
--arg buildDisk false)
echo
echo "Run ./result/bin/deploy-update to deploy."
elif [ "$TARGET" == "validation" ]; then
scripts/info-branch-commit
scripts/confirm-or-abort
(set -x; nix-build \
--arg updateCert ./pki/validation/cert.pem \
--arg updateUrl https://dist.dividat.com/releases/playos/validation/ \
--arg deployUrl s3://dist.dividat.ch/releases/playos/validation/ \
--arg kioskUrl https://val-play.dividat.com/ \
--arg watchdogUrls '["https://val-play.dividat.com/" "https://val-api.dividat.com"]' \
--arg buildDisk false)
echo
echo "Run ./result/bin/deploy-update to deploy."
elif [ "$TARGET" == "master" ]; then
scripts/info-branch-commit
scripts/confirm-or-abort
(set -x; nix-build \
--arg updateCert ./pki/master/cert.pem \
--arg updateUrl https://dist.dividat.com/releases/playos/master/ \
--arg deployUrl s3://dist.dividat.ch/releases/playos/master/ \
--arg kioskUrl https://play.dividat.com/ \
--arg watchdogUrls '["https://play.dividat.com/" "https://api.dividat.com"]' \
--arg buildDisk false)
echo
echo "Run ./result/bin/deploy-update to deploy."
elif [ "$TARGET" == "stuck" ]; then
echo "Creating a stuck system that will not self-update."
echo
printf "Kiosk URL? "
read KIOSK_URL
KIOSK_URL=$(echo "$KIOSK_URL" | xargs) # Trim
(set -x; nix-build \
--arg kioskUrl "$KIOSK_URL" \
--arg buildBundle false \
--arg buildDisk false)
elif [ "$TARGET" == "lab-key" ]; then
(set -x; nix-build \
--arg kioskUrl https://lab.dividat.com/ \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildDisk false)
elif [ "$TARGET" == "shed-key" ]; then
(set -x; nix-build \
--arg kioskUrl https://shed.dividat.com/ \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildDisk false)
elif [ "$TARGET" == "test-e2e" ]; then
test_flags="
--arg kioskUrl http://10.0.2.99:8989/ \
--arg updateUrl http://update-server.local/ \
--arg buildVm false \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildLive false \
--arg buildDisk false \
--arg buildTest true
"
echo "Building e2e test runners."
(set -x; nix-build $test_flags)
echo "Running e2e tests..."
(set -x; nix-build $test_flags -A tests -o test-output)
exit $(cat test-output/status)
# builds a disk to be used as a base image in ./testing/release-validation.nix
elif [ "$TARGET" == "release-disk" ]; then
echo -e "
Building release disk image for release validation tests.
Note: requires around 30GiB of free space for storing the intermediate disk
images. The final compressed disk image is much smaller (~4 GiB).
"
(set -x; nix-build \
--arg kioskUrl "http://kiosk-server.local/" \
--arg updateUrl "http://update-server.local/" \
--arg buildVm false \
--arg buildInstaller false \
--arg buildBundle false \
--arg buildLive false \
--arg buildDisk false \
--arg buildReleaseDisk true
)
elif [ "$TARGET" == "all" ]; then
(set -x; nix-build)
else
echo
echo "I do not know how to build '$TARGET'."
echo "Aborting."
usage
fi