1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 06:45:13 +01:00

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: https://github.com/containers/bootc/issues/570
Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Colin Walters
2024-06-16 12:10:00 +00:00
parent a15090bbd0
commit 836cdd81bc
5 changed files with 22 additions and 9 deletions

View File

@@ -17,10 +17,16 @@ RUN mkdir -p /build/target/dev-rootfs # This can hold arbitrary extra content
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
FROM $base
# We support e.g. adding cloud-init
ARG variant=
COPY hack/provision-derived.sh /tmp
RUN /tmp/provision-derived.sh "$variant" && rm -f /tmp/*.sh
# Also copy in some default install configs we use for testing
COPY hack/install-test-configs/* /usr/lib/bootc/install/
# Inject our built code
COPY --from=build /out/bootc.tar.zst /tmp
COPY --from=build /build/target/dev-rootfs/ /
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vf /tmp/*
# Also copy over arbitrary bits from the target root
COPY --from=build /build/target/dev-rootfs/ /
# Test our own linting
RUN bootc container lint

View File

@@ -642,10 +642,18 @@ async fn initialize_ostree_root_from_self(
imgref: src_imageref,
};
let install_config_kargs = state
.install_config
.as_ref()
.and_then(|c| c.kargs.as_ref())
.into_iter()
.flatten()
.map(|s| s.as_str());
let kargs = root_setup
.kargs
.iter()
.map(|v| v.as_str())
.chain(install_config_kargs)
.chain(state.config_opts.karg.iter().flatten().map(|v| v.as_str()))
.collect::<Vec<_>>();
let mut options = ostree_container::deploy::DeployOpts::default();

View File

@@ -401,19 +401,11 @@ pub(crate) fn install_create_rootfs(
fstype: MountSpec::AUTO.into(),
options: Some("ro".into()),
});
let install_config_kargs = state
.install_config
.as_ref()
.and_then(|c| c.kargs.as_ref())
.into_iter()
.flatten()
.map(ToOwned::to_owned);
let kargs = root_blockdev_kargs
.into_iter()
.flatten()
.chain([rootarg, RW_KARG.to_string()].into_iter())
.chain(bootarg)
.chain(install_config_kargs)
.collect::<Vec<_>>();
mount::mount(&rootdev, &rootfs)?;

View File

@@ -88,11 +88,18 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
std::fs::write(&tmp_keys, b"ssh-ed25519 ABC0123 testcase@example.com")?;
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()?;
// Test kargs injected via CLI
cmd!(
sh,
"sudo /bin/sh -c 'grep foo=bar /boot/loader/entries/*.conf'"
)
.run()?;
// And kargs we added into our default container image
cmd!(
sh,
"sudo /bin/sh -c 'grep localtestkarg=somevalue /boot/loader/entries/*.conf'"
)
.run()?;
let deployment = &find_deployment_root()?;
let cwd = sh.push_dir(format!("/proc/self/fd/{}", deployment.as_raw_fd()));
cmd!(