From 7ae4362515e75e6ba8be696ee59019d88f5917ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 7 Feb 2025 10:48:25 +0200 Subject: [PATCH] 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. --- master-libvirt/master.cfg | 26 +++---------- scripts/bash_lib.sh | 78 ++++++++++++++++++++++++++++++++++++--- scripts/rpm-upgrade.sh | 5 ++- 3 files changed, 83 insertions(+), 26 deletions(-) diff --git a/master-libvirt/master.cfg b/master-libvirt/master.cfg index 67458391..68137b3f 100644 --- a/master-libvirt/master.cfg +++ b/master-libvirt/master.cfg @@ -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( @@ -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, }, @@ -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, @@ -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, @@ -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, diff --git a/scripts/bash_lib.sh b/scripts/bash_lib.sh index 2752440b..a1137cd2 100644 --- a/scripts/bash_lib.sh +++ b/scripts/bash_lib.sh @@ -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 @@ -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 @@ -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 <