This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new ce22573e8e1 [v3-0-test] Fix reproducibility issue for tarballs with 
symlink (#54264) (#54267)
ce22573e8e1 is described below

commit ce22573e8e1b14b07df3022aa2e8eecddbaf427c
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Aug 8 18:09:00 2025 +0200

    [v3-0-test] Fix reproducibility issue for tarballs with symlink (#54264) 
(#54267)
    
    Bulk-removing of user and group permissions on MacOS is not a good
    idea for symlinks for reproducibility, because symlinks on linux
    cannot have other/group permissions changed but on MacOS they can
    even if it has no effect. Instead of bulk-change with chmod command
    we now change the permissions individually on all files except symlinks
    (cherry picked from commit 746017639e3d2e5acabb9823601eaeb0291f848c)
    
    Co-authored-by: Jarek Potiuk <[email protected]>
---
 .../src/airflow_breeze/utils/reproducible.py       | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/reproducible.py 
b/dev/breeze/src/airflow_breeze/utils/reproducible.py
index 4ec1c887ca3..bc8e9f1bc78 100644
--- a/dev/breeze/src/airflow_breeze/utils/reproducible.py
+++ b/dev/breeze/src/airflow_breeze/utils/reproducible.py
@@ -37,6 +37,7 @@ import itertools
 import locale
 import os
 import shutil
+import stat
 import tarfile
 from argparse import ArgumentParser
 from pathlib import Path
@@ -106,15 +107,6 @@ def repack_deterministically(
     if result.returncode != 0:
         return result
     dest_archive.unlink(missing_ok=True)
-    result = run_command(
-        [
-            "chmod",
-            "-R",
-            "go=",
-            REPRODUCIBLE_PATH.as_posix(),
-        ],
-        check=False,
-    )
     with cd(REPRODUCIBLE_PATH):
         current_dir = "."
         file_list = [current_dir]
@@ -133,6 +125,19 @@ def repack_deterministically(
             with gzip.GzipFile(fileobj=out_file, mtime=0, mode="wb") as 
gzip_file:
                 with tarfile.open(fileobj=gzip_file, mode="w:") as tar_file:  
# type: ignore
                     for entry in file_list:
+                        entry_path = Path(entry)
+                        if not entry_path.is_symlink():
+                            # For non symlinks clear other and group 
permission bits,
+                            # keep others unchanged
+                            current_mode = entry_path.stat().st_mode
+                            new_mode = current_mode & ~(stat.S_IRWXO | 
stat.S_IRWXG)
+                            entry_path.chmod(new_mode)
+                        else:
+                            # for symlinks on the other hand set rwx for all - 
to match Linux on MacOS
+                            # on platforms like Linux symlink permissions 
cannot be changed
+                            with contextlib.suppress(NotImplementedError):
+                                # Python 3.9 does not support follow_symlinks
+                                entry_path.lchmod(0o777)
                         arcname = entry
                         if prepend_path is not None:
                             arcname = 
os.path.normpath(os.path.join(prepend_path, arcname))

Reply via email to