Skip to content

Commit

Permalink
Update to ostree-ext 0.20, cap-std-ext 2.0
Browse files Browse the repository at this point in the history
- ostree-ext updates to new ostree, so adjust our usage of the
  ostree crate
- Also adjust for changed ostree-ext APIs
- ostree-ext now re-exports cap-std-ext 2.0, which stopped re-exporting
  rustix, so depend on that directly
  • Loading branch information
RishabhSaini authored and cgwalters committed May 10, 2023
1 parent e8ed798 commit b68c64d
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 82 deletions.
49 changes: 29 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ anyhow = "1.0.69"
binread = "2.2.0"
bitflags = "1.3"
camino = "1.1.1"
cap-std-ext = "1.0"
cap-std-ext = "2.0"
cap-std = { version = "1.0.3", features = ["fs_utf8"] }
containers-image-proxy = "0.5.1"
# Explicitly force on libc
rustix = { version = "0.36", features = ["use-libc"] }
rustix = { version = "0.37", features = ["use-libc"] }
cap-primitives = "1.0.3"
cap-tempfile = "1.0.1"
chrono = { version = "0.4.23", features = ["serde"] }
Expand All @@ -72,7 +72,7 @@ nix = "0.26.1"
openssl = "0.10.49"
once_cell = "1.16.0"
os-release = "0.1.0"
ostree-ext = "0.10.0"
ostree-ext = { git = "https://github.com/ostreedev/ostree-rs-ext.git", branch = "main"}
paste = "1.0"
phf = { version = "0.11", features = ["macros"] }
rand = "0.8.5"
Expand Down
6 changes: 3 additions & 3 deletions rust/src/builtins/apply_live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn get_args_variant(sysroot: &ostree::Sysroot, opts: &Opts) -> Result<glib::Vari
} else if opts.reset {
let booted = sysroot.require_booted_deployment()?;
// Unwrap safety: This can't return NULL
let csum = booted.csum().expect("csum");
let csum = booted.csum();
r.insert(live::OPT_TARGET, &csum.as_str());
}

Expand Down Expand Up @@ -76,9 +76,9 @@ pub(crate) fn applylive_finish(sysroot: &crate::ffi::OstreeSysroot) -> CxxResult
let sysroot = sysroot.glib_reborrow();
let cancellable = gio::Cancellable::NONE;
sysroot.load_if_changed(cancellable)?;
let repo = &sysroot.repo().unwrap();
let repo = &sysroot.repo();
let booted = &sysroot.require_booted_deployment()?;
let booted_commit = booted.csum().expect("csum");
let booted_commit = booted.csum();
let booted_commit = booted_commit.as_str();

let live_state = live::get_live_state(repo, booted)?
Expand Down
3 changes: 1 addition & 2 deletions rust/src/builtins/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use anyhow::{Context, Result};
use cap_std::fs::{Dir, DirBuilder, Permissions};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use cap_std_ext::rustix;
use cap_std_ext::rustix::fd::AsFd;
use fn_error_context::context;
use rustix::fd::AsFd;
use rustix::fs::{FileType, MetadataExt};
use std::io::Read;
use std::os::unix::fs::DirBuilderExt;
Expand Down
1 change: 0 additions & 1 deletion rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::normalization;
use anyhow::{Context, Result};
use cap_std::fs::Dir;
use cap_std_ext::prelude::{CapStdExtCommandExt, CapStdExtDirExt};
use cap_std_ext::rustix;
use fn_error_context::context;
use ostree_ext::{gio, glib};
use std::num::NonZeroUsize;
Expand Down
1 change: 0 additions & 1 deletion rust/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::cxxrsutil::*;
use crate::ffi::SystemHostType;
use crate::utils;
use anyhow::{anyhow, Result};
use cap_std_ext::rustix;
use fn_error_context::context;
use gio::prelude::*;
use ostree_ext::{gio, glib};
Expand Down
1 change: 0 additions & 1 deletion rust/src/cliwrap/cliutil.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::Result;
use cap_std_ext::rustix;
use nix::sys::statvfs;
use std::os::unix::process::CommandExt;
use std::{thread, time};
Expand Down
2 changes: 1 addition & 1 deletion rust/src/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub(crate) fn compose_image(args: Vec<String>) -> CxxResult<()> {
Ok::<_, anyhow::Error>(manifest)
})?;

