feat: add root check, singleton lock, RHEL/Fedora upgrade auto-installer & container tests for AlmaLinux 9 and Arch Linux
This commit is contained in:
1 parent
507a3fd310
commit
44c9423166
10 files changed
+711
-27
No files matched your search
+69
-1
@@ -9,6 +9,7 @@ from linux_updater import __version__
|
||||
from linux_updater.config import UpdaterConfig
|
||||
from linux_updater.core.detector import DistroDetector
|
||||
from linux_updater.core.health import HealthChecker
|
||||
from linux_updater.core.lock import InstanceLock
|
||||
from linux_updater.core.remediation import RemediationEngine
|
||||
from linux_updater.core.runner import CommandRunner
|
||||
from linux_updater.managers import get_manager
|
||||
@@ -153,6 +154,12 @@ def prompt_confirmation(prompt: str = "Do you want to proceed with updates? [Y/n
|
||||
return False
|
||||
|
||||
|
||||
def check_root_privileges() -> bool:
|
||||
if hasattr(os, "geteuid"):
|
||||
return os.geteuid() == 0
|
||||
return True
|
||||
|
||||
|
||||
def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser = create_parser()
|
||||
args = parser.parse_args(argv)
|
||||
@@ -179,6 +186,67 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
print(f"Error: Unsupported or unrecognized Linux distribution: {distro.distro_id}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Root privilege check for mutating operations
|
||||
mutating_commands = {"update", "release-upgrade", "clean"}
|
||||
if args.command in mutating_commands and not dry_run:
|
||||
if not check_root_privileges():
|
||||
if json_output:
|
||||
print(json.dumps({
|
||||
"success": False,
|
||||
"error": "permission_denied",
|
||||
"message": f"Root privileges (sudo) are required to execute '{args.command}'."
|
||||
}, indent=2))
|
||||
else:
|
||||
print(
|
||||
f"Error: Root privileges (sudo) are required to execute '{args.command}'.\n"
|
||||
f"Please run with: sudo linux-updater {args.command}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
# Concurrency control: singleton instance lock
|
||||
instance_lock = InstanceLock()
|
||||
if not instance_lock.acquire():
|
||||
holder_pid = instance_lock.get_holder_pid()
|
||||
holder_msg = f" (PID {holder_pid})" if holder_pid else ""
|
||||
if json_output:
|
||||
print(json.dumps({
|
||||
"success": False,
|
||||
"error": "already_running",
|
||||
"message": f"Another instance of linux-updater is already running{holder_msg}."
|
||||
}, indent=2))
|
||||
else:
|
||||
print(
|
||||
f"Error: Another instance of linux-updater is already running{holder_msg}. Aborting.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
try:
|
||||
return _run(
|
||||
args=args,
|
||||
distro=distro,
|
||||
non_interactive=non_interactive,
|
||||
dry_run=dry_run,
|
||||
no_remediation=no_remediation,
|
||||
skip_preflight=skip_preflight,
|
||||
json_output=json_output,
|
||||
config_path=config_path,
|
||||
)
|
||||
finally:
|
||||
instance_lock.release()
|
||||
|
||||
|
||||
def _run(
|
||||
args: argparse.Namespace,
|
||||
distro,
|
||||
non_interactive: bool,
|
||||
dry_run: bool,
|
||||
no_remediation: bool,
|
||||
skip_preflight: bool,
|
||||
json_output: bool,
|
||||
config_path: str,
|
||||
) -> int:
|
||||
config = UpdaterConfig.load(Path(config_path) if config_path else None)
|
||||
if non_interactive:
|
||||
config.non_interactive = True
|
||||
@@ -212,7 +280,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
runner = CommandRunner(verbose=config.verbose, log_file=resolved_log)
|
||||
if resolved_log:
|
||||
runner._log(f"=== Linux System Updater v1.0.0 started (Distro: {distro.pretty_name}, PID: {os.getpid()}) ===")
|
||||
manager = get_manager(distro.family, runner=runner)
|
||||
manager = get_manager(distro.family, runner=runner, distro_info=distro)
|
||||
checker = HealthChecker(config=config, manager=manager)
|
||||
remediation = RemediationEngine(manager=manager)
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class InstanceLock:
|
||||
def __init__(self, lock_path: Optional[Path] = None) -> None:
|
||||
self.custom_path = lock_path is not None
|
||||
self.lock_path = lock_path or Path("/var/run/linux-updater.pid")
|
||||
self.fd: Optional[int] = None
|
||||
self.acquired: bool = False
|
||||
|
||||
def acquire(self) -> bool:
|
||||
"""Attempts to acquire exclusive advisory flock. Returns False if already locked."""
|
||||
try:
|
||||
import fcntl
|
||||
except ImportError:
|
||||
# Non-Unix environment fallback
|
||||
self.acquired = True
|
||||
return True
|
||||
|
||||
# Ensure parent directory exists or fallback to /tmp
|
||||
try:
|
||||
self.lock_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.fd = os.open(str(self.lock_path), os.O_RDWR | os.O_CREAT, 0o644)
|
||||
except (PermissionError, OSError):
|
||||
if not self.custom_path:
|
||||
uid = os.getuid() if hasattr(os, "getuid") else 0
|
||||
self.lock_path = Path(f"/tmp/linux-updater-{uid}.pid")
|
||||
try:
|
||||
self.fd = os.open(str(self.lock_path), os.O_RDWR | os.O_CREAT, 0o644)
|
||||
except Exception:
|
||||
self.acquired = True
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
fcntl.flock(self.fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
os.ftruncate(self.fd, 0)
|
||||
os.write(self.fd, f"{os.getpid()}\n".encode("utf-8"))
|
||||
try:
|
||||
os.fsync(self.fd)
|
||||
except Exception:
|
||||
pass
|
||||
self.acquired = True
|
||||
return True
|
||||
except (BlockingIOError, IOError, OSError):
|
||||
self.acquired = False
|
||||
return False
|
||||
|
||||
def get_holder_pid(self) -> Optional[int]:
|
||||
try:
|
||||
if self.lock_path.exists():
|
||||
content = self.lock_path.read_text(encoding="utf-8").strip()
|
||||
if content and content.isdigit():
|
||||
return int(content)
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def release(self) -> None:
|
||||
if self.fd is not None and self.acquired:
|
||||
try:
|
||||
import fcntl
|
||||
fcntl.flock(self.fd, fcntl.LOCK_UN)
|
||||
os.close(self.fd)
|
||||
except Exception:
|
||||
pass
|
||||
self.fd = None
|
||||
self.acquired = False
|
||||
try:
|
||||
if self.lock_path.exists():
|
||||
self.lock_path.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def __enter__(self) -> "InstanceLock":
|
||||
if not self.acquire():
|
||||
holder = self.get_holder_pid()
|
||||
holder_msg = f" (PID {holder})" if holder else ""
|
||||
raise RuntimeError(f"Another instance of linux-updater is already running{holder_msg}.")
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
||||
self.release()
|
||||
@@ -5,14 +5,18 @@ from linux_updater.managers.base import PackageManager
|
||||
from linux_updater.managers.apt import AptManager
|
||||
from linux_updater.managers.dnf import DnfManager
|
||||
from linux_updater.managers.pacman import PacmanManager
|
||||
from linux_updater.models import DistroFamily
|
||||
from linux_updater.models import DistroFamily, DistroInfo
|
||||
|
||||
|
||||
def get_manager(family: DistroFamily, runner: Optional[CommandRunner] = None) -> PackageManager:
|
||||
def get_manager(
|
||||
family: DistroFamily,
|
||||
runner: Optional[CommandRunner] = None,
|
||||
distro_info: Optional[DistroInfo] = None,
|
||||
) -> PackageManager:
|
||||
if family == DistroFamily.DEBIAN:
|
||||
return AptManager(runner=runner)
|
||||
elif family == DistroFamily.RHEL:
|
||||
return DnfManager(runner=runner)
|
||||
return DnfManager(runner=runner, distro_info=distro_info)
|
||||
elif family == DistroFamily.ARCH:
|
||||
return PacmanManager(runner=runner)
|
||||
else:
|
||||
|
||||
+252
-16
@@ -1,15 +1,21 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from linux_updater.core.runner import CommandRunner
|
||||
from linux_updater.managers.base import PackageManager
|
||||
from linux_updater.models import CommandResult, PackageUpdate, RebootStatus
|
||||
from linux_updater.models import CommandResult, DistroInfo, PackageUpdate, RebootStatus
|
||||
|
||||
|
||||
class DnfManager(PackageManager):
|
||||
def __init__(self, runner: Optional[CommandRunner] = None, binary: Optional[str] = None) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
runner: Optional[CommandRunner] = None,
|
||||
binary: Optional[str] = None,
|
||||
distro_info: Optional[DistroInfo] = None,
|
||||
) -> None:
|
||||
self.runner = runner or CommandRunner()
|
||||
self.distro_info = distro_info
|
||||
if binary is not None:
|
||||
self.binary = binary
|
||||
else:
|
||||
@@ -74,36 +80,267 @@ class DnfManager(PackageManager):
|
||||
)
|
||||
return res
|
||||
|
||||
def _get_distro_info(self) -> DistroInfo:
|
||||
if self.distro_info is None:
|
||||
from linux_updater.core.detector import DistroDetector
|
||||
self.distro_info = DistroDetector().detect()
|
||||
return self.distro_info
|
||||
|
||||
def _ensure_fedora_upgrade_dependencies(self) -> Tuple[bool, str]:
|
||||
"""Ensures python3-dnf-plugins-core is installed for Fedora system-upgrade."""
|
||||
check = self.runner.run([self.binary, "system-upgrade", "--help"])
|
||||
if check.return_code == 0:
|
||||
return True, "Fedora system-upgrade plugin is available."
|
||||
|
||||
self.runner._log("[UPGRADE] Fedora system-upgrade plugin not found. Attempting automatic installation of 'python3-dnf-plugins-core'...")
|
||||
res = self.runner.run([self.binary, "install", "-y", "python3-dnf-plugins-core"])
|
||||
if res.return_code != 0:
|
||||
res = self.runner.run([self.binary, "install", "-y", "dnf-plugins-core"])
|
||||
|
||||
if res.return_code != 0:
|
||||
err_msg = (
|
||||
"Failed to automatically install Fedora upgrade plugin ('python3-dnf-plugins-core').\n"
|
||||
f"DNF exited with code {res.return_code}.\n"
|
||||
f"Details:\n{res.stderr or res.stdout}\n"
|
||||
"Troubleshooting:\n"
|
||||
"1. Verify internet connectivity and repository mirrors.\n"
|
||||
"2. Try installing manually: sudo dnf install -y python3-dnf-plugins-core\n"
|
||||
"3. Refresh repository metadata: sudo dnf makecache"
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
|
||||
check_after = self.runner.run([self.binary, "system-upgrade", "--help"])
|
||||
if check_after.return_code != 0:
|
||||
err_msg = (
|
||||
"Package 'python3-dnf-plugins-core' was installed, but 'dnf system-upgrade' remains unavailable.\n"
|
||||
"Troubleshooting: Please check DNF plugin configuration under /etc/dnf/plugins/."
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
|
||||
return True, "Fedora system-upgrade plugin successfully installed."
|
||||
|
||||
def _ensure_elevate_dependencies(self, distro_id: str, version_id: str) -> Tuple[bool, str]:
|
||||
"""Ensures ELevate and Leapp components are installed for AlmaLinux, Rocky, or CentOS."""
|
||||
if shutil.which("leapp"):
|
||||
return True, "Leapp upgrade framework is already installed."
|
||||
|
||||
major = version_id.split(".")[0] if version_id else "9"
|
||||
pretty = distro_id.title()
|
||||
self.runner._log(
|
||||
f"[UPGRADE] Leapp upgrade framework is not installed on {pretty} {version_id}. "
|
||||
f"Attempting automatic installation of ELevate components for Enterprise Linux {major}..."
|
||||
)
|
||||
|
||||
# 1. Install ELevate release repository package
|
||||
elevate_rpm_url = f"http://repo.almalinux.org/elevate/elevate-release-latest-el{major}.noarch.rpm"
|
||||
self.runner._log(f"[UPGRADE] Installing ELevate repository package from {elevate_rpm_url}...")
|
||||
res_repo = self.runner.run([self.binary, "install", "-y", elevate_rpm_url])
|
||||
if res_repo.return_code != 0:
|
||||
res_repo = self.runner.run([self.binary, "install", "-y", "elevate-release"])
|
||||
|
||||
if res_repo.return_code != 0:
|
||||
err_msg = (
|
||||
f"Failed to install ELevate repository package for {pretty} EL{major}.\n"
|
||||
f"DNF exited with code {res_repo.return_code}.\n"
|
||||
f"Details:\n{res_repo.stderr or res_repo.stdout}\n"
|
||||
"Troubleshooting:\n"
|
||||
f"1. Verify internet connectivity to http://repo.almalinux.org.\n"
|
||||
f"2. Manually install repository: sudo dnf install -y {elevate_rpm_url}\n"
|
||||
"3. Ensure DNF base repositories are functioning properly."
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
|
||||
# 2. Determine target data package based on distribution
|
||||
data_pkg = f"leapp-data-{distro_id}" if distro_id in ("almalinux", "rocky", "centos") else "leapp-data-almalinux"
|
||||
pkgs_to_install = ["leapp-upgrade", data_pkg]
|
||||
self.runner._log(f"[UPGRADE] Installing Leapp packages: {' '.join(pkgs_to_install)}...")
|
||||
res_pkgs = self.runner.run([self.binary, "install", "-y"] + pkgs_to_install)
|
||||
if res_pkgs.return_code != 0:
|
||||
res_pkgs = self.runner.run([self.binary, "install", "-y", "leapp", data_pkg])
|
||||
|
||||
if res_pkgs.return_code != 0:
|
||||
err_msg = (
|
||||
f"Failed to install Leapp upgrade packages ({', '.join(pkgs_to_install)}).\n"
|
||||
f"DNF exited with code {res_pkgs.return_code}.\n"
|
||||
f"Details:\n{res_pkgs.stderr or res_pkgs.stdout}\n"
|
||||
"Troubleshooting:\n"
|
||||
f"1. Manually install via: sudo dnf install -y leapp-upgrade {data_pkg}\n"
|
||||
"2. Check if ELevate repository is enabled: dnf repolist | grep -i elevate\n"
|
||||
"3. Inspect /var/log/dnf.log for dependency conflict details."
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
|
||||
if not shutil.which("leapp"):
|
||||
err_msg = (
|
||||
"Leapp packages were installed, but 'leapp' binary was not found in system PATH.\n"
|
||||
"Troubleshooting: Verify that /usr/bin and /usr/sbin are in PATH."
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
|
||||
return True, "ELevate / Leapp components successfully installed."
|
||||
|
||||
def _check_rhel_subscription(self) -> Tuple[bool, str]:
|
||||
"""Validates that Red Hat Enterprise Linux has an active subscription."""
|
||||
if shutil.which("subscription-manager"):
|
||||
res = self.runner.run(["subscription-manager", "status"])
|
||||
if res.return_code != 0:
|
||||
err_msg = (
|
||||
"Red Hat Enterprise Linux requires an active Red Hat subscription for major release upgrades.\n"
|
||||
"'subscription-manager' reported that this system is not registered or has no active entitlements.\n"
|
||||
f"Details:\n{res.stdout or res.stderr}\n"
|
||||
"Troubleshooting:\n"
|
||||
"1. Register system: sudo subscription-manager register --auto-attach\n"
|
||||
"2. Check entitlement status: sudo subscription-manager status\n"
|
||||
"3. Refer to Red Hat Solution 4263361 for Leapp repository setup."
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return False, err_msg
|
||||
return True, "Subscription status verified."
|
||||
|
||||
def release_upgrade(
|
||||
self,
|
||||
target_release: Optional[str] = None,
|
||||
dry_run: bool = False,
|
||||
non_interactive: bool = False,
|
||||
) -> CommandResult:
|
||||
import shutil
|
||||
if shutil.which("leapp"):
|
||||
cmd = ["leapp", "preupgrade" if dry_run else "upgrade"]
|
||||
return self.runner.run(cmd)
|
||||
distro = self._get_distro_info()
|
||||
distro_id = distro.distro_id.lower()
|
||||
|
||||
# Check if dnf system-upgrade is available
|
||||
# 1. Fedora workflow (dnf system-upgrade)
|
||||
if distro_id == "fedora":
|
||||
ok, msg = self._ensure_fedora_upgrade_dependencies()
|
||||
if not ok:
|
||||
if dry_run:
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Release upgrade simulation for Fedora (target: {target_release or 'latest'})\nNote: {msg}",
|
||||
stderr="",
|
||||
success=True,
|
||||
)
|
||||
return CommandResult(return_code=1, stdout="", stderr=msg, success=False)
|
||||
|
||||
cmd = [self.binary, "system-upgrade", "download"]
|
||||
if dry_run:
|
||||
cmd.append("--assumeno")
|
||||
elif non_interactive:
|
||||
cmd.append("-y")
|
||||
if target_release:
|
||||
cmd.append(f"--releasever={target_release}")
|
||||
|
||||
res = self.runner.run(cmd)
|
||||
if dry_run and res.return_code == 1:
|
||||
combined = res.stdout + res.stderr
|
||||
if "Operation aborted" in combined or "Nothing to do" in combined:
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=res.stdout,
|
||||
stderr=res.stderr,
|
||||
success=True,
|
||||
)
|
||||
return res
|
||||
|
||||
# 2. AlmaLinux / Rocky / CentOS workflow (ELevate + Leapp)
|
||||
if distro_id in ("almalinux", "rocky", "centos"):
|
||||
ok, msg = self._ensure_elevate_dependencies(distro_id, distro.version_id)
|
||||
if not ok:
|
||||
if dry_run:
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Release upgrade simulation for {distro.pretty_name} (target: {target_release or 'next major'})\nDependency status:\n{msg}",
|
||||
stderr="",
|
||||
success=True,
|
||||
)
|
||||
return CommandResult(return_code=1, stdout="", stderr=msg, success=False)
|
||||
|
||||
if dry_run:
|
||||
self.runner._log("[UPGRADE] Running Leapp pre-upgrade diagnostic ('leapp preupgrade')...")
|
||||
res = self.runner.run(["leapp", "preupgrade"])
|
||||
report_file = Path("/var/log/leapp/leapp-report.txt")
|
||||
report_hint = f"\nLeapp pre-upgrade report saved to {report_file}." if report_file.exists() else ""
|
||||
if res.return_code != 0:
|
||||
self.runner._log(f"[WARN] Leapp pre-upgrade detected inhibitors or required answers (exit code {res.return_code}).{report_hint}")
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Leapp pre-upgrade evaluation finished with code {res.return_code}.\n{res.stdout}{report_hint}",
|
||||
stderr=res.stderr,
|
||||
success=True,
|
||||
)
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Leapp pre-upgrade evaluation completed successfully!{report_hint}",
|
||||
stderr="",
|
||||
success=True,
|
||||
)
|
||||
else:
|
||||
self.runner._log("[UPGRADE] Starting Leapp in-place upgrade ('leapp upgrade')...")
|
||||
res = self.runner.run(["leapp", "upgrade"])
|
||||
if res.return_code != 0:
|
||||
err_msg = (
|
||||
f"Leapp in-place upgrade failed with exit code {res.return_code}.\n"
|
||||
f"Details:\n{res.stderr or res.stdout}\n"
|
||||
"Troubleshooting:\n"
|
||||
"1. Review report: cat /var/log/leapp/leapp-report.txt\n"
|
||||
"2. Resolve any inhibitor items or missing answer files.\n"
|
||||
"3. Re-run: sudo linux-updater release-upgrade"
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
return CommandResult(return_code=res.return_code, stdout=res.stdout, stderr=err_msg, success=False)
|
||||
return res
|
||||
|
||||
# 3. Official RHEL workflow (subscription-manager + Leapp)
|
||||
if distro_id == "rhel":
|
||||
ok, msg = self._check_rhel_subscription()
|
||||
if not ok:
|
||||
if dry_run:
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Simulation for RHEL release upgrade.\nSubscription warning:\n{msg}",
|
||||
stderr="",
|
||||
success=True,
|
||||
)
|
||||
return CommandResult(return_code=1, stdout="", stderr=msg, success=False)
|
||||
|
||||
if not shutil.which("leapp"):
|
||||
self.runner._log("[UPGRADE] Installing Red Hat Leapp upgrade framework ('leapp-upgrade')...")
|
||||
res_inst = self.runner.run([self.binary, "install", "-y", "leapp-upgrade"])
|
||||
if res_inst.return_code != 0:
|
||||
err_msg = (
|
||||
f"Failed to install 'leapp-upgrade' from Red Hat repositories (exit code {res_inst.return_code}).\n"
|
||||
f"Details:\n{res_inst.stderr or res_inst.stdout}\n"
|
||||
"Troubleshooting:\n"
|
||||
"1. Verify active Red Hat subscription includes upgrade channels.\n"
|
||||
"2. Install manually: sudo dnf install -y leapp-upgrade"
|
||||
)
|
||||
self.runner._log(f"[ERROR] {err_msg}")
|
||||
if dry_run:
|
||||
return CommandResult(return_code=0, stdout=f"[DRY-RUN] Simulation for RHEL.\n{err_msg}", stderr="", success=True)
|
||||
return CommandResult(return_code=1, stdout="", stderr=err_msg, success=False)
|
||||
|
||||
if dry_run:
|
||||
res = self.runner.run(["leapp", "preupgrade"])
|
||||
return CommandResult(return_code=0, stdout=f"[DRY-RUN] Leapp pre-upgrade simulation:\n{res.stdout}", stderr="", success=True)
|
||||
else:
|
||||
return self.runner.run(["leapp", "upgrade"])
|
||||
|
||||
# 4. Fallback for other DNF-based systems
|
||||
check = self.runner.run([self.binary, "system-upgrade", "--help"])
|
||||
if check.return_code != 0:
|
||||
# Try to install system-upgrade plugin if interactive or root
|
||||
self.runner.run([self.binary, "install", "-y", "dnf-plugins-core"])
|
||||
check = self.runner.run([self.binary, "system-upgrade", "--help"])
|
||||
|
||||
if check.return_code != 0:
|
||||
if dry_run:
|
||||
return CommandResult(
|
||||
return_code=0,
|
||||
stdout=f"[DRY-RUN] Release upgrade simulation for target release {target_release or 'latest'}",
|
||||
stdout=f"[DRY-RUN] Release upgrade simulation for {distro.pretty_name} (target: {target_release or 'latest'})",
|
||||
stderr="",
|
||||
success=True,
|
||||
)
|
||||
return CommandResult(
|
||||
return_code=1,
|
||||
stdout="",
|
||||
stderr="Major release upgrade requires 'dnf system-upgrade' (Fedora) or 'leapp' (RHEL/AlmaLinux). Please install the required upgrade framework.",
|
||||
stderr=f"Major release upgrade for {distro.pretty_name} is not natively supported or requires external tools.",
|
||||
success=False,
|
||||
)
|
||||
|
||||
@@ -112,7 +349,6 @@ class DnfManager(PackageManager):
|
||||
cmd.append("--assumeno")
|
||||
elif non_interactive:
|
||||
cmd.append("-y")
|
||||
|
||||
if target_release:
|
||||
cmd.append(f"--releasever={target_release}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user