Skip to content

Commit 465607b

Browse files
authored
Fix argument list too long error (#68)
* Fix argument list too long error * Fix test
1 parent 15a495d commit 465607b

2 files changed

Lines changed: 10 additions & 12 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.1"
3+
version = "0.5.2"
44
authors = [
55
{ name="Mattéo Delabre", email="git.matteo@delab.re" },
66
{ name="Eeems", email="eeems@eeems.email" },

toltec/builder.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from types import TracebackType
88
import re
99
import os
10-
import shlex
1110
import logging
1211
import textwrap
12+
from inspect import getsource
1313
from importlib.util import find_spec, module_from_spec
1414
import docker
1515
import requests
@@ -405,19 +405,17 @@ def _build(self, recipe: Recipe, src_dir: str) -> None:
405405
repo_src = "/repo"
406406
uid = os.getuid()
407407
gid = os.getgid()
408-
restore_script: list[str] = []
409408

410409
# Set fixed atime and mtime for all the source files
411410
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-
)
411+
restore_script: list[str] = [
412+
"python3 -u <<EOF",
413+
"import os",
414+
getsource(util.list_tree),
415+
f'for file_path in list_tree("{mount_src}"):',
416+
f" os.utime(file_path, ns=({epoch}, {epoch}))",
417+
"EOF",
418+
]
421419

422420
logs = self._run_script(
423421
[

0 commit comments

Comments
 (0)