Skip to content

Commit 18afafd

Browse files
committed
Add very crude parsing of "repomd.xml"
This gives us more accurate version scraping that's not reliant on the cache of the HTML file listing (which instead matches how `yum`/`dnf` query these version numbers, so should stay in sync better). This should fix our issues with CI sometimes returning a mismatch in 8.0 versions. **However**, this *causes* a mismatch in 5.7 versions because the latest 5.7 release (that we were not picking up before due to the aforementioned HTML caching but are now with this updated code) is apparently not built/released for Debian (https://dev.mysql.com/downloads/mysql/), so we also need to decide whether we're going to introduce Debian/Oracle version skew or perhaps deprecate/remove the Debian variants of 5.7 (which is ostensibly EOL in ~3 months).
1 parent 2baf92d commit 18afafd

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

versions.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,28 @@ fetch_rpm_versions() {
2323
local oracleVersion="$1"; shift
2424
local package="$1"; shift
2525

26-
curl -fsSL "$repo/$arch/" 2>/dev/null \
26+
local baseurl="$repo/$arch"
27+
28+
# *technically*, we should parse "repodata/repomd.xml", look for <data type="primary">, and use the <location href="..."> value out of it, but parsing XML is not trivial with only basic tools, it turns out, so instead we rely on MySQL's use of "*-primary.xml.*" as the filename we're after 👀
29+
local primaryLocation
30+
primaryLocation="$(
31+
# 2>/dev/null in case "$arch" doesn't exist in "$repo" 🙈
32+
curl -fsSL "$baseurl/repodata/repomd.xml" 2>/dev/null \
33+
| grep -oE 'href="[^"]+-primary[.]xml([.]gz)?"' \
34+
| cut -d'"' -f2
35+
)" || return 1
36+
[ -n "$primaryLocation" ] || return 1
37+
38+
local decompressor='cat'
39+
case "$primaryLocation" in
40+
*.gz) decompressor='gunzip' ;;
41+
*.xml) ;;
42+
*) echo >&2 "error: unknown compression (from '$baseurl'): $primaryLocation"; exit 1 ;;
43+
esac
44+
45+
# again, *technically* we should properly parse XML here, but y'know, it's complicated
46+
curl -fsSL "$baseurl/$primaryLocation" \
47+
| "$decompressor" \
2748
| grep -oE '"'"$package"'-[0-9][^"]+[.]el'"$oracleVersion"'[.]'"$arch"'[.]rpm"' \
2849
| sed -r 's/^"'"$package-|[.]$arch[.]rpm"'"$//g' \
2950
| sort -rV
@@ -111,6 +132,10 @@ for version in "${versions[@]}"; do
111132
export bashbrewArch
112133
doc="$(jq <<<"$doc" -c '.oracle.architectures = (.oracle.architectures + [ env.bashbrewArch ] | sort)')"
113134
done
135+
if [ -z "$rpmVersion" ]; then
136+
echo >&2 "error: missing version for '$version'"
137+
exit 1
138+
fi
114139
baseVersion="$(jq <<<"$doc" -r '.version // ""')"
115140
# example 8.0.22-1.el7 => 8.0.22
116141
oracleBaseVersion="${rpmVersion%-*}"

0 commit comments

Comments
 (0)