Skip to content

Commit 216b897

Browse files
committed
MDBF-960: Decouple master-libvirt arch variable from install/upgrade scripts
The arch environment variable was overused to generate proper repository paths, when the whole information was already available as part of dist_name and version_name. This patch moves the URL transformation logic within bash_lib.sh, allowing master_libvirt to pass in fewer environment variables.
1 parent 7efbcb8 commit 216b897

File tree

3 files changed

+87
-26
lines changed

3 files changed

+87
-26
lines changed

master-libvirt/master.cfg

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,8 @@ for builder_name in BUILDERS_INSTALL:
222222
)
223223
)
224224

225-
if builder_type == "deb":
226-
factory_install = f_deb_install
227-
factory_upgrade = f_deb_upgrade
228-
build_arch = platform
229-
elif builder_type == "rpm":
230-
factory_install = f_rpm_install
231-
factory_upgrade = f_rpm_upgrade
232-
build_arch = (
233-
os_name + str(OS_INFO[os_info_name]["version_name"]) + "-" + platform
234-
)
235-
236-
# FIXME - all RPM's should follow the same conventions!
237-
if os_name == "centos" and OS_INFO[os_info_name]["version_name"] >= 9:
238-
if platform == "amd64":
239-
platform = "x86_64"
240-
build_arch = f"centos/{OS_INFO[os_info_name]['version_name']}/{platform}"
225+
factory_install = f_deb_install if builder_type == "deb" else f_rpm_install
226+
factory_upgrade = f_deb_upgrade if builder_type == "deb" else f_rpm_upgrade
241227

