|
1 | 1 | #!/bin/bash |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | | -# Build and compose every non-Debian guest component. Cache-aware staging is |
4 | | -# kept here so the release pipeline in build.sh remains cache-agnostic. |
5 | 3 | set -euo pipefail |
6 | 4 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd) |
7 | 5 | SELF="$ROOT/os/mkosi" |
8 | 6 | # shellcheck source=/dev/null |
9 | 7 | source "$SELF/versions.env" |
10 | 8 | # shellcheck source=/dev/null |
11 | 9 | source "$SELF/scripts/dev-cache.sh" |
| 10 | +# shellcheck source=/dev/null |
| 11 | +source "$SELF/scripts/component-framework.sh" |
12 | 12 |
|
13 | 13 | use_cache=0 |
14 | 14 | if [[ ${1:-} == --dev-cache ]]; then use_cache=1; shift; fi |
15 | | -WORK=$(realpath -m "${1:?work directory required}") |
16 | | -STAGE=$(realpath -m "${2:?rootfs staging tree required}") |
17 | | -KSTAGE=$(realpath -m "${3:?kernel staging tree required}") |
18 | | -FLAVOR=${4:?flavor required} |
19 | | -COMPONENTS="$WORK/component-stages" |
20 | | -mkdir -p "$STAGE" "$KSTAGE" "$COMPONENTS" |
21 | | -dev_cache_init "$use_cache" "$ROOT" "$FLAVOR" "${SOURCE_DATE_EPOCH:?}" |
22 | | - |
23 | | -merge() { cp -a "$1/." "$2/"; } |
24 | | - |
25 | | -root="$COMPONENTS/dstack-rust" |
26 | | -dev_cache_run dstack-rust "$WORK" component-stages/dstack-rust -- \ |
27 | | - "$SELF/scripts/stage-rootfs.sh" "$root" "$FLAVOR" |
28 | | -merge "$root" "$STAGE" |
29 | | - |
30 | | -root="$COMPONENTS/container-stack" |
31 | | -dev_cache_run container-stack "$WORK" component-stages/container-stack -- \ |
32 | | - "$SELF/scripts/build-container-stack.sh" "$WORK/container-stack-build" "$root" |
33 | | -merge "$root" "$STAGE" |
34 | | - |
35 | | -root="$COMPONENTS/sysbox" |
36 | | -dev_cache_run sysbox "$WORK" component-stages/sysbox -- \ |
37 | | - "$SELF/scripts/build-sysbox.sh" "$WORK/sysbox-build" "$root" |
38 | | -merge "$root" "$STAGE" |
39 | | - |
40 | | -root="$COMPONENTS/nvattest" |
41 | | -dev_cache_run nvattest "$WORK" component-stages/nvattest -- \ |
42 | | - "$SELF/scripts/build-nvattest.sh" "$WORK/nvattest-build" "$root" |
43 | | -merge "$root" "$STAGE" |
44 | | - |
45 | | -dev_cache_run kernel "$WORK" "linux-$KERNEL_VERSION" kernel-build kernel-stage -- \ |
46 | | - "$SELF/scripts/build-kernel.sh" "$WORK" "$KSTAGE" |
47 | | - |
48 | | -root="$COMPONENTS/nvidia-root" modules="$COMPONENTS/nvidia-kernel" |
49 | | -dev_cache_run nvidia "$WORK" component-stages/nvidia-root component-stages/nvidia-kernel -- \ |
50 | | - "$SELF/scripts/build-nvidia.sh" "$WORK/nvidia-build" \ |
51 | | - "$WORK/linux-$KERNEL_VERSION" "$WORK/kernel-build" "$root" "$modules" |
52 | | -merge "$root" "$STAGE"; merge "$modules" "$KSTAGE" |
53 | | - |
54 | | -root="$COMPONENTS/zfs-root" modules="$COMPONENTS/zfs-kernel" |
55 | | -dev_cache_run zfs "$WORK" component-stages/zfs-root component-stages/zfs-kernel -- \ |
56 | | - "$SELF/scripts/build-zfs.sh" "$WORK/zfs-build" \ |
57 | | - "$WORK/linux-$KERNEL_VERSION" "$WORK/kernel-build" "$root" "$modules" |
58 | | -merge "$root" "$STAGE"; merge "$modules" "$KSTAGE" |
59 | | - |
60 | | -root="$COMPONENTS/ovmf"; mkdir -p "$root" |
61 | | -dev_cache_run ovmf "$WORK" component-stages/ovmf -- \ |
62 | | - "$SELF/scripts/build-ovmf.sh" "$WORK/ovmf-build" \ |
63 | | - "$root/ovmf.fd" "$root/ovmf-sev.fd" |
64 | | -install -Dm0644 "$root/ovmf.fd" "$KSTAGE/ovmf.fd" |
65 | | -install -Dm0644 "$root/ovmf-sev.fd" "$KSTAGE/ovmf-sev.fd" |
| 15 | +work=${1:?work directory required} |
| 16 | +stage=${2:?rootfs staging tree required} |
| 17 | +kstage=${3:?kernel staging tree required} |
| 18 | +flavor=${4:?flavor required} |
| 19 | +component_framework_init "$use_cache" "$ROOT" "$SELF" \ |
| 20 | + "$(realpath -m "$work")" "$(realpath -m "$stage")" \ |
| 21 | + "$(realpath -m "$kstage")" "$flavor" |
| 22 | + |
| 23 | +components=( |
| 24 | + dstack-rust |
| 25 | + container-stack |
| 26 | + sysbox |
| 27 | + nvattest |
| 28 | + kernel |
| 29 | + nvidia |
| 30 | + zfs |
| 31 | + ovmf |
| 32 | +) |
| 33 | + |
| 34 | +for component in "${components[@]}"; do component_run "$component"; done |
| 35 | +component_assemble |
0 commit comments