Lines 42-106
QA_FLAGS_IGNORED="usr/bin/ncdu"
Link Here
|
42 |
# Adapted from https://github.com/gentoo/gentoo/pull/28986 |
42 |
# Adapted from https://github.com/gentoo/gentoo/pull/28986 |
43 |
# Set the EZIG environment variable. |
43 |
# Set the EZIG environment variable. |
44 |
zig-set_EZIG() { |
44 |
zig-set_EZIG() { |
45 |
[[ -n ${EZIG} ]] && return |
45 |
local candidate selected selected_ver ver |
46 |
|
46 |
|
47 |
if [[ -n ${EZIG_OVERWRITE} ]]; then |
47 |
if [[ ${EZIG} ]]; then |
48 |
export EZIG="${EZIG_OVERWRITE}" |
48 |
return |
|
|
49 |
elif [[ ${EZIG_OVERWRITE} ]]; then |
50 |
export EZIG=${EZIG_OVERWRITE} |
49 |
return |
51 |
return |
50 |
fi |
52 |
fi |
51 |
|
53 |
|
52 |
local candidates candidate selected selected_ver |
54 |
for candidate in "${BROOT}"/usr/bin/zig-*; do |
53 |
|
55 |
if [[ -L ${candidate} && ${candidate} == */zig?(-bin)-+([0-9.]) ]]; then |
54 |
candidates=$(compgen -c zig-) |
56 |
ver=${candidate##*-} |
55 |
|
57 |
if [[ ${EZIG_EXACT_VER} ]]; then |
56 |
for candidate in ${candidates}; do |
58 |
if ver_test "${ver}" -ne "${EZIG_EXACT_VER}"; then |
57 |
if [[ ! ${candidate} =~ zig(-bin)?-([.0-9]+) ]]; then |
59 |
continue |
58 |
continue |
60 |
else |
59 |
fi |
61 |
selected=${candidate} |
60 |
|
62 |
selected_ver=${ver} |
61 |
local ver |
63 |
break |
62 |
if (( ${#BASH_REMATCH[@]} == 3 )); then |
64 |
fi |
63 |
ver="${BASH_REMATCH[2]}" |
65 |
elif [[ ${EZIG_MIN} ]] && |
64 |
else |
66 |
ver_test "${ver}" -lt "${EZIG_MIN}"; then |
65 |
ver="${BASH_REMATCH[1]}" |
67 |
# Candidate does not satisfy EZIG_MIN condition. |
66 |
fi |
68 |
continue |
67 |
|
69 |
elif [[ ${EZIG_MAX_EXCLUSIVE} ]] && |
68 |
if [[ -n ${EZIG_EXACT_VER} ]]; then |
70 |
ver_test "${ver}" -ge "${EZIG_MAX_EXCLUSIVE}"; then |
69 |
ver_test "${ver}" -ne "${EZIG_EXACT_VER}" && continue |
71 |
# Candidate does not satisfy EZIG_MAX_EXCLUSIVE condition. |
70 |
|
72 |
continue |
71 |
selected="${candidate}" |
73 |
elif [[ ${selected_ver} ]] && |
72 |
selected_ver="${ver}" |
74 |
ver_test "${selected_ver}" -gt "${ver}"; then |
73 |
break |
75 |
# Candidate is older than the currently selected candidate. |
|
|
76 |
continue |
77 |
else |
78 |
selected=${candidate} |
79 |
selected_ver=${ver} |
80 |
fi |
74 |
fi |
81 |
fi |
75 |
|
|
|
76 |
if [[ -n ${EZIG_MIN} ]] \ |
77 |
&& ver_test "${ver}" -lt "${EZIG_MIN}"; then |
78 |
# Candidate does not satisfy EZIG_MIN condition. |
79 |
continue |
80 |
fi |
81 |
|
82 |
if [[ -n ${EZIG_MAX_EXCLUSIVE} ]] \ |
83 |
&& ver_test "${ver}" -ge "${EZIG_MAX_EXCLUSIVE}"; then |
84 |
# Candidate does not satisfy EZIG_MAX_EXCLUSIVE condition. |
85 |
continue |
86 |
fi |
87 |
|
88 |
if [[ -n ${selected_ver} ]] \ |
89 |
&& ver_test "${selected_ver}" -gt "${ver}"; then |
90 |
# Candidate is older than the currently selected candidate. |
91 |
continue |
92 |
fi |
93 |
|
94 |
selected="${candidate}" |
95 |
selected_ver="${ver}" |
96 |
done |
82 |
done |
97 |
|
83 |
|
98 |
if [[ -z ${selected} ]]; then |
84 |
if [[ ! ${selected} ]]; then |
99 |
die "Could not find (suitable) zig installation in PATH" |
85 |
die "Could not find (suitable) zig installation in ${BROOT}/usr/bin" |
|
|
86 |
else |
87 |
export EZIG=${selected} |
88 |
export EZIG_VER=${selected_ver} |
100 |
fi |
89 |
fi |
101 |
|
|
|
102 |
export EZIG="${selected}" |
103 |
export EZIG_VER="${ver}" |
104 |
} |
90 |
} |
105 |
|
91 |
|
106 |
# Invoke zig with the optionally provided arguments. |
92 |
# Invoke zig with the optionally provided arguments. |
107 |
- |
|
|