diff options
author | Michael Schroeder <mls@suse.de> | 2012-10-29 15:55:57 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-10-29 15:55:57 +0100 |
commit | 50ada341c2ef6d348c59b4478fdfacf956369f69 (patch) | |
tree | e56701f31d9f964131a633a00b00b1e612d70f4d /examples/pysolv | |
parent | d16e24a7df388dc2e8c2d373446d93f09ef3d517 (diff) | |
download | libsolv-50ada341c2ef6d348c59b4478fdfacf956369f69.tar.gz libsolv-50ada341c2ef6d348c59b4478fdfacf956369f69.tar.bz2 libsolv-50ada341c2ef6d348c59b4478fdfacf956369f69.zip |
unify cookie generation for solv/pysolv/rbsolv/p5solv
Diffstat (limited to 'examples/pysolv')
-rwxr-xr-x | examples/pysolv | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/examples/pysolv b/examples/pysolv index f529d5d..479aba2 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -53,9 +53,22 @@ def calc_cookie_file(filename): def calc_cookie_fp(fp): chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256) + chksum.add("1.1"); chksum.add_fp(fp) return chksum.raw() +def calc_cookie_ext(f, cookie): + chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256) + chksum.add("1.1"); + chksum.add(cookie) + if f: + chksum.add_fstat(f.fileno()) + extcookie = chksum.raw() + # compatibility to c code + if ord(extcookie[0]) == 0: + extcookie[0] = chr(1) + return extcookie + class repo_generic(dict): def __init__(self, name, type, attribs = {}): for k in attribs: @@ -225,21 +238,6 @@ class repo_generic(dict): return False return True - def genextcookie(self, f): - chksum = solv.Chksum(solv.REPOKEY_TYPE_SHA256) - chksum.add(self['cookie']) - if f: - stat = os.fstat(f.fileno()) - chksum.add(str(stat[ST_DEV])) - chksum.add(str(stat[ST_INO])) - chksum.add(str(stat[ST_SIZE])) - chksum.add(str(stat[ST_MTIME])) - extcookie = chksum.raw() - # compatibility to c code - if ord(extcookie[0]) == 0: - extcookie[0] = chr(1) - self['extcookie'] = extcookie - def writecachedrepo(self, ext, info=None): try: if not os.path.isdir("/var/cache/solv"): @@ -255,7 +253,7 @@ class repo_generic(dict): self.handle.write_first_repodata(f) if self.type != 'system' and not ext: if 'extcookie' not in self: - self.genextcookie(f) + self['extcookie'] = calc_cookie_ext(f, self['cookie']) f.write(self['extcookie']) if not ext: f.write(self['cookie']) |