Skip to content

Commit

Permalink
Port to ostree-ext 0.13, cap-std 3
Browse files Browse the repository at this point in the history
- Soooo much churn around the extension traits
- A little bit of small ostree-ext porting
  • Loading branch information
cgwalters committed Feb 5, 2024
1 parent 3e3cbd5 commit d392712
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 95 deletions.
39 changes: 10 additions & 29 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ anyhow = "1.0.75"
binread = "2.2.0"
bitflags = "2.4"
camino = "1.1.6"
cap-std-ext = "3.0"
cap-std-ext = "4"
cap-primitives = "3"
cap-std = { version = "2", features = ["fs_utf8"] }
cap-std = { version = "3", features = ["fs_utf8"] }
containers-image-proxy = { version = "0.5.8", features = ["proxy_v0_2_4"] }
# Explicitly force on libc
rustix = { version = "0.38", features = ["use-libc", "process", "fs"] }
Expand All @@ -73,7 +73,7 @@ nix = { version = "0.27.1", features = ["fs", "mount", "signal", "user"] }
openssl = "0.10.60"
once_cell = "1.19.0"
os-release = "0.1.0"
ostree-ext = "0.12"
ostree-ext = "0.13"
paste = "1.0"
phf = { version = "0.11", features = ["macros"] }
rand = "0.8.5"
Expand Down Expand Up @@ -129,3 +129,6 @@ bin-unit-tests = []
sanitizers = []

default = []

[patch.crates-io]
ostree-ext = { path = "../../ostreedev/ostree-rs-ext/lib" }
28 changes: 13 additions & 15 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,6 @@ struct ContainerImageState final
{
::rust::String base_commit;
::rust::String merge_commit;
bool is_layered;
::rust::String image_digest;
::rust::String version;
::rpmostreecxx::ExportedManifestDiff cached_update_diff;
Expand Down Expand Up @@ -2815,6 +2814,9 @@ extern "C"
::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$complete_rpm_layering (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$passwd_cleanup (::std::int32_t rootfs) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$migrate_group_except_root (
Expand Down Expand Up @@ -2944,9 +2946,6 @@ extern "C"
void rpmostreecxx$cxxbridge1$cache_branch_to_nevra (::rust::Str nevra,
::rust::String *return$) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (::std::int32_t rootfs) noexcept;

::std::uint32_t
rpmostreecxx$cxxbridge1$CxxGObjectArray$length (::rpmostreecxx::CxxGObjectArray &self) noexcept
{
Expand Down Expand Up @@ -5699,6 +5698,16 @@ complete_rpm_layering (::std::int32_t rootfs)
}
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}

void
passwd_cleanup (::std::int32_t rootfs)
{
Expand Down Expand Up @@ -6105,16 +6114,6 @@ cache_branch_to_nevra (::rust::Str nevra) noexcept
rpmostreecxx$cxxbridge1$cache_branch_to_nevra (nevra, &return$.value);
return ::std::move (return$.value);
}

void
deduplicate_tmpfiles_entries (::std::int32_t rootfs)
{
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$deduplicate_tmpfiles_entries (rootfs);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}
} // namespace rpmostreecxx

extern "C"
Expand Down Expand Up @@ -6829,6 +6828,5 @@ Vec< ::rpmostreecxx::LockedPackage>::truncate (::std::size_t len)
{
return cxxbridge1$rust_vec$rpmostreecxx$LockedPackage$truncate (this, len);
}

} // namespace cxxbridge1
} // namespace rust
5 changes: 2 additions & 3 deletions rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,6 @@ struct ContainerImageState final
{
::rust::String base_commit;
::rust::String merge_commit;
bool is_layered;
::rust::String image_digest;
::rust::String version;
::rpmostreecxx::ExportedManifestDiff cached_update_diff;
Expand Down Expand Up @@ -2016,6 +2015,8 @@ bool prepare_rpm_layering (::std::int32_t rootfs, ::rust::Str merge_passwd_dir);

void complete_rpm_layering (::std::int32_t rootfs);

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);

void passwd_cleanup (::std::int32_t rootfs);

