Skip to content

Commit e536c9f

Browse files
committed
install: Add print-configuration
Even when an external process is creating the disk, we want it to be able to honor the root filesystem type specified in the container. Signed-off-by: Colin Walters <[email protected]>
1 parent 1257878 commit e536c9f

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106
name: "Container testing"
107107
needs: build-fedora
108108
runs-on: ubuntu-latest
109-
container: quay.io/fedora/fedora-coreos:testing-devel
109+
container: quay.io/centos-bootc/fedora-bootc:eln
110110
steps:
111111
- name: Download
112112
uses: actions/download-artifact@v3

lib/src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ pub(crate) enum InstallOpts {
118118
ToDisk(crate::install::InstallToDiskOpts),
119119
/// Install to the target filesystem
120120
ToFilesystem(crate::install::InstallToFilesystemOpts),
121+
/// Output JSON to stdout that contains the merged installation configuration
122+
/// as it may be relevant to calling processes using `install to-filesystem`
123+
/// that want to honor e.g. `root-fs-type`.
124+
///
125+
/// At the current time, the only output key is `root-fs-type` which is a string-valued
126+
/// filesystem name suitable for passing to `mkfs.$type`.
127+
PrintConfiguration,
121128
}
122129

123130
/// Options for man page generation
@@ -522,6 +529,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
522529
Opt::Install(opts) => match opts {
523530
InstallOpts::ToDisk(opts) => crate::install::install_to_disk(opts).await,
524531
InstallOpts::ToFilesystem(opts) => crate::install::install_to_filesystem(opts).await,
532+
InstallOpts::PrintConfiguration => crate::install::print_configuration(),
525533
},
526534
#[cfg(feature = "install")]
527535
Opt::ExecInHostMountNamespace { args } => {

lib/src/install.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
// This sub-module is the "basic" installer that handles creating basic block device
88
// and filesystem setup.
9-
mod baseline;
9+
pub(crate) mod baseline;
1010

1111
use std::io::BufWriter;
1212
use std::io::Write;
@@ -429,6 +429,13 @@ impl SourceInfo {
429429
}
430430
}
431431

432+
pub(crate) fn print_configuration() -> Result<()> {
433+
let mut install_config = config::load_config()?;
434+
install_config.filter_to_external();
435+
let stdout = std::io::stdout().lock();
436+
serde_json::to_writer(stdout, &install_config).map_err(Into::into)
437+
}
438+
432439
pub(crate) mod config {
433440
use super::*;
434441

@@ -447,6 +454,7 @@ pub(crate) mod config {
447454
/// Root filesystem type
448455
pub(crate) root_fs_type: Option<super::baseline::Filesystem>,
449456
/// Kernel arguments, applied at installation time
457+
#[serde(skip_serializing_if = "Option::is_none")]
450458
pub(crate) kargs: Option<Vec<String>>,
451459
}
452460

@@ -465,6 +473,11 @@ pub(crate) mod config {
465473
.extend(other_kargs)
466474
}
467475
}
476+
477+
// Remove all configuration which is handled by `install to-filesystem`.
478+
pub(crate) fn filter_to_external(&mut self) {
479+
self.kargs.take();
480+
}
468481
}
469482

470483
#[context("Loading configuration")]

lib/src/privtests.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::process::Command;
22

3-
use anyhow::Result;
3+
use anyhow::{Context, Result};
44
use camino::Utf8Path;
55
use fn_error_context::context;
66
use rustix::fd::AsFd;
77
use xshell::{cmd, Shell};
88

99
use crate::blockdev::LoopbackDevice;
10+
use crate::install::config::InstallConfiguration;
1011

1112
use super::cli::TestingOpts;
1213
use super::spec::Host;
@@ -98,6 +99,14 @@ pub(crate) fn impl_run_container() -> Result<()> {
9899
let stderr = String::from_utf8(o.stderr)?;
99100
assert!(stderr.contains("requires root privileges"));
100101

102+
let config = cmd!(sh, "bootc install print-configuration").read()?;
103+
let config: InstallConfiguration =
104+
serde_json::from_str(&config).context("Parsing install config")?;
105+
assert_eq!(
106+
config.root_fs_type.unwrap(),
107+
crate::install::baseline::Filesystem::Xfs
108+
);
109+
101110
println!("ok container integration testing");
102111
Ok(())
103112
}

0 commit comments

Comments
 (0)