Skip to content

Commit 15a495d

Browse files
authored
Make mtime setting happen as part of build script (#67)
1 parent d1b1653 commit 15a495d

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "toltecmk"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = [
55
{ name="Mattéo Delabre", email="git.matteo@delab.re" },
66
{ name="Eeems", email="eeems@eeems.email" },

toltec/builder.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from types import TracebackType
88
import re
99
import os
10+
import shlex
1011
import logging
1112
import textwrap
1213
from importlib.util import find_spec, module_from_spec
@@ -400,19 +401,27 @@ def _build(self, recipe: Recipe, src_dir: str) -> None:
400401

401402
logger.info("Building artifacts")
402403

403-
# Set fixed atime and mtime for all the source files
404-
epoch = int(recipe.timestamp.timestamp())
405-
406-
for filename in util.list_tree(src_dir):
407-
os.utime(filename, (epoch, epoch))
408-
409404
mount_src = "/src"
410405
repo_src = "/repo"
411406
uid = os.getuid()
412407
gid = os.getgid()
408+
restore_script: list[str] = []
409+
410+
# Set fixed atime and mtime for all the source files
411+
epoch = int(recipe.timestamp.timestamp())
412+
for file_path in util.list_tree(src_dir):
413+
docker_path = shlex.quote(
414+
os.path.join(mount_src, os.path.relpath(file_path, src_dir))
415+
)
416+
restore_script.append(
417+
'echo "import os; os.utime('
418+
+ f'\\"{docker_path}\\", ns=({epoch}, {epoch})'
419+
+ ')" | python3 -u'
420+
)
413421

414422
logs = self._run_script(
415423
[
424+
*restore_script,
416425
f'cd "{mount_src}"',
417426
recipe.build,
418427
f"chown -R {uid}:{gid} {mount_src} {repo_src}",

0 commit comments

Comments
 (0)