Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 170 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ inherits = "release"
lto = "yes"

[workspace.dependencies]
anstream = "0.6"
anstream = "1.0"
anyhow = "1.0.82"
camino = "1.1.6"
canon-json = "0.2.1"
cap-std-ext = "4.0.3"
cap-std-ext = "5.0.0"
cfg-if = "1.0"
chrono = { version = "0.4.38", default-features = false }
clap = "4.5.4"
Expand Down Expand Up @@ -72,7 +72,7 @@ tempfile = "3.10.1"
thiserror = "2.0.11"
tokio = ">= 1.37.0"
tokio-util = { features = ["io-util"], version = "0.7.10" }
toml = "0.9.5"
toml = "1.0.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-journald = "0.3.1"
Expand Down
4 changes: 3 additions & 1 deletion crates/lib/src/bootc_composefs/export.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::os::fd::AsFd;
use std::{fs::File, os::fd::AsRawFd};

use anyhow::{Context, Result};
use cap_std_ext::cap_std::{ambient_authority, fs::Dir};
use composefs::splitstream::SplitStreamData;
use composefs_oci::open_config;
use ocidir::cap_std::fs::Dir as OciCapDir;
use ocidir::{OciDir, oci_spec::image::Platform};
use ostree_ext::container::Transport;
use ostree_ext::container::skopeo;
Expand Down Expand Up @@ -57,7 +59,7 @@ pub async fn export_repo_to_image(
Dir::open_ambient_dir("/var/tmp", ambient_authority()).context("Opening /var/tmp")?;

let tmpdir = cap_std_ext::cap_tempfile::tempdir_in(&var_tmp)?;
let oci_dir = OciDir::ensure(tmpdir.try_clone()?).context("Opening OCI")?;
let oci_dir = OciDir::ensure(OciCapDir::reopen_dir(&tmpdir.as_fd())?).context("Opening OCI")?;

// Use composefs_oci::open_config to get the config and layer map
let (config, layer_map) =
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/bootc_composefs/update.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use cap_std_ext::cap_std::ambient_authority;
use cap_std_ext::{cap_std::fs::Dir, dirext::CapStdExtDirExt};
use composefs::fsverity::{FsVerityHashValue, Sha512HashValue};
use composefs_boot::BootOps;
use composefs_oci::image::create_filesystem;
use fn_error_context::context;
use ocidir::cap_std::ambient_authority;
use ostree_ext::container::ManifestDiff;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ostree-ext/src/container/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ pub async fn deploy(
#[cfg(feature = "bootc")]
if !options.skip_completion {
use bootc_utils::CommandRunExt;
use cap_std_ext::cap_std::fs::Dir;
use cap_std_ext::cmdext::CapStdExtCommandExt;
use ocidir::cap_std::fs::Dir;

let sysroot_dir = &Dir::reopen_dir(&crate::sysroot::sysroot_fd(sysroot))?;

Expand Down
8 changes: 5 additions & 3 deletions crates/ostree-ext/src/container/encapsulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ use crate::objectsource::ContentID;
use crate::tar as ostree_tar;
use anyhow::{Context, Result, anyhow};
use camino::{Utf8Path, Utf8PathBuf};
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::Dir;
use chrono::DateTime;
use containers_image_proxy::oci_spec;
use flate2::Compression;
use fn_error_context::context;
use gio::glib;
use oci_spec::image as oci_image;
use ocidir::cap_std::fs::Dir as OciCapDir;
use ocidir::{Layer, OciDir};
use ostree::gio;
use std::borrow::Cow;
use std::collections::{BTreeMap, HashMap};
use std::num::NonZeroU32;
use std::os::fd::AsFd;
use tracing::instrument;

/// The label which may be used in addition to the standard OCI label.
Expand Down Expand Up @@ -355,7 +357,7 @@ async fn build_impl(
if !Utf8Path::new(path).exists() {
std::fs::create_dir(path).with_context(|| format!("Creating {path}"))?;
}
let ocidir = Dir::open_ambient_dir(path, cap_std::ambient_authority())
let ocidir = OciCapDir::open_ambient_dir(path, ocidir::cap_std::ambient_authority())
.with_context(|| format!("Opening {path}"))?;
let mut ocidir = OciDir::ensure(ocidir).context("Opening OCI")?;
build_oci(repo, ostree_ref, &mut ocidir, tag, config, opts)?;
Expand All @@ -365,7 +367,7 @@ async fn build_impl(
let vartmp = Dir::open_ambient_dir("/var/tmp", cap_std::ambient_authority())?;
cap_std_ext::cap_tempfile::tempdir_in(&vartmp)?
};
let mut ocidir = OciDir::ensure(tempdir.try_clone()?)?;
let mut ocidir = OciDir::ensure(OciCapDir::reopen_dir(&tempdir.as_fd())?)?;

// Minor TODO: refactor to avoid clone
let authfile = opts.authfile.clone();
Expand Down
4 changes: 3 additions & 1 deletion crates/ostree-ext/src/container/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ use camino::{Utf8Path, Utf8PathBuf};
use canon_json::CanonJsonSerialize;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::{Dir, MetadataExt};
use ocidir::cap_std::fs::Dir as OciCapDir;
use std::os::fd::AsFd;

use cap_std_ext::dirext::CapStdExtDirExt;
use containers_image_proxy::{ImageProxy, OpenedImage};
Expand Down Expand Up @@ -1652,7 +1654,7 @@ pub(crate) fn export_to_oci(

let mut labels = HashMap::new();

let mut dest_oci = ocidir::OciDir::ensure(dest_oci.try_clone()?)?;
let mut dest_oci = ocidir::OciDir::ensure(OciCapDir::reopen_dir(&dest_oci.as_fd())?)?;

let commit_chunk_ref = commit_layer
.as_ref()
Expand Down
5 changes: 2 additions & 3 deletions crates/ostree-ext/src/container/update_detachedmeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::container::{DIFFID_LABEL, skopeo};
use crate::container::{Transport, store as container_store};
use anyhow::{Context, Result, anyhow};
use camino::Utf8Path;
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use containers_image_proxy::oci_spec::image as oci_image;
use ocidir::cap_std::fs::Dir;
use std::io::{BufReader, BufWriter};

/// Given an OSTree container image reference, update the detached metadata (e.g. GPG signature)
Expand Down Expand Up @@ -39,7 +38,7 @@ pub async fn update_detached_metadata(
// Fork a thread to do the heavy lifting of filtering the tar stream, rewriting the manifest/config.
crate::tokio_util::spawn_blocking_cancellable_flatten(move |cancellable| {
// Open the temporary OCI directory.
let tempsrc = Dir::open_ambient_dir(tempsrc_ref_path, cap_std::ambient_authority())
let tempsrc = Dir::open_ambient_dir(tempsrc_ref_path, ocidir::cap_std::ambient_authority())
.context("Opening src")?;
let tempsrc = ocidir::OciDir::open(tempsrc)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/ostree-ext/src/container_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Read;
use std::path::Path;

use anyhow::Result;
use ocidir::cap_std::fs::Dir;
use cap_std_ext::cap_std::fs::Dir;
use ostree::glib;

use crate::keyfileext::KeyFileExt;
Expand Down
5 changes: 3 additions & 2 deletions crates/ostree-ext/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ use bootc_utils::CommandRunExt;
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::{DirBuilder, DirBuilderExt as _};
use cap_std_ext::prelude::CapStdExtCommandExt;
use chrono::TimeZone;
use containers_image_proxy::oci_spec::image as oci_image;
use fn_error_context::context;
use gvariant::aligned_bytes::TryAsAligned;
use gvariant::{Marker, Structure};
use io_lifetimes::AsFd;
use ocidir::cap_std::fs::{DirBuilder, DirBuilderExt as _};
use ocidir::cap_std::fs::Dir as OciCapDir;
use ocidir::oci_spec::image::ImageConfigurationBuilder;
use regex::Regex;
use std::borrow::Cow;
Expand Down Expand Up @@ -977,7 +978,7 @@ impl NonOstreeFixture {
// Create the src/ directory
dir.create_dir_all(Self::SRCOCI)?;
let src_oci = dir.open_dir(Self::SRCOCI)?;
let src_oci = ocidir::OciDir::ensure(src_oci)?;
let src_oci = ocidir::OciDir::ensure(OciCapDir::reopen_dir(&src_oci.as_fd())?)?;

dir.create_dir("dest")?;
let destrepo = ostree::Repo::create_at_dir(
Expand Down
5 changes: 2 additions & 3 deletions crates/ostree-ext/src/integrationtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use std::path::Path;
use crate::container_utils::{is_ostree_container, ostree_booted};
use anyhow::{Context, Result, anyhow};
use camino::Utf8Path;
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use containers_image_proxy::oci_spec;
use flate2::write::GzEncoder;
use fn_error_context::context;
use gio::prelude::*;
use oci_spec::image as oci_image;
use ocidir::cap_std::fs::Dir;
use ocidir::{
LayerWriter,
oci_spec::image::{Arch, Platform},
Expand Down Expand Up @@ -67,7 +66,7 @@ where
F: for<'a> FnOnce(&mut LayerWriter<'a, GzEncoder<ocidir::BlobWriter<'a>>>) -> Result<()>,
{
let src = src.as_ref();
let src = Dir::open_ambient_dir(src, cap_std::ambient_authority())?;
let src = Dir::open_ambient_dir(src, ocidir::cap_std::ambient_authority())?;
let src = ocidir::OciDir::open(src)?;

let idx = src.read_index()?;
Expand Down
2 changes: 1 addition & 1 deletion crates/ostree-ext/src/ostree_prepareroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::str::FromStr;

use anyhow::{Context, Result};
use camino::Utf8Path;
use cap_std_ext::cap_std::fs::Dir;
use cap_std_ext::dirext::CapStdExtDirExt;
use fn_error_context::context;
use ocidir::cap_std::fs::Dir;
use ostree::glib::object::Cast;
use ostree::prelude::FileExt;
use ostree::{gio, glib};
Expand Down
2 changes: 1 addition & 1 deletion crates/ostree-ext/src/sysroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::{ops::Deref, os::fd::BorrowedFd, time::SystemTime};

use anyhow::Result;
use cap_std_ext::cap_std::fs_utf8::Dir;
use chrono::Datelike as _;
use ocidir::cap_std::fs_utf8::Dir;
use ostree::gio;

/// We may automatically allocate stateroots, this string is the prefix.
Expand Down
16 changes: 12 additions & 4 deletions crates/ostree-ext/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use gvariant::aligned_bytes::TryAsAligned;
use gvariant::{Marker, Structure};
use oci_image::ImageManifest;
use oci_spec::image as oci_image;
use ocidir::cap_std::fs::Dir as OciCapDir;
use ocidir::oci_spec::distribution::Reference;
use ocidir::oci_spec::image::{Arch, DigestAlgorithm};
use ostree_ext::chunking::ObjectMetaSized;
Expand All @@ -23,6 +24,7 @@ use ostree_ext::{gio, glib};
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::io::{BufReader, BufWriter};
use std::os::fd::AsFd;
use std::process::{Command, Stdio};
use std::sync::{LazyLock, OnceLock};
use std::time::SystemTime;
Expand Down Expand Up @@ -686,7 +688,9 @@ async fn test_export_as_container_nonderived() -> Result<()> {
name: format!("{}:exported-test", fixture.path.join(exported_ocidir_name)),
};
fixture.dir.create_dir(exported_ocidir_name)?;
let ocidir = ocidir::OciDir::ensure(fixture.dir.open_dir(exported_ocidir_name)?)?;
let ocidir = ocidir::OciDir::ensure(OciCapDir::reopen_dir(
&fixture.dir.open_dir(exported_ocidir_name)?.as_fd(),
)?)?;
let exported = store::export(fixture.destrepo(), &src_imgref, &dest, None)
.await
.unwrap();
Expand Down Expand Up @@ -790,7 +794,9 @@ async fn test_export_as_container_derived() -> Result<()> {
name: format!("{}:exported-test", fixture.path.join(exported_ocidir_name)),
};
fixture.dir.create_dir(exported_ocidir_name)?;
let ocidir = ocidir::OciDir::ensure(fixture.dir.open_dir(exported_ocidir_name)?)?;
let ocidir = ocidir::OciDir::ensure(OciCapDir::reopen_dir(
&fixture.dir.open_dir(exported_ocidir_name)?.as_fd(),
)?)?;
let exported = store::export(fixture.destrepo(), &derived_imgref, &dest, None)
.await
.unwrap();
Expand Down Expand Up @@ -883,7 +889,9 @@ async fn test_export_etc_remapping() -> Result<()> {
name: format!("{}:exported-test", fixture.path.join(exported_ocidir_name)),
};
fixture.dir.create_dir(exported_ocidir_name)?;
let ocidir = ocidir::OciDir::ensure(fixture.dir.open_dir(exported_ocidir_name)?)?;
let ocidir = ocidir::OciDir::ensure(OciCapDir::reopen_dir(
&fixture.dir.open_dir(exported_ocidir_name)?.as_fd(),
)?)?;
let _exported = store::export(fixture.destrepo(), &derived_imgref, &dest, None)
.await
.unwrap();
Expand Down Expand Up @@ -986,7 +994,7 @@ async fn test_unencapsulate_unbootable() -> Result<()> {
fn validate_chunked_structure(oci_path: &Utf8Path) -> Result<()> {
use tar::EntryType::Link;

let d = Dir::open_ambient_dir(oci_path, cap_std::ambient_authority())?;
let d = OciCapDir::open_ambient_dir(oci_path, ocidir::cap_std::ambient_authority())?;
let d = ocidir::OciDir::open(d)?;
let idx = d.read_index()?;
let desc = idx.manifests().first().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bootc-kernel-cmdline = { path = "../kernel_cmdline", version = "0.0.0" }

# Crate-specific dependencies
libtest-mimic = "0.8.0"
oci-spec = "0.8.0"
oci-spec = "0.9.0"
rexpect = "0.6"
scopeguard = "1.2.0"

Expand Down