Skip to content

Commit

Permalink
Fix rpm install script
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fauust committed Feb 26, 2024
1 parent 36d6dec commit de9efa6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
21 changes: 15 additions & 6 deletions scripts/bash_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 14 additions & 9 deletions scripts/rpm-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -26,19 +29,19 @@ 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

# 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)
Expand All @@ -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
Expand Down

0 comments on commit de9efa6

Please sign in to comment.