[gnome-ostree/wip/gjs-round3: 2/3] gjs-round3
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree/wip/gjs-round3: 2/3] gjs-round3
- Date: Sun, 6 Jan 2013 17:48:19 +0000 (UTC)
commit 6c558472b16c93db0f4b56ecdef56cb62f66b9dc
Author: Colin Walters <walters verbum org>
Date: Wed Dec 12 07:52:33 2012 -0500
gjs-round3
src/ostbuild/js/build.js | 79 +++++++++++++++++++++++++++++++-------------
src/ostbuild/js/dyntask.js | 2 -
2 files changed, 56 insertions(+), 25 deletions(-)
---
diff --git a/src/ostbuild/js/build.js b/src/ostbuild/js/build.js
index 54b89d5..9c74ec3 100644
--- a/src/ostbuild/js/build.js
+++ b/src/ostbuild/js/build.js
@@ -31,6 +31,7 @@ const Snapshot = imports.snapshot;
const Config = imports.config;
const BuildUtil = imports.buildutil;
const Vcs = imports.vcs;
+const DynTask = imports.dyntask;
const ArgParse = imports.argparse;
const OPT_COMMON_CFLAGS = {'i686': '-O2 -g -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables',
@@ -38,6 +39,52 @@ const OPT_COMMON_CFLAGS = {'i686': '-O2 -g -m32 -march=i686 -mtune=atom -fasynch
var loop = GLib.MainLoop.new(null, true);
+const TaskComposeTarget = new Lang.Class({
+ Name: "TaskComposeTarget",
+ Extends: TaskDef,
+
+ _init: function(repo, workdir, tmpdir) {
+ this.repo = repo;
+ this.workdir = workdir;
+ this.tmpdir = tmpdir;
+ },
+
+ getPattern: function() {
+ return [/\/ComposeTarget\/(.*)$/, 'NAME'];
+ },
+
+ getDepends: function(inputs) {
+ return [];
+ },
+
+ execute: function(inputs, dependResults, cancellable, onComplete) {
+ let name = inputs.NAME;
+ let composeRootdir = this.tmpdir.get_child('contents-' + name).get_path();
+ let context = GSystem.Subprocess.new_simple_argv(['ostree', '--repo=' + this.repo.get_path(),
+ 'checkout', '--user-mode', '--no-triggers', '--union',
+ '--from-file=ostbuild-compose-' + name,
+ composeRootdir],
+ GSystem.SubprocessStreamDisposition.INHERIT,
+ GSystem.SubprocessStreamDisposition.INHERIT);
+ context.init(cancellable);
+
+ let contentsPath = composeRootdir.get_child('contents.json');
+ JsonUtil.writeJsonFileAtomic(contentsPath, this._snapshot, cancellable);
+
+ let treename = 'trees/' + target['name'];
+
+ ProcUtil.runSync(['ostree', '--repo=' + this.repo.get_path(),
+ 'commit', '-b', treename, '-s', 'Compose',
+ '--owner-uid=0', '--owner-gid=0', '--no-xattrs',
+ '--related-objects-file=' + relatedTmpPath.get_path(),
+ '--skip-if-unchanged'
+ ], cancellable, {cwd: composeRootdir.get_path()});
+ GSystem.file_unlink(relatedTmpPath, cancellable);
+ GSystem.shutil_rm_rf(composeRootdir, cancellable);
+
+ }
+});
+
const Build = new Lang.Class({
Name: "Build",
@@ -499,8 +546,9 @@ const Build = new Lang.Class({
relatedRefs[buildRef] = rev;
}
- let [relatedTmpPath, stream] = Gio.File.new_tmp("ostbuild-compose-XXXXXX.txt");
- let dataOut = Gio.DataOutputStream.new(stream.get_output_stream());
+ let relatedTmpPath = this.tmpdir.get_child('compose-related-' + target[name]);
+ let dataOut = Gio.DataOutputStream.new(relatedTmpPath.replace(null, false,
+ Gio.FileCreateFlags.REPLACE_DESTINATION, cancellable));
for (let name in relatedRefs) {
let rev = relatedRefs[name];
dataOut.put_string(name, cancellable);
@@ -522,8 +570,9 @@ const Build = new Lang.Class({
}
}
- let [contentsTmpPath, stream] = Gio.File.new_tmp("ostbuild-compose-XXXXXX.txt");
- let dataOut = Gio.DataOutputStream.new(stream.get_output_stream());
+ let contentsTmpPath = this.tmpdir.get_child('compose-contents-' + target[name]);
+ dataOut = Gio.DataOutputStream.new(contentsTmpPath.replace(null, false,
+ Gio.FileCreateFlags.REPLACE_DESTINATION, cancellable));
for (let i = 0; i < composeContents.length; i++) {
let [branch, subpath] = composeContents[i];
dataOut.put_string(branch, cancellable);
@@ -533,25 +582,7 @@ const Build = new Lang.Class({
}
dataOut.close(cancellable);
- ProcUtil.runSync(['ostree', '--repo=' + this.repo.get_path(),
- 'checkout', '--user-mode', '--no-triggers', '--union',
- '--from-file=' + contentsTmpPath.get_path(), composeRootdir.get_path()],
- cancellable);
- GSystem.file_unlink(contentsTmpPath, cancellable);
-
- let contentsPath = composeRootdir.get_child('contents.json');
- JsonUtil.writeJsonFileAtomic(contentsPath, this._snapshot, cancellable);
-
- let treename = 'trees/' + target['name'];
-
- ProcUtil.runSync(['ostree', '--repo=' + this.repo.get_path(),
- 'commit', '-b', treename, '-s', 'Compose',
- '--owner-uid=0', '--owner-gid=0', '--no-xattrs',
- '--related-objects-file=' + relatedTmpPath.get_path(),
- '--skip-if-unchanged'
- ], cancellable, {cwd: composeRootdir.get_path()});
- GSystem.file_unlink(relatedTmpPath, cancellable);
- GSystem.shutil_rm_rf(composeRootdir, cancellable);
+ this._taskMaster.push('/ComposeTarget/' + treename);
},
/* Build the Yocto base system. */
@@ -614,6 +645,8 @@ const Build = new Lang.Class({
this.prefix = args.prefix || this.config.getPrefix();
this._snapshotDir = this.workdir.get_child('snapshots');
this.libdir = Gio.File.new_for_path(GLib.getenv('OSTBUILD_LIBDIR'));
+ this.tmpdir = this.workdir.get_child('tmp');
+ GSystem.file_ensure_directory(this.tmpdir, true, cancellable);
this._srcDb = new JsonDB.JsonDB(this._snapshotDir, this.prefix + '-src-snapshot');
[this._snapshot, this._snapshotPath] = Snapshot.load(this._srcDb, this.prefix, args.snapshot, cancellable);
diff --git a/src/ostbuild/js/dyntask.js b/src/ostbuild/js/dyntask.js
index fe269ff..09ae97b 100644
--- a/src/ostbuild/js/dyntask.js
+++ b/src/ostbuild/js/dyntask.js
@@ -6,8 +6,6 @@ const Lang = imports.lang;
const GSystem = imports.gi.GSystem;
const Params = imports.params;
-const VERSION_RE = /(\d+)\.(\d+)/;
-
const TaskMaster = new Lang.Class({
Name: 'TaskMaster',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]