From 8ec429509a3f6dd66184cb5f8612c4268ddd9716 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 22 Oct 2023 13:54:27 -0400 Subject: [PATCH] install: Query skopeo upfront If we don't have skopeo on the host (and it turns out the default Fedora Workstation install has podman but not skopeo) then we only error out halfway through an install. Do this upfront to make the error clearer. Signed-off-by: Colin Walters --- lib/src/install.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/install.rs b/lib/src/install.rs index 9b2044f57..32b632a89 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -203,6 +203,8 @@ pub(crate) struct State { pub(crate) source: SourceInfo, /// Force SELinux off in target system pub(crate) override_disable_selinux: bool, + /// True if the skoepo on host supports containers-storage: + pub(crate) skopeo_supports_containers_storage: bool, #[allow(dead_code)] pub(crate) setenforce_guard: Option, pub(crate) config_opts: InstallConfigOpts, @@ -501,7 +503,7 @@ async fn initialize_ostree_root_from_self( }; let mut temporary_dir = None; - let src_imageref = if skopeo_supports_containers_storage()? { + let src_imageref = if state.skopeo_supports_containers_storage { // We always use exactly the digest of the running image to ensure predictability. let spec = crate::utils::digested_pullspec(&state.source.imageref.name, &state.source.digest); @@ -792,6 +794,9 @@ async fn prepare_install( anyhow::bail!("Cannot install from rootless podman; this command must be run as root"); } + let skopeo_supports_containers_storage = skopeo_supports_containers_storage() + .context("Failed to run skopeo (it currently must be installed in the host root)")?; + let source = SourceInfo::from_container(&container_info)?; ensure_var()?; @@ -815,6 +820,7 @@ async fn prepare_install( // combines our command line options along with some bind mounts from the host. let state = Arc::new(State { override_disable_selinux, + skopeo_supports_containers_storage, setenforce_guard, source, config_opts,