Skip to content

Commit 85ff19a

Browse files
committed
devenv: Deduplicate kani setup and devcontainer configs
Move gcc installation into install-kani.sh so the distro-specific package manager command isn't duplicated across all three Containerfiles. The script auto-detects dnf vs apt-get. Add devcontainer-generate and devcontainer-validate recipes to generate per-OS devcontainer.json files from the default template and validate they stay in sync. Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent 56e4f61 commit 85ff19a

5 files changed

Lines changed: 36 additions & 5 deletions

File tree

Justfile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1-
# Validate devcontainer.json syntax
1+
# Generate per-OS devcontainer.json from the default (debian) template
2+
devcontainer-generate:
3+
#!/bin/bash
4+
set -euo pipefail
5+
template=common/.devcontainer/devcontainer.json
6+
for os in debian ubuntu; do
7+
mkdir -p "common/.devcontainer/${os}"
8+
sed -e "s/devenv-debian/devenv-${os}/g" "$template" > "common/.devcontainer/${os}/devcontainer.json"
9+
done
10+
11+
# Validate devcontainer.json syntax and that per-OS configs are in sync
212
devcontainer-validate:
13+
#!/bin/bash
14+
set -euo pipefail
15+
template=common/.devcontainer/devcontainer.json
16+
rc=0
17+
for os in debian ubuntu; do
18+
expected=$(sed "s/devenv-debian/devenv-${os}/g" "$template")
19+
actual=$(cat "common/.devcontainer/${os}/devcontainer.json")
20+
if [ "$expected" != "$actual" ]; then
21+
echo "ERROR: common/.devcontainer/${os}/devcontainer.json is out of sync with template"
22+
echo "Run 'just devcontainer-generate' to fix"
23+
rc=1
24+
fi
25+
done
26+
if [ $rc -ne 0 ]; then
27+
exit $rc
28+
fi
29+
echo "All devcontainer configs are in sync"
330
npx --yes @devcontainers/cli read-configuration --workspace-folder .
431

532
# Build devenv Debian image with local tag

devenv/Containerfile.c10s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ RUN rust_nightly=$rust_nightly /run/src/install-rust.sh
4242
FROM rust as kani
4343
# renovate: datasource=crate depName=kani-verifier
4444
ARG kaniversion=0.67.0
45-
RUN dnf install -y gcc && dnf clean all
4645
COPY install-kani.sh /run/src/
4746
RUN kaniversion=$kaniversion /run/src/install-kani.sh
4847

devenv/Containerfile.debian

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ RUN rust_nightly=$rust_nightly /run/src/install-rust.sh
4545
FROM rust AS kani
4646
# renovate: datasource=crate depName=kani-verifier
4747
ARG kaniversion=0.67.0
48-
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
4948
COPY install-kani.sh /run/src/
5049
RUN kaniversion=$kaniversion /run/src/install-kani.sh
5150

devenv/Containerfile.ubuntu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ RUN rust_nightly=$rust_nightly /run/src/install-rust.sh
5757
FROM rust AS kani
5858
# renovate: datasource=crate depName=kani-verifier
5959
ARG kaniversion=0.67.0
60-
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
6160
COPY install-kani.sh /run/src/
6261
RUN kaniversion=$kaniversion /run/src/install-kani.sh
6362

devenv/install-kani.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#!/bin/bash
22
# Install Kani formal verification tool
3-
# This script is shared between c10s and debian container builds.
3+
# This script is shared between c10s, debian, and ubuntu container builds.
44
# Prerequisites: rustup must already be installed (via install-rust.sh)
55
set -xeuo pipefail
66

77
# Required environment variable (passed as build ARG)
88
: "${kaniversion:?kaniversion is required}"
99

10+
# Install gcc (required to compile Kani's C stubs)
11+
if command -v dnf >/dev/null; then
12+
dnf install -y gcc && dnf clean all
13+
elif command -v apt-get >/dev/null; then
14+
apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
15+
fi
16+
1017
export RUSTUP_HOME=/usr/local/rustup
1118
export CARGO_HOME=/usr/local/cargo
1219
export PATH="/usr/local/bin:$PATH"

0 commit comments

Comments
 (0)