Skip to content

Commit 606721a

Browse files
committed
ostree-ext: Stub out config loading if we detect nspawn
Workaround for rpm-software-management/mock#1613 (comment) Signed-off-by: Colin Walters <[email protected]>
1 parent eaa155a commit 606721a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

contrib/packaging/bootc.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ cat vendor-config.toml >> .cargo/config.toml
9595
rm vendor-config.toml
9696

9797
%build
98+
env
9899
# Build the main bootc binary
99100
%if %new_cargo_macros
100101
%cargo_build %{?with_rhsm:-f rhsm}

crates/ostree-ext/src/globals.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use cap_std_ext::cap_std::fs::Dir;
77
use cap_std_ext::RootDir;
88
use fn_error_context::context;
99
use ostree::glib;
10+
use ostree::glib::property::PropertyGet;
1011
use std::fs::File;
1112
use std::sync::OnceLock;
1213

@@ -93,8 +94,12 @@ impl ConfigPaths {
9394
/// Return the path to the global container authentication file, if it exists.
9495
#[context("Loading global authfile")]
9596
pub fn get_global_authfile(root: &Dir) -> Result<Option<(Utf8PathBuf, File)>> {
96-
let root = &RootDir::new(root, ".").context("Opening RootDir")?;
97+
// Workaround for https://github.com/rpm-software-management/mock/pull/1613#issuecomment-3421908652
98+
if std::env::var("RPM_BUILD_TIME").is_ok() {
99+
return Ok(None);
100+
}
97101
let am_uid0 = rustix::process::getuid() == rustix::process::Uid::ROOT;
102+
let root = &RootDir::new(root, ".").context("Opening RootDir")?;
98103
get_global_authfile_impl(root, am_uid0)
99104
}
100105

@@ -127,6 +132,7 @@ mod tests {
127132
}
128133

129134
#[test]
135+
#[ignore = "https://github.com/rpm-software-management/mock/pull/1613#issuecomment-3421908652"]
130136
fn test_config_paths() -> Result<()> {
131137
let root = &cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
132138
let rootdir = &RootDir::new(root, ".")?;

0 commit comments

Comments
 (0)