From de9efa6472c01a6226d01a01319c3ac76c9e0bce Mon Sep 17 00:00:00 2001 From: Faustin Lammler Date: Mon, 26 Feb 2024 18:21:18 +0100 Subject: [PATCH] Fix rpm install script It needs to use galera from BB artifacts and should not depend on fetching rpms. Also use either yum or dnf but do not default to yum. --- scripts/bash_lib.sh | 21 +++++++++++++++------ scripts/rpm-install.sh | 23 ++++++++++++++--------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/scripts/bash_lib.sh b/scripts/bash_lib.sh index 74895839..a5066151 100644 --- a/scripts/bash_lib.sh +++ b/scripts/bash_lib.sh @@ -135,17 +135,26 @@ apt_get_update() { fi } -yum_makecache() { +rpm_pkg() { + if command -v dnf >/dev/null; then + echo dnf + elif command -v yum >/dev/null; then + echo yum + fi +} + +rpm_pkg_makecache() { + pkg_cmd=$(rpm_pkg) # Try several times, to avoid sporadic "The requested URL returned error: 404" made_cache=0 for i in {1..5}; do - sudo rm -rf /var/cache/yum/* - sudo yum clean all + sudo rm -rf "/var/cache/$pkg_cmd/*" + sudo "$pkg_cmd" clean all source /etc/os-release if [[ $ID == "rhel" ]]; then sudo subscription-manager refresh fi - if sudo yum makecache; then + if sudo "$pkg_cmd" makecache; then made_cache=1 break else @@ -277,8 +286,8 @@ rpm_setup_bb_galera_artifacts_mirror() { # stop if any variable is undefined set -u bb_log_info "setup buildbot galera artifact repository" - sudo wget "$artifactsURL/galera/mariadb-4.x-latest-gal-${parentbuildername/-rpm-autobake}.repo" -O /etc/yum.repos.d/galera.repo || { - bb_log_err "unable to download $artifactsURL/galera/mariadb-4.x-latest-gal-${parentbuildername/-rpm-autobake}.repo" + sudo wget "$artifactsURL/galera/mariadb-4.x-latest-gal-${parentbuildername/-rpm-autobake/}.repo" -O /etc/yum.repos.d/galera.repo || { + bb_log_err "unable to download $artifactsURL/galera/mariadb-4.x-latest-gal-${parentbuildername/-rpm-autobake/}.repo" exit 1 } set +u diff --git a/scripts/rpm-install.sh b/scripts/rpm-install.sh index 33f7784d..66cac01e 100755 --- a/scripts/rpm-install.sh +++ b/scripts/rpm-install.sh @@ -11,6 +11,9 @@ set -e # shellcheck disable=SC1091 . ./bash_lib.sh +# yum/dnf switch +pkg_cmd=$(rpm_pkg) + # function to be able to run the script manually (see bash_lib.sh) manual_run_switch "$1" @@ -26,11 +29,11 @@ bb_print_env set -x -yum_makecache +rpm_pkg_makecache -sudo yum search mysql | { grep "^mysql" || true; } -sudo yum search maria | { grep "^maria" || true; } -sudo yum search percona | { grep percona || true; } +sudo "$pkg_cmd" search mysql | { grep "^mysql" || true; } +sudo "$pkg_cmd" search maria | { grep "^maria" || true; } +sudo "$pkg_cmd" search percona | { grep percona || true; } # setup repository for galera dependency rpm_setup_bb_galera_artifacts_mirror @@ -38,7 +41,7 @@ rpm_setup_bb_galera_artifacts_mirror # setup artifact repository rpm_setup_bb_artifacts_mirror -yum_makecache +rpm_pkg_makecache if [[ -f /etc/yum.repos.d/MariaDB.repo ]]; then repo_name_tmp=$(head -n1 /etc/yum.repos.d/MariaDB.repo) @@ -48,11 +51,13 @@ if [[ -f /etc/yum.repos.d/MariaDB.repo ]]; then else bb_log_err "/etc/yum.repos.d/MariaDB.repo is missing" fi -repoquery --disablerepo=* --enablerepo="${repo_name}" | xargs sudo yum -y install -# here is to keep track of it how to install everything from a MDBF repo (they -# contain 3 versions). -# repoquery --disablerepo=* --enablerepo=mariadb -a | cut -d ":" -f1 | sort -u | sed 's/-0//' | xargs dnf -y install +# Install all produced packages. Note that the upgrade test comes with various +# mode (server/all/deps/columnstore), we might want to add those modes in the +# future. +repoquery --disablerepo=* --enablerepo="${repo_name}" -a | + cut -d ":" -f1 | sort -u | sed 's/-0//' | + xargs sudo "$pkg_cmd" -y install sh -c 'g=/usr/lib*/galera*/libgalera_smm.so; echo -e "[galera]\nwsrep_provider=$g"' | sudo tee /etc/my.cnf.d/galera.cnf case "$systemdCapability" in