From aff688f30c092289e841af911c731d38a95feea6 Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Thu, 18 Nov 2021 14:31:33 +1300 Subject: [PATCH 1/3] grep is needed for all migrations. Move the check for grep to the main list of binaries instead of the ones just needed for EFI boot. --- migrate2rocky/migrate2rocky.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index b95bb9f..4d6f3bc 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -230,10 +230,10 @@ bin_check() { local -a missing bins bins=( rpm dnf awk column tee tput mkdir cat arch sort uniq rmdir - rm head curl sha512sum mktemp systemd-detect-virt sed + rm head curl sha512sum mktemp systemd-detect-virt sed grep ) if [[ $update_efi ]]; then - bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil lsblk) + bins+=(findmnt grub2-mkconfig efibootmgr mokutil lsblk) fi for bin in "${bins[@]}"; do if ! type "$bin" >/dev/null 2>&1; then From 22455ba2213f97dad28ed6dee094a29d69da8445 Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Thu, 18 Nov 2021 14:38:29 +1300 Subject: [PATCH 2/3] Fix config-manager dnf plugin name. See RHBZ #1980712. --- migrate2rocky/migrate2rocky.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index 4d6f3bc..79796c5 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -838,7 +838,7 @@ EOF # Distrosync infomsg $'Ensuring repos are enabled before the package swap\n' - safednf -y --enableplugin=config-manager config-manager \ + safednf -y --enableplugin=config_manager config-manager \ --set-enabled "${!repo_map[@]}" || { printf '%s\n' 'Repo name missing?' exit 25 @@ -853,7 +853,7 @@ EOF if (( ${#managed_repos[@]} )); then infomsg $'\nDisabling subscription managed repos\n' - safednf -y --enableplugin=config-manager config-manager \ + safednf -y --enableplugin=config_manager config-manager \ --disable "${managed_repos[@]}" fi fi From 28be74a123d1c6c9dd0234522693bf53c2722c2e Mon Sep 17 00:00:00 2001 From: Peter Ajamian Date: Thu, 18 Nov 2021 14:50:00 +1300 Subject: [PATCH 3/3] Shellcheck fixes. Various fixes reported by shellcheck. --- migrate2rocky/migrate2rocky.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/migrate2rocky/migrate2rocky.sh b/migrate2rocky/migrate2rocky.sh index 79796c5..026012c 100644 --- a/migrate2rocky/migrate2rocky.sh +++ b/migrate2rocky/migrate2rocky.sh @@ -204,11 +204,13 @@ exit_clean () { pre_check () { if [[ -e /etc/rhsm/ca/katello-server-ca.pem ]]; then +# shellcheck disable=SC2026 exit_message \ 'Migration from Katello-modified systems is not supported by migrate2rocky. '\ 'See the README file for details.' fi if [[ -e /etc/salt/minion.d/susemanager.conf ]]; then +# shellcheck disable=SC2026 exit_message \ 'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\ 'migrate2rocky. See the README file for details.' @@ -222,6 +224,7 @@ pre_check () { bin_check() { # Check the platform. if [[ $(os-release PLATFORM_ID) != "$SUPPORTED_PLATFORM" ]]; then +# shellcheck disable=SC2026 exit_message \ 'This script must be run on an EL8 distribution. Migration from other '\ 'distributions is not supported.' @@ -258,6 +261,7 @@ bin_check() { done; if (( ${#missing[@]} )); then +# shellcheck disable=SC2140 exit_message \ "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt "\ "installation." @@ -536,6 +540,7 @@ $'because continuing with the migration could cause further damage to system.' addl_pkg_removes+=("$pkg") done +# shellcheck disable=SC2140 printf '%s\n' '' '' \ "Found the following system packages which map from $PRETTY_NAME to Rocky "\ "Linux 8:" @@ -576,6 +581,7 @@ $'because continuing with the migration could cause further damage to system.' fi done +# shellcheck disable=SC2140 printf '%s\n' '' \ "We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 "\ "equivalents" @@ -586,6 +592,7 @@ $'because continuing with the migration could cause further damage to system.' ) if (( ${#installed_sys_stream_repos_pkgs[@]} )); then +# shellcheck disable=SC2026 printf '%s\n' '' \ 'Also to aid the transition from CentOS Stream the following packages will be '\ 'removed from the rpm database but the included repos will be renamed and '\ @@ -594,6 +601,7 @@ $'because continuing with the migration could cause further damage to system.' fi if (( ${#installed_stream_repos_pkgs[@]} )); then +# shellcheck disable=SC2026 printf '%s\n' '' \ 'Also to aid the transition from CentOS Stream the repos included in the '\ 'following packages will be renamed and retained but disabled:' \ @@ -661,6 +669,7 @@ $'because continuing with the migration could cause further damage to system.' "${enabled_modules[@]}" '' if (( ${#managed_repos[@]} )); then +# shellcheck disable=SC2026 printf '%s\n' '' \ 'In addition, since this system uses subscription-manager the following '\ 'managed repos will be disabled:' \ @@ -687,6 +696,7 @@ usage() { generate_rpm_info() { mkdir /root/convert infomsg "Creating a list of RPMs installed: $1"$'\n' +# shellcheck disable=SC2140 rpm -qa --qf \ "%{NAME}|%{VERSION}|%{RELEASE}|%{INSTALLTIME}|%{VENDOR}|%{BUILDTIME}|"\ "%{BUILDHOST}|%{SOURCERPM}|%{LICENSE}|%{PACKAGER}\n" | @@ -735,7 +745,7 @@ package_swaps() { # Remove the package from the rpm db. saferpm -e --justdb --nodeps -a "${installed_sys_stream_repos_pkgs[@]}" || exit_message \ -"Could not remove packages from the rpm db: ${installed_sys_stream_repos_pkgs[@]}" +"Could not remove packages from the rpm db: ${installed_sys_stream_repos_pkgs[*]}" # Rename the stream repos with a prefix. sed -i 's/^\[/['"$stream_prefix"'/' "${repos_files[@]}"