From 9e04e53bfb9ec5f7e861918b220d932f3dc4ae3f Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Jul 19 2024 14:48:03 +0000 Subject: [PATCH 1/2] Revert "postprocess: Workaround for Python timestamp mismatch" See: https://pagure.io/workstation-ostree-config/pull-request/507 See: https://github.com/keszybz/add-determinism/pull/27 See: https://gitlab.com/fedora/bootc/tracker/-/issues/3 This reverts commit d085e9fecccaf5d0c164b8a67d3b046dc36df39f. --- diff --git a/common.yaml b/common.yaml index 2b4d4e5..a6deb4b 100644 --- a/common.yaml +++ b/common.yaml @@ -141,5 +141,3 @@ postprocess: # Fix triggerin for samba-client in cups package (not supported by rpm-ostree yet) # https://github.com/fedora-silverblue/issue-tracker/issues/532 ln -snf /usr/libexec/samba/cups_backend_smb /usr/lib/cups/backend/smb - -postprocess-script: "postprocess.sh" diff --git a/postprocess.sh b/postprocess.sh deleted file mode 100755 index d871a85..0000000 --- a/postprocess.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -set -xeuo pipefail - -# Workaround for Python timestamp mismatch -# See: https://github.com/ostreedev/ostree/issues/1469 - -echo ' -import os -import re - -MIN_MAGIC = 3390 # The first magic number supporting PEP 552 -ZERO = bytes((0, 0, 0, 0)) - -def pyc_set_zero_mtime(pyc_path): - with open(pyc_path, "r+b") as f: - w = f.read(4) - if len(w) < 4: - return 0 - - magic = (w[0] + (w[1] << 8) + (w[2] << 16) + (w[3] << 24)) & 0xFFFF - if magic < MIN_MAGIC: - invalidation = ZERO - else: - invalidation = f.read(4) - if len(invalidation) < 4: - return 0 - - if invalidation == ZERO: - f.write(ZERO) - return 1 - return 0 - -if __name__ == "__main__": - REGEX = re.compile(r".*/__pycache__/[^/]+\.cpython-.*(\.opt-1|\.opt-2)?\.pyc$") - count = 0 - - for root, dirs, files in os.walk("/usr"): - for file in files: - path = os.path.join(root, file) - if REGEX.match(path): - count += pyc_set_zero_mtime(path) - - print(f"Processed {count} pyc files") -' | python From 36c70e09eaa4ab07d3abbfa6d67dea140cc0d403 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: Jul 19 2024 15:13:49 +0000 Subject: [PATCH 2/2] common: Use add-determinism as workraround for pyc mtime mismatch See: https://gitlab.com/fedora/bootc/tracker/-/issues/3 See: https://pagure.io/workstation-ostree-config/pull-request/505 See: https://github.com/ostreedev/ostree/issues/1469 --- diff --git a/common.yaml b/common.yaml index a6deb4b..9572e7c 100644 --- a/common.yaml +++ b/common.yaml @@ -58,6 +58,8 @@ packages: # Always include at least full English language support by default # https://gitlab.com/fedora/ostree/sig/-/issues/14 - langpacks-en + # Workaround for https://github.com/ostreedev/ostree/issues/1469 + - add-determinism selinux: true documentation: true @@ -141,3 +143,6 @@ postprocess: # Fix triggerin for samba-client in cups package (not supported by rpm-ostree yet) # https://github.com/fedora-silverblue/issue-tracker/issues/532 ln -snf /usr/libexec/samba/cups_backend_smb /usr/lib/cups/backend/smb + + # Workaround for https://github.com/ostreedev/ostree/issues/1469 + add-determinism -j --handler pyc-zero-mtime /usr