]> git.scottworley.com Git - pinch/commitdiff
Write back to config file
authorScott Worley <scottworley@scottworley.com>
Fri, 10 Apr 2020 03:21:15 +0000 (20:21 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 10 Apr 2020 03:22:08 +0000 (20:22 -0700)
pinch.py

index 0eafb90814516f31b9f17d5c0da1d29c8f0378d0..dd707180d0ff474a2af30d649a98a44c80be32ca 100644 (file)
--- a/pinch.py
+++ b/pinch.py
@@ -27,6 +27,7 @@ Digest32 = NewType('Digest32', str)
 
 
 class ChannelTableEntry(types.SimpleNamespace):
 
 
 class ChannelTableEntry(types.SimpleNamespace):
+    absolute_url: str
     digest: Digest16
     file: str
     size: int
     digest: Digest16
     file: str
     size: int
@@ -200,8 +201,10 @@ def fetch_with_nix_prefetch_url(
 def fetch_resources(v: Verification, channel: Channel) -> None:
     for resource in ['git-revision', 'nixexprs.tar.xz']:
         fields = channel.table[resource]
 def fetch_resources(v: Verification, channel: Channel) -> None:
     for resource in ['git-revision', 'nixexprs.tar.xz']:
         fields = channel.table[resource]
-        url = urllib.parse.urljoin(channel.forwarded_url, fields.url)
-        fields.file = fetch_with_nix_prefetch_url(v, url, fields.digest)
+        fields.absolute_url = urllib.parse.urljoin(
+            channel.forwarded_url, fields.url)
+        fields.file = fetch_with_nix_prefetch_url(
+            v, fields.absolute_url, fields.digest)
     v.status('Verifying git commit on main page matches git commit in table')
     v.result(
         open(
     v.status('Verifying git commit on main page matches git commit in table')
     v.result(
         open(
@@ -370,7 +373,11 @@ def main(argv: List[str]) -> None:
         fetch_resources(v, channel)
         git_fetch(v, channel)
         check_channel_contents(v, channel)
         fetch_resources(v, channel)
         git_fetch(v, channel)
         check_channel_contents(v, channel)
-        print(channel)
+        config[section]['git_rev'] = channel.git_revision
+        config[section]['tarball_url'] = channel.table['nixexprs.tar.xz'].absolute_url
+        config[section]['tarball_sha256'] = channel.table['nixexprs.tar.xz'].digest
+    with open(argv[1], 'w') as configfile:
+        config.write(configfile)
 
 
 main(sys.argv)
 
 
 main(sys.argv)