Skip to content

Commit

Permalink
Merge pull request containers#154 from cgwalters/check-skopeo
Browse files Browse the repository at this point in the history
install: Query skopeo upfront
  • Loading branch information
cgwalters authored Oct 23, 2023
2 parents c5ecb15 + 8ec4295 commit b9b311f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::lsm::SetEnforceGuard>,
pub(crate) config_opts: InstallConfigOpts,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()?;
Expand All @@ -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,
Expand Down

0 comments on commit b9b311f

Please sign in to comment.