Skip to content

Commit

Permalink
On a bootc host print the BOOTC_HOST_DOC if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Jul 19, 2024
1 parent bfd01bb commit 6eb2394
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dnf/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ def do_transaction(self, display=()):
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_bootc_host():
_bootc_host_msg = _("""
bootc_docs = dnf.util._bootc_doc_url()
if bootc_docs:
_bootc_host_msg = _("""
*** Error: system is configured to be read-only; for more
*** information see: """ + dnf.util._bootc_doc_url())
else:
_bootc_host_msg = _("""
*** Error: system is configured to be read-only; for more
*** information run `bootc status` or `ostree admin status`.
""")
Expand Down
9 changes: 9 additions & 0 deletions dnf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,12 @@ def _is_bootc_host():
# temporary changes (until reboot).
return os.path.isfile(ostree_booted) and not os.access(usr, os.W_OK)


def _bootc_doc_url():
try:
with open('/etc/os-release', 'r') as f:
for line in f:
if line.startswith('BOOTC_HOST_DOC='):
return line.split('=')[1].strip().strip('"')
except Exception as e:
return None

0 comments on commit 6eb2394

Please sign in to comment.