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

install: Drop default config #152

Merged
merged 1 commit into from
Oct 23, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ all-test:

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

bin-archive: all
Expand Down
21 changes: 19 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ other options.
Here's an example:

```
$ 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
$ podman run --privileged --pid=host --net=none --security-opt label=type:unconfined_t <image> bootc install --target-no-signature-verification /path/to/disk
```

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

### Operating system install configuration required

The container image must define its default install configuration. For example,
create `/usr/lib/bootc/install/00-exampleos.toml` with the contents:

```
[install]
root-fs-type = "xfs"
```

At the current time, `root-fs-type` is the only available configuration option, and it must be set.

Configuration files found in this directory will be merged, with higher alphanumeric values
taking precedence. If for example you are building a derived container image from the above OS,
you coudl create a `50-myos.toml` that sets `root-fs-type = "btrfs"` which will override the
prior setting.

### Note: Today `bootc install` has a host requirement on `skopeo`

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

```
FROM ghcr.io/cgwalters/c9s-oscore
FROM <image>
RUN mkdir -p /usr/etc-system/ && \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo 'ssh-ed25519 AAAAC3Nza... root@example.com' > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/keys && \
Expand Down
11 changes: 8 additions & 3 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,20 @@ pub(crate) mod config {
config = c.install;
}
}
config.ok_or_else(|| anyhow::anyhow!("Failed to find any installation config files"))
config.ok_or_else(|| anyhow::anyhow!("No bootc/install config found; this operating system must define a default configuration to be installable"))
}

#[test]
/// Verify that we can parse our default config file
fn test_parse_config() {
use super::baseline::Filesystem;
let buf = include_str!("install/00-defaults.toml");
let c: InstallConfigurationToplevel = toml::from_str(buf).unwrap();

let c: InstallConfigurationToplevel = toml::from_str(
r##"[install]
root-fs-type = "xfs"
"##,
)
.unwrap();
let mut install = c.install.unwrap();
assert_eq!(install.root_fs_type.unwrap(), Filesystem::Xfs);
let other = InstallConfigurationToplevel {
Expand Down
3 changes: 0 additions & 3 deletions lib/src/install/00-defaults.toml

This file was deleted.

2 changes: 1 addition & 1 deletion lib/src/privtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn test_install_filesystem(image: &str, blockdev: &Utf8Path) -> Result<()> {
let mountpoint: &Utf8Path = mountpoint_dir.path().try_into().unwrap();

// And run the install
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()?;
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()?;

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

Expand Down
4 changes: 2 additions & 2 deletions tests/kolainst/install
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
set -xeuo pipefail

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

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

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
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}
podman run --rm -ti --privileged --pid=host --net=none -v /usr/bin/bootc:/usr/bin/bootc ${IMAGE} bootc install --karg=foo=bar ${DEV}
# In theory we could e.g. wipe the bootloader setup on the primary disk, then reboot;
# but for now let's just sanity test that the install command executes.
lsblk ${DEV}
Expand Down
Loading