mirror of
https://github.com/ostreedev/ostree.git
synced 2025-02-14 05:57:51 +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:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
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
|
# TODO: Automatically query this from the C side
|
||||||
LATEST_LIBOSTREE: "v2022_6"
|
LATEST_LIBOSTREE: "v2022_6"
|
||||||
# Pinned toolchain for linting
|
|
||||||
ACTION_LINTS_TOOLCHAIN: 1.64.0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -25,10 +23,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Cache Dependencies
|
- name: Cache Dependencies
|
||||||
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
|
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
|
||||||
|
- name: cargo fmt (check)
|
||||||
|
run: cargo fmt -p ostree -- --check -l
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo build --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
run: cargo build --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
|
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:
|
build-minimum-toolchain:
|
||||||
name: "Build, minimum supported toolchain (MSRV)"
|
name: "Build, minimum supported toolchain (MSRV)"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -83,25 +85,6 @@ jobs:
|
|||||||
run: cargo test --no-run --verbose --features=${{ env['LATEST_LIBOSTREE'] }}
|
run: cargo test --no-run --verbose --features=${{ env['LATEST_LIBOSTREE'] }}
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --verbose --features=${{ env['LATEST_LIBOSTREE'] }}
|
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:
|
cargo-deny:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -8,7 +8,7 @@ license = "MIT"
|
|||||||
name = "ostree"
|
name = "ostree"
|
||||||
readme = "rust-bindings/README.md"
|
readme = "rust-bindings/README.md"
|
||||||
repository = "https://github.com/ostreedev/ostree"
|
repository = "https://github.com/ostreedev/ostree"
|
||||||
rust-version = "1.64.0"
|
rust-version = "1.70.0"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
|
|
||||||
exclude = [
|
exclude = [
|
||||||
@ -40,8 +40,6 @@ members = [".", "rust-bindings/sys"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.20.0"
|
base64 = "0.20.0"
|
||||||
bitflags = "1.2.1"
|
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" }
|
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.13.0" }
|
||||||
gio = "0.16"
|
gio = "0.16"
|
||||||
glib = "0.16"
|
glib = "0.16"
|
||||||
@ -53,10 +51,10 @@ thiserror = "1.0.20"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
cap-tempfile = "1.0"
|
io-lifetimes = "1"
|
||||||
|
cap-tempfile = "2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
cap-std-apis = ["cap-std", "io-lifetimes", "v2017_10"]
|
|
||||||
dox = ["ffi/dox"]
|
dox = ["ffi/dox"]
|
||||||
v2014_9 = ["ffi/v2014_9"]
|
v2014_9 = ["ffi/v2014_9"]
|
||||||
v2015_7 = ["v2014_9", "ffi/v2015_7"]
|
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
|
// 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
|
// "Dependencies are re-exported". Users will need e.g. `gio::File`, so this avoids
|
||||||
// them needing to update matching versions.
|
// them needing to update matching versions.
|
||||||
#[cfg(feature = "cap-std-apis")]
|
|
||||||
pub use cap_std;
|
|
||||||
pub use ffi;
|
pub use ffi;
|
||||||
pub use gio;
|
pub use gio;
|
||||||
pub use glib;
|
pub use glib;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#[cfg(any(feature = "v2016_4", feature = "dox"))]
|
#[cfg(any(feature = "v2016_4", feature = "dox"))]
|
||||||
use crate::RepoListRefsExtFlags;
|
use crate::RepoListRefsExtFlags;
|
||||||
#[cfg(feature = "cap-std-apis")]
|
|
||||||
use crate::RepoMode;
|
use crate::RepoMode;
|
||||||
use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats};
|
use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats};
|
||||||
use ffi::OstreeRepoListObjectsFlags;
|
use ffi::OstreeRepoListObjectsFlags;
|
||||||
use glib::ffi as glib_sys;
|
use glib::ffi as glib_sys;
|
||||||
use glib::{self, translate::*, Error, IsA};
|
use glib::{self, translate::*, Error, IsA};
|
||||||
|
use std::os::fd::BorrowedFd;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
future::Future,
|
future::Future,
|
||||||
@ -105,17 +105,17 @@ impl Repo {
|
|||||||
Repo::new(&gio::File::for_path(path.as_ref()))
|
Repo::new(&gio::File::for_path(path.as_ref()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "cap-std-apis")]
|
/// Open using the target directory file descriptor.
|
||||||
/// A version of [`open_at`] which uses cap-std.
|
#[cfg(any(feature = "v2017_10", feature = "dox"))]
|
||||||
pub fn open_at_dir(dir: &cap_std::fs::Dir, path: &str) -> Result<Repo, glib::Error> {
|
pub fn open_at_dir(dir: BorrowedFd<'_>, path: &str) -> Result<Repo, glib::Error> {
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
crate::Repo::open_at(dir.as_raw_fd(), path, gio::Cancellable::NONE)
|
crate::Repo::open_at(dir.as_raw_fd(), path, gio::Cancellable::NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "cap-std-apis")]
|
/// A version of [`create_at`] which resolves the path relative to the provided directory file descriptor, and also returns the opened repo.
|
||||||
/// A version of [`create_at`] which uses cap-std, and also returns the opened repo.
|
#[cfg(any(feature = "v2017_10", feature = "dox"))]
|
||||||
pub fn create_at_dir(
|
pub fn create_at_dir(
|
||||||
dir: &cap_std::fs::Dir,
|
dir: BorrowedFd<'_>,
|
||||||
path: &str,
|
path: &str,
|
||||||
mode: RepoMode,
|
mode: RepoMode,
|
||||||
options: Option<&glib::Variant>,
|
options: Option<&glib::Variant>,
|
||||||
@ -152,17 +152,9 @@ impl Repo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Borrow the directory file descriptor for this repository.
|
/// Borrow the directory file descriptor for this repository.
|
||||||
#[cfg(feature = "cap-std-apis")]
|
#[cfg(feature = "v2017_10")]
|
||||||
pub fn dfd_borrow(&self) -> io_lifetimes::BorrowedFd {
|
pub fn dfd_borrow(&self) -> BorrowedFd {
|
||||||
unsafe { io_lifetimes::BorrowedFd::borrow_raw(self.dfd()) }
|
unsafe { 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())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find all objects reachable from a commit.
|
/// Find all objects reachable from a commit.
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
use crate::util::*;
|
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::prelude::*;
|
||||||
use ostree::{ObjectName, ObjectType};
|
use ostree::{ObjectName, ObjectType};
|
||||||
|
#[cfg(feature = "v2017_10")]
|
||||||
|
use std::os::fd::AsFd;
|
||||||
|
|
||||||
#[cfg(any(feature = "v2016_8", feature = "dox"))]
|
#[cfg(any(feature = "v2016_8", feature = "dox"))]
|
||||||
mod checkout_at;
|
mod checkout_at;
|
||||||
@ -54,13 +60,15 @@ fn list_commits() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "cap-std-apis")]
|
#[cfg(feature = "v2017_10")]
|
||||||
fn cap_std_commit() {
|
fn cap_std_commit() {
|
||||||
let test_repo = CapTestRepo::new();
|
let test_repo = CapTestRepo::new();
|
||||||
|
|
||||||
assert!(test_repo.dir.exists("config"));
|
assert!(test_repo.dir.exists("config"));
|
||||||
// Also test re-acquiring a new dfd
|
// 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());
|
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);
|
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
|
let refs = repo2
|
||||||
.list_refs(None, gio::Cancellable::NONE)
|
.list_refs(None, gio::Cancellable::NONE)
|
||||||
.expect("failed to list refs");
|
.expect("failed to list refs");
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
#[cfg(feature = "v2017_10")]
|
||||||
|
use cap_tempfile::cap_std;
|
||||||
use glib::prelude::*;
|
use glib::prelude::*;
|
||||||
use glib::GString;
|
use glib::GString;
|
||||||
|
#[cfg(feature = "v2017_10")]
|
||||||
|
use std::os::fd::AsFd;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -28,13 +32,13 @@ impl TestRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg(feature = "cap-std-apis")]
|
#[cfg(feature = "v2017_10")]
|
||||||
pub struct CapTestRepo {
|
pub struct CapTestRepo {
|
||||||
pub dir: cap_tempfile::TempDir,
|
pub dir: cap_tempfile::TempDir,
|
||||||
pub repo: ostree::Repo,
|
pub repo: ostree::Repo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "cap-std-apis")]
|
#[cfg(feature = "v2017_10")]
|
||||||
impl CapTestRepo {
|
impl CapTestRepo {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::new_with_mode(ostree::RepoMode::Archive)
|
Self::new_with_mode(ostree::RepoMode::Archive)
|
||||||
@ -42,7 +46,8 @@ impl CapTestRepo {
|
|||||||
|
|
||||||
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> Self {
|
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> Self {
|
||||||
let dir = cap_tempfile::tempdir(cap_std::ambient_authority()).unwrap();
|
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 }
|
Self { dir, repo }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user