[ostree] ostbuild: Add tree-to-bin and bin-to-src
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] ostbuild: Add tree-to-bin and bin-to-src
- Date: Sat, 5 May 2012 13:57:41 +0000 (UTC)
commit a6a8e00edf5e2d695240a6f1663315ff65eaac5e
Author: Colin Walters <walters verbum org>
Date: Tue May 1 10:02:34 2012 -0400
ostbuild: Add tree-to-bin and bin-to-src
Makefile-ostbuild.am | 1 +
src/ostbuild/pyostbuild/builtin_bin_to_src.py | 4 +-
src/ostbuild/pyostbuild/builtin_tree_to_bin.py | 57 ++++++++++++++++++++++++
src/ostbuild/pyostbuild/builtins.py | 16 ++++---
src/ostbuild/pyostbuild/main.py | 1 +
5 files changed, 72 insertions(+), 7 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index a227916..21ec7b4 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -33,6 +33,7 @@ pyostbuild_PYTHON = \
src/ostbuild/pyostbuild/builtin_prefix.py \
src/ostbuild/pyostbuild/builtin_resolve.py \
src/ostbuild/pyostbuild/builtin_modify_snapshot.py \
+ src/ostbuild/pyostbuild/builtin_tree_to_bin.py \
src/ostbuild/pyostbuild/builtin_status.py \
src/ostbuild/pyostbuild/builtins.py \
src/ostbuild/pyostbuild/filemonitor.py \
diff --git a/src/ostbuild/pyostbuild/builtin_bin_to_src.py b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
index b8cbb0a..d3b75b2 100755
--- a/src/ostbuild/pyostbuild/builtin_bin_to_src.py
+++ b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
@@ -71,6 +71,8 @@ class OstbuildBinToSrc(builtins.Builtin):
self.parse_bin_snapshot(args.prefix, args.bin_snapshot)
snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
- json.dump(snapshot, sys.stdout, indent=4, sort_keys=True)
+ db = self.get_src_snapshot_db()
+ path = db.store(snapshot)
+ log("Source snapshot: %s" % (path, ))
builtins.register(OstbuildBinToSrc)
diff --git a/src/ostbuild/pyostbuild/builtin_tree_to_bin.py b/src/ostbuild/pyostbuild/builtin_tree_to_bin.py
new file mode 100755
index 0000000..f25f2e3
--- /dev/null
+++ b/src/ostbuild/pyostbuild/builtin_tree_to_bin.py
@@ -0,0 +1,57 @@
+# 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 OstbuildTreeToBin(builtins.Builtin):
+ name = "tree-to-bin"
+ short_description = "Turn a tree into a binary snapshot"
+
+ def __init__(self):
+ builtins.Builtin.__init__(self)
+
+ def execute(self, argv):
+ parser = argparse.ArgumentParser(description=self.short_description)
+ parser.add_argument('--prefix')
+ parser.add_argument('--tree')
+
+ args = parser.parse_args(argv)
+ self.parse_config()
+ if args.prefix:
+ self.prefix = args.prefix
+
+ if args.tree:
+ self.load_bin_snapshot_from_path(args.tree)
+ else:
+ self.load_bin_snapshot_from_current()
+
+ db = self.get_bin_snapshot_db()
+ path = db.store(self.bin_snapshot)
+ log("Binary snapshot: %s" % (path, ))
+
+builtins.register(OstbuildTreeToBin)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index c71431f..4c3f502 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -92,7 +92,14 @@ class Builtin(object):
self.snapshot_dir = os.path.join(self.workdir, 'snapshots')
self.patchdir = os.path.join(self.workdir, 'patches')
- def parse_active_branch(self):
+ def load_bin_snapshot_from_path(self, path):
+ self.bin_snapshot_path = os.path.join(path, 'contents.json')
+ self.bin_snapshot = json.load(open(self.bin_snapshot_path))
+ bin_ver = self.bin_snapshot['00ostree-bin-snapshot-version']
+ if bin_ver != 0:
+ fatal("Unhandled 00ostree-bin-snapshot-version \"%d\", expected 0", bin_ver)
+
+ def load_bin_snapshot_from_current(self):
if self.ostree_dir is None:
fatal("/ostree directory not found")
repo_path = os.path.join(self.ostree_dir, 'repo')
@@ -101,11 +108,8 @@ class Builtin(object):
self.repo = repo_path
if self.active_branch is None:
fatal("No \"current\" link found")
- branch_path = os.path.join(self.ostree_dir, self.active_branch)
- contents_path = os.path.join(branch_path, 'contents.json')
- f = open(contents_path)
- self.active_branch_contents = json.load(f)
- f.close()
+ tree_path = os.path.join(self.ostree_dir, self.active_branch)
+ self.load_bin_snapshot_from_path(tree_path)
def get_component_snapshot(self, name):
found = False
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 63827c1..2a60f85 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -33,6 +33,7 @@ from . import builtin_pull_components
from . import builtin_prefix
from . import builtin_resolve
from . import builtin_modify_snapshot
+from . import builtin_tree_to_bin
from . import builtin_status
def usage(ecode):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]