Skip to content

Commit cf22473

Browse files
committed
fix(os): rebuild pinned tools for production images
1 parent a7b7251 commit cf22473

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

os/mkosi/build.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ case "$action" in
1414
*) echo "Usage: $0 {image|dev-image|repro-check|lint} [build-dir]" >&2; exit 2 ;;
1515
esac
1616
if [[ $action == lint ]]; then exec "$SELF/tests/acceptance.sh"; fi
17-
command -v mkosi >/dev/null || { echo 'mkosi >= 26 is required' >&2; exit 1; }
17+
command -v mkosi >/dev/null || { echo "mkosi $MKOSI_VERSION is required" >&2; exit 1; }
1818
actual=$(mkosi --version | awk '{print $2}' | cut -d. -f1)
19-
(( actual >= MKOSI_MIN_VERSION )) || { echo "mkosi >= $MKOSI_MIN_VERSION required" >&2; exit 1; }
19+
[[ $actual == "$MKOSI_VERSION" ]] || {
20+
echo "mkosi $MKOSI_VERSION required, found $actual" >&2; exit 1;
21+
}
2022
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git -C "$ROOT" log -1 --format=%ct)}
2123
export TZ=UTC LC_ALL=C
2224

2325
build_one() {
2426
local out=$1 work=$2 flavor=$3
2527
local kstage="$work/kernel-stage" tree="$work/rootfs"
2628
rm -rf "$work" "$out"; mkdir -p "$out"
29+
# Production builds reconstruct the tools tree from the immutable snapshot;
30+
# no previously generated build environment is trusted.
31+
if [[ $action != dev-image ]]; then
32+
mkosi --directory "$SELF" clean -f
33+
fi
2734

2835
mkosi_args=(
2936
--directory "$SELF"

os/mkosi/mkosi.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ else
3030
fi
3131
export PATH="/opt/dstack-toolchains/rust/bin:/opt/dstack-toolchains/go/bin:$PATH"
3232
"$SELF/scripts/install-toolchains.sh" "$toolchain_downloads"
33+
printf 'gcc: '; gcc --version | head -1
34+
printf 'g++: '; g++ --version | head -1
35+
printf 'ld: '; ld --version | head -1
36+
printf 'cmake: '; cmake --version | head -1
37+
dpkg-query -W -f='build-package: ${binary:Package}=${Version}\n' \
38+
gcc g++ binutils cmake make ninja-build dwarves
3339

3440
work=/var/tmp/dstack-component-work
3541
kernel_stage=/var/tmp/dstack-kernel-stage

os/mkosi/scripts/component-framework.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ component_run() {
8989
"${SOURCE_DATE_EPOCH:?}" "$(uname -m)"
9090
key_file "$definition" "$SELF/scripts/component-framework.sh" \
9191
"$SELF/scripts/dev-cache.sh" "$SELF/scripts/install-toolchains.sh" \
92-
"$SELF/mkosi.build" "$SELF/mkosi.conf"
92+
"$SELF/mkosi.build" "$SELF/mkosi.conf" "$SELF/mkosi.tools.conf"
9393
component_cache_key
9494
} | sha256sum | cut -d' ' -f1)
9595
COMPONENT_KEYS[$name]=$key

os/mkosi/tests/acceptance.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ grep -q 'DSTACK_COMPONENT_CACHE.*dev-image' "$D/build.sh"
6161
grep -q 'scripts/build-components.sh' "$D/mkosi.build"
6262
grep -q '^BuildPackages=' "$D/mkosi.conf"
6363
grep -q '^ToolsTree=yes$' "$D/mkosi.conf"
64+
grep -q '^Snapshot=20260721T000000Z$' "$D/mkosi.tools.conf"
65+
grep -q 'clean -f' "$D/build.sh"
6466
grep -q 'install-toolchains.sh' "$D/mkosi.build"
67+
grep -q '^RUST_TOOLCHAIN_VERSION=1.92.0$' "$D/versions.env"
68+
grep -q '^GO_TOOLCHAIN_VERSION=1.22.2$' "$D/versions.env"
6569
for component in dstack-rust container-stack sysbox nvattest kernel nvidia zfs ovmf; do
6670
definition="$D/components/$component/$component.sh"
6771
grep -q "^COMPONENT_NAME=$component$" "$definition"

os/mkosi/versions.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ KERNEL_VERSION=7.1.4
44
KERNEL_SHA256=1c63922a119675d38e3ae0f8f6ee07f15c41a786ab9ed66563749bb8c9a08e2e
55
DEBIAN_RELEASE=trixie
66
DEBIAN_SNAPSHOT=20260721T000000Z
7-
MKOSI_MIN_VERSION=26
7+
MKOSI_VERSION=26
88
RUST_TOOLCHAIN_VERSION=1.92.0
99
RUSTC_TOOLCHAIN_SHA256=78b2dd9c6b1fcd2621fa81c611cf5e2d6950690775038b585c64f364422886e0
1010
CARGO_TOOLCHAIN_SHA256=e5e12be2c7126a7036c8adf573078a28b92611f5767cc9bd0a6f7c83081df103

0 commit comments

Comments
 (0)