mirror of
https://github.com/ostreedev/ostree.git
synced 2025-02-11 21:58:44 +03:00
Merge pull request #3027 from cgwalters/drop-cap-std-public
Drop cap-std from our public APIs
This commit is contained in:
commit
5fe050f51a
27
.github/workflows/rust.yml
vendored
27
.github/workflows/rust.yml
vendored
@ -11,11 +11,9 @@ on:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_PROJECT_FEATURES: "v2021_5,cap-std-apis"
|
||||
CARGO_PROJECT_FEATURES: "v2022_6"
|
||||
# TODO: Automatically query this from the C side
|
||||
LATEST_LIBOSTREE: "v2022_6"
|
||||
# Pinned toolchain for linting
|
||||
ACTION_LINTS_TOOLCHAIN: 1.64.0
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -25,10 +23,14 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache Dependencies
|
||||
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
|
||||
- name: cargo fmt (check)
|
||||
run: cargo fmt -p ostree -- --check -l
|
||||
- name: Build
|
||||
run: cargo build --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
||||
- name: Run tests
|
||||
run: cargo test --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
||||
- name: cargo clippy (non-gating)
|
||||
run: cargo clippy -p ostree --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
||||
build-minimum-toolchain:
|
||||
name: "Build, minimum supported toolchain (MSRV)"
|
||||
runs-on: ubuntu-latest
|
||||
@ -83,25 +85,6 @@ jobs:
|
||||
run: cargo test --no-run --verbose --features=${{ env['LATEST_LIBOSTREE'] }}
|
||||
- name: Run tests
|
||||
run: cargo test --verbose --features=${{ env['LATEST_LIBOSTREE'] }}
|
||||
linting:
|
||||
name: "Lints, pinned toolchain"
|
||||
runs-on: ubuntu-latest
|
||||
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: Remove system Rust toolchain
|
||||
run: dnf remove -y rust cargo
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env['ACTION_LINTS_TOOLCHAIN'] }}
|
||||
default: true
|
||||
components: rustfmt, clippy
|
||||
- name: cargo fmt (check)
|
||||
run: cargo fmt -p ostree -- --check -l
|
||||
- name: cargo clippy (warnings)
|
||||
run: cargo clippy -p ostree --features=${{ env['CARGO_PROJECT_FEATURES'] }} -- -D warnings
|
||||
cargo-deny:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -8,7 +8,7 @@ license = "MIT"
|
||||
name = "ostree"
|
||||
readme = "rust-bindings/README.md"
|
||||
repository = "https://github.com/ostreedev/ostree"
|
||||
rust-version = "1.64.0"
|
||||
rust-version = "1.70.0"
|
||||
version = "0.18.0"
|
||||
|
||||
exclude = [
|
||||
@ -40,8 +40,6 @@ members = [".", "rust-bindings/sys"]
|
||||
[dependencies]
|
||||
base64 = "0.20.0"
|
||||
bitflags = "1.2.1"
|
||||
cap-std = { version = "1.0", optional = true}
|
||||
io-lifetimes = { version = "1.0", optional = true}
|
||||
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.13.0" }
|
||||
gio = "0.16"
|
||||
glib = "0.16"
|
||||
@ -53,10 +51,10 @@ thiserror = "1.0.20"
|
||||
[dev-dependencies]
|
||||
maplit = "1.0.2"
|
||||
tempfile = "3"
|
||||
cap-tempfile = "1.0"
|
||||
io-lifetimes = "1"
|
||||
cap-tempfile = "2"
|
||||
|
||||
[features]
|
||||
cap-std-apis = ["cap-std", "io-lifetimes", "v2017_10"]
|
||||
dox = ["ffi/dox"]
|
||||
v2014_9 = ["ffi/v2014_9"]
|
||||
v2015_7 = ["v2014_9", "ffi/v2015_7"]
|
||||
|
@ -12,8 +12,6 @@
|
||||
// Re-export our dependencies. See https://gtk-rs.org/blog/2021/06/22/new-release.html
|
||||
// "Dependencies are re-exported". Users will need e.g. `gio::File`, so this avoids
|
||||
// them needing to update matching versions.
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
pub use cap_std;
|
||||
pub use ffi;
|
||||
pub use gio;
|
||||
pub use glib;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#[cfg(any(feature = "v2016_4", feature = "dox"))]
|
||||
use crate::RepoListRefsExtFlags;
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
use crate::RepoMode;
|
||||
use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats};
|
||||
use ffi::OstreeRepoListObjectsFlags;
|
||||
use glib::ffi as glib_sys;
|
||||
use glib::{self, translate::*, Error, IsA};
|
||||
use std::os::fd::BorrowedFd;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
future::Future,
|
||||
@ -105,17 +105,17 @@ impl Repo {
|
||||
Repo::new(&gio::File::for_path(path.as_ref()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
/// A version of [`open_at`] which uses cap-std.
|
||||
pub fn open_at_dir(dir: &cap_std::fs::Dir, path: &str) -> Result<Repo, glib::Error> {
|
||||
/// Open using the target directory file descriptor.
|
||||
#[cfg(any(feature = "v2017_10", feature = "dox"))]
|
||||
pub fn open_at_dir(dir: BorrowedFd<'_>, path: &str) -> Result<Repo, glib::Error> {
|
||||
use std::os::unix::io::AsRawFd;
|
||||
crate::Repo::open_at(dir.as_raw_fd(), path, gio::Cancellable::NONE)
|
||||
}
|
||||
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
/// A version of [`create_at`] which uses cap-std, and also returns the opened repo.
|
||||
/// A version of [`create_at`] which resolves the path relative to the provided directory file descriptor, and also returns the opened repo.
|
||||
#[cfg(any(feature = "v2017_10", feature = "dox"))]
|
||||
pub fn create_at_dir(
|
||||
dir: &cap_std::fs::Dir,
|
||||
dir: BorrowedFd<'_>,
|
||||
path: &str,
|
||||
mode: RepoMode,
|
||||
options: Option<&glib::Variant>,
|
||||
@ -152,17 +152,9 @@ impl Repo {
|
||||
}
|
||||
|
||||
/// Borrow the directory file descriptor for this repository.
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
pub fn dfd_borrow(&self) -> io_lifetimes::BorrowedFd {
|
||||
unsafe { io_lifetimes::BorrowedFd::borrow_raw(self.dfd()) }
|
||||
}
|
||||
|
||||
/// Return a new `cap-std` directory reference for this repository.
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
pub fn dfd_as_dir(&self) -> std::io::Result<cap_std::fs::Dir> {
|
||||
use io_lifetimes::AsFd;
|
||||
let dfd = self.dfd_borrow();
|
||||
cap_std::fs::Dir::reopen_dir(&dfd.as_fd())
|
||||
#[cfg(feature = "v2017_10")]
|
||||
pub fn dfd_borrow(&self) -> BorrowedFd {
|
||||
unsafe { BorrowedFd::borrow_raw(self.dfd()) }
|
||||
}
|
||||
|
||||
/// Find all objects reachable from a commit.
|
||||
|
@ -1,6 +1,12 @@
|
||||
use crate::util::*;
|
||||
#[cfg(feature = "v2017_10")]
|
||||
use cap_std::fs::Dir;
|
||||
#[cfg(feature = "v2017_10")]
|
||||
use cap_tempfile::cap_std;
|
||||
use ostree::prelude::*;
|
||||
use ostree::{ObjectName, ObjectType};
|
||||
#[cfg(feature = "v2017_10")]
|
||||
use std::os::fd::AsFd;
|
||||
|
||||
#[cfg(any(feature = "v2016_8", feature = "dox"))]
|
||||
mod checkout_at;
|
||||
@ -54,13 +60,15 @@ fn list_commits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
#[cfg(feature = "v2017_10")]
|
||||
fn cap_std_commit() {
|
||||
let test_repo = CapTestRepo::new();
|
||||
|
||||
assert!(test_repo.dir.exists("config"));
|
||||
// Also test re-acquiring a new dfd
|
||||
assert!(test_repo.repo.dfd_as_dir().unwrap().exists("config"));
|
||||
assert!(Dir::reopen_dir(&test_repo.repo.dfd_borrow())
|
||||
.unwrap()
|
||||
.exists("config"));
|
||||
|
||||
assert!(test_repo.repo.require_rev("nosuchrev").is_err());
|
||||
|
||||
@ -69,7 +77,7 @@ fn cap_std_commit() {
|
||||
|
||||
assert_eq!(test_repo.repo.require_rev("test").unwrap(), checksum);
|
||||
|
||||
let repo2 = ostree::Repo::open_at_dir(&test_repo.dir, ".").unwrap();
|
||||
let repo2 = ostree::Repo::open_at_dir(test_repo.dir.as_fd(), ".").unwrap();
|
||||
let refs = repo2
|
||||
.list_refs(None, gio::Cancellable::NONE)
|
||||
.expect("failed to list refs");
|
||||
|
@ -1,5 +1,9 @@
|
||||
#[cfg(feature = "v2017_10")]
|
||||
use cap_tempfile::cap_std;
|
||||
use glib::prelude::*;
|
||||
use glib::GString;
|
||||
#[cfg(feature = "v2017_10")]
|
||||
use std::os::fd::AsFd;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -28,13 +32,13 @@ impl TestRepo {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
#[cfg(feature = "v2017_10")]
|
||||
pub struct CapTestRepo {
|
||||
pub dir: cap_tempfile::TempDir,
|
||||
pub repo: ostree::Repo,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
#[cfg(feature = "v2017_10")]
|
||||
impl CapTestRepo {
|
||||
pub fn new() -> Self {
|
||||
Self::new_with_mode(ostree::RepoMode::Archive)
|
||||
@ -42,7 +46,8 @@ impl CapTestRepo {
|
||||
|
||||
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> Self {
|
||||
let dir = cap_tempfile::tempdir(cap_std::ambient_authority()).unwrap();
|
||||
let repo = ostree::Repo::create_at_dir(&dir, ".", repo_mode, None).expect("repo create");
|
||||
let repo =
|
||||
ostree::Repo::create_at_dir(dir.as_fd(), ".", repo_mode, None).expect("repo create");
|
||||
Self { dir, repo }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user