Offer automatic package downloads, now that the machinery is installed
The page had a row for the case where dnf-automatic is absent and nothing for the case where it is present, so installing it made the setting disappear rather than appear. The switch enables downloading only, which is the shipped default and the right one to keep: a machine that installs packages unattended can reboot into a kernel nobody chose. Downloading ahead of time is what makes the install quick when someone does choose it, and the row says exactly that rather than implying updates apply themselves. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
@@ -256,6 +256,23 @@ def apply(source: str) -> dict:
|
||||
raise BoundaryError("That is not an update source.")
|
||||
|
||||
|
||||
def set_auto_dnf(enabled: bool) -> None:
|
||||
"""Enable the packaging timer, which DOWNLOADS updates but does not apply them.
|
||||
|
||||
That is the shipped default (apply_updates = no) and it is the right one to
|
||||
leave alone: a machine that installs packages unattended can reboot into a
|
||||
kernel nobody chose. Downloading ahead of time makes the install quick when
|
||||
someone does choose it.
|
||||
"""
|
||||
state = automatic_state()
|
||||
if not state["dnfAutomaticAvailable"]:
|
||||
raise BoundaryError("Automatic package updates are not installed.")
|
||||
action = ["enable", "--now"] if enabled else ["disable", "--now"]
|
||||
result = run(["pkexec", "systemctl", *action, "dnf5-automatic.timer"], timeout=120)
|
||||
if result.returncode != 0:
|
||||
raise BoundaryError(_refusal(result, "Automatic package updates could not be changed."))
|
||||
|
||||
|
||||
def set_auto_flatpak(enabled: bool) -> None:
|
||||
action = ["enable", "--now"] if enabled else ["disable", "--now"]
|
||||
result = run(["systemctl", "--user", *action, FLATPAK_TIMER], timeout=60)
|
||||
@@ -294,10 +311,12 @@ def main(arguments: list[str]) -> int:
|
||||
return 0
|
||||
if len(arguments) == 2 and arguments[0] == "set-auto-flatpak":
|
||||
set_auto_flatpak(arguments[1] == "true")
|
||||
elif len(arguments) == 2 and arguments[0] == "set-auto-dnf":
|
||||
set_auto_dnf(arguments[1] == "true")
|
||||
else:
|
||||
raise BoundaryError(
|
||||
"Usage: panama-updates snapshot | check | apply dnf|flatpak|firmware | "
|
||||
"set-auto-flatpak true|false")
|
||||
"set-auto-flatpak true|false | set-auto-dnf true|false")
|
||||
except BoundaryError as error:
|
||||
state = snapshot()
|
||||
state["error"] = str(error)
|
||||
|
||||
Reference in New Issue
Block a user