Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion rust/src/composepost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use std::os::unix::prelude::IntoRawFd;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::process::Stdio;
use cap_std_ext::cmdext::CapStdExtCommandExt;

/// Directories that are moved out and symlinked from their `/var/lib/<entry>`
/// location to `/usr/lib/<entry>`.
Expand Down Expand Up @@ -1198,10 +1199,42 @@ fn workaround_selinux_cross_labeling_recurse(
Ok(())
}

fn run_add_determinisim(rootfs: &Dir) -> CxxResult<()> {
let path = std::env::var_os("PATH").unwrap();
let bin = "add-determinism";
if let Some(path) = std::env::var_os("PATH") {
for path in std::env::split_paths(&path){
let bin_path = path.join(bin);
if bin_path.exists() {
// let usr_path = rootfs.open_dir("usr");
// cwd_dir(usr_path);
let mut cmd = std::process::Command::new("/bin/bash");
cmd.cwd_dir(rootfs.try_clone()?);
let usr_path = Path::new("usr");
std::env::set_current_dir(&usr_path)?;
// add-determinism --handler pyc-zero-mtime
let r = std::process::Command::new("add-determinism")
.arg("--handler")
.arg("pyc-zero-mtime")
.arg(".")
.status()?;
// .expect("Failed to normalize .pyc files using add-determinism");
// if !r.success() {
// return Err(anyhow!("Failed to execute add-determinism --handler pyc-zero-mtime: {:?}", r).into());
// }
}
}
}
else {
return Err(anyhow!("Failed to find PATH var").into());
}
Ok(())
}

/// This is the nearly the last code executed before we run `ostree commit`.
pub fn compose_postprocess_final(rootfs_dfd: i32, _treefile: &Treefile) -> CxxResult<()> {
let rootfs = unsafe { &crate::ffiutil::ffi_dirfd(rootfs_dfd)? };

run_add_determinisim(rootfs)?;
hardlink_rpmdb_base_location(rootfs, None)?;
Ok(())
}
Expand Down