summary refs log tree commit diff
path: root/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2017-09-17 09:58:02 +0200
committerMichael Raskin <7c6f434c@mail.ru>2017-09-17 09:58:35 +0200
commit08b1bc9fcb72961eefb1f25673f353ad3705a2ee (patch)
tree7b48acbb749c50582fbef9087c0f3fc0996bc8e3 /pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py
parent02f439d062d05785d7bdf47c8a275b6bfb604ae1 (diff)
downloadnixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar.gz
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar.bz2
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar.lz
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar.xz
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.tar.zst
nixlib-08b1bc9fcb72961eefb1f25673f353ad3705a2ee.zip
libreoffice-fresh: 5.3.1.2 -> 5.4.1.2; fixes #29379
Diffstat (limited to 'pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py')
-rwxr-xr-xpkgs/applications/office/libreoffice/generate-libreoffice-srcs.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py b/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py
index f77829da3400..dcda0ff782dc 100755
--- a/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py
+++ b/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py
@@ -22,12 +22,19 @@ def main():
     for x in packages:
 
         md5 = x['md5']
+        upstream_sha256 = x['sha256']
+        if upstream_sha256:
+            hash = upstream_sha256
+            hashtype = 'sha256'
+        else:
+            hash = md5
+            hashtype = 'md5'
         tarball = x['tarball']
 
         url = construct_url(x)
         print('url: {}'.format(url), file=sys.stderr)
 
-        path = download(url, tarball, md5)
+        path = download(url, tarball, hash, hashtype)
         print('path: {}'.format(path), file=sys.stderr)
 
         sha256 = get_sha256(path)
@@ -38,7 +45,7 @@ def main():
         print('    url = "{}";'.format(url))
         print('    sha256 = "{}";'.format(sha256))
         print('    md5 = "{}";'.format(md5))
-        print('    md5name = "{}-{}";'.format(md5,tarball))
+        print('    md5name = "{}-{}";'.format(md5 or upstream_sha256,tarball))
         print('  }')
 
     print(']')
@@ -53,9 +60,9 @@ def construct_url(x):
             x.get('subdir', ''), x['md5'], x['tarball'])
 
 
-def download(url, name, md5):
-    cmd = ['nix-prefetch-url', url, md5, '--print-path',
-           '--type', 'md5', '--name', name]
+def download(url, name, hash, hashtype):
+    cmd = ['nix-prefetch-url', url, hash, '--print-path',
+           '--type', hashtype, '--name', name]
     proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True,
                           universal_newlines=True)
     return proc.stdout.split('\n')[1].strip()
@@ -114,7 +121,7 @@ def get_packages_from_download_list():
         Groups lines according to their order within the file, to support
         packages that are listed in `download.lst` more than once.
         """
-        keys = ['tarball', 'md5', 'brief']
+        keys = ['tarball', 'md5', 'sha256', 'brief']
         a = {k: [x for x in xs if k in x['attrs']] for k in keys}
         return zip(*[a[k] for k in keys])
 
@@ -220,7 +227,7 @@ def sub_symbols(xs):
 
     def get_value(k):
         x = symbols.get(k)
-        return x['value'] if x is not None else None
+        return x['value'] if x is not None else ''
 
     for x in xs:
         yield dict_merge([{'value': sub_str(x['value'], get_value)},
@@ -249,7 +256,7 @@ def interpret(x):
     Output: One of 1. Dict with keys 'name' and 'attrs'
                    2. 'unrecognized' (if interpretation failed)
     """
-    for f in [interpret_md5, interpret_tarball_with_md5, interpret_tarball]:
+    for f in [interpret_md5, interpret_sha256, interpret_tarball_with_md5, interpret_tarball]:
         result = f(x)
         if result is not None:
             return result
@@ -267,8 +274,14 @@ def interpret_md5(x):
 
     if match:
         return {'name': match.group(1),
-                'attrs': {'md5': x['value']}}
+                'attrs': {'md5': x['value'], 'sha256': ''}}
+
+def interpret_sha256(x):
+    match = re.match('^(.*)_SHA256SUM$', x['key'])
 
+    if match:
+        return {'name': match.group(1),
+                'attrs': {'sha256': x['value'], 'md5': ''}}
 
 def interpret_tarball(x):
     """
@@ -301,6 +314,7 @@ def interpret_tarball_with_md5(x):
         return {'name': match['key'].group(1),
                 'attrs': {'tarball': match['value'].group('tarball'),
                           'md5': match['value'].group('md5'),
+                          'sha256': '',
                           'brief': False}}