-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·75 lines (65 loc) · 1.79 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·75 lines (65 loc) · 1.79 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
#!/bin/bash
# SPDX-FileCopyrightText: © 2026 Phala Network <dstack@phala.network>
#
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
usage() {
cat <<EOF
Usage: ${0##*/} [--backend NAME] [--flavors "FLAVOR ..."] [--build-dir DIR]
Build dstack guest OS release artifacts with a selected backend.
Available backends:
yocto Reproducible Yocto build (default)
A backend lives at os/<name>/build.sh and implements the "image" action.
The common image contract is documented in os/README.md.
EOF
}
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
BACKEND=yocto
FLAVORS=${FLAVORS:-prod}
BUILD_DIR=
while [ $# -gt 0 ]; do
case "$1" in
--backend)
[ $# -ge 2 ] || { echo "Error: --backend requires a value" >&2; exit 1; }
BACKEND=$2
shift 2
;;
--flavors)
[ $# -ge 2 ] || { echo "Error: --flavors requires a value" >&2; exit 1; }
FLAVORS=$2
shift 2
;;
--build-dir)
[ $# -ge 2 ] || { echo "Error: --build-dir requires a value" >&2; exit 1; }
BUILD_DIR=$2
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
case "$BACKEND" in
''|*[!0-9A-Za-z_-]*)
echo "Error: invalid OS backend name: $BACKEND" >&2
exit 1
;;
esac
BACKEND_SCRIPT="$SCRIPT_DIR/$BACKEND/build.sh"
if [ ! -x "$BACKEND_SCRIPT" ]; then
echo "Error: OS backend is not available: $BACKEND" >&2
echo "Expected executable: $BACKEND_SCRIPT" >&2
exit 1
fi
export FLAVORS
if [ -n "$BUILD_DIR" ]; then
exec "$BACKEND_SCRIPT" image "$BUILD_DIR"
else
exec "$BACKEND_SCRIPT" image
fi