void migrate_group_except_root (::std::int32_t rootfs,
Expand Down Expand Up @@ -2058,6 +2059,4 @@ ::rpmostreecxx::GKeyFile *treefile_to_origin (::rpmostreecxx::Treefile const &tf
void origin_validate_roundtrip (::rpmostreecxx::GKeyFile const &kf) noexcept;

::rust::String cache_branch_to_nevra (::rust::Str nevra) noexcept;

void deduplicate_tmpfiles_entries (::std::int32_t rootfs);
} // namespace rpmostreecxx
6 changes: 2 additions & 4 deletions rust/src/builtins/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ pub(crate) mod commit;

use crate::cxxrsutil::CxxResult;
use anyhow::{Context, Result};
use cap_std::fs::{Dir, DirBuilder, Permissions};
use cap_std::fs::{Dir, DirBuilder, DirBuilderExt, MetadataExt, Permissions, PermissionsExt};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use fn_error_context::context;
use rustix::fd::AsFd;
use rustix::fs::{AtFlags, FileType, MetadataExt};
use rustix::fs::{AtFlags, FileType};
use std::io::Read;
use std::os::unix::fs::DirBuilderExt;
use std::os::unix::prelude::PermissionsExt;

use crate::core::OSTREE_BOOTED;

Expand Down
3 changes: 1 addition & 2 deletions rust/src/builtins/scriptlet_intercept/groupadd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use super::common::{self, SYSUSERS_DIR};
use anyhow::{anyhow, Context, Result};
use cap_std::fs::{Dir, Permissions};
use cap_std::fs::{Dir, Permissions, PermissionsExt};
use cap_std_ext::prelude::CapStdExtDirExt;
use clap::{Arg, ArgAction, Command};
use fn_error_context::context;
use std::io::Write;
use std::os::unix::prelude::PermissionsExt;

/// Entrypoint for (the rpm-ostree implementation of) `groupadd`.
#[context("Intercepting groupadd")]
Expand Down
3 changes: 1 addition & 2 deletions rust/src/builtins/scriptlet_intercept/useradd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use super::common::{self, SYSUSERS_DIR};
use anyhow::{anyhow, Context, Result};
use cap_std::fs::{Dir, Permissions};
use cap_std::fs::{Dir, Permissions, PermissionsExt};
use cap_std_ext::prelude::CapStdExtDirExt;
use clap::{Arg, ArgAction, Command};
use fn_error_context::context;
use std::io::Write;
use std::os::unix::prelude::PermissionsExt;

/// Entrypoint for (the rpm-ostree implementation of) `useradd`.
#[context("Intercepting useradd")]
Expand Down
3 changes: 1 addition & 2 deletions rust/src/builtins/scriptlet_intercept/usermod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use super::common::{self, SYSUSERS_DIR};
use anyhow::{anyhow, Context, Result};
use cap_std::fs::{Dir, Permissions};
use cap_std::fs::{Dir, Permissions, PermissionsExt};
use cap_std_ext::prelude::CapStdExtDirExt;
use clap::{Arg, ArgAction, Command};
use fn_error_context::context;
use std::io::Write;
use std::os::unix::prelude::PermissionsExt;

/// Entrypoint for (the rpm-ostree implementation of) `usermod`.
#[context("Intercepting usermod")]
Expand Down
3 changes: 1 addition & 2 deletions rust/src/capstdext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

use cap_std::fs::DirBuilder;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::Dir;
use cap_std_ext::cap_std::fs::{Dir, DirBuilderExt};
use std::ffi::OsStr;
use std::io::Result;
use std::os::unix::fs::DirBuilderExt;
use std::path::Path;

pub(crate) fn dirbuilder_from_mode(m: u32) -> DirBuilder {
Expand Down
4 changes: 1 addition & 3 deletions rust/src/cliwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

use anyhow::{anyhow, Result};
use camino::Utf8Path;
use cap_std::fs::{Dir, DirBuilder, Permissions};
use cap_std::fs::{Dir, DirBuilder, DirBuilderExt, Permissions, PermissionsExt};
use cap_std_ext::cap_std;
use cap_std_ext::prelude::CapStdExtDirExt;
use fn_error_context::context;
use rayon::prelude::*;
use std::collections::HashSet;
use std::io::prelude::*;
use std::os::unix::fs::DirBuilderExt;
use std::os::unix::prelude::PermissionsExt;
mod cliutil;
mod dracut;
mod grubby;
Expand Down
4 changes: 1 addition & 3 deletions rust/src/composepost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ use cap_std::fs::Dir;
use cap_std::fs_utf8::Dir as Utf8Dir;
use cap_std::io_lifetimes::AsFilelike;
use cap_std_ext::cap_std;
use cap_std_ext::cap_std::fs::Permissions;
use cap_std_ext::cap_std::fs::{DirBuilderExt, MetadataExt, Permissions, PermissionsExt};
use cap_std_ext::dirext::CapStdExtDirExt;
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;
use std::io::{BufRead, BufReader, Seek, Write};
use std::os::unix::fs::{DirBuilderExt, PermissionsExt};
use std::os::unix::io::AsRawFd;
use std::os::unix::prelude::IntoRawFd;
use std::path::{Path, PathBuf};
Expand Down
4 changes: 1 addition & 3 deletions rust/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use crate::ffiutil;
use anyhow::Context;
use anyhow::{anyhow, Result};
use camino::Utf8Path;
use cap_std::fs::Dir;
use cap_std::fs::Permissions;
use cap_std::fs::{Dir, Permissions, PermissionsExt};
use cap_std_ext::cap_std;
use cap_std_ext::prelude::CapStdExtDirExt;
use ffiutil::*;
Expand All @@ -22,7 +21,6 @@ use ostree_ext::ostree;
use std::fs::File;
use std::io::{BufReader, Read};
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::os::unix::prelude::PermissionsExt;

/// The binary forked from useradd that pokes the sss cache.
/// It spews warnings (and sometimes fatal errors) when used
Expand Down
4 changes: 1 addition & 3 deletions rust/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ use crate::ffi::{
OverrideReplacementSource, OverrideReplacementType, ParsedRevision, ParsedRevisionKind,
};
use anyhow::{anyhow, format_err, Result};
use cap_std::fs::Dir;
use cap_std::fs::{Dir, MetadataExt, PermissionsExt};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use fn_error_context::context;
use glib::prelude::*;
use ostree_ext::{gio, glib, ostree};
use rustix::fd::BorrowedFd;
use rustix::fs::MetadataExt;
use std::collections::{BTreeMap, BTreeSet};
use std::io::Read;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;

const RPM_OSTREED_COMMIT_VERIFICATION_CACHE: &str = "rpm-ostree/gpgcheck-cache";
Expand Down
3 changes: 1 addition & 2 deletions rust/src/dirdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ pub(crate) fn diff(src: &Dir, dest: &Dir) -> Result<Diff> {
#[cfg(test)]
mod test {
use super::*;
use cap_std::fs::Permissions;
use cap_std::fs::{Permissions, PermissionsExt};
use cap_std_ext::cap_tempfile;
use std::os::unix::fs::PermissionsExt;

#[test]
fn test_diff() -> Result<()> {
Expand Down
3 changes: 1 addition & 2 deletions rust/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

use anyhow::{bail, Context, Result};
use cap_std::fs::Dir;
use cap_std::fs::Permissions;
use cap_std::fs::{Permissions, PermissionsExt};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use serde_derive::{Deserialize, Serialize};
use std::collections::HashMap;
use std::io::Read;
use std::os::unix::prelude::PermissionsExt;

use crate::cxxrsutil::*;
use crate::ffi::StringMapping;
Expand Down
1 change: 0 additions & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ pub mod ffi {
pub(crate) struct ContainerImageState {
pub base_commit: String,
pub merge_commit: String,
pub is_layered: bool,
pub image_digest: String,
pub version: String,
pub cached_update_diff: ExportedManifestDiff,
Expand Down
Loading

0 comments on commit d392712

Please sign in to comment.