Commit 4072533d authored by Paul Sherwood's avatar Paul Sherwood

Add support for Definitions VERSION 8

YBD doesn't process VERSION file directly - the aim so far is to
handle all versions as they arrive. This commit has been
tested on ci.morph, both with and without the VERSION 8 migration
parent 2d7f4c9c
......@@ -127,7 +127,7 @@ def run_build(defs, this):
if this.get('repo'):
repos.checkout(this['name'], this['repo'], this['ref'], this['build'])
this['SOURCE_DATE_EPOCH'] = repos.source_date_epoch(this['build'])
get_build_commands(defs, this)
......@@ -59,7 +59,7 @@ def cache_key(defs, this):
for factor in definition.get('contents', []):
hash_factors[factor] = cache_key(defs, factor)
for factor in ['tree'] + defs.defaults.build_steps:
for factor in ['tree', 'submodules'] + defs.defaults.build_steps:
if definition.get(factor):
hash_factors[factor] = definition[factor]
......@@ -28,7 +28,6 @@ import app
import utils
import tempfile
if sys.version_info.major == 2:
# For compatibility with Python 2.
from ConfigParser import RawConfigParser
......@@ -164,7 +163,17 @@ def update_mirror(name, repo, gitdir):
app.exit(name, 'ERROR: git update mirror failed', repo)
def checkout(name, repo, ref, checkout):
def checkout(this):
_checkout(this['name'], this['repo'], this['ref'], this['build'])
with app.chdir(this['build']):
if os.path.exists('.gitmodules') or this.get('submodules'):
def _checkout(name, repo, ref, checkout):
gitdir = os.path.join(app.config['gits'], get_repo_name(repo))
if not os.path.exists(gitdir):
mirror(name, repo)
......@@ -189,11 +198,6 @@ def checkout(name, repo, ref, checkout):
app.log(name, 'Git checkout %s in %s' % (repo, checkout))
app.log(name, 'Upstream version %s' % get_version(checkout, ref))
if os.path.exists('.gitmodules'):
checkout_submodules(name, ref)
def source_date_epoch(checkout):
with app.chdir(checkout):
......@@ -228,8 +232,8 @@ def extract_commit(name, repo, ref, target_dir):
def checkout_submodules(name, ref):
app.log(name, 'Git submodules')
def checkout_submodules(this):
app.log(this, 'Checking git submodules')
with open('.gitmodules', "r") as gitfile:
# drop indentation in sections, as RawConfigParser cannot handle it
content = '\n'.join([l.strip() for l in])
......@@ -240,13 +244,18 @@ def checkout_submodules(name, ref):
for section in parser.sections():
# validate section name against the 'submodule "foo"' pattern
submodule = re.sub(r'submodule "(.*)"', r'\1', section)
url = parser.get(section, 'url')
path = parser.get(section, 'path')
url = this['submodules'][path]['url']
app.log(this, 'Processing submodule %s from' % path, url)
url = parser.get(section, 'url')
app.log(this, 'WARNING: fallback to submodule %s from' % path, url)
# list objects in the parent repo tree to find the commit
# object that corresponds to the submodule
commit = check_output(['git', 'ls-tree', ref, path])
commit = check_output(['git', 'ls-tree', this['ref'], path])
# read the commit hash from the output
fields = commit.split()
......@@ -258,11 +267,11 @@ def checkout_submodules(name, ref):
raise Exception
fulldir = os.path.join(os.getcwd(), path)
checkout(name, url, submodule_commit, fulldir)
_checkout(this['name'], url, submodule_commit, fulldir)
app.log(name, 'Skipping submodule %s, not a commit:' % path,
app.log(this, 'Skipping submodule %s, not a commit:' % path,
app.exit(name, "ERROR: git submodules problem")
app.exit(this, "ERROR: git submodules problem", "")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment