Skip to content

Commit

Permalink
base: Reset utimes before packing xbps packages
Browse files Browse the repository at this point in the history
This ensures that packing yields reproducible archives.
  • Loading branch information
avdgrinten committed Feb 13, 2024
1 parent f72b19d commit 1d43a2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xbstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ def installtree(src_root, dest_root):
shutil.copy2(src_path, dest_path)


def touchtree(root):
for name in os.listdir(root):
path = os.path.join(root, name)

os.utime(path, (0, 0))

if not os.path.islink(path) and os.path.isdir(path):
touchtree(path)


class ResetMode(Enum):
NONE = 0
RESET = 1
Expand Down Expand Up @@ -2430,6 +2440,8 @@ def pack_pkg(cfg, pkg, reproduce=False):
with open(os.path.join(pack_dir, "INSTALL"), "wt") as f:
f.write(install_sh)

touchtree(pack_dir)

# The directory is now prepared, call xbps-create.
environ = os.environ.copy()
_util.build_environ_paths(
Expand Down

0 comments on commit 1d43a2a

Please sign in to comment.