diff --git a/Makefile b/Makefile index 5f072b022..75d6888cb 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,16 @@ all-test: install: install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc install -d $(DESTDIR)$(prefix)/lib/bootc/install + # Support installing pre-generated man pages shipped in source tarball, to avoid + # a dependency on pandoc downstream + if test -d man; then install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man5 man/*.5; fi if test -d man; then install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 man/*.8; fi +# These are not installed by default; one recommendation is to put them in a separate +# sub-package or sub-component. +install-systemd-auto: + install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer + bin-archive: all $(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf diff --git a/manpages-md-extra/bootc-fetch-apply-updates.service.md b/manpages-md-extra/bootc-fetch-apply-updates.service.md new file mode 100644 index 000000000..c4831c2d1 --- /dev/null +++ b/manpages-md-extra/bootc-fetch-apply-updates.service.md @@ -0,0 +1,27 @@ +# NAME + +bootc-fetch-apply-updates.service + +# DESCRIPTION + +This service causes `bootc` to perform the following steps: + +- Check the source registry for an updated container image +- If one is found, download it +- Reboot + +This service also comes with a companion `bootc-fetch-apply-updates.timer` +systemd unit. The current default systemd timer shipped in the upstream +project is enabled for daily updates. + +However, it is fully expected that different operating systems +and distributions choose different defaults. + +## Customizing updates + +Note that all three of these steps can be decoupled; they +are: + +- `bootc upgrade --check` +- `bootc upgrade` +- `bootc upgrade --apply` diff --git a/systemd/bootc-fetch-apply-updates.service b/systemd/bootc-fetch-apply-updates.service new file mode 100644 index 000000000..2a958005c --- /dev/null +++ b/systemd/bootc-fetch-apply-updates.service @@ -0,0 +1,8 @@ +[Unit] +Description=Apply bootc updates +Documentation=man:bootc(8) +ConditionPathExists=/run/ostree-booted + +[Service] +Type=oneshot +ExecStart=/usr/bin/bootc update --apply --quiet diff --git a/systemd/bootc-fetch-apply-updates.timer b/systemd/bootc-fetch-apply-updates.timer new file mode 100644 index 000000000..4ad60cbbc --- /dev/null +++ b/systemd/bootc-fetch-apply-updates.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Apply bootc updates +Documentation=man:bootc(8) +ConditionPathExists=/run/ostree-booted + +[Timer] +OnBootSec=1h +# This time is relatively arbitrary and obviously expected to be overridden/changed +OnUnitInactiveSec=8h + +[Install] +WantedBy=timers.target diff --git a/xtask/src/xtask.rs b/xtask/src/xtask.rs index f98d9a41e..b79043293 100644 --- a/xtask/src/xtask.rs +++ b/xtask/src/xtask.rs @@ -79,12 +79,37 @@ fn gitrev(sh: &Shell) -> Result { #[context("Manpages")] fn manpages(sh: &Shell) -> Result<()> { + // We currently go: clap (Rust) -> man -> markdown for the CLI sh.create_dir("target/man")?; cmd!( sh, "cargo run --features=docgen -- man --directory target/man" ) .run()?; + // We also have some man pages for the systemd units which are canonically + // maintained as markdown; convert them to man pages. + let extradir = sh.current_dir().join("manpages-md-extra"); + for ent in std::fs::read_dir(extradir)? { + let ent = ent?; + let srcpath = ent.path(); + let extension = if let Some(extension) = srcpath.extension() { + extension + } else { + continue; + }; + if extension != "md" { + continue; + } + let base_filename = srcpath + .file_stem() + .and_then(|name| name.to_str()) + .ok_or_else(|| anyhow!("Expected filename in {srcpath:?}"))?; + cmd!( + sh, + "pandoc --from=markdown --to=man --output=target/man/{base_filename}.5 {srcpath}" + ) + .run()?; + } Ok(()) }