timplement reusing of old checksums - amprolla - devuan's apt repo merger HTML git clone git://parazyd.org/amprolla.git DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 66f0a884b01c8175f5f33a9c320eedcc9b8d195f DIR parent 3dfb1c87a27fe13183bd8cf7ed1c891adc172b1c HTML Author: parazyd <parazyd@dyne.org> Date: Wed, 8 Nov 2017 21:38:29 +0100 implement reusing of old checksums If an updated Release file changes only the date, and none if its checksums have changed. This makes incremental updates faster and saves resources. Diffstat: M amprolla_update.py | 1 + M lib/parse.py | 5 +++-- M lib/release.py | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) --- DIR diff --git a/amprolla_update.py b/amprolla_update.py t@@ -43,6 +43,7 @@ def perform_update(suite, paths): info('Checking for updates in %s' % suite) # print(paths) globalvars.suite = suite + globalvars.rehash = False needsmerge = {} needsmerge['downloads'] = [] # all files that have to be downloaded DIR diff --git a/lib/parse.py b/lib/parse.py t@@ -33,7 +33,7 @@ def get_date(relfile): def parse_release(reltext): """ Parses a Release file and returns a dict of the files we need - key = filename, value = sha256 checksum + key = filename, value = tuple of sha256sum and file size """ hashes = {} t@@ -43,8 +43,9 @@ def parse_release(reltext): for line in contents: if sha256 is True and line != '': filename = line.split()[2] + filesize = line.split()[1] checksum = line.split()[0] - hashes[filename] = checksum + hashes[filename] = (checksum, filesize) elif line.startswith('SHA256:'): sha256 = True DIR diff --git a/lib/release.py b/lib/release.py t@@ -14,7 +14,7 @@ import lib.globalvars as globalvars from lib.config import (checksums, distrolabel, gpgdir, release_aliases, release_keys, signingkey) from lib.log import info -from lib.parse import parse_release_head +from lib.parse import parse_release_head, parse_release def rewrite_release_head(headers): t@@ -49,6 +49,10 @@ def write_release(oldrel, newrel, filelist, r, sign=True, rewrite=True): prettyt1 = t1.strftime('%a, %d %b %Y %H:%M:%S UTC') # prettyt2 = t2.strftime('%a, %d %b %Y %H:%M:%S UTC') + # this holds our local data in case we don't want to rehash files + local_rel = open(newrel).read() + local_rel = parse_release(local_rel) + old = open(oldrel).read() new = open(newrel, 'w') t@@ -66,6 +70,10 @@ def write_release(oldrel, newrel, filelist, r, sign=True, rewrite=True): if globalvars.rehash: rehash_release(filelist, new, r) + else: + info('Reusing old checksums') + for i, j in local_rel.items(): + new.write(' %s %8s %s\n' % (j[0], j[1], i)) new.close()