MCPcopy Create free account
hub / github.com/bootc-dev/bootc / deploy

Function deploy

crates/lib/src/deploy.rs:899–965  ·  view source on GitHub ↗
(
    sysroot: &Storage,
    from: MergeState,
    image: &ImageState,
    origin: &glib::KeyFile,
    lock_finalization: bool,
)

Source from the content-addressed store, hash-verified

897
898#[context("Writing deployment")]
899async fn deploy(
900 sysroot: &Storage,
901 from: MergeState,
902 image: &ImageState,
903 origin: &glib::KeyFile,
904 lock_finalization: bool,
905) -> Result<Deployment> {
906 // Compute the kernel argument overrides. In practice today this API is always expecting
907 // a merge deployment. The kargs code also always looks at the booted root (which
908 // is a distinct minor issue, but not super important as right now the install path
909 // doesn't use this API).
910 let (stateroot, override_kargs) = match &from {
911 MergeState::MergeDeployment(deployment) => {
912 let kargs = crate::bootc_kargs::get_kargs(sysroot, &deployment, image)?;
913 (deployment.stateroot().into(), Some(kargs))
914 }
915 MergeState::Reset { stateroot, kargs } => (stateroot.clone(), Some(kargs.clone())),
916 };
917 // Clone all the things to move to worker thread
918 let ostree = sysroot.get_ostree_cloned()?;
919 // ostree::Deployment is incorrectly !Send 😢 so convert it to an integer
920 let merge_deployment = from.as_merge_deployment();
921 let merge_deployment = merge_deployment.map(|d| d.index() as usize);
922 let ostree_commit = image.ostree_commit.to_string();
923 // GKeyFile also isn't Send! So we serialize that as a string...
924 let origin_data = origin.to_data();
925 let r = async_task_with_spinner(
926 "Deploying",
927 spawn_blocking_cancellable_flatten(move |cancellable| -> Result<_> {
928 let ostree = ostree;
929 let stateroot = Some(stateroot);
930 let mut opts = ostree::SysrootDeployTreeOpts::default();
931
932 // Set finalization lock if requested
933 opts.locked = lock_finalization;
934
935 // Because the C API expects a Vec<&str>, convert the Cmdline to string slices.
936 // The references borrow from the Cmdline, which outlives this usage.
937 let override_kargs_refs = override_kargs
938 .as_ref()
939 .map(|kargs| kargs.iter_str().collect::<Vec<_>>());
940 if let Some(kargs) = override_kargs_refs.as_ref() {
941 opts.override_kernel_argv = Some(kargs);
942 }
943
944 let deployments = ostree.deployments();
945 let merge_deployment = merge_deployment.map(|m| &deployments[m]);
946 let origin = glib::KeyFile::new();
947 origin.load_from_data(&origin_data, glib::KeyFileFlags::NONE)?;
948 let d = ostree.stage_tree_with_options(
949 stateroot.as_deref(),
950 &ostree_commit,
951 Some(&origin),
952 merge_deployment,
953 &opts,
954 Some(cancellable),
955 )?;
956 Ok(d.index())

Callers 2

install_containerFunction · 0.70
stageFunction · 0.70

Calls 11

get_kargsFunction · 0.85
get_ostree_clonedMethod · 0.80
as_merge_deploymentMethod · 0.80
iter_strMethod · 0.80
deploymentsMethod · 0.80
get_ostreeMethod · 0.80
async_task_with_spinnerFunction · 0.70
intoMethod · 0.45
staterootMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected