Skip to content

Commit

Permalink
Decouple master-libvirt arch variable from install/upgrade scripts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cvicentiu committed Feb 12, 2025
1 parent c667796 commit 7ae4362
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 26 deletions.
26 changes: 6 additions & 20 deletions master-libvirt/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,8 @@ for builder_name in BUILDERS_INSTALL:
)
)

if builder_type == "deb":
factory_install = f_deb_install
factory_upgrade = f_deb_upgrade
build_arch = platform
elif builder_type == "rpm":
factory_install = f_rpm_install
factory_upgrade = f_rpm_upgrade
build_arch = (
os_name + str(OS_INFO[os_info_name]["version_name"]) + "-" + platform
)

# FIXME - all RPM's should follow the same conventions!
if os_name == "centos" and OS_INFO[os_info_name]["version_name"] >= 9:
if platform == "amd64":
platform = "x86_64"
build_arch = f"centos/{OS_INFO[os_info_name]['version_name']}/{platform}"
factory_install = f_deb_install if builder_type == "deb" else f_rpm_install
factory_upgrade = f_deb_upgrade if builder_type == "deb" else f_rpm_upgrade

c["builders"].append(
util.BuilderConfig(
Expand All @@ -257,7 +243,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"BB_CI": True,
"artifactsURL": artifactsURL,
},
Expand All @@ -281,7 +267,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"test_mode": "server",
"test_type": "major",
"BB_CI": True,
Expand All @@ -307,7 +293,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"test_mode": "all",
"test_type": "minor",
"BB_CI": True,
Expand All @@ -331,7 +317,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "no",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"test_mode": "columnstore",
"test_type": "minor",
"BB_CI": True,
Expand Down
78 changes: 73 additions & 5 deletions scripts/bash_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,64 @@ rpm_repo_dir() {
set -u
}

_rpm_get_base_mirror_url() {
local branch=$1
echo "https://rpm.mariadb.org/$branch"
}

_rpm_get_base_archive_url() {
local branch=$1
echo "https://archive.mariadb.org/mariadb-$branch/yum/"
}

_rpm_get_repo_path() {
# Construct a distro repo URL path based on the file hierarchy set up
# by buildbot / release scripts.
local arch=$1
local dist_name=$2
local version_number=$3
local path="${dist_name}${version_number}-${arch}"

# Special handling for centos 9
# This uses the previous hierarchy in release scripts instead of a flattened
# path.
if [[ "$dist_name" == "centos" && "$version_number" -ge 9 ]]; then
# Check if architecture is amd64 and convert to x86_64
if [[ "$arch" == "amd64" ]]; then
arch="x86_64"
fi
path="$dist_name/$version_number/$arch"
fi

echo $path
}

rpm_get_mirror_url() {
# Return full URL to corresponding distro repo on the mariadb mirror.
local branch=$1
local arch=$2
local dist_name=$3
local version_number=$4

local base=$(_rpm_get_base_mirror_url "$branch")
local path=$(_rpm_get_repo_path $arch $dist_name $version_number)
# Print the final constructed URL
echo "${base}/${path}"
}

rpm_get_archive_url() {
# Return full URL to corresponding distro repo on the archive.
local branch=$1
local arch=$2
local dist_name=$3
local version_number=$4

local base=$(_rpm_get_base_archive_url "$branch")
local path=$(_rpm_get_repo_path $arch $dist_name $version_number)
# Print the final constructed URL
echo "${base}/${path}"
}

rpm_pkg() {
# ID_LIKE may not exist
set +u
Expand Down Expand Up @@ -279,15 +337,25 @@ rpm_setup_mariadb_mirror() {
bb_log_err "missing the branch variable"
exit 1
}
branch=$1
[[ -n $2 ]] || {
bb_log_err "missing the mirror_url variable"
exit 1
}
[[ -n $3 ]] || {
bb_log_err "missing the archive_url variable"
exit 1
}
local branch=$1
local mirror_url=$2
local archive_url=$3

bb_log_info "setup MariaDB repository for $branch branch"
command -v wget >/dev/null || {
bb_log_err "wget command not found"
exit 1
}
#//TEMP it's probably better to install the last stable release here...?
mirror_url="https://rpm.mariadb.org/$branch/$arch"
archive_url="https://archive.mariadb.org/mariadb-$branch/yum/$arch"

local baseurl
if wget -q --spider "$mirror_url"; then
baseurl="$mirror_url"
elif wget -q --spider "$archive_url"; then
Expand All @@ -297,7 +365,7 @@ rpm_setup_mariadb_mirror() {
# since we know it will always fail. But apparently, it's not going to
# happen soon in BB. Once done though, replace the warning with an error
# and use a non-zero exit code.
bb_log_warn "rpm_setup_mariadb_mirror: $branch packages for $dist_name $version_name does not exist on https://rpm.mariadb.org/"
bb_log_warn "rpm_setup_mariadb_mirror: $branch packages do not exist on $baseurl"
exit 0
fi
cat <<EOF | sudo tee "$(rpm_repo_dir)/MariaDB.repo"
Expand Down
5 changes: 4 additions & 1 deletion scripts/rpm-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ set -x

rpm_pkg_makecache

rpm_setup_mariadb_mirror "$prev_major_version"

mirror_url=$(rpm_get_mirror_url $prev_major_version $arch $dist_name $version_name)
archive_url=$(rpm_get_archive_url $prev_major_version $arch $dist_name $version_name)
rpm_setup_mariadb_mirror "$prev_major_version" "$mirror_url" "$archive_url"

# Define the list of packages to install/upgrade
case $test_mode in
Expand Down

0 comments on commit 7ae4362

Please sign in to comment.