Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: ShellCheck

on:
pull_request:

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install ShellCheck
run: sudo apt-get update && sudo apt-get install -y shellcheck

- name: Run ShellCheck
run: shellcheck -e SC2086 opensuse-migration-tool scripts/*.sh
55 changes: 24 additions & 31 deletions opensuse-migration-tool
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ if [[ ! -f /etc/os-release ]]; then
exit 2
fi
# Source OS release info
# shellcheck source=/etc/os-release
source /etc/os-release
ARCH=$(uname -i) # x86_64 XXX: check for other arches

# Fetch distribution data from API
API_URL="https://get.opensuse.org/api/v0/distributions.json"
API_DATA=$(curl -s --fail "$API_URL")
if [ $? != 0 ]; then
if ! API_DATA=$(curl -s --fail "$API_URL"); then
echo "Network error: Unable to fetch release data from $API_URL"
echo "Ensure that you have working network connectivity and get.opensuse.org is accessible."
echo "Trying local fallback distributions.json ..."
Expand Down Expand Up @@ -212,7 +212,7 @@ elif [[ "$NAME" == "openSUSE MicroOS-Slowroll" ]]; then
MIGRATION_OPTIONS["$CURRENT_INDEX"]="MicroOS"
((CURRENT_INDEX++))
elif [[ "$NAME" == "openSUSE Leap" ]]; then
MIGRATION_OPTIONS["$CURRENT_INDEX"]="SUSE Linux Enterprise $(sed 's/\./ SP/' <<<"$VERSION")"
MIGRATION_OPTIONS["$CURRENT_INDEX"]="SUSE Linux Enterprise ${VERSION/./ SP}"
((CURRENT_INDEX++))
MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE Tumbleweed"
((CURRENT_INDEX++))
Expand Down Expand Up @@ -267,7 +267,7 @@ REPO_LIST=()
# Known 3rd party repos with no $releasever or hardcoded version
exceptions=("google-chrome" )

while IFS="|" read -r num alias name enabled rest; do
while IFS="|" read -r _ alias name enabled rest; do
alias=$(echo "$alias" | xargs) # trim
name=$(echo "$name" | xargs)
enabled=$(echo "$enabled" | xargs)
Expand Down Expand Up @@ -316,7 +316,7 @@ if [[ -n $CHOICE ]]; then
*"SUSE Linux Enterprise"*|"SLE")
$DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"

SP=$(sed 's/\./-SP/' <<<"$VERSION") # VERSION from /etc/os-release 15.6 -> 15-SP6
SP=${VERSION/./-SP} # VERSION from /etc/os-release 15.6 -> 15-SP6

while true; do
# Capture output and return code
Expand Down Expand Up @@ -363,8 +363,8 @@ if [[ -n $CHOICE ]]; then
#$DRYRUN zypper install --force-resolution -y suseconnect-ng
#$DRYRUN zypper install --force-resolution -y unified-installer-release SLE_BCI-release # sles-release is not in BCI

MAJVER=$(echo $VERSION| awk -F"." '{ print $1 }') # 15
MINVER=$(echo $VERSION| awk -F"." '{ print $2 }') # 6
MAJVER=${VERSION%%.*} # 15
MINVER=${VERSION#*.} # 6
$DRYRUN zypper install -y suseconnect-ng snapper grub2-snapper-plugin
# Backup /etc/os-release before release package removal
echo "Backing up /etc/os-release as /etc/os-release.backup"
Expand Down Expand Up @@ -398,8 +398,7 @@ EOL
$DRYRUN suseconnect -e "$EMAIL" -r "$REGCODE"
$DRYRUN SUSEConnect -p "PackageHub/$VERSION/$ARCH"

$DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
if ! $DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance
fi

Expand All @@ -422,13 +421,12 @@ EOL
exit 1
fi
fi
$DRYRUN zypper addrepo -f $REPOURL $TMP_REPO_NAME
$DRYRUN zypper addrepo -f "$REPOURL" $TMP_REPO_NAME
$DRYRUN zypper install --repo $TMP_REPO_NAME -y --force-resolution --from $TMP_REPO_NAME openSUSE-repos-Tumbleweed # install repos from the nextrelease
$DRYRUN zypper removerepo $TMP_REPO_NAME # drop the temp repo, we have now definitions of all repos we need
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

$DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
if ! $DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance
fi

Expand All @@ -446,29 +444,27 @@ EOL
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

# --allow-downgrade is important in case that you choose Tumblweed -> Slowroll migration
$DRYRUN zypper dup -y --force-resolution --allow-downgrade --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
if ! $DRYRUN zypper dup -y --force-resolution --allow-downgrade --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper dup --force-resolution --allow-downgrade --allow-vendor-change --download in-advance
fi
;;
*"openSUSE LeapMicro"*)
# Has to be before Leap*
$DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
# !Important to use MIGRATION_RAW as otherwise MIGRATION_OPTIONS have tips and other decorations
TARGET_VER=`echo ${MIGRATION_RAW[$CHOICE]} | awk '{ print $NF }'`
$DRYRUN zypper addrepo -f https://download.opensuse.org/distribution/leap-micro/$TARGET_VER/product/repo/openSUSE-Leap-Micro-$TARGET_VER-$ARCH/ $TMP_REPO_NAME
TARGET_VER="${MIGRATION_RAW[$CHOICE]}"
$DRYRUN zypper addrepo -f "https://download.opensuse.org/distribution/leap-micro/$TARGET_VER/product/repo/openSUSE-Leap-Micro-$TARGET_VER-$ARCH/" $TMP_REPO_NAME
$DRYRUN zypper install --repo $TMP_REPO_NAME -y --force-resolution --from $TMP_REPO_NAME openSUSE-repos-LeapMicro # install repos from the nextrelease
$DRYRUN zypper removerepo $TMP_REPO_NAME # drop the temp repo, we have now definitions of all repos we need
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

$DRYRUN zypper --releasever $TARGET_VER dup -y --force-resolution --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper --releasever $TARGET_VER dup --force-resolution --allow-vendor-change --download in-advance
if ! $DRYRUN zypper --releasever "$TARGET_VER" dup -y --force-resolution --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper --releasever "$TARGET_VER" dup --force-resolution --allow-vendor-change --download in-advance
fi
;;
*"openSUSE Leap"*)
$DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
TARGET_VER=`echo ${MIGRATION_RAW[$CHOICE]} | awk '{ print $NF }'`
TARGET_VER="${MIGRATION_RAW[$CHOICE]}"
if [ "$ARCH" == "x86_64" ] && [[ ${TARGET_VER%.*} -ge 16 ]] && ! check_x86_64_v2_support; then
#echo "Unsupported CPU for openSUSE Leap $TARGET_VER"
$DIALOGCMD --clear \
Expand All @@ -478,14 +474,13 @@ EOL
reset; exit 1
fi

$DRYRUN zypper addrepo -f https://download.opensuse.org/distribution/leap/$TARGET_VER/repo/oss $TMP_REPO_NAME
$DRYRUN zypper addrepo -f "https://download.opensuse.org/distribution/leap/$TARGET_VER/repo/oss" $TMP_REPO_NAME
$DRYRUN zypper install --repo $TMP_REPO_NAME -y --force-resolution --from $TMP_REPO_NAME openSUSE-repos-Leap # install repos from the nextrelease
$DRYRUN zypper removerepo $TMP_REPO_NAME # drop the temp repo, we have now definitions of all repos we need
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

$DRYRUN zypper --releasever $TARGET_VER dup -y --force-resolution --allow-vendor-change --download-in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper --releasever $TARGET_VER dup --force-resolution --allow-vendor-change --download-in-advance
if ! $DRYRUN zypper --releasever "$TARGET_VER" dup -y --force-resolution --allow-vendor-change --download-in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper --releasever "$TARGET_VER" dup --force-resolution --allow-vendor-change --download-in-advance
fi
;;
*"MicroOS-Slowroll"*)
Expand All @@ -505,8 +500,7 @@ EOL
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

# --allow-downgrade is important in case that you choose MicroOS -> MicroOS-Slowroll migration
$DRYRUN zypper dup -y --force-resolution --allow-downgrade --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
if ! $DRYRUN zypper dup -y --force-resolution --allow-downgrade --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper dup --force-resolution --allow-downgrade --allow-vendor-change --download in-advance
fi
;;
Expand All @@ -523,13 +517,12 @@ EOL
exit 1
fi
fi
$DRYRUN zypper addrepo -f $REPOURL $TMP_REPO_NAME
$DRYRUN zypper addrepo -f "$REPOURL" $TMP_REPO_NAME
$DRYRUN zypper install --repo $TMP_REPO_NAME -y --force-resolution --from $TMP_REPO_NAME openSUSE-repos-MicroOS # install repos from the nextrelease
$DRYRUN zypper removerepo $TMP_REPO_NAME # drop the temp repo, we have now definitions of all repos we need
$DRYRUN zypper refresh-services # !Important! make sure that all repo files under index service were regenerated

$DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance
if [ $? -ne 0 ]; then # re-run zypper dup as interactive in case of failure in non-interactive mode
if ! $DRYRUN zypper dup -y --force-resolution --allow-vendor-change --download in-advance; then # re-run zypper dup as interactive in case of failure in non-interactive mode
$DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance
fi
;;
Expand Down Expand Up @@ -572,11 +565,11 @@ fi

# Basic ordering of execution
# We use prefixes and simple string comparison e.g. scripts/05_script.sh ...
sorted_selected_tasks=$(echo $SELECTED_TASKS | tr ' ' '\n' | sort)
sorted_selected_tasks=$(echo "$SELECTED_TASKS" | tr ' ' '\n' | sort)
for task in $sorted_selected_tasks; do
SCRIPT="$POST_MIGRATION_DIR/$task.sh"
echo "[INFO] Running post-migration task: $task"
$DRYRUN $SCRIPT
$DRYRUN "$SCRIPT"
done

if [[ -n "$DRYRUN" ]] ; then
Expand Down
Loading