[ostree/wip/ostbuild-v3: 3/10] ostbuild: Make binary snapshots an extension of source



commit b118590b4ae07e33ae447b1b21e242d6e4160918
Author: Colin Walters <walters verbum org>
Date:   Thu May 10 19:07:54 2012 -0400

    ostbuild: Make binary snapshots an extension of source
    
    This significantly simplifies things; we no longer need to retrieve
    individual components via 'pull-components', etc.

 Makefile-ostbuild.am                               |    3 +-
 src/ostbuild/pyostbuild/builtin_bin_to_src.py      |   81 --------------------
 .../pyostbuild/builtin_build_components.py         |   20 +++--
 src/ostbuild/pyostbuild/builtin_compose.py         |    2 +-
 ...iltin_tree_to_bin.py => builtin_tree_to_src.py} |   23 ++++--
 src/ostbuild/pyostbuild/builtins.py                |   12 ++-
 src/ostbuild/pyostbuild/main.py                    |    3 +-
 7 files changed, 37 insertions(+), 107 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index 1ee7150..7a0f52b 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -23,7 +23,6 @@ EXTRA_DIST += src/ostbuild/ostbuild.in
 pyostbuilddir=$(libdir)/ostbuild/pyostbuild
 pyostbuild_PYTHON =					\
 	src/ostbuild/pyostbuild/buildutil.py		\
-	src/ostbuild/pyostbuild/builtin_bin_to_src.py	\
 	src/ostbuild/pyostbuild/builtin_branch_prefix.py	\
 	src/ostbuild/pyostbuild/builtin_build_components.py	\
 	src/ostbuild/pyostbuild/builtin_checkout.py	\
@@ -38,7 +37,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_tree_to_src.py	\
 	src/ostbuild/pyostbuild/builtin_init.py	\
 	src/ostbuild/pyostbuild/builtin_status.py	\
 	src/ostbuild/pyostbuild/builtins.py		\
diff --git a/src/ostbuild/pyostbuild/builtin_build_components.py b/src/ostbuild/pyostbuild/builtin_build_components.py
index 010f498..126fe3e 100755
--- a/src/ostbuild/pyostbuild/builtin_build_components.py
+++ b/src/ostbuild/pyostbuild/builtin_build_components.py
@@ -178,7 +178,7 @@ class OstbuildBuildComponents(builtins.Builtin):
         bin_snapshot = dict(self.snapshot)
 
         del bin_snapshot['00ostree-src-snapshot-version']
-        bin_snapshot['00ostree-bin-snapshot-version'] = 0
+        bin_snapshot['00ostree-bin-snapshot-version'] = 1
 
         for target in bin_snapshot['targets']:
             base = target['base']
@@ -199,14 +199,14 @@ class OstbuildBuildComponents(builtins.Builtin):
             for architecture in component_architectures[name]:
                 component_refs.append('components/%s/%s' % (name, architecture))
 
-        new_components = {}
+        component_revisions = {}
         resolved_refs = self._resolve_refs(component_refs)
         for name,rev in zip(components.iterkeys(), resolved_refs):
             for architecture in component_architectures[name]:
                 archname = '%s/%s' % (name, architecture)
-                new_components[archname] = rev
+                component_revisions[archname] = rev
 
-        bin_snapshot['components'] = new_components
+        bin_snapshot['component-revisions'] = component_revisions
 
         path = self.get_bin_snapshot_db().store(bin_snapshot)
         log("Binary snapshot: %s" % (path, ))
@@ -218,6 +218,7 @@ class OstbuildBuildComponents(builtins.Builtin):
         parser.add_argument('--prefix')
         parser.add_argument('--src-snapshot')
         parser.add_argument('--compose', action='store_true')
+        parser.add_argument('--compose-only', action='store_true')
         parser.add_argument('--start-at')
         parser.add_argument('--shell-on-failure', action='store_true')
         parser.add_argument('--debug-shell', action='store_true')
@@ -276,11 +277,12 @@ class OstbuildBuildComponents(builtins.Builtin):
         else:
             start_at_index = 0
 
-        for component_name in build_component_order[start_at_index:]:
-            component = required_components[component_name]
-            architectures = component_architectures[component_name]
-            for architecture in architectures:
-                self._build_one_component(component_name, component, architecture)
+        if not args.compose_only:
+            for component_name in build_component_order[start_at_index:]:
+                component = required_components[component_name]
+                architectures = component_architectures[component_name]
+                for architecture in architectures:
+                    self._build_one_component(component_name, component, architecture)
 
         self._save_bin_snapshot(required_components, component_architectures)   
 