242228
c["builders"].append(
243229
util.BuilderConfig(
@@ -252,7 +238,7 @@ for builder_name in BUILDERS_INSTALL:
252238
"needsGalera": "yes",
253239
"dist_name": os_name,
254240
"version_name": OS_INFO[os_info_name]["version_name"],
255-
"arch": build_arch,
241+
"arch": platform,
256242
"BB_CI": True,
257243
"artifactsURL": artifactsURL,
258244
},
@@ -276,7 +262,7 @@ for builder_name in BUILDERS_INSTALL:
276262
"needsGalera": "yes",
277263
"dist_name": os_name,
278264
"version_name": OS_INFO[os_info_name]["version_name"],
279-
"arch": build_arch,
265+
"arch": platform,
280266
"test_mode": "server",
281267
"test_type": "major",
282268
"BB_CI": True,
@@ -302,7 +288,7 @@ for builder_name in BUILDERS_INSTALL:
302288
"needsGalera": "yes",
303289
"dist_name": os_name,
304290
"version_name": OS_INFO[os_info_name]["version_name"],
305-
"arch": build_arch,
291+
"arch": platform,
306292
"test_mode": "all",
307293
"test_type": "minor",
308294
"BB_CI": True,
@@ -326,7 +312,7 @@ for builder_name in BUILDERS_INSTALL:
326312
"needsGalera": "no",
327313
"dist_name": os_name,
328314
"version_name": OS_INFO[os_info_name]["version_name"],
329-
"arch": build_arch,
315+
"arch": platform,
330316
"test_mode": "columnstore",
331317
"test_type": "minor",
332318
"BB_CI": True,

scripts/bash_lib.sh

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,68 @@ rpm_repo_dir() {
143143
set -u
144144
}
145145

146+
_rpm_get_base_mirror_url() {
147+
local branch=$1
148+
echo "https://rpm.mariadb.org/$branch"
149+
}
150+
151+
_rpm_get_base_archive_url() {
152+
local branch=$1
153+
echo "https://archive.mariadb.org/mariadb-$branch/yum/"
154+
}
155+
156+
_rpm_get_repo_path() {
157+
# Construct a distro repo URL path based on the file hierarchy set up
158+
# by buildbot / release scripts.
159+
local arch=$1
160+
local dist_name=$2
161+
local version_number=$3
162+
local path="${dist_name}${version_number}-${arch}"
163+
164+
# Special handling for centos 9
165+
# This uses the previous hierarchy in release scripts instead of a flattened
166+
# path.
167+
if [[ "$dist_name" == "centos" && "$version_number" -ge 9 ]]; then
168+
# Check if architecture is amd64 and convert to x86_64
169+
if [[ "$arch" == "amd64" ]]; then
170+
arch="x86_64"
171+
fi
172+
path="$dist_name/$version_number/$arch"
173+
fi
174+
175+
echo "$path"
176+
}
177+
178+
rpm_get_mirror_url() {
179+
# Return full URL to corresponding distro repo on the mariadb mirror.
180+
local branch=$1
181+
local arch=$2
182+
local dist_name=$3
183+
local version_number=$4
184+
local base
185+
local path
186+
187+
base=$(_rpm_get_base_mirror_url "$branch")
188+
path=$(_rpm_get_repo_path "$arch" "$dist_name" "$version_number")
189+
# Print the final constructed URL
190+
echo "${base}/${path}"
191+
}
192+
193+
rpm_get_archive_url() {
194+
# Return full URL to corresponding distro repo on the archive.
195+
local branch=$1
196+
local arch=$2
197+
local dist_name=$3
198+
local version_number=$4
199+
local base
200+
local path
201+
202+
base=$(_rpm_get_base_archive_url "$branch")
203+
path=$(_rpm_get_repo_path "$arch" "$dist_name" "$version_number")
204+
# Print the final constructed URL
205+
echo "${base}/${path}"
206+
}
207+
146208
rpm_pkg() {
147209
# ID_LIKE may not exist
148210
set +u
@@ -279,15 +341,25 @@ rpm_setup_mariadb_mirror() {
279341
bb_log_err "missing the branch variable"
280342
exit 1
281343
}
282-
branch=$1
344+
[[ -n $2 ]] || {
345+
bb_log_err "missing the mirror_url variable"
346+
exit 1
347+
}
348+
[[ -n $3 ]] || {
349+
bb_log_err "missing the archive_url variable"
350+
exit 1
351+
}
352+
local branch=$1
353+
local mirror_url=$2
354+
local archive_url=$3
355+
283356
bb_log_info "setup MariaDB repository for $branch branch"
284357
command -v wget >/dev/null || {
285358
bb_log_err "wget command not found"
286359
exit 1
287360
}
288-
#//TEMP it's probably better to install the last stable release here...?
289-
mirror_url="https://rpm.mariadb.org/$branch/$arch"
290-
archive_url="https://archive.mariadb.org/mariadb-$branch/yum/$arch"
361+
362+
local baseurl
291363
if wget -q --spider "$mirror_url"; then
292364
baseurl="$mirror_url"
293365
elif wget -q --spider "$archive_url"; then
@@ -297,7 +369,7 @@ rpm_setup_mariadb_mirror() {
297369
# since we know it will always fail. But apparently, it's not going to
298370
# happen soon in BB. Once done though, replace the warning with an error
299371
# and use a non-zero exit code.
300-
bb_log_warn "rpm_setup_mariadb_mirror: $branch packages for $dist_name $version_name does not exist on https://rpm.mariadb.org/"
372+
bb_log_warn "rpm_setup_mariadb_mirror: $branch packages do not exist on either $mirror_url or $archive_url"
301373
exit 0
302374
fi
303375
cat <<EOF | sudo tee "$(rpm_repo_dir)/MariaDB.repo"

scripts/rpm-upgrade.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ set -x
3434

3535
rpm_pkg_makecache
3636

37-
rpm_setup_mariadb_mirror "$prev_major_version"
37+
38+
mirror_url=$(rpm_get_mirror_url "$prev_major_version" "$arch" "$dist_name" "$version_name")
39+
archive_url=$(rpm_get_archive_url "$prev_major_version" "$arch" "$dist_name" "$version_name")
40+
rpm_setup_mariadb_mirror "$prev_major_version" "$mirror_url" "$archive_url"
3841

3942
# Define the list of packages to install/upgrade
4043
case $test_mode in

0 commit comments

Comments
 (0)