| 38 | } |
| 39 | |
| 40 | fn builder_from_image(sh: &Shell, cimage: &str) -> Result<String> { |
| 41 | let mut inspect: serde_json::Value = |
| 42 | serde_json::from_str(&cmd!(sh, "podman inspect --type image {cimage}").read()?)?; |
| 43 | let inspect = inspect |
| 44 | .as_array_mut() |
| 45 | .and_then(|v| v.pop()) |
| 46 | .ok_or_else(|| anyhow::anyhow!("Failed to parse inspect output"))?; |
| 47 | let config = inspect |
| 48 | .get("Config") |
| 49 | .ok_or_else(|| anyhow::anyhow!("Missing config"))?; |
| 50 | let config: oci_spec::image::Config = |
| 51 | serde_json::from_value(config.clone()).context("Parsing config")?; |
| 52 | let builder = config |
| 53 | .labels() |
| 54 | .as_ref() |
| 55 | .and_then(|l| l.get(BUILDER_ANNOTATION)) |
| 56 | .ok_or_else(|| anyhow::anyhow!("Missing {BUILDER_ANNOTATION}"))?; |
| 57 | Ok(builder.to_owned()) |
| 58 | } |
| 59 | |
| 60 | #[context("Running bootc-image-builder")] |
| 61 | fn run_bib(sh: &Shell, cimage: &str, tmpdir: &Utf8Path, diskpath: &Utf8Path) -> Result<()> { |