Skip to content

Commit 836cdd8

Browse files
committed
install: Fix install config kargs + to-filesystem
I think this got broken in a refactoring; add test coverage. In general all the heavy lifting should move out of `baseline.rs`; a good way to do that is probably to take the next step of making it its own crate that doesn't depend on the bootc core logic perhaps. Closes: #570 Signed-off-by: Colin Walters <[email protected]>
1 parent a15090b commit 836cdd8

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

hack/Containerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ RUN mkdir -p /build/target/dev-rootfs # This can hold arbitrary extra content
1717
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make test-bin-archive && mkdir -p /out && cp target/bootc.tar.zst /out
1818

1919
FROM $base
20+
# We support e.g. adding cloud-init
2021
ARG variant=
2122
COPY hack/provision-derived.sh /tmp
2223
RUN /tmp/provision-derived.sh "$variant" && rm -f /tmp/*.sh
24+
# Also copy in some default install configs we use for testing
25+
COPY hack/install-test-configs/* /usr/lib/bootc/install/
26+
# Inject our built code
2327
COPY --from=build /out/bootc.tar.zst /tmp
24-
COPY --from=build /build/target/dev-rootfs/ /
2528
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vf /tmp/*
29+
# Also copy over arbitrary bits from the target root
30+
COPY --from=build /build/target/dev-rootfs/ /
31+
# Test our own linting
2632
RUN bootc container lint

lib/src/install.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,18 @@ async fn initialize_ostree_root_from_self(
642642
imgref: src_imageref,
643643
};
644644

645+
let install_config_kargs = state
646+
.install_config
647+
.as_ref()
648+
.and_then(|c| c.kargs.as_ref())
649+
.into_iter()
650+
.flatten()
651+
.map(|s| s.as_str());
645652
let kargs = root_setup
646653
.kargs
647654
.iter()
648655
.map(|v| v.as_str())
656+
.chain(install_config_kargs)
649657
.chain(state.config_opts.karg.iter().flatten().map(|v| v.as_str()))
650658
.collect::<Vec<_>>();
651659
let mut options = ostree_container::deploy::DeployOpts::default();

lib/src/install/baseline.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,11 @@ pub(crate) fn install_create_rootfs(
401401
fstype: MountSpec::AUTO.into(),
402402
options: Some("ro".into()),
403403
});
404-
let install_config_kargs = state
405-
.install_config
406-
.as_ref()
407-
.and_then(|c| c.kargs.as_ref())
408-
.into_iter()
409-
.flatten()
410-
.map(ToOwned::to_owned);
411404
let kargs = root_blockdev_kargs
412405
.into_iter()
413406
.flatten()
414407
.chain([rootarg, RW_KARG.to_string()].into_iter())
415408
.chain(bootarg)
416-
.chain(install_config_kargs)
417409
.collect::<Vec<_>>();
418410

419411
mount::mount(&rootdev, &rootfs)?;

tests-integration/src/install.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,18 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
8888
std::fs::write(&tmp_keys, b"ssh-ed25519 ABC0123 [email protected]")?;
8989
cmd!(sh, "sudo {BASE_ARGS...} {target_args...} -v {tmp_keys}:/test_authorized_keys {image} bootc install to-filesystem {generic_inst_args...} --acknowledge-destructive --karg=foo=bar --replace=alongside --root-ssh-authorized-keys=/test_authorized_keys /target").run()?;
9090

91+
// Test kargs injected via CLI
9192
cmd!(
9293
sh,
9394
"sudo /bin/sh -c 'grep foo=bar /boot/loader/entries/*.conf'"
9495
)
9596
.run()?;
97+
// And kargs we added into our default container image
98+
cmd!(
99+
sh,
100+
"sudo /bin/sh -c 'grep localtestkarg=somevalue /boot/loader/entries/*.conf'"
101+
)
102+
.run()?;
96103
let deployment = &find_deployment_root()?;
97104
let cwd = sh.push_dir(format!("/proc/self/fd/{}", deployment.as_raw_fd()));
98105
cmd!(

0 commit comments

Comments
 (0)