diff --git a/Cargo.lock b/Cargo.lock index 4582f2a26..f25b71eaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,6 +185,13 @@ dependencies = [ "tracing", ] +[[package]] +name = "bootc-initramfs-setup" +version = "0.1.0" +dependencies = [ + "anyhow", +] + [[package]] name = "bootc-internal-blockdev" version = "0.0.0" diff --git a/Dockerfile b/Dockerfile index 3515f73e3..09d3dec67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,6 +39,8 @@ EORUN # bootc binaries in /out. The intention is that the target rootfs is extracted from /out # back into a final stae (without the build deps etc) below. FROM base as build +# Flip this on to enable initramfs code +ARG initramfs=0 # This installs our package dependencies, and we want to cache it independently of the rest. # Basically we don't want changing a .rs file to blow out the cache of packages. So we only # copy files necessary @@ -59,8 +61,14 @@ COPY --from=src /src /src WORKDIR /src # See https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/ # We aren't using the full recommendations there, just the simple bits. -RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome \ - make && make install-all DESTDIR=/out +RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome < Result<()> { + let _ = std::fs::metadata("/sysroot/usr")?; + println!("setup OK"); + Ok(()) +} + +fn main() -> Result<()> { + let v = std::env::args().collect::>(); + let args = match v.as_slice() { + [] => anyhow::bail!("Missing argument".to_string()), + [_, rest @ ..] => rest, + }; + match args { + [] => anyhow::bail!("Missing argument".to_string()), + [s] if s == "setup-root" => setup_root(), + [o, ..] => anyhow::bail!(format!("Unknown command {o}")), + } +} diff --git a/tmt/tests/booted/readonly/051-test-initramfs.nu b/tmt/tests/booted/readonly/051-test-initramfs.nu new file mode 100644 index 000000000..150054eee --- /dev/null +++ b/tmt/tests/booted/readonly/051-test-initramfs.nu @@ -0,0 +1,13 @@ +use std assert +use tap.nu + +tap begin "initramfs" + +if (not ("/usr/lib/bootc/initramfs-setup" | path exists)) { + print "No initramfs support" + exit 0 +} + +journalctl -b -t bootc-root-setup.service --grep=OK + +tap ok