amprolla

devuan's apt repo merger
git clone git://parazyd.org/amprolla.git
Log | Files | Refs | README | LICENSE

commit 66f0a884b01c8175f5f33a9c320eedcc9b8d195f
parent 3dfb1c87a27fe13183bd8cf7ed1c891adc172b1c
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:
Mamprolla_update.py | 1+
Mlib/parse.py | 5+++--
Mlib/release.py | 10+++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/amprolla_update.py b/amprolla_update.py @@ -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 diff --git a/lib/parse.py b/lib/parse.py @@ -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 = {} @@ -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 diff --git a/lib/release.py b/lib/release.py @@ -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): @@ -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') @@ -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()