Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #532 from cgwalters/bump-ostree
Browse files Browse the repository at this point in the history
lib: Bump to ostree 0.19, cap-std-ext 3.0 && lib: Bump to rustix 0.38 && Bump semver to 0.12
  • Loading branch information
jmarrero authored Sep 8, 2023
2 parents f237597 + 0be1883 commit bd9eb91
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 46 deletions.
8 changes: 4 additions & 4 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
name = "ostree-ext"
readme = "README.md"
repository = "https://github.com/ostreedev/ostree-rs-ext"
version = "0.11.6"
version = "0.12.0"
rust-version = "1.70.0"

[dependencies]
Expand All @@ -19,7 +19,7 @@ chrono = "0.4.19"
olpc-cjson = "0.1.1"
clap = { version= "4.2", features = ["derive"] }
clap_mangen = { version = "0.2", optional = true }
cap-std-ext = "2.0"
cap-std-ext = "3.0"
flate2 = { features = ["zlib"], default_features = false, version = "1.0.20" }
fn-error-context = "0.2.0"
futures-util = "0.3.13"
Expand All @@ -31,10 +31,10 @@ once_cell = "1.9"
libc = "0.2.92"
libsystemd = "0.6.0"
openssl = "0.10.33"
ostree = { features = ["v2022_5", "cap-std-apis"], version = "0.18.0" }
ostree = { features = ["v2022_6"], version = "0.19.0" }
pin-project = "1.0"
regex = "1.5.4"
rustix = { version = "0.37.19", features = ["fs", "process"] }
rustix = { version = "0.38", features = ["fs", "process"] }
serde = { features = ["derive"], version = "1.0.125" }
serde_json = "1.0.64"
tar = "0.4.38"
Expand Down
6 changes: 4 additions & 2 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
use anyhow::{Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use cap_std_ext::cap_std;
use clap::{Parser, Subcommand};
use fn_error_context::context;
use ostree::{cap_std, gio, glib};
use io_lifetimes::AsFd;
use ostree::{gio, glib};
use std::collections::BTreeMap;
use std::ffi::OsString;
use std::io::BufWriter;
Expand Down Expand Up @@ -38,7 +40,7 @@ pub fn parse_base_imgref(s: &str) -> Result<ImageReference> {
pub fn parse_repo(s: &Utf8Path) -> Result<ostree::Repo> {
let repofd = cap_std::fs::Dir::open_ambient_dir(s, cap_std::ambient_authority())
.with_context(|| format!("Opening directory at '{s}'"))?;
ostree::Repo::open_at_dir(&repofd, ".")
ostree::Repo::open_at_dir(repofd.as_fd(), ".")
.with_context(|| format!("Opening ostree repository at '{s}'"))
}

Expand Down
5 changes: 3 additions & 2 deletions lib/src/container/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::sysroot::SysrootLock;
use crate::utils::ResultExt;
use anyhow::{anyhow, Context};
use camino::{Utf8Path, Utf8PathBuf};
use cap_std_ext::cap_std::fs::Dir;
use containers_image_proxy::{ImageProxy, OpenedImage};
use fn_error_context::context;
use futures_util::TryFutureExt;
Expand Down Expand Up @@ -839,7 +840,7 @@ impl ImageImporter {
let txn = repo.auto_transaction(cancellable)?;

let devino = ostree::RepoDevInoCache::new();
let repodir = repo.dfd_as_dir()?;
let repodir = Dir::reopen_dir(&repo.dfd_borrow())?;
let repo_tmp = repodir.open_dir("tmp")?;
let td = cap_std_ext::cap_tempfile::TempDir::new_in(&repo_tmp)?;

Expand Down Expand Up @@ -1310,7 +1311,7 @@ fn compare_file_info(src: &gio::FileInfo, target: &gio::FileInfo) -> bool {

#[context("Querying object inode")]
fn inode_of_object(repo: &ostree::Repo, checksum: &str) -> Result<u64> {
let repodir = repo.dfd_as_dir()?;
let repodir = Dir::reopen_dir(&repo.dfd_borrow())?;
let (prefix, suffix) = checksum.split_at(2);
let objpath = format!("objects/{}/{}.file", prefix, suffix);
let metadata = repodir.symlink_metadata(objpath)?;
Expand Down
21 changes: 15 additions & 6 deletions lib/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use crate::{gio, glib};
use anyhow::{anyhow, Context, Result};
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use cap_std_ext::prelude::CapStdExtCommandExt;
use chrono::TimeZone;
use fn_error_context::context;
use io_lifetimes::AsFd;
use once_cell::sync::Lazy;
use ostree::cap_std;
use regex::Regex;
use std::borrow::Cow;
use std::io::Write;
Expand Down Expand Up @@ -394,13 +395,21 @@ impl Fixture {
.status()?;
assert!(st.success());

let srcrepo =
ostree::Repo::create_at_dir(srcdir_dfd, "repo", ostree::RepoMode::Archive, None)
.context("Creating src/ repo")?;
let srcrepo = ostree::Repo::create_at_dir(
srcdir_dfd.as_fd(),
"repo",
ostree::RepoMode::Archive,
None,
)
.context("Creating src/ repo")?;

dir.create_dir("dest")?;
let destrepo =
ostree::Repo::create_at_dir(&dir, "dest/repo", ostree::RepoMode::BareUser, None)?;
let destrepo = ostree::Repo::create_at_dir(
dir.as_fd(),
"dest/repo",
ostree::RepoMode::BareUser,
None,
)?;
Ok(Self {
tempdir,
dir,
Expand Down
26 changes: 0 additions & 26 deletions lib/src/keyfileext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ pub trait KeyFileExt {
fn optional_string(&self, group: &str, key: &str) -> Result<Option<GString>, glib::Error>;
/// Get a boolean value, but return `None` if the key does not exist.
fn optional_bool(&self, group: &str, key: &str) -> Result<Option<bool>, glib::Error>;
/// Get a string list value, but return `None` if the key does not exist.
fn optional_string_list(
&self,
group: &str,
key: &str,
) -> Result<Option<Vec<GString>>, glib::Error>;
}

/// Consume a keyfile error, mapping the case where group or key is not found to `Ok(None)`.
Expand Down Expand Up @@ -42,14 +36,6 @@ impl KeyFileExt for glib::KeyFile {
fn optional_bool(&self, group: &str, key: &str) -> Result<Option<bool>, glib::Error> {
map_keyfile_optional(self.boolean(group, key))
}

fn optional_string_list(
&self,
group: &str,
key: &str,
) -> Result<Option<Vec<GString>>, glib::Error> {
map_keyfile_optional(self.string_list(group, key))
}
}

#[cfg(test)]
Expand All @@ -71,17 +57,5 @@ mod tests {
assert_eq!(kf.optional_bool("foo", "bar").unwrap(), None);
kf.set_boolean("foo", "somebool", false);
assert_eq!(kf.optional_bool("foo", "somebool").unwrap(), Some(false));

assert_eq!(kf.optional_string_list("foo", "bar").unwrap(), None);
kf.set_string("foo", "somelist", "one;two;three");
assert_eq!(
kf.optional_string_list("foo", "somelist").unwrap(),
Some(
vec!["one", "two", "three"]
.iter()
.map(|&v| GString::from(v))
.collect()
)
);
}
}
2 changes: 1 addition & 1 deletion lib/src/repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl InodeCheck {
#[doc(hidden)]
/// Detect if any commits are potentially incorrect due to inode truncations.
pub fn check_inode_collision(repo: &ostree::Repo, verbose: bool) -> Result<InodeCheck> {
let repo_dir = repo.dfd_as_dir()?;
let repo_dir = Dir::reopen_dir(&repo.dfd_borrow())?;
let objects = repo_dir.open_dir("objects")?;

println!(
Expand Down
10 changes: 6 additions & 4 deletions lib/src/tar/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,21 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> {
let target = meta
.symlink_target()
.ok_or_else(|| anyhow!("Missing symlink target"))?;
let target = target
.to_str()
.ok_or_else(|| anyhow!("Invalid UTF-8 symlink target: {target:?}"))?;
let context = || format!("Writing content symlink: {}", checksum);
h.set_entry_type(tar::EntryType::Symlink);
h.set_size(0);
// Handle //chkconfig, see above
if symlink_is_denormal(&target) {
h.set_link_name_literal(meta.symlink_target().unwrap().as_str())
.with_context(context)?;
if symlink_is_denormal(target) {
h.set_link_name_literal(target).with_context(context)?;
self.out
.append_data(&mut h, &path, &mut std::io::empty())
.with_context(context)?;
} else {
self.out
.append_link(&mut h, &path, target.as_str())
.append_link(&mut h, &path, target)
.with_context(context)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use anyhow::{Context, Result};
use camino::Utf8Path;
use cap_std::fs::{Dir, DirBuilder};
use cap_std_ext::cap_std;
use containers_image_proxy::oci_spec;
use containers_image_proxy::oci_spec::image::ImageManifest;
use once_cell::sync::Lazy;
use ostree::cap_std;
use ostree_ext::chunking::ObjectMetaSized;
use ostree_ext::container::{store, ManifestDiff};
use ostree_ext::container::{
Expand Down

0 comments on commit bd9eb91

Please sign in to comment.