X-Git-Url: http://git.scottworley.com/pinch/blobdiff_plain/9ee71b8de80b57ed5851203b581ac09b3792d2c8..96063a5164fcd9e6ec72c1912d41d77856fa980f:/pinch.py?ds=sidebyside diff --git a/pinch.py b/pinch.py index b5e3b81..8c9e976 100644 --- a/pinch.py +++ b/pinch.py @@ -127,6 +127,15 @@ def copy_to_nix_store(v: Verification, filename: str) -> str: return process.stdout.decode().strip() # type: ignore # (for old mypy) +def symlink_archive(v: Verification, path: str) -> str: + with tempfile.TemporaryDirectory() as td: + archive_filename = os.path.join(td, 'link.tar.gz') + os.symlink(path, os.path.join(td, 'link')) + with tarfile.open(archive_filename, mode='x:gz') as t: + t.add(os.path.join(td, 'link'), arcname='link') + return copy_to_nix_store(v, archive_filename) + + class AliasSearchPath(NamedTuple): alias_of: str @@ -143,12 +152,7 @@ class SymlinkSearchPath(NamedTuple): return SymlinkPin() def fetch(self, v: Verification, _: Pin) -> str: - with tempfile.TemporaryDirectory() as td: - archive_filename = os.path.join(td, 'link.tar.gz') - os.symlink(self.path, os.path.join(td, 'link')) - with tarfile.open(archive_filename, mode='x:gz') as t: - t.add(os.path.join(td, 'link'), arcname='link') - return copy_to_nix_store(v, archive_filename) + return symlink_archive(v, self.path) class GitSearchPath(NamedTuple):