Write a layered container image into an OSTree commit.
(
repo: &ostree::Repo,
imgref: &OstreeImageReference,
ostree_digestfile: Option<Utf8PathBuf>,
proxyopts: ContainerProxyOpts,
quiet: bool,
check: Option<Utf8PathBuf>,
)
| 864 | |
| 865 | /// Write a layered container image into an OSTree commit. |
| 866 | async fn container_store( |
| 867 | repo: &ostree::Repo, |
| 868 | imgref: &OstreeImageReference, |
| 869 | ostree_digestfile: Option<Utf8PathBuf>, |
| 870 | proxyopts: ContainerProxyOpts, |
| 871 | quiet: bool, |
| 872 | check: Option<Utf8PathBuf>, |
| 873 | ) -> Result<()> { |
| 874 | let mut imp = ImageImporter::new(repo, imgref, proxyopts.into()).await?; |
| 875 | let prep = match imp.prepare().await? { |
| 876 | PrepareResult::AlreadyPresent(c) => { |
| 877 | write_digest_file(ostree_digestfile, &c.merge_commit)?; |
| 878 | println!("No changes in {} => {}", imgref, c.merge_commit); |
| 879 | return Ok(()); |
| 880 | } |
| 881 | PrepareResult::Ready(r) => r, |
| 882 | }; |
| 883 | if let Some(warning) = prep.deprecated_warning() { |
| 884 | print_deprecated_warning(warning).await; |
| 885 | } |
| 886 | if let Some(check) = check.as_deref() { |
| 887 | let rootfs = Dir::open_ambient_dir("/", cap_std::ambient_authority())?; |
| 888 | rootfs.atomic_replace_with(check.as_str().trim_start_matches('/'), |w| { |
| 889 | prep.manifest |
| 890 | .to_canon_json_writer(w) |
| 891 | .context("Serializing manifest") |
| 892 | })?; |
| 893 | // In check mode, we're done |
| 894 | return Ok(()); |
| 895 | } |
| 896 | if let Some(previous_state) = prep.previous_state.as_ref() { |
| 897 | let diff = ManifestDiff::new(&previous_state.manifest, &prep.manifest); |
| 898 | diff.print(); |
| 899 | } |
| 900 | print_layer_status(&prep); |
| 901 | let printer = (!quiet).then(|| { |
| 902 | let layer_progress = imp.request_progress(); |
| 903 | let layer_byte_progress = imp.request_layer_progress(); |
| 904 | tokio::task::spawn(async move { |
| 905 | handle_layer_progress_print(layer_progress, layer_byte_progress).await |
| 906 | }) |
| 907 | }); |
| 908 | let import = imp.import(prep).await; |
| 909 | if let Some(printer) = printer { |
| 910 | let _ = printer.await; |
| 911 | } |
| 912 | let import = import?; |
| 913 | if let Some(msg) = |
| 914 | ostree_container::store::image_filtered_content_warning(&import.filtered_files)? |
| 915 | { |
| 916 | eprintln!("{msg}") |
| 917 | } |
| 918 | if let Some(ref text) = import.verify_text { |
| 919 | println!("{text}"); |
| 920 | } |
| 921 | write_digest_file(ostree_digestfile, &import.merge_commit)?; |
| 922 | println!("Wrote: {} => {}", imgref, import.merge_commit); |
| 923 | Ok(()) |
no test coverage detected