Skip to content

Commit

Permalink
Merge pull request #606 from cgwalters/debug-kargs
Browse files Browse the repository at this point in the history
install: Fix install config kargs + to-filesystem
  • Loading branch information
cgwalters authored Jun 16, 2024
2 parents 2138aa0 + 836cdd8 commit 2f6b7ec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
8 changes: 7 additions & 1 deletion hack/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
8 changes: 8 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 0 additions & 8 deletions lib/src/install/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
7 changes: 7 additions & 0 deletions tests-integration/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]")?;
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!(
Expand Down

0 comments on commit 2f6b7ec

Please sign in to comment.