File opensuse-migration-tool-20250731.8b95d00.obscpio of Package opensuse-migration-tool

07070100000000000081A4000000000000000000000001688B3683000023C2000000000000000000000000000000000000003100000000opensuse-migration-tool-20250731.8b95d00/LICENSEApache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.

"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

    You must give any other recipients of the Work or Derivative Works a copy of this License; and
    You must cause any modified files to carry prominent notices stating that You changed the files; and
    You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
    If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

07070100000001000081A4000000000000000000000001688B36830000111E000000000000000000000000000000000000003300000000opensuse-migration-tool-20250731.8b95d00/README.md# ๐Ÿ›๏ธ openSUSE Migration Tool

    

A command-line tool to **simplify upgrades and migrations** across openSUSE distributions โ€” including *Leap*, *Tumbleweed*, *Slowroll*, and even migrations from **Leap to SLE**.

> ๐Ÿ—ช **Experimental** โ€” not recommended for production use yet. Use with caution until a complete test suite is implemented.

---
<img width="1441" height="914" alt="image" src="https://github.com/user-attachments/assets/e3e47132-389f-4311-a077-97248f9d47fd" />

## ๐ŸŒŸ Key Features

๐Ÿ‘‰ **Upgrade to pre-releases such as Leap 16.0 Beta**
๐Ÿ‘‰ **Migration across various openSUSE distributions**
๐Ÿ‘‰ **Migration to SUSE Linux Enterprise products**
๐Ÿ‘‰ **Integrates get.opensuse.org product API + openSUSE-repos**
๐Ÿ‘‰ **Dry-run mode for safe previews**
๐Ÿ‘‰ **Support for immutable systems (Leap Micro)**
๐Ÿ‘‰ **Disabling 3rd party repos prior to migration**

---

## ๐Ÿ”„ Supported Migration Paths

```
Leap           โ†’ Leap n+1, SLES, Tumbleweed, Slowroll
Leap Micro     โ†’ Leap Micro n+1, MicroOS
Slowroll       โ†’ Tumbleweed
Tumbleweed     โ†’ Slowroll
```

โš ๏ธ **Unsupported or discouraged paths**:

* Tumbleweed โ†’ Leap (downgrade, not supported)
* Tumbleweed โ†’ MicroOS (immutable shift)
* Non-immutable โ†’ Immutable (generally unsupported)

---

## ๐Ÿ“œ License

This project is licensed under the [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0). ๐Ÿ‘

---

## ๐Ÿงช Quick Start: Testing the Tool

> Always use `--dry-run` first to preview planned changes!

### ๐Ÿ”ง On regular systems (Leap, Tumbleweed, Slowroll)

```bash
sudo zypper in opensuse-migration-tool
opensuse-migration-tool --dry-run
sudo opensuse-migration-tool
reboot
```

---

### ๐Ÿ’จ On immutable systems (Leap Micro)

```bash
sudo transactional-update shell
# Inside shell:
zypper in opensuse-migration-tool
opensuse-migration-tool --dry-run
sudo opensuse-migration-tool
exit && reboot  # boot into new snapshot
```

---

### ๐Ÿšง Upgrading to Alpha/Beta/RC Releases

By default, **pre-release versions are hidden** to avoid accidental installs.

Use `--pre-release` to opt-in:

```bash
./opensuse-migration-tool --pre-release --dry-run
sudo ./opensuse-migration-tool --pre-release
```

---

## ๐Ÿณ Development & Testing in Distrobox (Recommended)

### Leap Micro inside Toolbox container

```bash
git clone https://github.com/openSUSE/opensuse-migration-tool.git
cd opensuse-migration-tool

distrobox create --image registry.opensuse.org/opensuse/leap-micro/6.0/toolbox --name micro60
distrobox enter micro60

zypper in bc jq curl dialog sed gawk
./opensuse-migration-tool --dry-run
sudo ./opensuse-migration-tool
```

### Leap 15.5 container

```bash
distrobox create --image opensuse/leap:15.5 --name leap155
distrobox enter leap155

sudo zypper in bc jq curl dialog sed gawk
./opensuse-migration-tool --dry-run
sudo ./opensuse-migration-tool
```

