[ostree/wip/ostbuild-v2] wip
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree/wip/ostbuild-v2] wip
- Date: Wed, 18 Apr 2012 19:16:17 +0000 (UTC)
commit acd38a1a8060cbf140dcdbbe675c5baf5c41229c
Author: Colin Walters <walters verbum org>
Date: Wed Apr 18 15:12:16 2012 -0400
wip
Makefile-ostbuild.am | 5 +-
src/ostbuild/pyostbuild/builtin_bin_to_src.py | 61 +++++++++++++
...uiltin_build.py => builtin_build_components.py} | 10 +-
src/ostbuild/pyostbuild/builtin_checkout.py | 2 +-
.../pyostbuild/builtin_chroot_compile_one.py | 1 -
.../pyostbuild/builtin_chroot_run_triggers.py | 47 ----------
src/ostbuild/pyostbuild/builtin_compose.py | 33 ++-----
src/ostbuild/pyostbuild/builtin_query_content.py | 94 --------------------
src/ostbuild/pyostbuild/builtin_resolve.py | 2 +-
src/ostbuild/pyostbuild/builtins.py | 2 +-
src/ostbuild/pyostbuild/main.py | 5 +-
11 files changed, 83 insertions(+), 179 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index 11e49e2..63e4127 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -22,13 +22,12 @@ bin_SCRIPTS += ostbuild
pyostbuilddir=$(libdir)/ostbuild/pyostbuild
pyostbuild_PYTHON = \
src/ostbuild/pyostbuild/buildutil.py \
- src/ostbuild/pyostbuild/builtin_build.py \
+ src/ostbuild/pyostbuild/builtin_bin_to_src.py \
+ src/ostbuild/pyostbuild/builtin_build_components.py \
src/ostbuild/pyostbuild/builtin_checkout.py \
src/ostbuild/pyostbuild/builtin_compose.py \
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py \
- src/ostbuild/pyostbuild/builtin_chroot_run_triggers.py \
src/ostbuild/pyostbuild/builtin_compile_one.py \
- src/ostbuild/pyostbuild/builtin_query_content.py \
src/ostbuild/pyostbuild/builtin_pull_components.py \
src/ostbuild/pyostbuild/builtin_resolve.py \
src/ostbuild/pyostbuild/builtin_replace_component.py \
diff --git a/src/ostbuild/pyostbuild/builtin_bin_to_src.py b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
new file mode 100755
index 0000000..1285c45
--- /dev/null
+++ b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
@@ -0,0 +1,61 @@
+# Copyright (C) 2011,2012 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# ostbuild-compile-one-make wraps systems that implement the GNOME build API:
+# http://people.gnome.org/~walters/docs/build-api.txt
+
+import os,sys,stat,subprocess,tempfile,re,shutil
+import argparse
+from StringIO import StringIO
+import json
+
+from . import builtins
+from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync, run_sync_get_output
+from . import buildutil
+
+class OstbuildBinToSrc(builtins.Builtin):
+ name = "bin-to-src"
+ short_description = "Turn a binary snapshot into a source snapshot"
+
+ def __init__(self):
+ builtins.Builtin.__init__(self)
+
+ def bin_snapshot_to_src(self, bin_snapshot):
+ src_snapshot = dict(bin_snapshot)
+
+ src_components = src_snapshot['components']
+ for name,component in bin_snapshot['components'].iteritems():
+ rev = component['ostree-revision']
+ meta = self.get_component_meta_from_revision(component['ostree-revision'])
+
+ src_components[name] = meta
+
+ return src_snapshot
+
+ def execute(self, argv):
+ parser = argparse.ArgumentParser(description=self.short_description)
+ parser.add_argument('--bin-snapshot')
+
+ args = parser.parse_args(argv)
+ self.parse_config()
+ self.parse_bin_snapshot(args.bin_snapshot)
+
+ snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
+ json.dump(snapshot, sys.stdout, indent=4, sort_keys=True)
+
+builtins.register(OstbuildBinToSrc)
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build_components.py
similarity index 97%
rename from src/ostbuild/pyostbuild/builtin_build.py
rename to src/ostbuild/pyostbuild/builtin_build_components.py
index aae6481..e85c309 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build_components.py
@@ -36,9 +36,9 @@ from . import vcs
class BuildOptions(object):
pass
-class OstbuildBuild(builtins.Builtin):
- name = "build"
- short_description = "Build artifacts and compose trees from snapshot"
+class OstbuildBuildComponents(builtins.Builtin):
+ name = "build-components"
+ short_description = "Build multiple components from given source snapshot"
def __init__(self):
builtins.Builtin.__init__(self)
@@ -171,7 +171,7 @@ class OstbuildBuild(builtins.Builtin):
bin_snapshot['components'] = new_components
path = self.get_bin_snapshot_db().store(bin_snapshot)
- print "Binary snapshot: %s" % (path, )
+ log("Binary snapshot: %s" % (path, ))
def execute(self, argv):
parser = argparse.ArgumentParser(description=self.short_description)
@@ -225,4 +225,4 @@ class OstbuildBuild(builtins.Builtin):
self._save_bin_snapshot()
-builtins.register(OstbuildBuild)
+builtins.register(OstbuildBuildComponents)
diff --git a/src/ostbuild/pyostbuild/builtin_checkout.py b/src/ostbuild/pyostbuild/builtin_checkout.py
index ae94163..73edf02 100755
--- a/src/ostbuild/pyostbuild/builtin_checkout.py
+++ b/src/ostbuild/pyostbuild/builtin_checkout.py
@@ -95,6 +95,6 @@ class OstbuildCheckout(builtins.Builtin):
json.dump(component, f, indent=4, sort_keys=True)
f.close()
- print "Checked out: %r" % (component_src, )
+ log("Checked out: %r" % (component_src, ))
builtins.register(OstbuildCheckout)
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
index f3d09d8..b9f4344 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
@@ -145,7 +145,6 @@ class OstbuildChrootCompileOne(builtins.Builtin):
sourcedir=os.path.join(builddir, 'source', component_name)
fileutil.ensure_dir(sourcedir)
- print "cwd: %r" % (os.getcwd(), )
output_metadata = open('_ostbuild-meta.json', 'w')
json.dump(self.metadata, output_metadata, indent=4, sort_keys=True)
output_metadata.close()
diff --git a/src/ostbuild/pyostbuild/builtin_compose.py b/src/ostbuild/pyostbuild/builtin_compose.py
index 51be34a..c431e43 100755
--- a/src/ostbuild/pyostbuild/builtin_compose.py
+++ b/src/ostbuild/pyostbuild/builtin_compose.py
@@ -51,26 +51,8 @@ class OstbuildCompose(builtins.Builtin):
shutil.rmtree(compose_rootdir)
os.mkdir(compose_rootdir)
- resolved_base = dict(target['base'])
- resolved_base['ostree-revision'] = base_revision
- resolved_contents = list(target['contents'])
- for tree_content_item in resolved_contents:
- name = tree_content_item['name']
- rev = components[name]['ostree-revision']
- tree_content_item['ostree-revision'] = rev
-
- metadata = {'source': 'ostbuild compose v0',
- 'base': resolved_base,
- 'contents': resolved_contents}
-
- # Copy all other keys
- for k,v in bin_snapshot.iteritems():
- if k in ['components', 'targets']:
- continue
- metadata[k] = v
-
compose_contents = [(base_revision, '/')]
- for tree_content in resolved_contents:
+ for tree_content in target['contents']:
rev = tree_content['ostree-revision']
subtrees = tree_content['trees']
for subpath in subtrees:
@@ -91,8 +73,13 @@ class OstbuildCompose(builtins.Builtin):
stdin=open(tmppath))
os.unlink(tmppath)
- contents_path = os.path.join(compose_rootdir, 'contents.json')
- f = open(contents_path, 'w')
+ contents = {}
+ for k,v in bin_snapshot:
+ if k not in ('components', 'targets'):
+ contents[k] = v
+
+ components_path = os.path.join(compose_rootdir, 'components.json')
+ f = open(components_path, 'w')
json.dump(metadata, f, indent=4, sort_keys=True)
f.close()
@@ -112,8 +99,8 @@ class OstbuildCompose(builtins.Builtin):
self.parse_bin_snapshot(args.bin_snapshot)
for target in self.bin_snapshot['targets']:
- print "Composing target %r from %u components" % (target['name'],
- len(target['contents']))
+ log("Composing target %r from %u components" % (target['name'],
+ len(target['contents'])))
self._compose_one_target(self.bin_snapshot, target)
builtins.register(OstbuildCompose)
diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py
index 4575b45..6d125d9 100755
--- a/src/ostbuild/pyostbuild/builtin_resolve.py
+++ b/src/ostbuild/pyostbuild/builtin_resolve.py
@@ -289,6 +289,6 @@ class OstbuildResolve(builtins.Builtin):
src_db = self.get_src_snapshot_db()
path = src_db.store(snapshot)
- print "Source snapshot: %s" % (path, )
+ log("Source snapshot: %s" % (path, ))
builtins.register(OstbuildResolve)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index 253e85a..2caaae2 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -174,4 +174,4 @@ def get(name):
return None
def get_all():
- return _all_builtins.itervalues()
+ return sorted(_all_builtins.itervalues(), lambda a, b: cmp(a.name, b.name))
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 0b2fd24..2b92e41 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -22,14 +22,13 @@ import sys
import argparse
from . import builtins
-from . import builtin_build
+from . import builtin_bin_to_src
+from . import builtin_build_components
from . import builtin_checkout
from . import builtin_chroot_compile_one
-from . import builtin_chroot_run_triggers
from . import builtin_compose
from . import builtin_compile_one
from . import builtin_pull_components
-from . import builtin_query_content
from . import builtin_resolve
from . import builtin_replace_component
from . import builtin_status
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]