Skip to content

Commit 9ba0141

Browse files
committed
brl-fetch gentoo: improve flavor detection
Previously mis-detected openrc vs hardened-openrc in some circumstances
1 parent 3a7719e commit 9ba0141

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

  • src/slash-bedrock/share/brl-fetch/distros

src/slash-bedrock/share/brl-fetch/distros/gentoo

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,40 @@ list_releases() {
6868
}
6969

7070
fetch() {
71-
# TODO: Gentoo apprently removed minimal Stage 3, now requires an init.
72-
# Defaulting to openrc. In Bedrock 0.8.0 when `brl fetch --flavor` is
73-
# available make deskop vs hardened vs musl, openrc vs systemd,
74-
# flavors.
75-
flavor="desktop-openrc"
71+
# Which flavors are available for a given stage 3 appears to be
72+
# variable depending on time and mirror. Iterate through possibilities
73+
# in minimal-to-maximal order and go with the first found.
74+
#
75+
# TODO: In Bedrock 0.8.0 when `brl fetch --flavor` is available make desktop
76+
# vs hardened vs musl, openrc vs systemd, etc flavors.
77+
flavors="minimal openrc desktop-openrc"
7678

7779
step "Finding bootstrap software"
80+
# stage3 balls are not necessarily in the obvious directory; need to
81+
# search multiple to find where the tarball we are interested in is.
7882
groups="$(download -q "${target_mirror}/releases/" - |
7983
list_links |
8084
grep '/$' |
8185
sed -e 's,/$,,')"
82-
group="$(for group in ${groups}; do
83-
if download -q "${target_mirror}/releases/${group}/autobuilds/" - |
84-
list_links |
85-
grep "^current-stage3-${distro_arch}-${flavor}/$" >/dev/null; then
86-
echo "${group}"
87-
break
88-
fi
86+
group_flavor="$(for group in ${groups}; do
87+
page="$(download -q "${target_mirror}/releases/${group}/autobuilds/" -)"
88+
for flavor in ${flavors}; do
89+
if echo "${page}" | list_links | grep "^current-stage3-${distro_arch}-${flavor}/$" >/dev/null; then
90+
echo "${group}"
91+
echo "${flavor}"
92+
return
93+
fi
94+
done
8995
done)"
90-
if [ -z "${group}" ]; then
96+
echo "group_flavor: ${group_flavor}"
97+
group="$(echo "${group_flavor}" | sed -n 1p)"
98+
flavor="$(echo "${group_flavor}" | sed -n 2p)"
99+
if [ -z "${group}" ] || [ -z "${flavor}" ]; then
91100
abort "Could not find bootstrap software at ${target_mirror} for ${distro_arch}."
92101
fi
93102

94103
step "Downloading bootstrap software"
95-
bootstrap_url="$(find_link "${target_mirror}/releases/${group}/autobuilds/current-stage3-${distro_arch}-${flavor}/" "^stage3-${distro_arch}-[^.]*[.]tar[.]\(xz\|bz2\)$")"
104+
bootstrap_url="$(find_link "${target_mirror}/releases/${group}/autobuilds/current-stage3-${distro_arch}-${flavor}/" "^stage3-${distro_arch}-${flavor}-[^.]*[.]tar[.]\(xz\|bz2\)$")"
96105
bootstrap_name="$(echo "${bootstrap_url}" | sed 's,^.*/,,')"
97106
download "${bootstrap_url}.DIGESTS" "${bootstrap_dir}/checksum"
98107
bootstrap_checksum="$(awk -v"name=${bootstrap_name}" '/^# .* HASH$/ {hash=$2;next} hash == "SHA512" && $2 == name {print$1;exit}' "${bootstrap_dir}/checksum")"

0 commit comments

Comments
 (0)