From 5c6b40767d74a5f2210751b9c405faf0ef35051c Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Wed, 17 Jul 2024 17:14:43 -0400 Subject: [PATCH] composepost: apply add-determinism pyc-zero-mtime Fixes: https://github.com/ostreedev/ostree/issues/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 Co-authored-by: Steven Presti --- rust/src/composepost.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rust/src/composepost.rs b/rust/src/composepost.rs index 1a5ae86937..c29d1c8c33 100644 --- a/rust/src/composepost.rs +++ b/rust/src/composepost.rs @@ -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(()) }