Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: New bootc-fetch-apply-updates.{timer,service} #179

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions manpages-md-extra/bootc-fetch-apply-updates.service.md
Original file line number Diff line number Diff line change
@@ -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`
8 changes: 8 additions & 0 deletions systemd/bootc-fetch-apply-updates.service
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions systemd/bootc-fetch-apply-updates.timer
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,37 @@ fn gitrev(sh: &Shell) -> Result<String> {

#[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(())
}

Expand Down