Skip to content

Commit

Permalink
Fix OpenSuse upgrade script
Browse files Browse the repository at this point in the history
- cache location is zypp
- "all" does not exist for clearing cache, instead zypper uses --all
-  when MariaDB.repo is first added the key should be trusted in a non-interactive manner, hence --gpg-auto-import-keys
- first zypper packages -r goes to /dev/null because there is a lot of noise from trusting the key. Sudo is needed to make the cache.
- second zypper packages -r runs as a normal user with no issues.
  • Loading branch information
RazvanLiviuVarzaru committed Oct 17, 2024
1 parent 9db192c commit 46c23d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 9 additions & 3 deletions scripts/bash_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ rpm_pkg_makecache() {
# 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/$pkg_cmd/*"
sudo "$pkg_cmd" clean all
if [[ $ID_LIKE =~ ^suse* ]]; then
sudo rm -rf "/var/cache/zypp/*"
sudo "$pkg_cmd" clean --all
else
sudo rm -rf "/var/cache/$pkg_cmd/*"
sudo "$pkg_cmd" clean all
fi
source /etc/os-release
if [[ $ID == "rhel" ]]; then
sudo subscription-manager refresh
Expand Down Expand Up @@ -210,7 +215,8 @@ rpm_repoquery() {
set +u
# return full package list from repository
if [[ $ID_LIKE =~ ^suse* ]]; then
zypper packages -r "${repo_name}" | grep "MariaDB" | awk '{print $8}'
sudo zypper --gpg-auto-import-keys packages -r "${repo_name}">/dev/null
zypper packages -r "${repo_name}" | grep "MariaDB" | awk '{print $4}' #After cache is made, no need for sudo
else
repoquery --disablerepo=* --enablerepo="${repo_name}" -a -q |
cut -d ":" -f1 | sort -u | sed 's/-0//'
Expand Down
16 changes: 11 additions & 5 deletions scripts/rpm-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,16 @@ bb_log_info "Package_list: $package_list"
# sudo rm -rf
# /etc/zypp/repos.d/SUSE_Linux_Enterprise_Server_12_SP3_x86_64:SLES12-SP3-Updates.repo
# /etc/zypp/repos.d/SUSE_Linux_Enterprise_Server_12_SP3_x86_64:SLES12-SP3-Pool.repo
sudo "$pkg_cmd" clean all
if [[ $ID_LIKE =~ ^suse* ]]; then
sudo "$pkg_cmd" clean --all
pkg_cmd_nonint="-n"
else
sudo "$pkg_cmd" clean all
pkg_cmd_nonint="-y"
fi

# Install previous release
echo "$package_list" | xargs sudo "$pkg_cmd" -y install ||
echo "$package_list" | xargs sudo "$pkg_cmd" "$pkg_cmd_nonint" install ||
bb_log_err "installation of a previous release failed, see the output above"
#fi

Expand Down Expand Up @@ -246,18 +252,18 @@ fi
if [[ $test_type == "major" ]]; then
bb_log_info "remove old packages for major upgrade"
packages_to_remove=$(rpm -qa | grep 'MariaDB-' | awk -F'-' '{print $1"-"$2}')
echo "$packages_to_remove" | xargs sudo "$pkg_cmd" -y remove
echo "$packages_to_remove" | xargs sudo "$pkg_cmd" "$pkg_cmd_nonint" remove
rpm -qa | grep -iE 'maria|mysql' || true
fi

rpm_setup_bb_galera_artifacts_mirror
rpm_setup_bb_artifacts_mirror
if [[ $test_type == "major" ]]; then
# major upgrade (remove then install)
echo "$package_list" | xargs sudo "$pkg_cmd" -y install
echo "$package_list" | xargs sudo "$pkg_cmd" "$pkg_cmd_nonint" install
else
# minor upgrade (upgrade works)
echo "$package_list" | xargs sudo "$pkg_cmd" -y upgrade
echo "$package_list" | xargs sudo "$pkg_cmd" "$pkg_cmd_nonint" upgrade
fi
# set +e

Expand Down

0 comments on commit 46c23d6

Please sign in to comment.