Shellcheck fixes.

Various fixes reported by shellcheck.
This commit is contained in:
Peter Ajamian 2021-11-18 14:50:00 +13:00
parent 22455ba221
commit 28be74a123

View File

@ -204,11 +204,13 @@ exit_clean () {
pre_check () { pre_check () {
if [[ -e /etc/rhsm/ca/katello-server-ca.pem ]]; then if [[ -e /etc/rhsm/ca/katello-server-ca.pem ]]; then
# shellcheck disable=SC2026
exit_message \ exit_message \
'Migration from Katello-modified systems is not supported by migrate2rocky. '\ 'Migration from Katello-modified systems is not supported by migrate2rocky. '\
'See the README file for details.' 'See the README file for details.'
fi fi
if [[ -e /etc/salt/minion.d/susemanager.conf ]]; then if [[ -e /etc/salt/minion.d/susemanager.conf ]]; then
# shellcheck disable=SC2026
exit_message \ exit_message \
'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\ 'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\
'migrate2rocky. See the README file for details.' 'migrate2rocky. See the README file for details.'
@ -222,6 +224,7 @@ pre_check () {
bin_check() { bin_check() {
# Check the platform. # Check the platform.
if [[ $(os-release PLATFORM_ID) != "$SUPPORTED_PLATFORM" ]]; then if [[ $(os-release PLATFORM_ID) != "$SUPPORTED_PLATFORM" ]]; then
# shellcheck disable=SC2026
exit_message \ exit_message \
'This script must be run on an EL8 distribution. Migration from other '\ 'This script must be run on an EL8 distribution. Migration from other '\
'distributions is not supported.' 'distributions is not supported.'
@ -258,6 +261,7 @@ bin_check() {
done; done;
if (( ${#missing[@]} )); then if (( ${#missing[@]} )); then
# shellcheck disable=SC2140
exit_message \ exit_message \
"Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt "\ "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt "\
"installation." "installation."
@ -536,6 +540,7 @@ $'because continuing with the migration could cause further damage to system.'
addl_pkg_removes+=("$pkg") addl_pkg_removes+=("$pkg")
done done
# shellcheck disable=SC2140
printf '%s\n' '' '' \ printf '%s\n' '' '' \
"Found the following system packages which map from $PRETTY_NAME to Rocky "\ "Found the following system packages which map from $PRETTY_NAME to Rocky "\
"Linux 8:" "Linux 8:"
@ -576,6 +581,7 @@ $'because continuing with the migration could cause further damage to system.'
fi fi
done done
# shellcheck disable=SC2140
printf '%s\n' '' \ printf '%s\n' '' \
"We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 "\ "We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 "\
"equivalents" "equivalents"
@ -586,6 +592,7 @@ $'because continuing with the migration could cause further damage to system.'
) )
if (( ${#installed_sys_stream_repos_pkgs[@]} )); then if (( ${#installed_sys_stream_repos_pkgs[@]} )); then
# shellcheck disable=SC2026
printf '%s\n' '' \ printf '%s\n' '' \
'Also to aid the transition from CentOS Stream the following packages will be '\ '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 '\ '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 fi
if (( ${#installed_stream_repos_pkgs[@]} )); then if (( ${#installed_stream_repos_pkgs[@]} )); then
# shellcheck disable=SC2026
printf '%s\n' '' \ printf '%s\n' '' \
'Also to aid the transition from CentOS Stream the repos included in the '\ 'Also to aid the transition from CentOS Stream the repos included in the '\
'following packages will be renamed and retained but disabled:' \ '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[@]}" '' "${enabled_modules[@]}" ''
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
# shellcheck disable=SC2026
printf '%s\n' '' \ printf '%s\n' '' \
'In addition, since this system uses subscription-manager the following '\ 'In addition, since this system uses subscription-manager the following '\
'managed repos will be disabled:' \ 'managed repos will be disabled:' \
@ -687,6 +696,7 @@ usage() {
generate_rpm_info() { generate_rpm_info() {
mkdir /root/convert mkdir /root/convert
infomsg "Creating a list of RPMs installed: $1"$'\n' infomsg "Creating a list of RPMs installed: $1"$'\n'
# shellcheck disable=SC2140
rpm -qa --qf \ rpm -qa --qf \
"%{NAME}|%{VERSION}|%{RELEASE}|%{INSTALLTIME}|%{VENDOR}|%{BUILDTIME}|"\ "%{NAME}|%{VERSION}|%{RELEASE}|%{INSTALLTIME}|%{VENDOR}|%{BUILDTIME}|"\
"%{BUILDHOST}|%{SOURCERPM}|%{LICENSE}|%{PACKAGER}\n" | "%{BUILDHOST}|%{SOURCERPM}|%{LICENSE}|%{PACKAGER}\n" |
@ -735,7 +745,7 @@ package_swaps() {
# Remove the package from the rpm db. # Remove the package from the rpm db.
saferpm -e --justdb --nodeps -a "${installed_sys_stream_repos_pkgs[@]}" || saferpm -e --justdb --nodeps -a "${installed_sys_stream_repos_pkgs[@]}" ||
exit_message \ 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. # Rename the stream repos with a prefix.
sed -i 's/^\[/['"$stream_prefix"'/' "${repos_files[@]}" sed -i 's/^\[/['"$stream_prefix"'/' "${repos_files[@]}"