[ostree/wip/ostbuild-v2] ostbuild: Version snapshots, update bin-to-src



commit 95ec3e304619f29a5a34fc7532677cd40cea5700
Author: Colin Walters <walters verbum org>
Date:   Tue Apr 24 20:05:05 2012 -0400

    ostbuild: Version snapshots, update bin-to-src

 src/ostbuild/pyostbuild/builtin_bin_to_src.py      |   22 ++++++++++++++-----
 .../pyostbuild/builtin_build_components.py         |    5 ++++
 src/ostbuild/pyostbuild/builtin_compose.py         |    6 +++++
 src/ostbuild/pyostbuild/builtin_resolve.py         |    4 +++
 src/ostbuild/pyostbuild/builtins.py                |    6 +++++
 5 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/builtin_bin_to_src.py b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
index 1285c45..4e35420 100755
--- a/src/ostbuild/pyostbuild/builtin_bin_to_src.py
+++ b/src/ostbuild/pyostbuild/builtin_bin_to_src.py
@@ -36,15 +36,25 @@ class OstbuildBinToSrc(builtins.Builtin):
         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_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_snapshot['00ostree-src-snapshot-version'] = 0
+
+        all_architectures = src_snapshot['architecture-buildroots'].keys()
+        # Arbitrarily take first architecture
+        first_arch = all_architectures[0]
 
+        bin_components = src_snapshot['components']
+        src_components = {}
+        src_snapshot['components'] = src_components
+        for archname,rev in bin_components.iteritems():
+            (name, arch) = archname.rsplit('/', 1)
+            if arch != first_arch:
+                continue
+            meta = self.get_component_meta_from_revision(rev)
             src_components[name] = meta
-            
+
         return src_snapshot
 
     def execute(self, argv):
diff --git a/src/ostbuild/pyostbuild/builtin_build_components.py b/src/ostbuild/pyostbuild/builtin_build_components.py
index 40f9b25..a180cd3 100755
--- a/src/ostbuild/pyostbuild/builtin_build_components.py
+++ b/src/ostbuild/pyostbuild/builtin_build_components.py
@@ -152,6 +152,9 @@ class OstbuildBuildComponents(builtins.Builtin):
     def _save_bin_snapshot(self, components, component_architectures):
         bin_snapshot = dict(self.snapshot)
 
+        del bin_snapshot['00ostree-src-snapshot-version']
+        bin_snapshot['00ostree-bin-snapshot-version'] = 0
+
         for target in bin_snapshot['targets']:
             base = target['base']
             base_name = 'bases/%s' % (base['name'], )
@@ -192,6 +195,8 @@ class OstbuildBuildComponents(builtins.Builtin):
         self.parse_config()
         self.parse_snapshot(args.src_snapshot)
 
+        log("Using source snapshot: %s" % (os.path.basename(self.snapshot_path), ))
+
         self.buildopts = BuildOptions()
         self.buildopts.shell_on_failure = args.shell_on_failure
         self.buildopts.skip_built = args.skip_built
diff --git a/src/ostbuild/pyostbuild/builtin_compose.py b/src/ostbuild/pyostbuild/builtin_compose.py
index a3d6424..61a8d19 100755
--- a/src/ostbuild/pyostbuild/builtin_compose.py
+++ b/src/ostbuild/pyostbuild/builtin_compose.py
@@ -87,18 +87,24 @@ class OstbuildCompose(builtins.Builtin):
                   'commit', '-b', target['name'], '-s', 'Compose',
                   '--owner-uid=0', '--owner-gid=0', '--no-xattrs', 
                   '--skip-if-unchanged'], cwd=compose_rootdir)
+        if not self.args.no_print_diff:
+            run_sync(['ostree', '--repo=' + self.repo, 'diff',
+                      target['name']])
 
         shutil.rmtree(compose_rootdir)
 
     def execute(self, argv):
         parser = argparse.ArgumentParser(description=self.short_description)
         parser.add_argument('--bin-snapshot')
+        parser.add_argument('--no-print-diff', action='store_true')
 
         args = parser.parse_args(argv)
         self.args = args
         
         self.parse_config()
         self.parse_bin_snapshot(args.bin_snapshot)
+        
+        log("Using binary snapshot: %s" % (os.path.basename(self.bin_snapshot_path), ))
 
         for target in self.bin_snapshot['targets']:
             log("Composing target %r from %u components" % (target['name'],
diff --git a/src/ostbuild/pyostbuild/builtin_resolve.py b/src/ostbuild/pyostbuild/builtin_resolve.py
index 5cf94a8..ef2293c 100755
--- a/src/ostbuild/pyostbuild/builtin_resolve.py
+++ b/src/ostbuild/pyostbuild/builtin_resolve.py
@@ -244,6 +244,8 @@ class OstbuildResolve(builtins.Builtin):
             builds[name] = component_arches
 
         # We expanded these keys
+        del snapshot['name-prefix']
+        del snapshot['base-prefix']
         del snapshot['config-opts']
         del snapshot['vcsconfig']
         del snapshot['patches']
@@ -283,6 +285,8 @@ class OstbuildResolve(builtins.Builtin):
             del component['name']
         snapshot['components'] = components_by_name
 
+        snapshot['00ostree-src-snapshot-version'] = 0
+
         current_time = time.time()
 
         src_db = self.get_src_snapshot_db()
diff --git a/src/ostbuild/pyostbuild/builtins.py b/src/ostbuild/pyostbuild/builtins.py
index 673512a..4027411 100755
--- a/src/ostbuild/pyostbuild/builtins.py
+++ b/src/ostbuild/pyostbuild/builtins.py
@@ -159,6 +159,9 @@ class Builtin(object):
         else:
             self.snapshot_path = path
         self.snapshot = json.load(open(self.snapshot_path))
+        src_ver = self.snapshot['00ostree-src-snapshot-version']
+        if src_ver != 0:
+            fatal("Unhandled 00ostree-src-snapshot-version \"%d\", expected 0", src_ver)
 
     def parse_bin_snapshot(self, path):
         self.repo = ostbuildrc.get_key('repo')
@@ -170,6 +173,9 @@ class Builtin(object):
         else:
             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)
 
     def execute(self, args):
         raise NotImplementedError()



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