Skip to content

Commit 85c55ef

Browse files
committed
container: Advertise install features in container inspect
Tools that prepare a target for `install to-filesystem`, such as disk image builders, need to know whether the bootc in an image initializes mounted /var filesystems before they mount them: older versions leave such filesystems empty, so they hide the image's /var content at boot, and versions before 1.12 reject mountpoints in the target entirely. Add an `install-features` list to `bootc container inspect` output, currently containing `initialize-var-mounts`. It describes the bootc binary rather than the image, but this is the command builders already run against the image. The human-readable output is unchanged. Generated-by: AI
1 parent 6352d8e commit 85c55ef

6 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎crates/lib/src/install.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ const ALONGSIDE_ROOT_MOUNT: &str = "/target";
225225
pub(crate) const DESTRUCTIVE_CLEANUP: &str = "etc/bootc-destructive-cleanup";
226226
/// This is an ext4 special directory we need to ignore.
227227
const LOST_AND_FOUND: &str = "lost+found";
228+
/// Optional `bootc install` behaviors, advertised by `bootc container inspect`.
229+
pub(crate) const INSTALL_FEATURES: &[&str] = &[var_mounts::FEATURE];
228230
/// The mount path for selinux
229231
const SELINUXFS: &str = "/sys/fs/selinux";
230232
/// The mount path for uefi

‎crates/lib/src/install/var_mounts.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ use rustix::fs::{Mode, OFlags};
1111

1212
use super::LOST_AND_FOUND;
1313

14+
/// Advertised by `bootc container inspect`, so that tools preparing a target
15+
/// for `install to-filesystem` know that mounting /var filesystems is useful.
16+
/// Older versions leave such filesystems empty, or reject them entirely.
17+
pub(super) const FEATURE: &str = "initialize-var-mounts";
18+
1419
const VAR: &str = "var";
1520

1621
/// The path of a mount (relative to /var) from the installation root.

‎crates/lib/src/spec.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ pub(crate) struct ContainerInspect {
473473
pub(crate) kargs: Vec<String>,
474474
/// Information about the kernel in the container image.
475475
pub(crate) kernel: Option<crate::kernel::Kernel>,
476+
/// Optional `bootc install` behaviors implemented by this bootc binary,
477+
/// for tools that prepare a target for `install to-filesystem`.
478+
pub(crate) install_features: Vec<&'static str>,
476479
}
477480

478481
impl Host {

‎crates/lib/src/status.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,11 @@ pub(crate) fn container_inspect(
990990
let kargs = crate::bootc_kargs::get_kargs_in_root(&root, std::env::consts::ARCH)?;
991991
let kargs: Vec<String> = kargs.iter_str().map(|s| s.to_owned()).collect();
992992
let kernel = crate::kernel::find_kernel(&root)?.map(Into::into);
993-
let inspect = crate::spec::ContainerInspect { kargs, kernel };
993+
let inspect = crate::spec::ContainerInspect {
994+
kargs,
995+
kernel,
996+
install_features: crate::install::INSTALL_FEATURES.to_vec(),
997+
};
994998

995999
// Determine output format: explicit --format wins, then --json, then default to human-readable
9961000
let format = format.unwrap_or(if json {
@@ -1295,6 +1299,7 @@ mod tests {
12951299
version: "6.12.0-100.fc41.x86_64".into(),
12961300
unified: false,
12971301
}),
1302+
install_features: vec![],
12981303
};
12991304
let mut w = Vec::new();
13001305
container_inspect_print_human(&inspect, &mut w).unwrap();
@@ -1315,6 +1320,7 @@ mod tests {
13151320
version: "6.12.0-100.fc41.x86_64".into(),
13161321
unified: true,
13171322
}),
1323+
install_features: vec![],
13181324
};
13191325
let mut w = Vec::new();
13201326
container_inspect_print_human(&inspect, &mut w).unwrap();
@@ -1332,6 +1338,7 @@ mod tests {
13321338
let inspect = crate::spec::ContainerInspect {
13331339
kargs: vec!["console=ttyS0".into()],
13341340
kernel: None,
1341+
install_features: vec![],
13351342
};
13361343
let mut w = Vec::new();
13371344
container_inspect_print_human(&inspect, &mut w).unwrap();

‎crates/tests-integration/src/container.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ pub(crate) fn test_bootc_container_inspect() -> Result<()> {
3434
assert!(kargs.iter().any(|arg| arg == "kargsd-othertest=2"));
3535
assert!(kargs.iter().any(|arg| arg == "testing-kargsd=3"));
3636

37+
// check advertised install features
38+
let features = inspect.get("install-features").unwrap().as_array().unwrap();
39+
assert!(features.iter().any(|f| f == "initialize-var-mounts"));
40+
3741
// check kernel field
3842
let kernel = inspect
3943
.get("kernel")

‎docs/src/man/bootc-container-inspect.8.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ The command outputs a JSON object with the following fields:
1818
- `kernel`: An object containing kernel information (or `null` if no kernel is found):
1919
- `version`: The kernel version identifier. For vmlinuz kernels, this is derived from the `/usr/lib/modules/<version>` directory name (equivalent to `uname -r`). For UKI images, this is the UKI filename without the `.efi` extension - which should usually be the same as the uname.
2020
- `unified`: A boolean indicating whether the kernel is packaged as a UKI (Unified Kernel Image).
21+
- `install-features`: An array of optional `bootc install` behaviors implemented by this bootc binary,
22+
for tools that prepare a target for `bootc install to-filesystem`:
23+
- `initialize-var-mounts`: Empty filesystems mounted at `/var` or below in the target are initialized
24+
from the image's `/var` content. See **bootc-install-to-filesystem**(8).
2125

2226
# OPTIONS
2327

@@ -60,7 +64,10 @@ Example output (vmlinuz kernel):
6064
"kernel": {
6165
"version": "6.12.0-0.rc6.51.fc42.x86_64",
6266
"unified": false
63-
}
67+
},
68+
"install-features": [
69+
"initialize-var-mounts"
70+
]
6471
}
6572
```
6673

@@ -72,7 +79,10 @@ Example output (UKI):
7279
"kernel": {
7380
"version": "7e11ac46e3e022053e7226a20104ac656bf72d1a",
7481
"unified": true
75-
}
82+
},
83+
"install-features": [
84+
"initialize-var-mounts"
85+
]
7686
}
7787
```
7888

0 commit comments

Comments
 (0)