Skip to content

Commit d720fdd

Browse files
authored
Merge pull request #179 from cgwalters/add-systemd-auto
systemd: New bootc-fetch-apply-updates.{timer,service}
2 parents 0910876 + c13c9eb commit d720fdd

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ all-test:
99
install:
1010
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
1111
install -d $(DESTDIR)$(prefix)/lib/bootc/install
12+
# Support installing pre-generated man pages shipped in source tarball, to avoid
13+
# a dependency on pandoc downstream
14+
if test -d man; then install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man5 man/*.5; fi
1215
if test -d man; then install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 man/*.8; fi
1316

17+
# These are not installed by default; one recommendation is to put them in a separate
18+
# sub-package or sub-component.
19+
install-systemd-auto:
20+
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer
21+
1422
bin-archive: all
1523
$(MAKE) install DESTDIR=tmp-install && tar --zstd -C tmp-install -cf target/bootc.tar.zst . && rm tmp-install -rf
1624

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NAME
2+
3+
bootc-fetch-apply-updates.service
4+
5+
# DESCRIPTION
6+
7+
This service causes `bootc` to perform the following steps:
8+
9+
- Check the source registry for an updated container image
10+
- If one is found, download it
11+
- Reboot
12+
13+
This service also comes with a companion `bootc-fetch-apply-updates.timer`
14+
systemd unit. The current default systemd timer shipped in the upstream
15+
project is enabled for daily updates.
16+
17+
However, it is fully expected that different operating systems
18+
and distributions choose different defaults.
19+
20+
## Customizing updates
21+
22+
Note that all three of these steps can be decoupled; they
23+
are:
24+
25+
- `bootc upgrade --check`
26+
- `bootc upgrade`
27+
- `bootc upgrade --apply`
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Apply bootc updates
3+
Documentation=man:bootc(8)
4+
ConditionPathExists=/run/ostree-booted
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=/usr/bin/bootc update --apply --quiet
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Apply bootc updates
3+
Documentation=man:bootc(8)
4+
ConditionPathExists=/run/ostree-booted
5+
6+
[Timer]
7+
OnBootSec=1h
8+
# This time is relatively arbitrary and obviously expected to be overridden/changed
9+
OnUnitInactiveSec=8h
10+
11+
[Install]
12+
WantedBy=timers.target

xtask/src/xtask.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,37 @@ fn gitrev(sh: &Shell) -> Result<String> {
7979

8080
#[context("Manpages")]
8181
fn manpages(sh: &Shell) -> Result<()> {
82+
// We currently go: clap (Rust) -> man -> markdown for the CLI
8283
sh.create_dir("target/man")?;
8384
cmd!(
8485
sh,
8586
"cargo run --features=docgen -- man --directory target/man"
8687
)
8788
.run()?;
89+
// We also have some man pages for the systemd units which are canonically
90+
// maintained as markdown; convert them to man pages.
91+
let extradir = sh.current_dir().join("manpages-md-extra");
92+
for ent in std::fs::read_dir(extradir)? {
93+
let ent = ent?;
94+
let srcpath = ent.path();
95+
let extension = if let Some(extension) = srcpath.extension() {
96+
extension
97+
} else {
98+
continue;
99+
};
100+
if extension != "md" {
101+
continue;
102+
}
103+
let base_filename = srcpath
104+
.file_stem()
105+
.and_then(|name| name.to_str())
106+
.ok_or_else(|| anyhow!("Expected filename in {srcpath:?}"))?;
107+
cmd!(
108+
sh,
109+
"pandoc --from=markdown --to=man --output=target/man/{base_filename}.5 {srcpath}"
110+
)
111+
.run()?;
112+
}
88113
Ok(())
89114
}
90115

0 commit comments

Comments
 (0)