[ostree] ostbuild: Fix circular dependency between resolve and git-mirror
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] ostbuild: Fix circular dependency between resolve and git-mirror
- Date: Wed, 6 Jun 2012 20:41:48 +0000 (UTC)
commit 2c385c00780da2ffba9106993aefc1b3a757f03e
Author: Colin Walters <walters verbum org>
Date: Wed Jun 6 12:56:48 2012 -0400
ostbuild: Fix circular dependency between resolve and git-mirror
git-mirror was looking for the latest snapshot, which we don't
have until we resolve.
This leads to some code duplication.
src/ostbuild/pyostbuild/buildutil.py | 36 ++++++++++++++++++++++-
src/ostbuild/pyostbuild/builtin_build.py | 1 +
src/ostbuild/pyostbuild/builtin_git_mirror.py | 9 +++++-
src/ostbuild/pyostbuild/builtin_resolve.py | 39 ++-----------------------
4 files changed, 47 insertions(+), 38 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/buildutil.py b/src/ostbuild/pyostbuild/buildutil.py
index 9bddeb1..94ad63b 100755
--- a/src/ostbuild/pyostbuild/buildutil.py
+++ b/src/ostbuild/pyostbuild/buildutil.py
@@ -22,6 +22,7 @@ import tempfile
import StringIO
from . import ostbuildrc
+from .ostbuildlog import log, fatal
from .subprocess_helpers import run_sync_get_output
BUILD_ENV = {
@@ -47,7 +48,8 @@ def parse_src_key(srckey):
def get_mirrordir(mirrordir, keytype, uri, prefix=''):
- assert keytype == 'git'
+ if keytype != 'git':
+ fatal("Unhandled keytype '%s' for uri '%s'" % (keytype, uri))
parsed = urlparse.urlsplit(uri)
return os.path.join(mirrordir, prefix, keytype, parsed.scheme, parsed.netloc, parsed.path[1:])
@@ -151,3 +153,35 @@ def get_base_user_chroot_args():
return args
+def resolve_component_meta(snapshot, component_meta):
+ result = dict(component_meta)
+ orig_src = component_meta['src']
+
+ did_expand = False
+ for (vcsprefix, expansion) in snapshot['vcsconfig'].iteritems():
+ prefix = vcsprefix + ':'
+ if orig_src.startswith(prefix):
+ result['src'] = expansion + orig_src[len(prefix):]
+ did_expand = True
+ break
+
+ name = component_meta.get('name')
+ if name is None:
+ if did_expand:
+ src = orig_src
+ idx = src.rindex(':')
+ name = src[idx+1:]
+ else:
+ src = result['src']
+ idx = src.rindex('/')
+ name = src[idx+1:]
+ if name.endswith('.git'):
+ name = name[:-4]
+ name = name.replace('/', '-')
+ result['name'] = name
+
+ branch_or_tag = result.get('branch') or result.get('tag')
+ if branch_or_tag is None:
+ result['branch'] = 'master'
+
+ return result
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index 58739be..225584b 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -167,6 +167,7 @@ class OstbuildBuild(builtins.Builtin):
f = os.fdopen(fd, 'w')
for path in setuid_files:
f.write('+2048 ' + path)
+ f.write('\n')
f.close()
args.append('--statoverride=' + statoverride_path)
diff --git a/src/ostbuild/pyostbuild/builtin_git_mirror.py b/src/ostbuild/pyostbuild/builtin_git_mirror.py
index 2b78bcf..6ecdafa 100755
--- a/src/ostbuild/pyostbuild/builtin_git_mirror.py
+++ b/src/ostbuild/pyostbuild/builtin_git_mirror.py
@@ -39,6 +39,7 @@ class OstbuildGitMirror(builtins.Builtin):
def execute(self, argv):
parser = argparse.ArgumentParser(description=self.short_description)
parser.add_argument('--prefix')
+ parser.add_argument('--manifest')
parser.add_argument('--src-snapshot')
parser.add_argument('--start-at',
help="Start at the given component")
@@ -52,7 +53,13 @@ class OstbuildGitMirror(builtins.Builtin):
args = parser.parse_args(argv)
self.parse_config()
- self.parse_snapshot(args.prefix, args.src_snapshot)
+ if args.manifest:
+ self.snapshot = json.load(open(args.manifest))
+ components = map(lambda x: buildutil.resolve_component_meta(self.snapshot, x), self.snapshot['components'])
+ self.snapshot['components'] = components
+ self.snapshot['patches'] = buildutil.resolve_component_meta(self.snapshot, self.snapshot['patches'])
+ else:
+ self.parse_snapshot(args.prefix, args.src_snapshot)
if len(args.components) == 0:
components = []
diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py
index d97150c..5fe7be5 100755
--- a/src/ostbuild/pyostbuild/builtin_resolve.py
+++ b/src/ostbuild/pyostbuild/builtin_resolve.py
@@ -40,39 +40,6 @@ class OstbuildResolve(builtins.Builtin):
def __init__(self):
builtins.Builtin.__init__(self)
- def _resolve_component_meta(self, component_meta):
- result = dict(component_meta)
- orig_src = component_meta['src']
-
- did_expand = False
- for (vcsprefix, expansion) in self.snapshot['vcsconfig'].iteritems():
- prefix = vcsprefix + ':'
- if orig_src.startswith(prefix):
- result['src'] = expansion + orig_src[len(prefix):]
- did_expand = True
- break
-
- name = component_meta.get('name')
- if name is None:
- if did_expand:
- src = orig_src
- idx = src.rindex(':')
- name = src[idx+1:]
- else:
- src = result['src']
- idx = src.rindex('/')
- name = src[idx+1:]
- if name.endswith('.git'):
- name = name[:-4]
- name = name.replace('/', '-')
- result['name'] = name
-
- branch_or_tag = result.get('branch') or result.get('tag')
- if branch_or_tag is None:
- result['branch'] = 'master'
-
- return result
-
def execute(self, argv):
parser = argparse.ArgumentParser(description=self.short_description)
parser.add_argument('--manifest', required=True)
@@ -87,7 +54,7 @@ class OstbuildResolve(builtins.Builtin):
self.snapshot = json.load(open(args.manifest))
self.prefix = self.snapshot['prefix']
- components = map(self._resolve_component_meta, self.snapshot['components'])
+ components = map(lambda x: buildutil.resolve_component_meta(self.snapshot, x), self.snapshot['components'])
self.snapshot['components'] = components
unique_component_names = set()
@@ -98,14 +65,14 @@ class OstbuildResolve(builtins.Builtin):
fatal("Duplicate component name '%s'" % (name, ))
unique_component_names.add(name)
- global_patches_meta = self._resolve_component_meta(self.snapshot['patches'])
+ global_patches_meta = buildutil.resolve_component_meta(self.snapshot, self.snapshot['patches'])
self.snapshot['patches'] = global_patches_meta
(keytype, uri) = vcs.parse_src_key(global_patches_meta['src'])
mirrordir = vcs.ensure_vcs_mirror(self.mirrordir, keytype, uri, global_patches_meta['branch'])
if args.fetch_patches:
run_sync(['git', 'fetch'], cwd=mirrordir, log_initiation=False)
- git_mirror_args = ['ostbuild', 'git-mirror']
+ git_mirror_args = ['ostbuild', 'git-mirror', '--manifest=' + args.manifest]
if args.fetch:
git_mirror_args.append('--fetch')
run_sync(git_mirror_args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]