From 7c3660b9aad68523e38899b40b4bdf198787be73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Tue, 6 Aug 2024 12:49:11 +0200 Subject: [PATCH] Revert "Add detection for ostree-based systems and warn users about losing changes" This reverts commit d100c8d717cb6fbd6ba9e16028a56b140275bc8b because it breaks "dnf --installroot". Related: https://issues.redhat.com/browse/RHEL-49670 --- dnf/cli/cli.py | 9 --------- dnf/util.py | 31 ------------------------------- 2 files changed, 40 deletions(-) diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py index 1fd0e96c3a..0c4f4c6ad9 100644 --- a/dnf/cli/cli.py +++ b/dnf/cli/cli.py @@ -214,15 +214,6 @@ def do_transaction(self, display=()): elif 'test' in self.conf.tsflags: logger.info(_("{prog} will only download packages, install gpg keys, and check the " "transaction.").format(prog=dnf.util.MAIN_PROG_UPPER)) - if dnf.util.is_container(): - _container_msg = _(""" -*** This system is managed with ostree. Changes to the system -*** made with dnf will be lost with the next ostree-based update. -*** If you do not want to lose these changes, use 'rpm-ostree'. -""") - logger.info(_container_msg) - raise CliError(_("Operation aborted.")) - if self._promptWanted(): if self.conf.assumeno or not self.output.userconfirm(): raise CliError(_("Operation aborted.")) diff --git a/dnf/util.py b/dnf/util.py index 9909f8fea5..16c5bc89c1 100644 --- a/dnf/util.py +++ b/dnf/util.py @@ -33,13 +33,11 @@ import functools import hawkey import itertools -import json import locale import logging import os import pwd import shutil -import subprocess import sys import tempfile import time @@ -633,32 +631,3 @@ def _tsi_or_pkg_nevra_cmp(item1, item2): def _name_unset_wrapper(input_name): # returns for everything that evaluates to False (None, empty..) return input_name if input_name else _("") - - -def is_container(): - """Returns true is the system is managed as an immutable container, - false otherwise. If msg is True, a warning message is displayed - for the user. - """ - - bootc = '/usr/bin/bootc' - ostree = '/sysroot/ostree' - - if os.path.isfile(bootc) and os.access(bootc, os.X_OK): - p = subprocess.Popen([bootc, "status", "--json"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (out, err) = p.communicate() - - if p.returncode == 0: - # check the output of 'bootc status' - j = json.loads(out) - - # XXX: the API from bootc status is evolving - status = j.get("status", "") - kind = j.get("kind", "") - - if kind.lower() == "bootchost" and bool(status.get("isContainer", None)): - return True - elif os.path.isdir(ostree): - return True - - return False \ No newline at end of file