From e263ee8392bfe039c5750c77d3ca82a5bd95a701 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Wed, 29 Oct 2025 20:23:04 -0600 Subject: [PATCH] Make mtime setting happen as part of build script --- pyproject.toml | 2 +- toltec/builder.py | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ff49e98..31c36ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "toltecmk" -version = "0.5.0" +version = "0.5.1" authors = [ { name="Mattéo Delabre", email="git.matteo@delab.re" }, { name="Eeems", email="eeems@eeems.email" }, diff --git a/toltec/builder.py b/toltec/builder.py index 5248d34..ddad507 100644 --- a/toltec/builder.py +++ b/toltec/builder.py @@ -7,6 +7,7 @@ from types import TracebackType import re import os +import shlex import logging import textwrap from importlib.util import find_spec, module_from_spec @@ -400,19 +401,27 @@ def _build(self, recipe: Recipe, src_dir: str) -> None: logger.info("Building artifacts") - # Set fixed atime and mtime for all the source files - epoch = int(recipe.timestamp.timestamp()) - - for filename in util.list_tree(src_dir): - os.utime(filename, (epoch, epoch)) - mount_src = "/src" repo_src = "/repo" uid = os.getuid() gid = os.getgid() + restore_script: list[str] = [] + + # Set fixed atime and mtime for all the source files + epoch = int(recipe.timestamp.timestamp()) + for file_path in util.list_tree(src_dir): + docker_path = shlex.quote( + os.path.join(mount_src, os.path.relpath(file_path, src_dir)) + ) + restore_script.append( + 'echo "import os; os.utime(' + + f'\\"{docker_path}\\", ns=({epoch}, {epoch})' + + ')" | python3 -u' + ) logs = self._run_script( [ + *restore_script, f'cd "{mount_src}"', recipe.build, f"chown -R {uid}:{gid} {mount_src} {repo_src}",