File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,24 +134,10 @@ jobs:
134134 run : |
135135 set -euo pipefail
136136 COMPRESSED_DIR="${PWD}/target/vm-runtime-compressed"
137- mkdir -p "$COMPRESSED_DIR"
138-
139- EXTRACT_DIR=$(mktemp -d)
140- zstd -d "runtime-download/vm-runtime-${{ matrix.platform }}.tar.zst" --stdout \
141- | tar -xf - -C "$EXTRACT_DIR"
142-
143- echo "Extracted runtime files:"
144- ls -lah "$EXTRACT_DIR"
145-
146- for file in "$EXTRACT_DIR"/*; do
147- [ -f "$file" ] || continue
148- name=$(basename "$file")
149- [ "$name" = "provenance.json" ] && continue
150- zstd -19 -f -q -T0 -o "${COMPRESSED_DIR}/${name}.zst" "$file"
151- done
152-
153- echo "Staged compressed runtime artifacts:"
154- ls -lah "$COMPRESSED_DIR"
137+ VM_RUNTIME_TARBALL="${PWD}/runtime-download/vm-runtime-${{ matrix.platform }}.tar.zst" \
138+ VM_RUNTIME_PLATFORM="${{ matrix.platform }}" \
139+ OPENSHELL_VM_RUNTIME_COMPRESSED_DIR="$COMPRESSED_DIR" \
140+ tasks/scripts/vm/compress-vm-runtime.sh
155141
156142 - name : Build bundled supervisor
157143 run : |
Original file line number Diff line number Diff line change @@ -165,24 +165,10 @@ jobs:
165165 run : |
166166 set -euo pipefail
167167 COMPRESSED_DIR="${PWD}/target/vm-runtime-compressed-macos"
168- mkdir -p "$COMPRESSED_DIR"
169-
170- EXTRACT_DIR=$(mktemp -d)
171- zstd -d "runtime-download/vm-runtime-darwin-aarch64.tar.zst" --stdout \
172- | tar -xf - -C "$EXTRACT_DIR"
173-
174- echo "Extracted darwin runtime files:"
175- ls -lah "$EXTRACT_DIR"
176-
177- for file in "$EXTRACT_DIR"/*; do
178- [ -f "$file" ] || continue
179- name=$(basename "$file")
180- [ "$name" = "provenance.json" ] && continue
181- zstd -19 -f -q -T0 -o "${COMPRESSED_DIR}/${name}.zst" "$file"
182- done
183-
184- echo "Staged macOS compressed runtime artifacts:"
185- ls -lah "$COMPRESSED_DIR"
168+ VM_RUNTIME_TARBALL="${PWD}/runtime-download/vm-runtime-darwin-aarch64.tar.zst" \
169+ VM_RUNTIME_PLATFORM="darwin-aarch64" \
170+ OPENSHELL_VM_RUNTIME_COMPRESSED_DIR="$COMPRESSED_DIR" \
171+ tasks/scripts/vm/compress-vm-runtime.sh
186172
187173 - name : Download bundled supervisor
188174 uses : actions/download-artifact@v4
Original file line number Diff line number Diff line change @@ -74,6 +74,38 @@ download_umoci_binary() {
7474 return 1
7575}
7676
77+ # Map a VM runtime platform to the Linux guest umoci architecture.
78+ # Usage: umoci_guest_arch_for_platform <platform>
79+ umoci_guest_arch_for_platform () {
80+ local platform=" $1 "
81+
82+ case " $platform " in
83+ linux-aarch64|darwin-aarch64) echo " arm64" ;;
84+ linux-x86_64) echo " amd64" ;;
85+ * )
86+ echo " Error: Unsupported platform for umoci guest binary: ${platform} " >&2
87+ return 1
88+ ;;
89+ esac
90+ }
91+
92+ # Ensure an extracted runtime directory contains the guest umoci binary.
93+ # Usage: ensure_umoci_for_platform <runtime_dir> <platform> <version>
94+ ensure_umoci_for_platform () {
95+ local runtime_dir=" $1 "
96+ local platform=" $2 "
97+ local version=" $3 "
98+
99+ if [ -f " ${runtime_dir} /umoci" ]; then
100+ return 0
101+ fi
102+
103+ local guest_arch
104+ guest_arch=" $( umoci_guest_arch_for_platform " $platform " ) "
105+ echo " Runtime tarball has no umoci"
106+ download_umoci_binary " ${runtime_dir} /umoci" " $version " " $guest_arch "
107+ }
108+
77109# ── Compression helpers ─────────────────────────────────────────────────
78110
79111# Compress a single file with zstd level 19, reporting sizes.
Original file line number Diff line number Diff line change @@ -127,6 +127,23 @@ if [ -n "${VM_RUNTIME_TARBALL:-}" ]; then
127127 # Extract tarball contents
128128 zstd -d " ${VM_RUNTIME_TARBALL} " --stdout | tar -xf - -C " $WORK_DIR "
129129
130+ VM_RUNTIME_PLATFORM=" ${VM_RUNTIME_PLATFORM:- } "
131+ if [ -z " $VM_RUNTIME_PLATFORM " ]; then
132+ case " $( basename " $VM_RUNTIME_TARBALL " ) " in
133+ vm-runtime-darwin-aarch64.tar.zst) VM_RUNTIME_PLATFORM=" darwin-aarch64" ;;
134+ vm-runtime-linux-aarch64.tar.zst) VM_RUNTIME_PLATFORM=" linux-aarch64" ;;
135+ vm-runtime-linux-x86_64.tar.zst) VM_RUNTIME_PLATFORM=" linux-x86_64" ;;
136+ esac
137+ fi
138+ if [ ! -f " ${WORK_DIR} /umoci" ]; then
139+ if [ -z " $VM_RUNTIME_PLATFORM " ]; then
140+ echo " Error: VM_RUNTIME_TARBALL has no umoci and platform could not be inferred." >&2
141+ echo " Set VM_RUNTIME_PLATFORM to linux-aarch64, linux-x86_64, or darwin-aarch64." >&2
142+ exit 1
143+ fi
144+ ensure_umoci_for_platform " $WORK_DIR " " $VM_RUNTIME_PLATFORM " " $UMOCI_VERSION "
145+ fi
146+
130147 echo " Extracted files:"
131148 ls -lah " $WORK_DIR "
132149
Original file line number Diff line number Diff line change @@ -111,19 +111,7 @@ mkdir -p "$EXTRACT_DIR"
111111
112112zstd -d " ${DOWNLOAD_DIR} /${TARBALL_NAME} " --stdout | tar -xf - -C " $EXTRACT_DIR "
113113
114- if [ ! -f " ${EXTRACT_DIR} /umoci" ]; then
115- UMOCI_GUEST_ARCH=" "
116- case " $PLATFORM " in
117- linux-aarch64|darwin-aarch64) UMOCI_GUEST_ARCH=" arm64" ;;
118- linux-x86_64) UMOCI_GUEST_ARCH=" amd64" ;;
119- * )
120- echo " Error: Unsupported platform for umoci guest binary: ${PLATFORM} " >&2
121- exit 1
122- ;;
123- esac
124- echo " Runtime tarball has no umoci"
125- download_umoci_binary " ${EXTRACT_DIR} /umoci" " ${UMOCI_VERSION} " " ${UMOCI_GUEST_ARCH} "
126- fi
114+ ensure_umoci_for_platform " $EXTRACT_DIR " " $PLATFORM " " $UMOCI_VERSION "
127115
128116echo " Extracted files:"
129117ls -lah " $EXTRACT_DIR "
You can’t perform that action at this time.
0 commit comments