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

Method write_merge_commit_impl

crates/ostree-ext/src/container/store.rs:1207–1363  ·  view source on GitHub ↗

Generate a single ostree commit that combines all layers, and also includes container image metadata such as the manifest and config.

(
        repo: &ostree::Repo,
        base_commit: Option<&str>,
        layer_commits: &[LayerRef],
        have_derived_layers: bool,
        metadata: glib::Variant,
        timestamp: u64,
      

Source from the content-addressed store, hash-verified

1205 /// Generate a single ostree commit that combines all layers, and also
1206 /// includes container image metadata such as the manifest and config.
1207 fn write_merge_commit_impl(
1208 repo: &ostree::Repo,
1209 base_commit: Option<&str>,
1210 layer_commits: &[LayerRef],
1211 have_derived_layers: bool,
1212 metadata: glib::Variant,
1213 timestamp: u64,
1214 ostree_ref: &str,
1215 no_imgref: bool,
1216 disable_gc: bool,
1217 cancellable: Option<&gio::Cancellable>,
1218 ) -> Result<Box<LayeredImageState>> {
1219 use rustix::fd::AsRawFd;
1220
1221 let txn = repo.auto_transaction(cancellable)?;
1222
1223 let devino = ostree::RepoDevInoCache::new();
1224 let repodir = Dir::reopen_dir(&repo.dfd_borrow())?;
1225 let repo_tmp = repodir.open_dir("tmp")?;
1226 let td = cap_std_ext::cap_tempfile::TempDir::new_in(&repo_tmp)?;
1227
1228 let rootpath = "root";
1229 let checkout_mode = if repo.mode() == ostree::RepoMode::Bare {
1230 ostree::RepoCheckoutMode::None
1231 } else {
1232 ostree::RepoCheckoutMode::User
1233 };
1234 let mut checkout_opts = ostree::RepoCheckoutAtOptions {
1235 mode: checkout_mode,
1236 overwrite_mode: ostree::RepoCheckoutOverwriteMode::UnionFiles,
1237 devino_to_csum_cache: Some(devino.clone()),
1238 no_copy_fallback: true,
1239 force_copy_zerosized: true,
1240 process_whiteouts: false,
1241 ..Default::default()
1242 };
1243 if let Some(base) = base_commit.as_ref() {
1244 repo.checkout_at(
1245 Some(&checkout_opts),
1246 (*td).as_raw_fd(),
1247 rootpath,
1248 &base,
1249 cancellable,
1250 )
1251 .context("Checking out base commit")?;
1252 }
1253
1254 // Layer all subsequent commits
1255 checkout_opts.process_whiteouts = true;
1256 for lc in layer_commits {
1257 let commit = &lc.commit;
1258 tracing::debug!("Unpacking {commit}");
1259 repo.checkout_at(
1260 Some(&checkout_opts),
1261 (*td).as_raw_fd(),
1262 rootpath,
1263 commit,
1264 cancellable,

Callers

nothing calls this directly

Calls 5

cleanup_rootFunction · 0.85
gc_image_layers_implFunction · 0.85
query_image_commitFunction · 0.85
as_refMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected