From ccd328ec9b7d207cf4ab354cc4b3b03284191770 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 11 Aug 2018 19:53:31 +0300 Subject: Change: build for a specific distribution --- ick_helpers.py | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/ick_helpers.py b/ick_helpers.py index e35078d..9d64e62 100644 --- a/ick_helpers.py +++ b/ick_helpers.py @@ -6,6 +6,7 @@ import glob +import json import os import re import sys @@ -139,7 +140,6 @@ class DebianReleaseBuilder: self.results = resultsdir def build(self, tag, distribution): - debug('Building release from tag', tag, 'for', distribution) cwd = os.getcwd() self.checkout(tag) @@ -175,6 +175,7 @@ class DebianReleaseBuilder: debug() def checkout(self, tag): + self.ex.run('git', 'reset', '--hard', check=False) self.ex.run('git', 'checkout', 'master', check=False) self.ex.run('git', 'branch', '-d', '__ickbuild', check=False) self.ex.run('git', 'checkout', '-b', '__ickbuild', tag) @@ -231,18 +232,29 @@ class DebianReleaseBuilder: os.remove(filename) -known_tags = '.known_tags' +class KnownTags: -def get_known_tags(): - if os.path.exists(known_tags): - with open(known_tags) as f: - return [line.strip() for line in f.readlines()] - return [] + filename = '.known_tags' + def __init__(self): + self.known = {} + if os.path.exists(self.filename): + with open(self.filename) as f: + self.known = json.load(f) -def remember_tag(tag): - with open(known_tags, 'a') as f: - f.write('{}\n'.format(tag)) + def is_empty(self): + return len(self.known) == 0 + + def is_known(self, tag, distribution): + dists = self.known.get(tag, []) + return distribution in dists + + def remember(self, tag, distribution): + dists = self.known.get(tag, []) + if distribution not in dists: + self.known[tag] = dists + [distribution] + with open(self.filename, 'w') as f: + json.dump(self.known, f, indent=4) def find_upstream_dirs(sources): @@ -254,15 +266,21 @@ def find_upstream_dirs(sources): def build_debian_releases(sources, distribution, resultsdir): - known_tags = get_known_tags() - debug('KNOWN:', known_tags) + known = KnownTags() + first_build = known.is_empty() dirnames = find_upstream_dirs(sources) for dirname in dirnames: ex = Exec(dirname) project = ex.get_debian_source_package() tags = ex.find_release_tags(project) + debug('release tags:', tags) builder = DebianReleaseBuilder(ex, resultsdir) for tag in tags: - if known_tags and tag not in known_tags: + if first_build: + debug('First build, not building', tag, 'for', distribution) + elif not known.is_known(tag, distribution): + debug('Building tag', tag, 'for', distribution) builder.build(tag, distribution) - remember_tag(tag) + else: + debug('Already built, not building', tag, 'for', distribution) + known.remember(tag, distribution) -- cgit v1.2.1