jw.pkg.cmds.distro.CmdRebootRequired: Add class

Add the command distro.CmdRebootRequired, adding support for "distro
reboot-required". The command exits with status code 1 if a reboot is
required and 0 otherwise.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-03 07:15:48 +01:00
commit 79d40af558
4 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
import os
from argparse import Namespace
from .....lib.log import *
from ...Cmd import Cmd
from ..BeRebootRequired import BeRebootRequired as Base
class RebootRequired(Base):
def __init__(self, parent: Cmd):
super().__init__(parent)
async def run(self, args: Namespace):
reboot_required = '/run/reboot_required'
if os.path.exists(reboot_required):
if args.verbose:
log(NOTICE, f'Yes. {reboot_required} exists.')
required_pkgs = '/run/reboot-required.pkgs'
if os.path.exists(required_pkgs):
with open(required_pkgs, 'r') as f:
content = f.read()
print(f'-- From {required_pkgs}:')
print(content.strip())
return 1
if args.verbose:
log(NOTICE, f'No. {reboot_required} doesn\'t exist.')
return 0