Formatting (#97)

* Various formatting and spelling fixes.

* Tab to space for more consistent text representation across different editors.
This commit is contained in:
Peter Ajamian 2021-08-14 16:32:10 +12:00 committed by GitHub
parent 7eb310f907
commit 8d68003ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 409 additions and 377 deletions

View File

@ -57,7 +57,7 @@ dnf command or the migration. You may safely ignore this message.
#### Grub still shows kernel entries from previous installation #### Grub still shows kernel entries from previous installation
This is normal. The running kernel cannot be safely removed when migrate2rocky This is normal. The running kernel cannot be safely removed when migrate2rocky
is run. The RockyLinux kernel should come up as the default highlighed kernel is run. The RockyLinux kernel should come up as the default highlighted kernel
on reboot but the other ones will remain until they are removed or replaced by on reboot but the other ones will remain until they are removed or replaced by
newer kernels. If you want you can manually remove the old kernels after reboot newer kernels. If you want you can manually remove the old kernels after reboot
with dnf or rpm. with dnf or rpm.

View File

@ -46,7 +46,8 @@ fi
# Make sure we're root. # Make sure we're root.
if (( EUID != 0 )); then if (( EUID != 0 )); then
printf '%s\n' "You must run this script as root. Either use sudo or 'su -c ${0}'" >&2 printf '%s\n' \
"You must run this script as root. Either use sudo or 'su -c ${0}'" >&2
exit 1 exit 1
fi fi
@ -202,21 +203,27 @@ 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
exit_message "Migration from Katello-modified systems is not supported by migrate2rocky. See the README file for details." exit_message \
'Migration from Katello-modified systems is not supported by migrate2rocky. '\
'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
exit_message "Migration from Uyuni/SUSE Manager-modified systems is not supported by migrate2rocky. See the README file for details." exit_message \
'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\
'migrate2rocky. See the README file for details.'
fi fi
} }
# All of the binaries used by this script are available in a EL8 minimal install # All of the binaries used by this script are available in a EL8 minimal install
# and are in /bin, so we should not encounter a system where the script doesn't # and are in /bin, so we should not encounter a system where the script doesn't
# work unless it's severly broken. This is just a simple check that will cause # work unless it's severely broken. This is just a simple check that will cause
# the script to bail if any expected system utilities are missing. # the script to bail if any expected system utilities are missing.
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
exit_message "This script must be run on an EL8 distribution. Migration from other distributions is not supported." exit_message \
'This script must be run on an EL8 distribution. Migration from other '\
'distributions is not supported.'
fi fi
local -a missing bins local -a missing bins
@ -250,7 +257,9 @@ bin_check() {
done; done;
if (( ${#missing[@]} )); then if (( ${#missing[@]} )); then
exit_message "Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt installation." exit_message \
"Commands not found: ${missing[*]}. Possible bad PATH setting or corrupt "\
"installation."
fi fi
} }
@ -346,7 +355,7 @@ provides_pkg () (
) )
# If you pass an empty arg as one of the package specs to rpm it will match # If you pass an empty arg as one of the package specs to rpm it will match
# every package on the system. This funtion simply strips out any empty args # every package on the system. This function simply strips out any empty args
# and passes the rest to rpm to avoid this side-effect. # and passes the rest to rpm to avoid this side-effect.
saferpm () ( saferpm () (
args=() args=()
@ -413,7 +422,9 @@ collect_system_info () {
# check if EFI secure boot is enabled # check if EFI secure boot is enabled
if [[ $update_efi ]]; then if [[ $update_efi ]]; then
if mokutil --sb-state 2>&1 | grep -q "SecureBoot enabled"; then if mokutil --sb-state 2>&1 | grep -q "SecureBoot enabled"; then
exit_message "EFI Secure Boot is enabled but Rocky Linux doesn't provide a signed shim yet. Disable EFI Secure Boot and reboot." exit_message \
"EFI Secure Boot is enabled but Rocky Linux doesn't provide a signed shim yet."\
" Disable EFI Secure Boot and reboot."
fi fi
fi fi
@ -460,10 +471,13 @@ collect_system_info () {
repo_map[$r]=${repoquery_results[Repository]} repo_map[$r]=${repoquery_results[Repository]}
done done
printf '%s\n' '' '' "Found the following repositories which map from $PRETTY_NAME to Rocky Linux 8:" printf '%s\n' '' '' \
column -t -s $'\t' -N "$PRETTY_NAME,Rocky Linux 8" < <(for r in "${!repo_map[@]}"; do "Found the following repositories which map from $PRETTY_NAME to Rocky Linux 8:"
column -t -s $'\t' -N "$PRETTY_NAME,Rocky Linux 8" < <(
for r in "${!repo_map[@]}"; do
printf '%s\t%s\n' "${repo_map[$r]}" "$r" printf '%s\t%s\n' "${repo_map[$r]}" "$r"
done) done
)
infomsg $'\n'"Getting system package names for $PRETTY_NAME" infomsg $'\n'"Getting system package names for $PRETTY_NAME"
@ -530,14 +544,20 @@ $'because continuing with the migration could cause further damage to system.'
addl_pkg_removes+=("$pkg") addl_pkg_removes+=("$pkg")
done done
printf '%s\n' '' '' "Found the following system packages which map from $PRETTY_NAME to Rocky Linux 8:" printf '%s\n' '' '' \
column -t -s $'\t' -N "$PRETTY_NAME,Rocky Linux 8" < <(for p in "${!pkg_map[@]}"; do "Found the following system packages which map from $PRETTY_NAME to Rocky "\
"Linux 8:"
column -t -s $'\t' -N "$PRETTY_NAME,Rocky Linux 8" < <(
for p in "${!pkg_map[@]}"; do
printf '%s\t%s\n' "${pkg_map[$p]}" "$p" printf '%s\t%s\n' "${pkg_map[$p]}" "$p"
done) done
)
infomsg $'\n'"Getting list of installed system packages."$'\n' infomsg $'\n'"Getting list of installed system packages."$'\n'
readarray -t installed_packages < <(saferpm -qa --queryformat="%{NAME}\n" "${pkg_map[@]}") readarray -t installed_packages < <(
saferpm -qa --queryformat="%{NAME}\n" "${pkg_map[@]}"
)
declare -g -A installed_pkg_check installed_pkg_map declare -g -A installed_pkg_check installed_pkg_map
for p in "${installed_packages[@]}"; do for p in "${installed_packages[@]}"; do
installed_pkg_check[$p]=1 installed_pkg_check[$p]=1
@ -564,7 +584,9 @@ $'because continuing with the migration could cause further damage to system.'
fi fi
done done
printf '%s\n' '' "We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 equivalents" printf '%s\n' '' \
"We will replace the following $PRETTY_NAME packages with their Rocky Linux 8 "\
"equivalents"
column -t -s $'\t' -N "Packages to be Removed,Packages to be Installed" < <( column -t -s $'\t' -N "Packages to be Removed,Packages to be Installed" < <(
for p in "${!installed_pkg_map[@]}"; do for p in "${!installed_pkg_map[@]}"; do
printf '%s\t%s\n' "${installed_pkg_map[$p]}" "$p" printf '%s\t%s\n' "${installed_pkg_map[$p]}" "$p"
@ -595,7 +617,7 @@ $'because continuing with the migration could cause further damage to system.'
# Release packages that are part of SIG's should be listed below when they # Release packages that are part of SIG's should be listed below when they
# are available. # are available.
# UPDATE: We may or may not do something with SIG's here, it could just be # UPDATE: We may or may not do something with SIG's here, it could just be
# left as a separate excersize to swap out the sig repos. # left as a separate exercise to swap out the sig repos.
#sigs_to_swap=() #sigs_to_swap=()
infomsg '%s' $'\n' \ infomsg '%s' $'\n' \
@ -647,7 +669,9 @@ $'because continuing with the migration could cause further damage to system.'
"${enabled_modules[@]}" '' "${enabled_modules[@]}" ''
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
printf '%s\n' '' "In addition, since this system uses subscription-manger the following managed repos will be disabled:" \ printf '%s\n' '' \
'In addition, since this system uses subscription-manager the following '\
'managed repos will be disabled:' \
"${managed_repos[@]}" "${managed_repos[@]}"
fi fi
} }
@ -671,9 +695,13 @@ 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'
rpm -qa --qf "%{NAME}|%{VERSION}|%{RELEASE}|%{INSTALLTIME}|%{VENDOR}|%{BUILDTIME}|%{BUILDHOST}|%{SOURCERPM}|%{LICENSE}|%{PACKAGER}\n" | sort > "${convert_info_dir}/$HOSTNAME-rpm-list-$1.log" rpm -qa --qf \
"%{NAME}|%{VERSION}|%{RELEASE}|%{INSTALLTIME}|%{VENDOR}|%{BUILDTIME}|"\
"%{BUILDHOST}|%{SOURCERPM}|%{LICENSE}|%{PACKAGER}\n" |
sort > "${convert_info_dir}/$HOSTNAME-rpm-list-$1.log"
infomsg "Verifying RPMs installed against RPM database: $1"$'\n\n' infomsg "Verifying RPMs installed against RPM database: $1"$'\n\n'
rpm -Va | sort -k3 > "${convert_info_dir}/$HOSTNAME-rpm-list-verified-$1.log" rpm -Va | sort -k3 > \
"${convert_info_dir}/$HOSTNAME-rpm-list-verified-$1.log"
} }
# Run a dnf update before the actual migration. # Run a dnf update before the actual migration.
@ -685,7 +713,7 @@ $'unstable state. Please correct the issues shown here and try again.'
} }
package_swaps() { package_swaps() {
# Save off any subscription-manger keys, just in case. # Save off any subscription-manager keys, just in case.
if ( shopt -s failglob dotglob; : "$sm_ca_dir"/* ) 2>/dev/null ; then if ( shopt -s failglob dotglob; : "$sm_ca_dir"/* ) 2>/dev/null ; then
tmp_sm_ca_dir=$tmp_dir/sm-certs tmp_sm_ca_dir=$tmp_dir/sm-certs
mkdir "$tmp_sm_ca_dir" || mkdir "$tmp_sm_ca_dir" ||
@ -732,7 +760,8 @@ package_swaps() {
exit exit
EOF EOF
# rocky-repos and rocky-gpg-keys are now installed, so we don't need the key file anymore # rocky-repos and rocky-gpg-keys are now installed, so we don't need the
# key file anymore
rm -rf "$gpg_tmp_dir" rm -rf "$gpg_tmp_dir"
# We need to check to make sure that all of the original system packages # We need to check to make sure that all of the original system packages
@ -817,7 +846,7 @@ EOF
# Distrosync # Distrosync
infomsg $'Ensuring repos are enabled before the package swap\n' 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[@]}" || { --set-enabled "${!repo_map[@]}" || {
printf '%s\n' 'Repo name missing?' printf '%s\n' 'Repo name missing?'
exit 25 exit 25
@ -826,7 +855,8 @@ EOF
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
# Filter the managed repos for ones still in the system. # Filter the managed repos for ones still in the system.
readarray -t managed_repos < <( readarray -t managed_repos < <(
safednf -q repolist "${managed_repos[@]}" | awk '$1!="repo" {print $1}' safednf -q repolist "${managed_repos[@]}" |
awk '$1!="repo" {print $1}'
) )
if (( ${#managed_repos[@]} )); then if (( ${#managed_repos[@]} )); then
@ -888,7 +918,7 @@ EOF
fi fi
if rpm --quiet -q subscription-manager; then if rpm --quiet -q subscription-manager; then
infomsg $'\nSubscription Manager found on system.\n\n' infomsg $'Subscription Manager found on system.\n\n'
cat <<EOF cat <<EOF
If you're converting from a subscription-managed distribution such as RHEL then If you're converting from a subscription-managed distribution such as RHEL then
you may no longer need subscription-manager or dnf-plugin-subscription-manager. you may no longer need subscription-manager or dnf-plugin-subscription-manager.
@ -969,13 +999,15 @@ fix_efi () (
# Download and verify the Rocky Linux package signing key # Download and verify the Rocky Linux package signing key
establish_gpg_trust () { establish_gpg_trust () {
# create temp dir and verify it is really created and empty, so we are sure deleting it afterwards won't cause any harm # create temp dir and verify it is really created and empty, so we are sure
# deleting it afterwards won't cause any harm
declare -g gpg_tmp_dir declare -g gpg_tmp_dir
gpg_tmp_dir=$tmp_dir/gpg gpg_tmp_dir=$tmp_dir/gpg
if ! mkdir "$gpg_tmp_dir" || [[ ! -d "$gpg_tmp_dir" ]]; then if ! mkdir "$gpg_tmp_dir" || [[ ! -d "$gpg_tmp_dir" ]]; then
exit_message "Error creating temp dir" exit_message "Error creating temp dir"
fi fi
# failglob makes pathname expansion fail if empty, dotglob adds files starting with . to pathname expansion # failglob makes pathname expansion fail if empty, dotglob adds files
# starting with . to pathname expansion
if ( shopt -s failglob dotglob; : "$gpg_tmp_dir"/* ) 2>/dev/null ; then if ( shopt -s failglob dotglob; : "$gpg_tmp_dir"/* ) 2>/dev/null ; then
exit_message "Temp dir not empty" exit_message "Temp dir not empty"
fi fi