def cache_key(this): defs = definitions.Definitions() definition = defs.get(this) if definition.get('cache'): return definition['cache'] if definition.get('repo') and not definition.get('tree'): definition['tree'] = repos.get_tree(definition) hash_factors = {'arch': app.settings['arch']} for factor in ['build-depends', 'contents']: for it in definition.get(factor, []): component = defs.get(it) if definition['name'] == component['name']: app.log(this, 'ERROR: recursion loop for', component['name']) raise SystemExit hash_factors[component['name']] = cache_key(component) for factor in ['tree'] + buildsystem.build_steps: if definition.get(factor): hash_factors[factor] = definition[factor] result = json.dumps(hash_factors, sort_keys=True).encode('utf-8') safename = definition['name'].replace('/', '-') definition['cache'] = safename + "@" + hashlib.sha256(result).hexdigest() app.log(definition, 'Cache_key is', definition['cache']) return definition['cache']
def cache_key(defs, this): definition = defs.get(this) if definition is None: app.exit(this, 'ERROR: No definition found for', this) if definition.get('cache') == 'calculating': app.exit(this, 'ERROR: recursion loop for', this) if definition.get('cache'): return definition['cache'] if definition.get('arch', app.config['arch']) != app.config['arch']: return False definition['cache'] = 'calculating' if definition.get('repo') and not definition.get('tree'): definition['tree'] = repos.get_tree(definition) hash_factors = {'arch': app.config['arch']} for factor in definition.get('build-depends', []): hash_factors[factor] = cache_key(defs, factor) for factor in definition.get('contents', []): hash_factors[factor] = cache_key(defs, factor) for factor in ['tree'] + defs.defaults.build_steps: if definition.get(factor): hash_factors[factor] = definition[factor] def hash_system_recursively(system): factor = system.get('path', 'BROKEN') hash_factors[factor] = cache_key(defs, factor) for subsystem in system.get('subsystems', []): hash_system_recursively(subsystem) if definition.get('kind') == 'cluster': for system in definition.get('systems', []): hash_system_recursively(system) result = json.dumps(hash_factors, sort_keys=True).encode('utf-8') safename = definition['name'].replace('/', '-') definition['cache'] = safename + "." + hashlib.sha256(result).hexdigest() app.config['total'] += 1 if not get_cache(defs, this) and definition.get('kind') != 'cluster': app.config['tasks'] += 1 app.log(definition, 'Cache_key is', definition['cache']) # If you want to catalog the artifacts for a system, do so if app.config.get('cache-log'): cache_list[definition.get('name')] = definition.get('cache') if definition.get('kind') == 'system': with open(app.config.get('cache-log'), 'w') as f: f.write(json.dumps(cache_list, indent=4)) app.log('cache-log', 'cache logged to', app.config.get('cache-log')) return definition['cache']
def cache_key(dn): if dn is None: app.log(dn, 'No definition found for', dn, exit=True) if type(dn) is not dict: dn = app.defs.get(dn) if dn.get('cache') == 'calculating': app.log(dn, 'Recursion loop for', dn, exit=True) if dn.get('cache'): return dn['cache'] if dn.get('arch', app.config['arch']) != app.config['arch']: if 'tried' not in dn: dn['tried'] = True app.log(dn, 'No cache_key for arch %s mismatch' % dn['arch'], app.config['arch']) return False dn['cache'] = 'calculating' key = 'no-build' if app.config.get('mode', 'normal') in ['keys-only', 'normal']: if dn.get('repo'): if not dn.get('tree'): dn['tree'], dn['sha'] = get_tree(dn) if not dn.get('repourl'): dn['repourl'] = get_repo_url(dn.get('repo')) factors = hash_factors(dn) factors = json.dumps(factors, sort_keys=True).encode('utf-8') key = hashlib.sha256(factors).hexdigest() dn['cache'] = dn['name'] + "." + key app.config['total'] += 1 x = 'x' if not get_cache(dn): x = ' ' app.config['tasks'] += 1 if dn.get('kind', 'chunk') == 'chunk': app.config['chunks'] += 1 if dn.get('kind', 'chunk') == 'stratum': app.config['strata'] += 1 if dn.get('kind', 'chunk') == 'system': app.config['systems'] += 1 app.log('CACHE-KEYS', '[%s]' % x, dn['cache']) if app.config.get('manifest', False): update_manifest(dn, app.config['manifest']) if 'keys' in app.config: app.config['keys'] += [dn['cache']] return dn['cache']
def cache_key(dn): if dn is None: app.log(dn, 'No definition found for', dn, exit=True) if type(dn) is not dict: dn = app.defs.get(dn) if dn.get('cache') == 'calculating': app.log(dn, 'Recursion loop for', dn, exit=True) if dn.get('cache'): return dn['cache'] if dn.get('arch', app.config['arch']) != app.config['arch']: if 'tried' not in dn: dn['tried'] = True app.log(dn, 'No cache_key for arch %s mismatch' % dn['arch'], app.config['arch']) return False dn['cache'] = 'calculating' key = 'no-build' if app.config.get('mode', 'normal') in ['keys-only', 'normal']: if dn.get('repo') and not dn.get('tree'): dn['tree'] = get_tree(dn) factors = hash_factors(dn) factors = json.dumps(factors, sort_keys=True).encode('utf-8') key = hashlib.sha256(factors).hexdigest() dn['cache'] = dn['name'] + "." + key app.config['total'] += 1 x = 'x' if not get_cache(dn): x = ' ' app.config['tasks'] += 1 if dn.get('kind', 'chunk') == 'chunk': app.config['chunks'] += 1 if dn.get('kind', 'chunk') == 'stratum': app.config['strata'] += 1 if dn.get('kind', 'chunk') == 'system': app.config['systems'] += 1 app.log('CACHE-KEYS', '[%s]' % x, dn['cache']) if app.config.get('manifest', False): update_manifest(dn, app.config['manifest']) if 'keys' in app.config: app.config['keys'] += [dn['cache']] return dn['cache']
def cache_key(defs, this): definition = defs.get(this) if definition is None: app.exit(this, "ERROR: No definition found for", this) if definition.get("cache") == "calculating": app.exit(this, "ERROR: recursion loop for", this) if definition.get("cache"): return definition["cache"] definition["cache"] = "calculating" if definition.get("repo") and not definition.get("tree"): definition["tree"] = repos.get_tree(definition) hash_factors = {"arch": app.config["arch"]} for factor in definition.get("build-depends", []): hash_factors[factor] = cache_key(defs, factor) for factor in definition.get("contents", []): hash_factors[factor] = cache_key(defs, factor) for factor in ["tree"] + defs.defaults.build_steps: if definition.get(factor): hash_factors[factor] = definition[factor] def hash_system_recursively(system): factor = system.get("path", "BROKEN") hash_factors[factor] = cache_key(defs, factor) for subsystem in system.get("subsystems", []): hash_system_recursively(subsystem) if definition.get("kind") == "cluster": for system in definition.get("systems", []): hash_system_recursively(system) result = json.dumps(hash_factors, sort_keys=True).encode("utf-8") safename = definition["name"].replace("/", "-") definition["cache"] = safename + "." + hashlib.sha256(result).hexdigest() app.config["total"] += 1 if not get_cache(defs, this): app.config["tasks"] += 1 app.log(definition, "Cache_key is", definition["cache"]) return definition["cache"]
def cache_key(defs, this): definition = defs.get(this) if definition is None: app.exit(this, 'ERROR: No definition found for', this) if definition.get('cache') == 'calculating': app.exit(this, 'ERROR: recursion loop for', this) if definition.get('cache'): return definition['cache'] definition['cache'] = 'calculating' if definition.get('repo') and not definition.get('tree'): definition['tree'] = repos.get_tree(definition) hash_factors = {'arch': app.config['arch']} for factor in definition.get('build-depends', []): hash_factors[factor] = cache_key(defs, factor) for factor in definition.get('contents', []): hash_factors[factor] = cache_key(defs, factor) for factor in ['tree'] + defs.defaults.build_steps: if definition.get(factor): hash_factors[factor] = definition[factor] def hash_system_recursively(system): factor = system.get('path', 'BROKEN') hash_factors[factor] = cache_key(defs, factor) for subsystem in system.get('subsystems', []): hash_system_recursively(subsystem) if definition.get('kind') == 'cluster': for system in definition.get('systems', []): hash_system_recursively(system) result = json.dumps(hash_factors, sort_keys=True).encode('utf-8') safename = definition['name'].replace('/', '-') definition['cache'] = safename + "." + hashlib.sha256(result).hexdigest() app.config['total'] += 1 if not get_cache(defs, this): app.config['tasks'] += 1 app.log(definition, 'Cache_key is', definition['cache']) return definition['cache']
def cache_key(defs, this): definition = defs.get(this) if definition is None: app.exit(this, 'ERROR: No definition found for', this) if definition.get('cache') == 'calculating': app.exit(this, 'ERROR: recursion loop for', this) if definition.get('cache'): return definition['cache'] if definition.get('arch', app.config['arch']) != app.config['arch']: return False definition['cache'] = 'calculating' if definition.get('repo') and not definition.get('tree'): definition['tree'] = repos.get_tree(definition) factors = hash_factors(defs, definition) factors = json.dumps(factors, sort_keys=True).encode('utf-8') key = hashlib.sha256(factors).hexdigest() if app.config.get('mode', 'normal') == 'no-build': key = 'no-build' definition['cache'] = definition['name'] + "." + key app.config['total'] += 1 if not get_cache(defs, this): app.config['tasks'] += 1 app.log(definition, 'Cache_key is', definition['cache']) # If you want to catalog the artifacts for a system, do so if app.config.get('cache-log'): cache_list[definition.get('name')] = definition.get('cache') if definition.get('kind') == 'system': with open(app.config.get('cache-log'), 'w') as f: f.write(json.dumps(cache_list, indent=4)) app.log('cache-log', 'cache logged to', app.config.get('cache-log')) app.config['keys'] += [definition['cache']] return definition['cache']
def cache_key(defs, this): definition = defs.get(this) if definition is None: app.exit(this, 'ERROR: No definition found for', this) if definition.get('cache') == 'calculating': app.exit(this, 'ERROR: recursion loop for', this) if definition.get('cache'): return definition['cache'] if definition.get('arch', app.config['arch']) != app.config['arch']: return False definition['cache'] = 'calculating' key = 'no-build' if app.config.get('mode', 'normal') in ['keys-only', 'normal']: if definition.get('repo') and not definition.get('tree'): definition['tree'] = get_tree(definition) factors = hash_factors(defs, definition) factors = json.dumps(factors, sort_keys=True).encode('utf-8') key = hashlib.sha256(factors).hexdigest() definition['cache'] = definition['name'] + "." + key app.config['total'] += 1 x = 'x' if not get_cache(defs, this): x = ' ' app.config['tasks'] += 1 app.log('CACHE-KEYS', '[%s]' % x, definition['cache']) if app.config.get('manifest', False): update_manifest(defs, this, app.config['manifest']) if 'keys' in app.config: app.config['keys'] += [definition['cache']] return definition['cache']
def cache_key(this): defs = definitions.Definitions() definition = defs.get(this) if definition is None: app.exit(this, 'ERROR: No definition found for', this) if definition.get('cache'): return definition['cache'] if definition.get('repo') and not definition.get('tree'): definition['tree'] = repos.get_tree(definition) hash_factors = {'arch': app.settings['arch']} for factor in definition.get('build-depends', []): hash_factors[factor] = cache_key(factor) for factor in definition.get('contents', []): hash_factors[factor] = cache_key(factor) for factor in ['tree'] + buildsystem.build_steps: if definition.get(factor): hash_factors[factor] = definition[factor] if definition.get('kind') == 'cluster': for system in definition.get('systems', []): factor = system.get('path', 'BROKEN') hash_factors[factor] = cache_key(factor) for subsystem in system.get('subsystems', []): factor = subsystem.get('path', 'BROKEN') hash_factors[factor] = cache_key(factor) result = json.dumps(hash_factors, sort_keys=True).encode('utf-8') safename = definition['name'].replace('/', '-') definition['cache'] = safename + "." + hashlib.sha256(result).hexdigest() app.log(definition, 'Cache_key is', definition['cache']) return definition['cache']