feat(zig-master,zig-master-bootstrap): Randomize mirrors inside spec (#5964) (#5967)

(cherry picked from commit 53d4e27aea)

Signed-off-by: GildedRoach <GildedRoach@users.noreply.github.com>
This commit is contained in:
Gilver
2025-07-27 17:32:25 -05:00
committed by GitHub
parent 7c2d123548
commit b52ad10814
5 changed files with 4 additions and 34 deletions
-20
View File
@@ -1,20 +0,0 @@
#!/bin/bash
version=0.15.0-dev.1254+c9ce1debe
# Self explanatory
function randomize_mirrors() {
mirrors=("https://pkg.machengine.org/zig" "https://zigmirror.hryx.net/zig" "https://zig.linus.dev/zig" "https://zig.squirl.dev" "https://zig.florent.dev")
number=${#mirrors[@]}
index=$(( RANDOM % number ))
mirror=${mirrors[$index]}
}
# ONLY export mirrors to the update scripts if they connect on both files
until curl -If $mirror/zig-${version}.tar.xz &>/dev/null && curl -If $mirror/zig-${version}.tar.xz.minisig &>/dev/null; do
randomize_mirrors
done
echo $mirror
exit 0
-6
View File
@@ -4,10 +4,4 @@ let v = json.master.version;
rpm.global("ver", v);
if rpm.changed() {
rpm.release();
// Update the Zig version in the script
sh(`sed -i 's/version=.*/version=${v}/' anda/langs/zig/bootstrap/choose-mirror.sh`, #{});
// This could be done with the rhai-rand Crate but Anda does not use this currently
let mirror = sh("anda/langs/zig/bootstrap/choose-mirror.sh", #{"stdout": "piped"}).ctx.stdout;
mirror.pop();
rpm.global("mirror_url", mirror);
}
@@ -36,7 +36,8 @@
%global zig_install_options %zig_build_options %{shrink: \
--prefix "%{_prefix}" \
}
%global mirror_url https://zig.squirl.dev
%global zig_mirrors ("https://pkg.machengine.org/zig" "https://zigmirror.hryx.net/zig" "https://zig.linus.dev/zig" "https://zig.squirl.dev" "https://zig.florent.dev")
%global mirror_url %(mirrors=%{zig_mirrors}; index=$(( RANDOM % ${#mirrors[@]} )); echo ${mirrors[$index]})
Name: zig-master-bootstrap
Version: %(echo %{ver} | sed 's/-/~/g')
-6
View File
@@ -1,9 +1,3 @@
import "andax/bump_extras.rhai" as bump;
rpm.version(bump::madoguchi("zig-master-bootstrap", labels.branch));
if rpm.changed() {
// This could be done with the rhai-rand Crate but Anda does not use this currently
let mirror = sh("anda/langs/zig/bootstrap/choose-mirror.sh", #{"stdout": "piped"}).ctx.stdout;
mirror.pop();
rpm.global("mirror_url", mirror);
}
+2 -1
View File
@@ -11,7 +11,8 @@
%bcond docs %{without bootstrap}
%bcond test 1
%global zig_cache_dir %{builddir}/zig-cache
%global mirror_url https://zig.squirl.dev
%global zig_mirrors ("https://pkg.machengine.org/zig" "https://zigmirror.hryx.net/zig" "https://zig.linus.dev/zig" "https://zig.squirl.dev" "https://zig.florent.dev")
%global mirror_url %(mirrors=%{zig_mirrors}; index=$(( RANDOM % ${#mirrors[@]} )); echo ${mirrors[$index]})
Name: zig-master
Version: 0.15.0~dev.1254+c9ce1debe