let diff = ostree_ext::container::manifest_diff(&previous_meta.manifest, &new_manifest);
let diff = ostree_ext::container::ManifestDiff::new(&previous_meta.manifest, &new_manifest);
diff.print();
}

Expand Down
4 changes: 2 additions & 2 deletions rust/src/composepost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use cap_std::io_lifetimes::AsFilelike;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::Permissions;
use cap_std_ext::dirext::CapStdExtDirExt;
use cap_std_ext::rustix::fs::MetadataExt;
use fn_error_context::context;
use gio::prelude::*;
use gio::FileType;
use ostree_ext::{gio, glib};
use rayon::prelude::*;
use rustix::fs::MetadataExt;
use std::borrow::Cow;
use std::collections::BTreeSet;
use std::fmt::Write as FmtWrite;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ fn hardlink_recurse(
mod tests {
use super::*;
use cap_std::fs::{Dir, DirBuilder};
use cap_std_ext::{cap_std, rustix};
use cap_std_ext::cap_std;

#[test]
fn stripany() {
Expand Down
16 changes: 5 additions & 11 deletions rust/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use chrono::prelude::*;
use clap::Parser;
use ostree::glib;
use ostree_ext::chunking::ObjectMetaSized;
use ostree_ext::container::{Config, ExportLayout, ExportOpts, ImageReference};
use ostree_ext::container::{Config, ExportOpts, ImageReference};
use ostree_ext::objectsource::{
ContentID, ObjectMeta, ObjectMetaMap, ObjectMetaSet, ObjectSourceMeta,
};
Expand Down Expand Up @@ -166,13 +166,13 @@ fn build_mapping_recurse(
}
}

let checksum = child.checksum().unwrap().to_string();
let checksum = child.checksum().to_string();
match state.content.entry(checksum) {
Entry::Vacant(v) => {
v.insert(pkgid);
}
Entry::Occupied(_) => {
let checksum = child.checksum().unwrap().to_string();
let checksum = child.checksum().to_string();
let v = state.duplicates.entry(checksum).or_default();
v.push(pkgid);
}
Expand Down Expand Up @@ -212,7 +212,7 @@ async fn compare_builds(old_build: &str, new_build: &str) -> Result<()> {
let (_, manifest_old) = proxy.fetch_manifest(&oi_old).await?;
let oi_now = proxy.open_image(new_build).await?;
let (_, new_manifest) = proxy.fetch_manifest(&oi_now).await?;
let diff = ostree_ext::container::manifest_diff(&manifest_old, &new_manifest);
let diff = ostree_ext::container::ManifestDiff::new(&manifest_old, &new_manifest);
diff.print();
Ok(())
}
Expand Down Expand Up @@ -315,7 +315,7 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {
.try_into()
.map_err(anyhow::Error::msg)?;
let initramfs = initramfs.downcast_ref::<ostree::RepoFile>().unwrap();
let checksum = initramfs.checksum().unwrap();
let checksum = initramfs.checksum();
let name = format!("initramfs (kernel {})", kernel_ver).into_boxed_str();
let name = Rc::from(name);
state.content.insert(checksum.to_string(), Rc::clone(&name));
Expand Down Expand Up @@ -396,16 +396,10 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {
labels: Some(labels),
cmd: opt.cmd,
};
let format = match opt.format_version {
0 => ExportLayout::V0,
1 => ExportLayout::V1,
n => return Err(anyhow::anyhow!("Invalid format version {n}").into()),
};
let opts = ExportOpts {
copy_meta_keys,
copy_meta_opt_keys,
max_layers: opt.max_layers,
format,
..Default::default()
};
let handle = tokio::runtime::Handle::current();
Expand Down
1 change: 0 additions & 1 deletion rust/src/countme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::{bail, Context, Result};
use cap_std_ext::rustix;
use os_release::OsRelease;
use std::path;

Expand Down
Loading

0 comments on commit b68c64d

Please sign in to comment.