summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-08-11 19:53:31 +0300
committerLars Wirzenius <liw@liw.fi>2018-08-11 19:53:31 +0300
commitccd328ec9b7d207cf4ab354cc4b3b03284191770 (patch)
tree3131deb0a07fd151715d41685ec93fc56caec086
parent7c1242e82b621a51bd89622b1eed01250cbac25e (diff)
downloadick-helpers-ccd328ec9b7d207cf4ab354cc4b3b03284191770.tar.gz
Change: build for a specific distribution
-rw-r--r--ick_helpers.py46
1 files 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)