[ostree] ostbuild: Stop using "compose" to make buildroots



commit 5dd62af628c71e5fa7211f0c3983e3e37d24a43d
Author: Colin Walters <walters verbum org>
Date:   Tue Mar 6 19:36:58 2012 -0500

    ostbuild: Stop using "compose" to make buildroots
    
    It pollutes the repository with a combinatorial explosion of .dirtree
    metadata files, and we don't really need to track buildroots at that
    level.

 src/ostbuild/pyostbuild/buildutil.py               |   10 ---
 src/ostbuild/pyostbuild/builtin_build.py           |    7 +--
 .../pyostbuild/builtin_chroot_compile_one.py       |   59 ++++++++++++--------
 3 files changed, 37 insertions(+), 39 deletions(-)
---
diff --git a/src/ostbuild/pyostbuild/buildutil.py b/src/ostbuild/pyostbuild/buildutil.py
index a0d94b7..e7cae93 100755
--- a/src/ostbuild/pyostbuild/buildutil.py
+++ b/src/ostbuild/pyostbuild/buildutil.py
@@ -115,13 +115,3 @@ def compose(repo, target, artifacts):
     revision = run_sync_get_output(child_args, log_initiation=True).strip()
     os.unlink(path)
     return revision
-
-def compose_buildroot(manifest, repo, buildroot_name, component, dependencies):
-    base = 'bases/%s' % (manifest['base'], )
-    buildroot_contents = [base + ':/']
-    for dep in dependencies:
-        dep_buildname = manifest_buildname(manifest, dep)
-        buildroot_contents.append(dep_buildname + ':/runtime')
-        buildroot_contents.append(dep_buildname + ':/devel')
-
-    return compose(repo, buildroot_name, buildroot_contents)
diff --git a/src/ostbuild/pyostbuild/builtin_build.py b/src/ostbuild/pyostbuild/builtin_build.py
index b30f992..b0ecc29 100755
--- a/src/ostbuild/pyostbuild/builtin_build.py
+++ b/src/ostbuild/pyostbuild/builtin_build.py
@@ -194,14 +194,9 @@ class OstbuildBuild(builtins.Builtin):
         # HACK
         manifest_build_name = self.manifest['name']
         is_runtime = manifest_build_name.endswith('-runtime')
-        # HACK - we should really name builds just like e.g. gnomeos-3.4-i686 
-        if is_runtime:
-            manifest_build_name = manifest_build_name[:-len('-runtime')] + '-devel'
 
         for component in components:
-            branch = 'artifacts/%s/%s/%s' % (manifest_build_name,
-                                             component['name'],
-                                             component['branch'])
+            branch = buildutil.manifest_buildname(self.manifest, component)
             contents.append(branch + ':/runtime')
             if not is_runtime:
                 # For now just hardcode docs going in devel
diff --git a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
index 2307a9b..f9dc4be 100755
--- a/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
+++ b/src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
@@ -29,6 +29,24 @@ class OstbuildChrootCompileOne(builtins.Builtin):
     name = "chroot-compile-one"
     short_description = "Build artifacts from the current source directory in a chroot"
 
+    def _compose_buildroot(self, component, dirpath):
+        components = self.manifest['components']
+        index = components.index(component)
+        dependencies = components[:index]
+
+        base = 'bases/%s' % (self.manifest['base'], )
+        checkout_trees = [(base, '/')]
+        for dep in dependencies:
+            buildname = buildutil.manifest_buildname(self.manifest, dep)
+            checkout_trees.append((buildname, '/runtime'))
+            checkout_trees.append((buildname, '/devel'))
+
+        for (branch, rootpath) in checkout_trees:
+            run_sync(['ostree', '--repo=' + self.repo,
+                      'checkout', '--user-mode',
+                      '--union', '--subpath=' + rootpath,
+                      branch, dirpath])
+
     def execute(self, argv):
         parser = argparse.ArgumentParser(description=self.short_description)
         parser.add_argument('--manifest', required=True)
@@ -50,14 +68,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
             self.metadata['src'] = 'dirty:worktree'
             self.metadata['revision'] = 'dirty-worktree'
 
-        components = self.manifest['components']
-        index = components.index(component)
-        dependencies = components[:index]
-
         architecture = os.uname()[4]
-        buildroot_name = self.manifest['name']
-        buildroot_version = buildutil.compose_buildroot(self.manifest, self.repo, buildroot_name,
-                                                        self.metadata, dependencies)
 
         if 'name' not in self.metadata:
             sys.stderr.write('Missing required key "%s" in metadata' % (k, ))
@@ -81,25 +92,27 @@ class OstbuildChrootCompileOne(builtins.Builtin):
         rootdir_prefix = os.path.join(workdir, 'roots')
         if not os.path.isdir(rootdir_prefix):
             os.makedirs(rootdir_prefix)
-        rootdir = os.path.join(rootdir_prefix, buildroot_version)
+        rootdir = os.path.join(rootdir_prefix, component['name'])
+        if os.path.isdir(rootdir):
+            shutil.rmtree(rootdir)
         
         rootdir_tmp = rootdir + '.tmp'
         builddir = os.path.join(rootdir, 'ostbuild');
-        if not os.path.isdir(rootdir):
-            if os.path.isdir(rootdir_tmp):
-                shutil.rmtree(rootdir_tmp)
-            child_args = ['ostree', '--repo=' + self.repo, 'checkout', '-U', buildroot_version, rootdir_tmp]
-            run_sync(child_args)
-            child_args = ['ostbuild', 'chroot-run-triggers', rootdir_tmp]
-            run_sync(child_args)
-            builddir_tmp = os.path.join(rootdir_tmp, 'ostbuild')
-            os.mkdir(builddir_tmp)
-            os.mkdir(os.path.join(builddir_tmp, 'source'))
-            os.mkdir(os.path.join(builddir_tmp, 'results'))
-            os.rename(rootdir_tmp, rootdir)
-            log("Checked out root: %s" % (rootdir, ))
-        else:
-            log("Using existing root: %s" % (rootdir, ))
+        if os.path.isdir(rootdir_tmp):
+            shutil.rmtree(rootdir_tmp)
+        os.mkdir(rootdir_tmp)
+            
+        self._compose_buildroot(component, rootdir_tmp)
+
+        child_args = ['ostbuild', 'chroot-run-triggers', rootdir_tmp]
+        run_sync(child_args)
+
+        builddir_tmp = os.path.join(rootdir_tmp, 'ostbuild')
+        os.mkdir(builddir_tmp)
+        os.mkdir(os.path.join(builddir_tmp, 'source'))
+        os.mkdir(os.path.join(builddir_tmp, 'results'))
+        os.rename(rootdir_tmp, rootdir)
+        log("Checked out buildroot: %s" % (rootdir, ))
         
         sourcedir=os.path.join(builddir, 'source', self.metadata['name'])
         if not os.path.isdir(sourcedir):



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