Skip to content

Commit d43e995

Browse files
committed
install: Drop default config
Let's require the OS/distro to inject the defaults they want. Signed-off-by: Colin Walters <[email protected]>
1 parent 083c1af commit d43e995

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ all-test:
88

99
install:
1010
install -D -m 0755 -t $(DESTDIR)$(prefix)/bin target/release/bootc
11-
install -D -m 0644 -t $(DESTDIR)$(prefix)/lib/bootc/install lib/src/install/*.toml
11+
install -d $(DESTDIR)$(prefix)/lib/bootc/install
1212
if test -d man; then install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 man/*.8; fi
1313

1414
bin-archive: all

docs/install.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ other options.
4343
Here's an example:
4444

4545
```
46-
$ podman run --privileged --pid=host --net=none --security-opt label=type:unconfined_t ghcr.io/cgwalters/c9s-oscore bootc install --target-no-signature-verification /path/to/disk
46+
$ podman run --privileged --pid=host --net=none --security-opt label=type:unconfined_t <image> bootc install --target-no-signature-verification /path/to/disk
4747
```
4848

4949
Note that while `--privileged` is used, this command will not
@@ -58,6 +58,23 @@ an installation by default is not fetching anything else external
5858
from the network - the content to be installed
5959
*is the running container image content*.
6060

61+
### Operating system install configuration required
62+
63+
The container image must define its default install configuration. For example,
64+
create `/usr/lib/bootc/install/00-exampleos.toml` with the contents:
65+
66+
```
67+
[install]
68+
root-fs-type = "xfs"
69+
```
70+
71+
At the current time, `root-fs-type` is the only available configuration option, and it must be set.
72+
73+
Configuration files found in this directory will be merged, with higher alphanumeric values
74+
taking precedence. If for example you are building a derived container image from the above OS,
75+
you coudl create a `50-myos.toml` that sets `root-fs-type = "btrfs"` which will override the
76+
prior setting.
77+
6178
### Note: Today `bootc install` has a host requirement on `skopeo`
6279

6380
The one exception to host requirements today is that the host must
@@ -110,7 +127,7 @@ The `AuthorizedKeysFile` invocation below then configures sshd to look
110127
for keys in this location.
111128

112129
```
113-
FROM ghcr.io/cgwalters/c9s-oscore
130+
FROM <image>
114131
RUN mkdir -p /usr/etc-system/ && \
115132
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
116133
echo 'ssh-ed25519 AAAAC3Nza... [email protected]' > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/keys && \

lib/src/install.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,20 @@ pub(crate) mod config {
403403
config = c.install;
404404
}
405405
}
406-
config.ok_or_else(|| anyhow::anyhow!("Failed to find any installation config files"))
406+
config.ok_or_else(|| anyhow::anyhow!("No bootc/install config found; this operating system must define a default configuration to be installable"))
407407
}
408408

409409
#[test]
410410
/// Verify that we can parse our default config file
411411
fn test_parse_config() {
412412
use super::baseline::Filesystem;
413-
let buf = include_str!("install/00-defaults.toml");
414-
let c: InstallConfigurationToplevel = toml::from_str(buf).unwrap();
413+
414+
let c: InstallConfigurationToplevel = toml::from_str(
415+
r##"[install]
416+
root-fs-type = "xfs"
417+
"##,
418+
)
419+
.unwrap();
415420
let mut install = c.install.unwrap();
416421
assert_eq!(install.root_fs_type.unwrap(), Filesystem::Xfs);
417422
let other = InstallConfigurationToplevel {

lib/src/install/00-defaults.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/src/privtests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn test_install_filesystem(image: &str, blockdev: &Utf8Path) -> Result<()> {
153153
let mountpoint: &Utf8Path = mountpoint_dir.path().try_into().unwrap();
154154

155155
// And run the install
156-
cmd!(sh, "podman run --rm --privileged --pid=host --net=none --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc -v /usr/lib/bootc:/usr/lib/bootc -v {mountpoint}:/target-root {image} bootc install-to-filesystem /target-root").run()?;
156+
cmd!(sh, "podman run --rm --privileged --pid=host --net=none --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc -v {mountpoint}:/target-root {image} bootc install-to-filesystem /target-root").run()?;
157157

158158
cmd!(sh, "umount -R {mountpoint}").run()?;
159159

tests/kolainst/install

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
set -xeuo pipefail
1212

1313
# See https://github.com/cgwalters/bootc-base-images
14-
IMAGE=ghcr.io/cgwalters/fedora-oscore:latest
14+
IMAGE=registry.gitlab.com/centos/cloud/sagano/fedora-boot-tier-0:38
1515
# TODO: better detect this, e.g. look for an empty device
1616
DEV=/dev/vda
1717

@@ -20,7 +20,7 @@ cd $(mktemp -d)
2020

2121
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
2222
"")
23-
podman run --rm -ti --privileged --pid=host --net=none -v /usr/bin/bootc:/usr/bin/bootc -v /usr/lib/bootc:/usr/lib/bootc ${IMAGE} bootc install --karg=foo=bar ${DEV}
23+
podman run --rm -ti --privileged --pid=host --net=none -v /usr/bin/bootc:/usr/bin/bootc ${IMAGE} bootc install --karg=foo=bar ${DEV}
2424
# In theory we could e.g. wipe the bootloader setup on the primary disk, then reboot;
2525
# but for now let's just sanity test that the install command executes.
2626
lsblk ${DEV}

0 commit comments

Comments
 (0)