diff --git a/src/ostbuild/pyostbuild/builtin_compose.py b/src/ostbuild/pyostbuild/builtin_compose.py
index dabb516..acc1ef7 100755
--- a/src/ostbuild/pyostbuild/builtin_compose.py
+++ b/src/ostbuild/pyostbuild/builtin_compose.py
@@ -41,7 +41,7 @@ class OstbuildCompose(builtins.Builtin):
         builtins.Builtin.__init__(self)
 
     def _compose_one_target(self, bin_snapshot, target):
-        components = bin_snapshot['components']
+        components = bin_snapshot['component-revisions']
         base = target['base']
         base_name = 'bases/%s' % (base['name'], )
         base_revision = target['base']['ostree-revision']
diff --git a/src/ostbuild/pyostbuild/builtin_tree_to_bin.py b/src/ostbuild/pyostbuild/builtin_tree_to_src.py
similarity index 74%
rename from src/ostbuild/pyostbuild/builtin_tree_to_bin.py
rename to src/ostbuild/pyostbuild/builtin_tree_to_src.py
index f25f2e3..b2df3b1 100755
--- a/src/ostbuild/pyostbuild/builtin_tree_to_bin.py
+++ b/src/ostbuild/pyostbuild/builtin_tree_to_src.py
@@ -28,13 +28,21 @@ 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"
+class OstbuildTreeToSrc(builtins.Builtin):
+    name = "tree-to-src"
+    short_description = "Turn a tree into a source snapshot"
 
     def __init__(self):
         builtins.Builtin.__init__(self)
 
+    def bin_snapshot_to_src(self, bin_snapshot):
+        del bin_snapshot['00ostree-bin-snapshot-version']
+
+        src_snapshot = dict(bin_snapshot)
+        src_snapshot['00ostree-src-snapshot-version'] = 0
+
+        return src_snapshot
+
     def execute(self, argv):
         parser = argparse.ArgumentParser(description=self.short_description)
         parser.add_argument('--prefix')
@@ -50,8 +58,9 @@ class OstbuildTreeToBin(builtins.Builtin):
         else:
             self.load_bin_snapshot_from_current()
 
-        db = self.get_bin_snapshot_db()
-        path = db.store(self.bin_snapshot)
-        log("Binary snapshot: %s" % (path, ))
+        snapshot = self.bin_snapshot_to_src(self.bin_snapshot)
+        db = self.get_src_snapshot_db()
+        path = db.store(snapshot)
+        log("Source snapshot: %s" % (path, ))
 
-builtins.register(OstbuildTreeToBin)
+builtins.register(OstbuildTreeToSrc)
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index a167e9b..109be65 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -93,11 +93,13 @@ class Builtin(object):
         self.patchdir = os.path.join(self.workdir, 'patches')
 
     def load_bin_snapshot_from_path(self, path):
-        self.bin_snapshot_path = os.path.join(path, 'contents.json')
+        self.bin_snapshot_path = os.path.join(path, 'ostree-meta', 'contents.json')
+        if not os.path.exists(self.bin_snapshot_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)
+        if bin_ver != 1:
+            fatal("Unhandled 00ostree-bin-snapshot-version %r, expected 1" % (bin_ver, ))
 
     def load_bin_snapshot_from_current(self):
         if self.ostree_dir is None:
@@ -211,8 +213,8 @@ class Builtin(object):
             self.bin_snapshot_path = path
         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, ))
+        if bin_ver != 1:
+            fatal("Unhandled 00ostree-bin-snapshot-version %r, expected 1" % (bin_ver, ))
 
     def execute(self, args):
         raise NotImplementedError()
diff --git a/src/ostbuild/pyostbuild/main.py b/src/ostbuild/pyostbuild/main.py
index 7f91e38..1c01bbc 100755
--- a/src/ostbuild/pyostbuild/main.py
+++ b/src/ostbuild/pyostbuild/main.py
@@ -22,7 +22,6 @@ import sys
 import argparse
 
 from . import builtins
-from . import builtin_bin_to_src
 from . import builtin_build_components
 from . import builtin_branch_prefix
 from . import builtin_checkout
@@ -37,7 +36,7 @@ from . import builtin_privhelper_deploy_qemu
 from . import builtin_prefix
 from . import builtin_resolve
 from . import builtin_modify_snapshot
-from . import builtin_tree_to_bin
+from . import builtin_tree_to_src
 from . import builtin_init
 from . import builtin_status
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]