mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 20:55:31 +03:00
nixos/image: use stable target dir for amended repart definitions
Output the amended repart definitions to a well-known directory in $TMPDIR instead of using a temporary directory with a random directory name. The output file `repart-output.json` also contains the full path to the repart definition file used to create the partition. As `amend-repart-definitions.py` uses `tempfile.mkdtemp`, this introduces an impurity: ```json { "type" : "root-x86-64", "label" : "rootfs", "uuid" : "f2fa2e49-e443-45d2-a2e2-c3754cab6363", "file" : "/build/tmppjo7kv5o/rootfs.conf", "node" : "image.raw2", "offset" : 135266304, "old_size" : 0, "raw_size" : 1651101696, "old_padding" : 0, "raw_padding" : 0, "activity" : "create", } ``` This commit changes the parent directory of the amended repart definitions to `/build/amended-repart.d/`.
This commit is contained in:
parent
d85f641287
commit
5fd478506d
1 changed files with 6 additions and 7 deletions
|
@ -15,8 +15,6 @@ files using the same mechanism.
|
|||
import json
|
||||
import sys
|
||||
import shutil
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
@ -92,12 +90,13 @@ def main() -> None:
|
|||
print("Partition config is empty.")
|
||||
sys.exit(1)
|
||||
|
||||
temp = tempfile.mkdtemp()
|
||||
shutil.copytree(repart_definitions, temp, dirs_exist_ok=True)
|
||||
target_dir = Path("amended-repart.d")
|
||||
target_dir.mkdir()
|
||||
shutil.copytree(repart_definitions, target_dir, dirs_exist_ok=True)
|
||||
|
||||
for name, config in partition_config.items():
|
||||
definition = Path(f"{temp}/{name}.conf")
|
||||
os.chmod(definition, 0o644)
|
||||
definition = target_dir.joinpath(f"{name}.conf")
|
||||
definition.chmod(0o644)
|
||||
|
||||
contents = config.get("contents")
|
||||
add_contents_to_definition(definition, contents)
|
||||
|
@ -106,7 +105,7 @@ def main() -> None:
|
|||
strip_nix_store_prefix = config.get("stripStorePaths")
|
||||
add_closure_to_definition(definition, closure, strip_nix_store_prefix)
|
||||
|
||||
print(temp)
|
||||
print(target_dir.absolute())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue