fixup! Add networked package management.

This commit is contained in:
Jonas 'Sortie' Termansen 2025-02-19 14:28:40 +01:00
parent 8a51a19e4e
commit fa952fb62c
4 changed files with 188 additions and 16 deletions

View file

@ -107,8 +107,6 @@ The signature on the downloaded release is still verified, stale files are
rejected, and the mirror must be up to date per the authoritative site.
.It Sy MIRROR
The URL to the base of the preferred mirror for downloading packages from.
.Pp
TODO: Rename to MIRROR as is kinda already the case per the hooks.
.It Sy PLATFORM
The host triplet the installed packages are built for.
Packages must have the same platform to be installed, or they must be platform
@ -187,7 +185,7 @@ The
.Xr tix-autoupgrade 8
daemon can be enabled by running:
.Bd -literal -offset indent
service tix-autoupgrade enable
service autoupgrade enable
.Ed
.Sh SEE ALSO
.Xr upgrade.conf 5 ,

View file

@ -43,6 +43,7 @@ tix-repository \
tix-upgrade \
MANPAGES8=\
tix-autoupgrade.8 \
tix-build.8 \
tix-collection.8 \
tix-eradicate-libtool-la.8 \

View file

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2024 Jonas 'Sortie' Termansen.
# Copyright (c) 2024, 2025 Jonas 'Sortie' Termansen.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -16,16 +16,13 @@
# tix-autoupgrade
# Daemon automatically applying system upgrades.
# TODO: Document tix-autoupgrade(8).
collection=/
interval=24h
prefix=/
unset interval
now=false
once=false
unset options
unset reboot
reboot_time=+1
wait=
unset reboot_time
dashdash=
previous_option=
@ -45,13 +42,17 @@ for argument do
case $dashdash$argument in
--) dashdash=yes ;;
--collection=*) collection=$parameter ;;
--collection) previous_option=output ;;
--collection) previous_option=collection ;;
--interval=*) interval=$parameter ;;
--interval) previous_option=interval ;;
--no-reboot) reboot=false ;;
--now) now=true ;;
--once) once=true; now=true ;;
--no-reboot) reboot=false ;;
--options=*) options=$parameter ;;
--options) previous_option=options ;;
--reboot) reboot=true ;;
--reboot-time=*) reboot_time=$parameter ;;
--reboot-time) previous_option=reboot_time ;;
-*) echo "$0: unrecognized option $argument" >&2
exit 1 ;;
*)
@ -70,10 +71,10 @@ reboot=${reboot:-false}
collection=$(cd "$collection" && pwd)
interval=$(tix-vars -d "$interval" "$collection/tix/collection.conf" AUTOUPGRADE_INTERVAL)
options=$(tix-vars -d "" "$collection/tix/collection.conf" AUTOUPGRADE_OPTIONS)
reboot=$(tix-vars -d "$reboot" "$collection/tix/collection.conf" AUTOUPGRADE_REBOOT)
reboot_time=$(tix-vars -d "$reboot_time" "$collection/tix/collection.conf" AUTOUPGRADE_REBOOT_TIME)
interval=${interval-$(tix-vars -d "24h" "$collection/tix/collection.conf" AUTOUPGRADE_INTERVAL)}
options=${options-$(tix-vars -d "" "$collection/tix/collection.conf" AUTOUPGRADE_OPTIONS)}
reboot=${reboot-$(tix-vars -d false "$collection/tix/collection.conf" AUTOUPGRADE_REBOOT)}
reboot_time=${reboot_time-$(tix-vars -d +1 "$collection/tix/collection.conf" AUTOUPGRADE_REBOOT_TIME)}
need_cancel=false

172
tix/tix-autoupgrade.8 Normal file
View file

