Skip to content

Commit

Permalink
composepost: apply add-determinism pyc-zero-mtime
Browse files Browse the repository at this point in the history
Fixes: ostreedev/ostree#1469

Assuming that add-determinism is installed on the system,
apply add-determinism to set the embedded mtime in all .pyc
files to zero.

Signed-off-by: Luke Yang <[email protected]>
Co-authored-by: Steven Presti <[email protected]>
  • Loading branch information
lukewarmtemp and prestist committed Jul 17, 2024
1 parent 8df0f59 commit 5c6b407
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rust/src/composepost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,18 @@ fn workaround_selinux_cross_labeling_recurse(
/// 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)? };

if std::process::Command::new("add-determinism").status().expect("Failed to find add-determinism on system.").success() {
// add-determinism --handler pyc-zero-mtime
let r = std::process::Command::new("add-determinism")
.arg("--handler")
.arg("pyc-zero-mtime")
.arg("/usr")
.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());
}
}
hardlink_rpmdb_base_location(rootfs, None)?;
Ok(())
}
Expand Down

0 comments on commit 5c6b407

Please sign in to comment.