โš ๏ธ **Heads-up:** Toolbox environments are not truly immutable and may exhibit issues (e.g. bind-mounted `/etc/hostname` โ€” [bug 1233982](https://bugzilla.opensuse.org/show_bug.cgi?id=1233982)).

---

## ๐Ÿ“‹ Manual Migration Resources

For traditional `zypper dup` approaches:

* ๐Ÿ”— [System Upgrade (Leap)](https://en.opensuse.org/SDB:System_upgrade)
* ๐Ÿ”— [Leap โ†’ SLE Migration Guide](https://en.opensuse.org/SDB:How_to_migrate_to_SLE)
* ๐Ÿ”— [Leap Micro Upgrade](https://en.opensuse.org/SDB:System_upgrade_to_LeapMicro_6.0)

---

## ๐Ÿ“ฆ Packaging & Submitting to openSUSE

### Working on the package (Base\:System)

```bash
osc bco Base:System opensuse-migration-tool
cd Base:System/opensuse-migration-tool

osc service runall
osc addremove
vim *.changes     # Review changelog
osc build         # Test build locally
osc commit
osc sr            # Submit to Base:System
```

### Forwarding to openSUSE\:Factory

If not done by the maintainer:

```bash
osc sr Base:System opensuse-migration-tool openSUSE:Factory
```

### Submitting to Leap and Leap Micro

After Factory acceptance:

```bash
osc sr openSUSE:Factory opensuse-migration-tool openSUSE:Leap:Micro:6.1
osc sr openSUSE:Factory opensuse-migration-tool openSUSE:Leap:16.0
osc sr openSUSE:Factory opensuse-migration-tool openSUSE:Leap:15.6:Update
```

---

## ๐Ÿค Contributions Welcome!

We're happy to receive PRs, testing reports, or feedback on supported scenarios.
Please open issues or pull requests on GitHub.
07070100000002000081A4000000000000000000000001688B368300000B95000000000000000000000000000000000000003300000000opensuse-migration-tool-20250731.8b95d00/SLES.prod<?xml version="1.0" encoding="UTF-8"?>
<product schemeversion="0">
  <vendor>SUSE</vendor>
  <name>SLES</name>
  <version>15.6</version>
  <baseversion>15</baseversion>
  <patchlevel>6</patchlevel>
  <release>0</release>
  <endoflife></endoflife>
  <arch>x86_64</arch>
  <cpeid>cpe:/o:suse:sles:15:sp6</cpeid>
  <productline>sles</productline>
  <codestream>
    <name>SUSE Linux Enterprise Server 15</name>
    <endoflife>2031-07-31</endoflife>
  </codestream>
  <register>
      <target>sle-15-x86_64</target>
  </register>
  <repositories>
      <repository type="update" repoid="obsrepository://build.suse.de/SUSE:Updates:SLE-Product-SLES:15-SP6:x86_64/update" />
      <repository type="update" repoid="obsrepository://build.suse.de/SUSE:Updates:SLE-Product-SLES:15-SP6:x86_64/update_debug" />
      <repository type="update" repoid="obsrepository://build.suse.de/SUSE:Updates:SLE-INSTALLER:15-SP6:x86_64/update" />
      <repository type="pool" repoid="obsproduct://build.suse.de/SUSE:Products:SLE-Product-SLES:15-SP6:x86_64/SLES/15.6/x86_64" />
  </repositories>
  <summary>SUSE Linux Enterprise Server 15 SP6</summary>
  <shortsummary>SLES15-SP6</shortsummary>
  <description>SUSE Linux Enterprise offers a comprehensive
        suite of products built on a single code base.
        The platform addresses business needs from
        the smallest thin-client devices to the world's
        most powerful high-performance computing
        and mainframe servers. SUSE Linux Enterprise
        offers common management tools and technology
        certifications across the platform, and
        each product is enterprise-class.</description>
  <linguas>
    <language>cs</language>
    <language>da</language>
    <language>de</language>
    <language>en</language>
    <language>en_GB</language>
    <language>en_US</language>
    <language>es</language>
    <language>fi</language>
    <language>fr</language>
    <language>hu</language>
    <language>it</language>
    <language>ja</language>
    <language>nb</language>
    <language>nl</language>
    <language>pl</language>
    <language>pt</language>
    <language>pt_BR</language>
    <language>ru</language>
    <language>sv</language>
    <language>zh</language>
    <language>zh_CN</language>
    <language>zh_TW</language>
  </linguas>
  <urls>
    <url name="releasenotes">https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15-SP6/release-notes-sles.rpm</url>
  </urls>
  <buildconfig>
    <producttheme>SLES</producttheme>
  </buildconfig>
  <installconfig>
    <defaultlang>en_US</defaultlang>
    <releasepackage name="sles-release" flag="EQ" version="15.6" release="150600.64.3.1"/>
    <distribution>SUSE_SLE</distribution>
  </installconfig>
  <runtimeconfig/>
  <productdependency relationship="provides" name="SUSE_SLE" baseversion="15" patchlevel="6" flag="EQ"/>
  <productdependency relationship="provides" name="SUSE_SLE-SP6" baseversion="15" patchlevel="6" flag="EQ"/>
</product>

07070100000003000081A4000000000000000000000001688B368300000B43000000000000000000000000000000000000003200000000opensuse-migration-tool-20250731.8b95d00/dialogrc#
# Run-time configuration file for dialog
#
# Automatically generated by "dialog --create-rc <file>"
#
#
# Types of values:
#
# Number     -  <number>
# String     -  "string"
# Boolean    -  <ON|OFF>
# Attribute  -  (foreground,background,highlight?)

# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 8

# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (GREEN,GREEN,ON)

# Shadow color
shadow_color = (BLACK,BLACK,ON)

# Dialog box color
dialog_color = (BLACK,WHITE,OFF)

# Dialog box title color
title_color = (BLACK,WHITE,ON)

# Dialog box border color
border_color = (WHITE,WHITE,ON)

# Active button color
button_active_color = (WHITE,GREEN,ON)

# Inactive button color
button_inactive_color = dialog_color

# Active button key color
button_key_active_color = button_active_color

# Inactive button key color
button_key_inactive_color = (BLACK,WHITE,OFF)

# Active button label color
button_label_active_color = (WHITE,GREEN,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)

# Input box color
inputbox_color = dialog_color

# Input box border color
inputbox_border_color = dialog_color

# Search box color
searchbox_color = dialog_color

# Search box title color
searchbox_title_color = title_color

# Search box border color
searchbox_border_color = border_color

# File position indicator color
position_indicator_color = title_color

# Menu box color
menubox_color = dialog_color

# Menu box border color
menubox_border_color = border_color

# Item color
item_color = dialog_color

# Selected item color
item_selected_color = button_active_color

# Tag color
tag_color = title_color

# Selected tag color
tag_selected_color = button_label_active_color

# Tag key color
tag_key_color = button_key_inactive_color

# Selected tag key color
tag_key_selected_color = (WHITE,GREEN,ON)

# Check box color
check_color = dialog_color

# Selected check box color
check_selected_color = button_active_color

# Up arrow color
uarrow_color = (GREEN,WHITE,ON)

# Down arrow color
darrow_color = uarrow_color

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = button_active_color

# Form text color
form_text_color = (WHITE,CYAN,ON)

# Readonly form item color
form_item_readonly_color = (CYAN,WHITE,ON)

# Dialog box gauge color
gauge_color = (GREEN,WHITE,ON)

# Dialog box border2 color
border2_color = dialog_color

# Input box border2 color
inputbox_border2_color = dialog_color

# Search box border2 color
searchbox_border2_color = dialog_color

# Menu box border2 color
menubox_border2_color = dialog_color
07070100000004000081ED000000000000000000000001688B368300005E77000000000000000000000000000000000000004100000000opensuse-migration-tool-20250731.8b95d00/opensuse-migration-tool#!/bin/bash
# openSUSE migration and upgrade tool utilizes get.opensuse.org product API and openSUSE-repos
# for a cross-distro migration and upgrade to a new versions of point releases.
#
# Copyright 2024 Marcela Maslanova, SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# For accessing files from git checkout
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Script dir for git-based execution
POST_MIGRATION_DIR="$SCRIPT_DIR/scripts"

# Migration scripts naming convention:
# Prefix numbers define execution order. Inspired by /etc/grub.d
# Use multiples of 5 or 10 for flexibility, e.g.:
#   05_ for very core low-level tasks,
#   20_ for pulse2pipewire migration,
#   30_ and above for desktop environment or user session tweaks.
#
# Example:
#   20_pulse2pipewire.sh  # Switch PulseAudio to PipeWire early but after core system tasks.

# Fallback to installed location if not found
if [[ ! -d "$POST_MIGRATION_DIR" ]]; then
    POST_MIGRATION_DIR="/usr/share/opensuse-migration-tool/scripts"
fi

# Warn if not found at all
if [[ ! -d "$POST_MIGRATION_DIR" ]]; then
    echo "[ERROR] Post-migration script directory not found: $POST_MIGRATION_DIR"
    exit 1
fi

# Set nice green instead of default blue

if [[ $COLORTERM =~ ^(truecolor|24bit)$ ]]; then
	DIALOGRC="/usr/share/opensuse-migration-tool/dialogrc"
	if [ -f "$SCRIPT_DIR/dialogrc" ]; then
		DIALOGRC="$SCRIPT_DIR/dialogrc"
	fi
	export DIALOGRC
fi

# Ensure required tools are installed
# Double check for zypper in case we're on dnf-based system
REQUIRED_TOOLS=("bc" "jq" "curl" "dialog" "sed" "gawk" "zypper")
for tool in "${REQUIRED_TOOLS[@]}"; do
    if ! command -v "$tool" &>/dev/null; then
        echo "$tool is required but not installed."
        echo "Please run: sudo zypper in ${REQUIRED_TOOLS[*]}"
        exit 1
    fi
done
# Ensure Bash version is 4.0+
if ((BASH_VERSINFO[0] < 4)); then
    echo "This script requires Bash 4.0 or higher." >&2
    exit 1
fi
# Ensure /etc/os-release exists
if [[ ! -f /etc/os-release ]]; then
    echo "File /etc/os-release not found." >&2
    exit 2
fi
# Source OS release info
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 "$API_URL")
if [ $? != 0 ]; then
    echo "Network error: Unable to fetch release data from https://get.opensuse.org/api/v0/distributions.json"
    echo "Ensure that you have working network connectivity and get.opensuse.org is accessible."
    exit 3
fi
DRYRUN=""
TMP_REPO_NAME="tmp-migration-tool-repo" # tmp repo to get sles-release or openSUSE-repos-*
# Initialize MIGRATION_OPTIONS as an empty associative array
declare -A MIGRATION_OPTIONS=()
declare -A AVAILABLE_TASKS=()

CURRENT_INDEX=1
# Parse command-line arguments
function print_help() {
    echo "Usage: opensuse-migration-tool [--dry-run] [--help]"
    echo "  --dry-run      Show commands without executing them."
    echo "  --help         Show this help message and exit."
    echo
    echo "Report issues: https://github.com/openSUSE/opensuse-migration-tool"
    exit 0
}
while [[ $# -gt 0 ]]; do
    case $1 in
        --dry-run) DRYRUN="echo Would execute: "; shift ;;
        --help) print_help ;;
        *) echo "Unknown option: $1"; exit 1 ;;
    esac
done
# Populate migration options
function fetch_versions() {
    local filter="$1"
    local key="$2"
    jq -r ".${key}[] | select(${filter}) | .version" <<<"$API_DATA"
}
function populate_options() {
    local key="$1"
    local current_version="$2"
    local filter="$3"
    local versions
    versions=$(fetch_versions "$filter" "$key")
    while IFS= read -r version; do
        if (( $(bc <<<"$current_version < $version") )); then
            MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE $key $version"
            ((CURRENT_INDEX++))
        fi
    done <<<"$versions"
}

# Required x86_64-v2 flags
#required_v2_flags=("cx16" "sse4_1" "sse4_2" "popcnt" "movbe" "xsave")
required_v2_flags=("cx16" "sse4_1" "sse4_2" "popcnt" "movbe" "xsave")

# Required x86_64-v3 flags
#required_v3_flags=("cx16" "sse4_1" "sse4_2" "popcnt" "movbe" "xsave" "avx" "avx2" "bmi1" "bmi2" "fma" "abm")

# CPU flags from /proc/cpuinfo
cpu_flags=$(grep -m1 "^flags" /proc/cpuinfo | awk '{for (i=2; i<=NF; i++) print $i}')

# Function to check if all required flags are present
function check_x86_64_v2_support() {
    for flag in "${required_v2_flags[@]}"; do
        if ! grep -qw "$flag" <<< "$cpu_flags"; then
            echo "CPU does not support x86_64-v2 (missing flag: $flag)"
            return 1
        fi
    done
    echo "CPU supports x86_64-v2"
    return 0
}

# Elevated permissions check unless DRYRUN is set
if [ -z "${DRYRUN:-}" ]; then
    if [ "$EUID" -ne 0 ]; then
        exec sudo "$0" "$@"
    fi

	# Requires elevated permissions or test will always fail
	test -w / || { echo "Please run the tool inside 'transactional-update shell' on Immutable systems."; exit 1; }
fi


# System-specific options
if [[ "$NAME" == "openSUSE Leap Micro" ]]; then
    MIGRATION_OPTIONS["$CURRENT_INDEX"]="MicroOS"
    ((CURRENT_INDEX++))
    populate_options "LeapMicro" "$VERSION" '.state!="EOL"'
elif [[ "$NAME" == "openSUSE Leap" ]]; then
    MIGRATION_OPTIONS["$CURRENT_INDEX"]="SUSE Linux Enterprise $(sed 's/\./ SP/' <<<"$VERSION")"
    ((CURRENT_INDEX++))
    MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE Tumbleweed"
    ((CURRENT_INDEX++))
    MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE Tumbleweed-Slowroll"
    ((CURRENT_INDEX++))
    populate_options "Leap" "$VERSION" '.state!="EOL"'
elif [[ "$NAME" == "openSUSE Tumbleweed" ]]; then
   MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE Tumbleweed-Slowroll"
   ((CURRENT_INDEX++))
   echo
elif [[ "$NAME" == "openSUSE Tumbleweed-Slowroll" ]]; then
    MIGRATION_OPTIONS["$CURRENT_INDEX"]="openSUSE Tumbleweed"
    ((CURRENT_INDEX++))
else
    dialog --clear \
    --title "[EXPERIMENTAL] System Migration - NOT FOR PRODUCTION" \
	--msgbox "\nMigration from $NAME is currently not supported.\n\nPlease report issue at https://github.com/openSUSE/opensuse-migration-tool" \
    10 60
    reset; exit 1;
fi

# Display migration options
if [[ ${#MIGRATION_OPTIONS[@]} -eq 0 ]]; then
    dialog --clear \
    --title "[EXPERIMENTAL] System Migration - NOT FOR PRODUCTION" \
	--msgbox "\nNo migration options available from $NAME.\n\nPlease report issue at https://github.com/openSUSE/opensuse-migration-tool." \
    10 60
    reset; exit 1
fi
# Prepare dialog items
DIALOG_ITEMS=()
for key in "${!MIGRATION_OPTIONS[@]}"; do
    DIALOG_ITEMS+=("$key" "${MIGRATION_OPTIONS[$key]}")
done
# Display dialog and get choice
CHOICE=$(dialog --clear \
    --title "[EXPERIMENTAL] System Migration - NOT FOR PRODUCTION" \
    --menu "Select the migration target from $NAME:" \
    20 60 10 \
    "${DIALOG_ITEMS[@]}" \
    2>&1 >/dev/tty) || exit

rpmsave_repo() {
### XXX: This could go away if we install openSUSE-repos before migration
### It does the same thing
for repo_file in \
repo-backports-debug-update.repo repo-oss.repo repo-backports-update.repo \
repo-sle-debug-update.repo repo-debug-non-oss.repo repo-sle-update.repo \
repo-debug.repo repo-source.repo repo-debug-update.repo repo-update.repo \
repo-debug-update-non-oss.repo repo-update-non-oss.repo repo-non-oss.repo \
download.opensuse.org-oss.repo download.opensuse.org-non-oss.repo download.opensuse.org-tumbleweed.repo \
repo-openh264.repo openSUSE-*-0.repo repo-main.repo $TMP_REPO_NAME.repo; do
  if [ -f /etc/zypp/repos.d/$repo_file ]; then
    echo "Storing old copy as /etc/zypp/repos.d/$repo_file.rpmsave"
    $DRYRUN mv /etc/zypp/repos.d/$repo_file /etc/zypp/repos.d/$repo_file.rpmsave
  fi
done
# regexpes
for file in /etc/zypp/repos.d/openSUSE-*.repo; do
    repo_file=$(basename $file)
    if [ -f /etc/zypp/repos.d/$repo_file ]; then
        echo "Storing old copy as /etc/zypp/repos.d/$repo_file.rpmsave"
        $DRYRUN mv /etc/zypp/repos.d/$repo_file /etc/zypp/repos.d/$repo_file.rpmsave
    fi
done
# Ensure to drop any SCC generated service/repo files for Leap
# e.g. /etc/zypp/services.d/openSUSE_Leap_15.6_x86_64.service
for file in /etc/zypp/services.d/openSUSE_*.service; do
    service_file=$(basename $file)
    if [ -f /etc/zypp/services.d/$service_file ]; then
        echo "Storing old copy as /etc/zypp/repos.d/$service_file.rpmsave"
        $DRYRUN mv /etc/zypp/services.d/$service_file /etc/zypp/services.d/$service_file.rpmsave
    fi
done
}

# Step: Detect and offer to disable 3rd-party repositories
# This is the #1 reason for failed migration
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
    alias=$(echo "$alias" | xargs)  # trim
    name=$(echo "$name" | xargs)
    enabled=$(echo "$enabled" | xargs)

    if [[ "$enabled" == "Yes" ]] && \
       [[ ! "$alias" =~ ^(openSUSE:|NVIDIA:) ]]; then
        if [[ " ${exceptions[*]} " == *" $alias "* ]]; then
            REPO_LIST+=("$alias" "$name" "off")
        else
            REPO_LIST+=("$alias" "$name" "on")
        fi
    fi
done < <(zypper lr -E -d --uri | tail -n +3 | awk -F '|' '{print $1 "|" $2 "|" $3 "|" $4}')

if [[ ${#REPO_LIST[@]} -eq 0 ]]; then
    echo "[INFO] No third-party repositories to disable."
else
    checklist_msg=$(
cat <<EOF
The following enabled repositories are not recognized.
It is strongly recommended to disable them before proceeding with the migration.

Such repositories often have hardcoded URLs or may not yet offer packages
for the target release. This can cause \`zypper dup\` to fail if a repository
is unreachable or incompatible.

You can deselect any repositories you prefer to keep enabled:
EOF
)
    SELECTED_REPOS=$(dialog --clear \
        --title "Disable Third-Party Repositories" \
        --checklist "$checklist_msg" \
        20 80 10 \
        "${REPO_LIST[@]}" \
        2>&1 >/dev/tty)

    for repo in $SELECTED_REPOS; do
        echo "[INFO] Disabling repository: $repo"
        $DRYRUN zypper --non-interactive modifyrepo -d "$repo"
    done
fi

if [[ -n $CHOICE ]]; then
    echo "Selected option: ${MIGRATION_OPTIONS[$CHOICE]}"
    case "${MIGRATION_OPTIONS[$CHOICE]}" in
        *"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

            while true; do
                # Capture output and return code
                OUTPUT=$(dialog --clear \
                    --backtitle "SCC - Registration code" \
                    --title "SCC - Registration code" \
                    --form "\nPlease enter valid email and registration code." 25 60 16 \
                    "Email:" 1 1 "" 1 25 25 50 \
                    "Regcode:" 2 1 "" 2 25 25 50 \
                    2>&1 >/dev/tty)
                RETCODE=$?

                #echo "Dialog output: '$OUTPUT'" >&2
                #echo "Return code: $RETCODE" >&2

                # Handle cancel or escape
                if [[ $RETCODE -ne 0 ]]; then
                    dialog --clear \
                        --backtitle "SCC - Registration code" \
                        --title "Operation Cancelled" \
                        --msgbox "You have cancelled the registration process." 10 40
                    reset; exit 1
                fi

                {
                    read -r EMAIL
                    read -r REGCODE 
                } <<< "$OUTPUT"
            
                # Check if both values are entered
                if [[ -n "$EMAIL" && -n "$REGCODE" ]]; then
                    break
                else
                    dialog --clear \
                        --backtitle "SCC - Registration code" \
                        --title "Input Error" \
                        --msgbox "Both email and registration code are required. Please try again." 10 40
                fi
            done

            # This is a dream workflow that doesn't really work. Enable BCI repo and register as SLES with BCI-release
            # Perhaps we can fix it in near future
            #$DRYRUN zypper ar -f https://updates.suse.com/SUSE/Products/SLE-BCI/$SP/$ARCH/product/ $TMP_REPO_NAME
            #$DRYRUN zypper in --force-resolution -y suseconnect-ng
            #$DRYRUN zypper in --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
            echo $REGCODE
            $DRYRUN zypper in -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"
            $DRYRUN cp /etc/os-release /etc/os-release.backup
            $DRYRUN rpm -e --nodeps openSUSE-release
            $DRYRUN rpm -e --nodeps openSUSE-repos
            if [ -z "$DRYRUN" ]; then
                cat > /etc/os-release  << EOL
NAME="SLES" 
VERSION="$SP" 
VERSION_ID="$VERSION"
PRETTY_NAME="SUSE Linux Enterprise Server $MAJVER SP$MINVER"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32" 
CPE_NAME="cpe:/o:suse:sles:$MAJVER:sp$MINVER"
DOCUMENTATION_URL="https://documentation.suse.com/"
EOL
            else
                echo "Would write a SLES $SP like /etc/os-release"
            fi

			if [ -f  "$SCRIPT_DIR/SLES.prod" ]; then
				$DRYRUN cp "$SCRIPT_DIR/SLES.prod" /etc/products.d
			else
				$DRYRUN cp /usr/share/opensuse-migration-tool/SLES.prod /etc/products.d
			fi
            $DRYRUN rm -r /etc/products.d/baseproduct
            $DRYRUN ln -s /etc/products.d/SLES.prod /etc/products.d/baseproduct
            if [ -z "$DRYRUN" ]; then
                rpmsave_repo # invalidates all standard openSUSE repos
            fi

	        $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
                $DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance 
            fi


            $DRYRUN rpm -e --nodeps branding-openSUSE grub2-branding-openSUSE wallpaper-branding-openSUSE plymouth-branding-openSUSE systemd-presets-branding-openSUSE systemd-presets-branding-MicroOS
	        $DRYRUN zypper remove -y opensuse-welcome # might not be present on text-installations
	        $DRYRUN zypper in -y branding-SLE-15 grub2-branding-SLE wallpaper-branding-SLE-15 plymouth-branding-SLE systemd-presets-branding-SLE
            ;;
        "openSUSE Tumbleweed")
            $DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
            # https://download.opensuse.org/ports/ # for other arches
            REPOURL="https://download.opensuse.org/tumbleweed/repo/oss/"
            if [ "$ARCH" != "x86_64" ]; then
                REPOURL=https://download.opensuse.org/ports/$ARCH # XXX this will likely work only for aarch64
                if [ "$ARCH" != "aarch64" ]; then 
                    # Let's not messup any systems and make sure this is properly implemented first
                    echo "Unsupported arch '$ARCH'."
                    echo "Please open an issue at https://github.com/openSUSE/opensuse-migration-tool/issues"
                    echo "Make sure to add output of 'uname -i' and content of your /etc/os-release into the ticket."
                    exit 1
                fi
            fi
            $DRYRUN zypper addrepo -f $REPOURL $TMP_REPO_NAME
            $DRYRUN zypper in -y --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 refs # !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
                $DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance 
            fi

            ;;
        "openSUSE Tumbleweed-Slowroll")
            $DRYRUN echo "Migrating to ${MIGRATION_OPTIONS[$CHOICE]}"
            REPOURL="https://download.opensuse.org/slowroll/repo/oss/"
            if [ "$ARCH" != "x86_64" ]; then
                echo "Unsupported arch '$ARCH' by Slowroll."
                exit 1
            fi
            $DRYRUN zypper addrepo -f $REPOURL $TMP_REPO_NAME
            $DRYRUN zypper in -y --from $TMP_REPO_NAME openSUSE-repos-Slowroll # 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 refs # !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
                $DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance 
            fi
            ;;
        *"openSUSE LeapMicro"*)
            # Has to be before Leap*
            $DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
            TARGET_VER=`echo ${MIGRATION_OPTIONS[$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
            $DRYRUN zypper in -y --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 refs # !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 
            fi
            ;;
        *"openSUSE Leap"*)
            $DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
            TARGET_VER=`echo ${MIGRATION_OPTIONS[$CHOICE]} | awk '{ print $NF }'`
            if [ "$ARCH" == "x86_64" ] && [[ ${TARGET_VER%.*} -ge 16 ]] && ! check_x86_64_v2_support; then
                #echo "Unsupported CPU for openSUSE Leap $TARGET_VER"
                dialog --clear \
                    --title "System Migration - Unsupported architecture" \
	--msgbox "\n${MIGRATION_OPTIONS[$CHOICE]} does not support your CPU architecture. The minimum baseline is x86_64-v2.\n\nSee https://en.opensuse.org/openSUSE:X86-64-Architecture-Levels" \
    10 60
    reset; exit 1
            fi
                
            $DRYRUN zypper addrepo -f https://download.opensuse.org/distribution/leap/$TARGET_VER/repo/oss $TMP_REPO_NAME
            $DRYRUN zypper in -y --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 refs # !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
            fi
            ;;
        *"MicroOS"*)
            $DRYRUN echo "Upgrading to ${MIGRATION_OPTIONS[$CHOICE]}"
            # https://download.opensuse.org/ports/ # for other arches
            REPOURL="https://download.opensuse.org/tumbleweed/repo/oss/"
            if [ "$ARCH" != "x86_64" ]; then
                REPOURL=https://download.opensuse.org/ports/$ARCH # XXX this will likely work only for aarch64
                if [ "$ARCH" != "aarch64" ]; then 
                    # Let's not messup any systems and make sure this is properly implemented first
                    echo "Unsupported arch '$ARCH'."
                    echo "Please open an issue at https://github.com/openSUSE/opensuse-migration-tool/issues"
                    echo "Make sure to add output of 'uname -i' and content of your /etc/os-release into the ticket."
                    exit 1
                fi
            fi
            $DRYRUN zypper addrepo -f $REPOURL $TMP_REPO_NAME
			$DRYRUN zypper in -y --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 refs # !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
                $DRYRUN zypper dup --force-resolution --allow-vendor-change --download in-advance 
            fi
            ;;
    esac
else
    echo "No option selected. Exiting."
    exit 1
fi

# Migration scripts, keep the desc short

for script in "$POST_MIGRATION_DIR"/*.sh; do
    name=$(basename "$script" .sh)
    if "$script" --check; then
        case "$name" in
            "10_keepapparmor") desc="Keep AppArmor (SELinux is the new default)" ;;
            "10_keepselinux") desc="Switch to SELinux (new default)" ;;
            "20_pulse2pipewire") desc="Switch to PipeWire (new default)" ;;
            "20_ia32") desc="Allow 32bit binary execution (Steam)" ;;
            *)                   desc="Run $name" ;;
        esac
        AVAILABLE_TASKS["$name"]="$desc"
    fi
done

if [[ ${#AVAILABLE_TASKS[@]} -gt 0 ]]; then
    CHECKLIST_ITEMS=()
    for key in "${!AVAILABLE_TASKS[@]}"; do
        CHECKLIST_ITEMS+=("$key" "${AVAILABLE_TASKS[$key]}" "off")
    done
    SELECTED_TASKS=$(dialog --clear \
        --title "Post-Migration Optional Tasks" \
        --checklist "Select tasks to run after system upgrade:" \
        20 70 10 \
        "${CHECKLIST_ITEMS[@]}" \
        2>&1 >/dev/tty)
else
    echo "[INFO] No available post-migration tasks."
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)
for task in $sorted_selected_tasks; do
    SCRIPT="$POST_MIGRATION_DIR/$task.sh"
    echo "[INFO] Running post-migration task: $task"
    $DRYRUN $SCRIPT
done

#dialog --clear \
#    --backtitle "[EXPERIMENTAL] Migration tool" \
#    --title "Migration process completed" \
#    --msgbox "\nMigration process completed.\nA reboot is recommended." 10 40
#
echo "Migration process completed. A reboot is recommended."
07070100000005000041ED000000000000000000000002688B368300000000000000000000000000000000000000000000003100000000opensuse-migration-tool-20250731.8b95d00/scripts07070100000006000081ED000000000000000000000001688B368300000528000000000000000000000000000000000000004400000000opensuse-migration-tool-20250731.8b95d00/scripts/10_keepapparmor.sh#!/bin/bash

# SELinux is the new default but some people prefer AppArmor
# https://code.opensuse.org/leap/features/issue/182
# https://en.opensuse.org/SDB:AppArmor#Switching_from_SELinux_to_AppArmor_for_Leap_16.0_and_Tumbleweed

set -euo pipefail

log() {
    echo "[MIGRATION] $1"
}

error_exit() {
    echo "[MIGRATION][ERROR] $1" >&2
    exit 1
}

# Check if we have security=apparmor as boot param
if [[ "${1:-}" == "--check" ]]; then
    if ! /usr/sbin/update-bootloader --get-option security | grep apparmor &>/dev/null; then
        exit 0
    else
        exit 1
    fi
fi

log "Drop any SELinux boot options"
sudo update-bootloader --del-option "security=selinux"
sudo update-bootloader --del-option "enforcing=1"
sudo update-bootloader --del-option "selinux=1"
log "Adding AppArmor boot options"
sudo update-bootloader --add-option "security=apparmor"

if rpm -q patterns-base-apparmor &>/dev/null; then
    log "Package patterns-base-apparmor is already installed. Skipping."
    exit 0

else
    log "Installing packages: patterns-base-apparmor"
    if sudo zypper --non-interactive install --force-resolution patterns-base-apparmor; then
        log "Installation completed successfully."
    else
        error_exit "Package installation failed. Please check zypper logs or try again manually."
    fi
fi
07070100000007000081ED000000000000000000000001688B3683000005B5000000000000000000000000000000000000004300000000opensuse-migration-tool-20250731.8b95d00/scripts/10_keepselinux.sh#!/bin/bash

# SELinux is the new default manual switch
# might be needed for people migrating from 15.X

# https://en.opensuse.org/SDB:AppArmor#Switching_from_SELinux_to_AppArmor_for_Leap_16.0_and_Tumbleweed

set -euo pipefail

log() {
    echo "[MIGRATION] $1"
}

error_exit() {
    echo "[MIGRATION][ERROR] $1" >&2
    exit 1
}

# Check if we have security=selinux as boot param
if [[ "${1:-}" == "--check" ]]; then
    if ! /usr/sbin/update-bootloader --get-option security | grep selinux &>/dev/null; then
        exit 0
    else
        exit 1
    fi
fi

log "Drop AppArmor boot options"
sudo update-bootloader --del-option "security=apparmor"

log "Add any SELinux boot options"
sudo update-bootloader --add-option "security=selinux"
sudo update-bootloader --add-option "enforcing=1"
sudo update-bootloader --add-option "selinux=1"

if rpm -q patterns-base-apparmor &>/dev/null; then
    log "Uninstalling packages: patterns-base-apparmor"
    if sudo zypper --non-interactive remove --force-resolution patterns-base-apparmor; then
        log "Uninstallation of AppArmor completed successfully."
    else
        error_exit "Package uninstallation failed. Please check zypper logs or try again manually."
    fi

else
    log "Installing packages: patterns-selinux selinux-policy-targeted-gaming"
    sudo zypper --non-interactive install -t pattern --force-resolution selinux
    sudo zypper --non-interactive install selinux-policy-targeted-gaming
fi
07070100000008000081ED000000000000000000000001688B3683000002C5000000000000000000000000000000000000003C00000000opensuse-migration-tool-20250731.8b95d00/scripts/20_ia32.sh#!/bin/bash

# SLES 16 disables 32bit support in kernel by default
# Things like Steam, Proton, Virtualbox will need it

set -euo pipefail

log() {
    echo "[MIGRATION] $1"
}

error_exit() {
    echo "[MIGRATION][ERROR] $1" >&2
    exit 1
}

# This is used to generate dynamic list of tasks
if [[ "${1:-}" == "--check" ]]; then
    if ! rpm -q grub2-compat-ia32 &>/dev/null; then
        exit 0
    else
        exit 1
    fi
fi

log "Installing packages: grub2-compat-ia32"
if sudo zypper --non-interactive install --force-resolution grub2-compat-ia32; then
    log "Installation completed successfully."
else
    error_exit "Package installation failed. Please check zypper logs or try again manually."
fi
07070100000009000081ED000000000000000000000001688B368300000518000000000000000000000000000000000000004600000000opensuse-migration-tool-20250731.8b95d00/scripts/20_pulse2pipewire.sh#!/bin/bash

# Pipewire is the new default in Leap 16.0+
# https://code.opensuse.org/leap/features/issue/140
# https://en.opensuse.org/openSUSE:Pipewire#Installation

set -euo pipefail

log() {
    echo "[MIGRATION] $1"
}

error_exit() {
    echo "[MIGRATION][ERROR] $1" >&2
    exit 1
}

# This is used to generate dynamic list of tasks
if [[ "${1:-}" == "--check" ]]; then
    if rpm -q pulseaudio &>/dev/null && zypper se -x pipewire-pulseaudio &>/dev/null; then
        exit 0
    else
        exit 1
    fi
fi

log "Starting PulseAudio to PipeWire migration..."

# Check if pipewire-pulseaudio is already installed
if rpm -q pipewire-pulseaudio >/dev/null 2>&1; then
    log "Package pipewire-pulseaudio is already installed. Skipping."
    exit 0
fi

# Check if pulseaudio was ever installed
if ! rpm -q pulseaudio >/dev/null 2>&1; then
    log "Package pulseaudio is not installed. Assuming minimal system. Skipping."
    exit 0
fi

log "Installing packages: pipewire-pulseaudio and ensure wireplumber-video-only-profile is removed"
if sudo zypper --non-interactive install --force-resolution pipewire-pulseaudio -wireplumber-video-only-profile; then
    log "Migration completed successfully."
else
    error_exit "Package installation failed. Please check zypper logs or try again manually."
fi
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!99 blocks
openSUSE Build Service is sponsored by