@ -0,0 +1,172 @@
.Dd February 19, 2025
.Dt TIX-AUTOUPGRADE 8
.Os
.Sh NAME
.Nm tix-autoupgrade
.Nd daemon for automated operating system upgrades
.Sh SYNOPSIS
.Nm
.Op Fl \-collection Ns = Ns Ar collection
.Op Fl \-interval Ns = Ns Ar interval
.Op Fl \-now
.Op Fl \-once
.Op Fl \-options Ns = Ns Ar options
.Op Fl \-no-reboot
.Op Fl \-reboot
.Op Fl \-reboot-time Ns = Ns Ar when
.Sh DESCRIPTION
.Nm
is a daemon that does an automated and unattended operating system
.Xr upgrade 7
by running
.Xr tix-upgrade 8 .
The upgrade will be scheduled for the next boot.
.Pp
.Nm
is configured in
.Xr collection.conf 5 .
The specified
.Ar collection
is upgraded, defaulting to the root directory collection.
.Pp
If no upgrade has ever been attempted, or an upgrade has just happened,
.Nm
will attempt an upgrade immediately.
Otherwise an upgrade will be attempted every
.Sy AUTOUPGRADE_INTERVAL
interval (default is
.Sy 24h )
since the previous attempt.
The
.Sy AUTOUPGRADE_OPTIONS
options are forwarded to
.Xr tix-upgrade 8 .
If an upgrade becomes scheduled and
.Sy AUTOUPGRADE_REBOOT
is set to
.Sy true
(the default is
.Sy false ) ,
then a reboot is scheduled with
.Xr shutdown 8
.Fl r
at
.Sy AUTOUPGRADE_REBOOT_TIME
(default is
.Sy +1 ,
one minute later).
.Pp
The options are as follows:
.Bl -tag -width "12345678"
.It Fl \-collection Ns = Ns Ar collection
Upgrade this
.Pa collection .
.It Fl \-interval Ns = Ns Ar interval
Override
.Sy AUTOUPGRADE_INTERVAL
and check for upgrades every
.Ar interval .
.It Fl \-now
Attempt an upgrade immediately.
Delay signaling daemon readiness until the first attempt has been made.
.It Fl \-no-reboot
Override
.Sy AUTOUPGRADE_REBOOT
with
.Sy false
and do not reboot after an upgrade has been scheduled.
.It Fl \-once
Attempt an upgrade immediately and exit 0 afterwards.
.It Fl \-options Ns = Ns Ar options
Override
.Sy AUTOUPGRADE_OPTIONS
and pass these
.Ar options
to
.Xr tix-upgrade 8 .
.It Fl \-reboot
Override
.Sy AUTOUPGRADE_REBOOT
with
.Sy true
and reboot after an upgrade has been scheduled.
.It Fl \-reboot-time Ns = Ns Ar when
Override
.Sy AUTOUPGRADE_REBOOT_TIME
and reboot at
.Ar when
after an upgrade has been scheduled.
.El
.Sh FILES
.Bl -tag -width "/tix/collection.conf" -compact
.It Pa /boot/sysmerge/
New kernel and initrd files.
.It Pa /sysmerge/
.Xr sysmerge 8
upgrades scheduled for the next boot.
.It Pa /tix/collection.conf
.Xr collection.conf 5
configuration.
.It Pa /var/cache/tix/
Temporary downloaded of the new release.
.It Pa /var/cache/tix/autoupgrade.stamp
Timestamp of the last upgrade attempt.
.It Pa /var/log/autoupgrade.log
The default
.Xr init 5
log file.
.El
.Sh ASYNCHRONOUS EVENTS
.Bl -tag -width "SIGUSR1"
.It Dv SIGTERM
Request daemon termination.
Any in-progress upgrade will be aborted and canceled.
.El
.Sh EXIT STATUS
.Nm
runs as a
.Xr daemon 7
until stopped by
.Dv SIGTERM .
.Nm
signals readiness on the
.Ev READYFD
when it has started, before checking for any upgrades.
.Pp
.Nm
exits 0 if
.Fl \-now
after an upgrade attempt.
.Pp
.Nm
exits non-zero on any fatal errors.
.Sh EXAMPLES
An example
.Xr collection.conf 5
configured to automatically upgrade every day and
reboot at 04:30 AM:
.Bd -literal -offset indent
TIX_COLLECTION_VERSION=3
BUILD_ID=578501924cd5463da9f3cf1e775924970607e504
PLATFORM=x86_64-sortix
PREFIX=
RELEASE_URL=https://example.com/local/channel/stable/1.0
AUTOUPGRADE_REBOOT=true
AUTOUPGRADE_REBOOT_TIME=04:30
.Ed
.Pp
The
.Xr tix-autoupgrade 8
daemon can be enabled by running:
.Bd -literal -offset indent
service autoupgrade enable
.Ed
.Sh SEE ALSO
.Xr collection.conf 5 ,
.Xr upgrade 7 ,
.Xr tix 8 ,
.Xr tix-release 8 ,
.Xr tix-upgrade 8
.Sh HISTORY
.Nm
originally appeared in Sortix 1.1.