Skip to content

Commit 2397e1a

Browse files
committed
Add zig/0.15.2
1 parent 6643784 commit 2397e1a

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ jobs:
8585
implementation: '3.4'
8686
- target: rust
8787
implementation: '1.89'
88+
- target: zig
89+
implementation: '0.15.2'
8890

8991
steps:
9092
- name: Dump matrix context
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM alpine:3.22
2+
3+
# Copy files common for all images
4+
COPY 4img/* ./
5+
6+
# Install all dependencies
7+
RUN \
8+
./prepare-alpine-init && \
9+
./prepare-alpine-ruby && \
10+
apk add curl minisign && \
11+
./prepare-alpine-uninit
12+
13+
# Download Zig
14+
RUN ./prepare 'zig-x86_64-linux-0.15.2.tar.xz'
15+
16+
# Add the `zig` binary to PATH
17+
ENV PATH="$PATH:/usr/local/zig-x86_64-linux-0.15.2"
18+
19+
# Validate that we've got correct version, e.g. something like this:
20+
#
21+
# $ zig version
22+
# 0.15.2
23+
24+
RUN ./validate '^0\.15\.2$'

src/zig/0.15.2-linux-x86_64/build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../generic-build

src/zig/0.15.2-linux-x86_64/run-it

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../generic-run-it

src/zig/_common/prepare

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh -ef
2+
3+
# See https://ziglang.org/download/community-mirrors/
4+
5+
# From https://ziglang.org/download/
6+
pubkey='RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U'
7+
8+
if [ "$#" -ne 1 ]; then
9+
echo "Usage: $0 <tarball_name>" >&2
10+
exit 1
11+
fi
12+
tarball_name=$1
13+
14+
cleanup()
15+
{
16+
rm -f shuffled_mirrors.txt "${tarball_name}" "${tarball_name}.minisig"
17+
}
18+
19+
trap 'cleanup' EXIT
20+
21+
source_query_param='?source=github-kaitai-io-kaitai_struct_docker_images'
22+
23+
mirrors=$(curl -fsSL "https://ziglang.org/download/community-mirrors.txt$source_query_param")
24+
printf '%s\n' "$mirrors" | shuf -o shuffled_mirrors.txt
25+
26+
i=0
27+
num_mirrors=$(wc -l < shuffled_mirrors.txt)
28+
29+
while IFS= read -r mirror_url; do
30+
i=$((i+1))
31+
echo "Mirror $i/$num_mirrors: $mirror_url"
32+
curl -fsSLO --url "$mirror_url/${tarball_name}${source_query_param}" || continue
33+
curl -fsSLO --url "$mirror_url/${tarball_name}.minisig${source_query_param}" || continue
34+
trusted_comment=$(minisign -Q -Vm "$tarball_name" -P "$pubkey") || continue
35+
actual_file_field=$(printf '%s\n' "$trusted_comment" | tr '\t' '\n' | grep '^file:')
36+
expected_file_field="file:$tarball_name"
37+
if [ "$actual_file_field" != "$expected_file_field" ]; then
38+
echo "Expected '$expected_file_field', but found '$actual_file_field'"
39+
continue
40+
fi
41+
echo "Successfully fetched $tarball_name"
42+
tar -C /usr/local -xf "$tarball_name"
43+
exit 0
44+
done < shuffled_mirrors.txt
45+
46+
echo "Failed to fetch $tarball_name: no working mirror found"
47+
exit 1

src/zig/_common/validate

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh -ef
2+
3+
ver=$(zig version)
4+
./validate-version Zig "$ver" "$@"

0 commit comments

Comments
 (0)