[gnome-ostree/wip/gjs-round2: 10/10] Finish port to gjs
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree/wip/gjs-round2: 10/10] Finish port to gjs
- Date: Tue, 11 Dec 2012 17:11:45 +0000 (UTC)
commit 2fae3c184032fbbb1ea33f30c6ce1c21b32459cb
Author: Colin Walters <walters verbum org>
Date: Tue Dec 11 00:01:51 2012 -0500
Finish port to gjs
Delete the crappy python code.
Makefile-ostbuild.am | 29 +---
configure.ac | 2 -
src/libgsystem | 2 +-
src/ostbuild/js/argparse.js | 1 +
src/ostbuild/js/autobuilder.js | 16 +-
src/ostbuild/js/build.js | 67 ++++----
src/ostbuild/js/buildutil.js | 4 +
src/ostbuild/js/checkout.js | 26 ++--
src/ostbuild/js/config.js | 1 +
src/ostbuild/js/git_mirror.js | 12 +-
src/ostbuild/js/main.js | 50 ++++++
src/ostbuild/js/procutil.js | 33 +++--
src/ostbuild/js/resolve.js | 12 +-
src/ostbuild/js/snapshot.js | 3 +
src/ostbuild/js/task.js | 1 +
src/ostbuild/ostbuild-js.in | 13 --
src/ostbuild/ostbuild.in | 38 +----
src/ostbuild/pyostbuild/buildutil.py | 199 ---------------------
src/ostbuild/pyostbuild/builtins.py | 230 -------------------------
src/ostbuild/pyostbuild/filemonitor.py | 87 ----------
src/ostbuild/pyostbuild/fileutil.py | 35 ----
src/ostbuild/pyostbuild/jsondb.py | 144 ---------------
src/ostbuild/pyostbuild/kvfile.py | 23 ---
src/ostbuild/pyostbuild/main.py | 62 -------
src/ostbuild/pyostbuild/mainloop.py | 104 -----------
src/ostbuild/pyostbuild/odict.py | 45 -----
src/ostbuild/pyostbuild/ostbuildlog.py | 35 ----
src/ostbuild/pyostbuild/ostbuildrc.py | 52 ------
src/ostbuild/pyostbuild/privileged_subproc.py | 39 ----
src/ostbuild/pyostbuild/snapshot.py | 50 ------
src/ostbuild/pyostbuild/subprocess_helpers.py | 151 ----------------
src/ostbuild/pyostbuild/task.py | 131 --------------
src/ostbuild/pyostbuild/vcs.py | 195 ---------------------
src/ostbuild/pyostbuild/warningfilter.py | 113 ------------
34 files changed, 165 insertions(+), 1840 deletions(-)
---
diff --git a/Makefile-ostbuild.am b/Makefile-ostbuild.am
index f7d6445..972bfe3 100644
--- a/Makefile-ostbuild.am
+++ b/Makefile-ostbuild.am
@@ -20,18 +20,12 @@ substitutions= \
-e s,@pkglibdir\@,$(pkglibdir), \
-e s,@datarootdir\@,$(datarootdir), \
-e s,@pkgdatadir\@,$(pkgdatadir), \
- -e s,@PYTHON\@,$(PYTHON), \
$(NULL)
-
ostbuild: src/ostbuild/ostbuild.in Makefile
sed $(substitutions) $< > $ tmp && mv $ tmp $@
EXTRA_DIST += ostbuild/ostbuild.in
-ostbuild-js: src/ostbuild/ostbuild-js.in Makefile
- sed $(substitutions) $< > $ tmp && mv $ tmp $@
-EXTRA_DIST += ostbuild/ostbuild-js.in
-
if BUILDSYSTEM
bin_SCRIPTS += ostbuild ostbuild-js $(srcdir)/src/ostbuild/ostbuild-qemu-pull-deploy
@@ -41,28 +35,6 @@ utils_SCRIPTS = \
$(NULL)
utilsdir = $(pkglibdir)
-pyostbuilddir=$(libdir)/ostbuild/pyostbuild
-pyostbuild_PYTHON = \
- src/ostbuild/pyostbuild/buildutil.py \
- src/ostbuild/pyostbuild/builtins.py \
- src/ostbuild/pyostbuild/filemonitor.py \
- src/ostbuild/pyostbuild/task.py \
- src/ostbuild/pyostbuild/fileutil.py \
- src/ostbuild/pyostbuild/__init__.py \
- src/ostbuild/pyostbuild/jsondb.py \
- src/ostbuild/pyostbuild/kvfile.py \
- src/ostbuild/pyostbuild/main.py \
- src/ostbuild/pyostbuild/mainloop.py \
- src/ostbuild/pyostbuild/odict.py \
- src/ostbuild/pyostbuild/ostbuildlog.py \
- src/ostbuild/pyostbuild/ostbuildrc.py \
- src/ostbuild/pyostbuild/privileged_subproc.py \
- src/ostbuild/pyostbuild/warningfilter.py \
- src/ostbuild/pyostbuild/snapshot.py \
- src/ostbuild/pyostbuild/subprocess_helpers.py \
- src/ostbuild/pyostbuild/vcs.py \
- $(NULL)
-
jsostbuilddir=$(pkgdatadir)/js
jsostbuild_DATA= \
src/ostbuild/js/argparse.js \
@@ -74,6 +46,7 @@ jsostbuild_DATA= \
src/ostbuild/js/git_mirror.js \
src/ostbuild/js/jsondb.js \
src/ostbuild/js/jsonutil.js \
+ src/ostbuild/js/main.js \
src/ostbuild/js/params.js \
src/ostbuild/js/prefix.js \
src/ostbuild/js/procutil.js \
diff --git a/configure.ac b/configure.ac
index febaec5..e94bfd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,8 +39,6 @@ LT_INIT([disable-static])
GOBJECT_INTROSPECTION_REQUIRE([1.34.0])
-AM_PATH_PYTHON([2.6])
-
AC_ARG_ENABLE(buildsystem,
AS_HELP_STRING([--disable-buildsystem], [Don't install buildsystem]),,
enable_buildsystem=yes)
diff --git a/src/libgsystem b/src/libgsystem
index 79ad77e..c0d3e96 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit 79ad77e45b5095494361e3f525a105708d8d0cb1
+Subproject commit c0d3e9641af40124e0b4a2b217c08de48bd2e5c5
diff --git a/src/ostbuild/js/argparse.js b/src/ostbuild/js/argparse.js
index 475d35a..9394d54 100644
--- a/src/ostbuild/js/argparse.js
+++ b/src/ostbuild/js/argparse.js
@@ -1,5 +1,6 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
+const Lang = imports.lang;
const ArgumentParser = new Lang.Class({
Name: 'ArgumentParser',
diff --git a/src/ostbuild/js/autobuilder.js b/src/ostbuild/js/autobuilder.js
index f261856..239d6fb 100644
--- a/src/ostbuild/js/autobuilder.js
+++ b/src/ostbuild/js/autobuilder.js
@@ -1,5 +1,3 @@
-#!/usr/bin/env gjs
-
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
@@ -284,9 +282,11 @@ const AutoBuilder = new Lang.Class({
}
});
-var ownId = Gio.DBus.session.own_name('org.gnome.OSTreeBuild', Gio.BusNameOwnerFlags.NONE,
- function(name) {},
- function(name) { loop.quit(); });
-
-var builder = new AutoBuilder();
-loop.run();
+function main(argv) {
+ var ownId = Gio.DBus.session.own_name('org.gnome.OSTreeBuild', Gio.BusNameOwnerFlags.NONE,
+ function(name) {},
+ function(name) { loop.quit(); });
+
+ var builder = new AutoBuilder();
+ loop.run();
+}
diff --git a/src/ostbuild/js/build.js b/src/ostbuild/js/build.js
index ecd708d..54b89d5 100644
--- a/src/ostbuild/js/build.js
+++ b/src/ostbuild/js/build.js
@@ -25,6 +25,7 @@ const GSystem = imports.gi.GSystem;
const Task = imports.task;
const JsonDB = imports.jsondb;
const ProcUtil = imports.procutil;
+const StreamUtil = imports.streamutil;
const JsonUtil = imports.jsonutil;
const Snapshot = imports.snapshot;
const Config = imports.config;
@@ -178,13 +179,13 @@ const Build = new Lang.Class({
_analyzeBuildFailure: function(t, architecture, component, componentSrcdir,
currentVcsVersion, previousVcsVersion,
cancellable) {
- let dataIn = Gio.DataInputStream.new(t.logfile_path.read());
+ let dataIn = Gio.DataInputStream.new(t.logfile_path.read(cancellable));
let lines = StreamUtil.dataInputStreamReadLines(dataIn, cancellable);
- dataIn.close();
+ dataIn.close(cancellable);
let maxLines = 250;
lines = lines.splice(Math.max(0, lines.length-maxLines), maxLines);
for (let i = 0; i < lines.length; i++) {
- print("| " + line);
+ print("| " + lines[i]);
}
if (currentVcsVersion && previousVcsVersion) {
let args = ['git', 'log', '--format=short'];
@@ -297,7 +298,7 @@ const Build = new Lang.Class({
previousBuildVersion = previousMetadata['ostree'];
} else {
previousBuildVersion = ProcUtil.runSyncGetOutputUTF8StrippedOrNull(['ostree', '--repo=' + this.repo.get_path(),
- 'rev-parse', buildRef]);
+ 'rev-parse', buildRef], cancellable);
}
let previousVcsVersion;
if (previousMetadata != null) {
@@ -305,7 +306,7 @@ const Build = new Lang.Class({
} else if (previousBuildVersion != null) {
let jsonstr = ProcUtil.runSyncGetOutputUTF8(['ostree', '--repo=' + this.repo.get_path(),
'cat', previousBuildVersion,
- '/_ostbuild-meta.json']);
+ '/_ostbuild-meta.json'], cancellable);
previousMetadata = JSON.parse(jsonstr);
previousVcsVersion = previousMetadata['revision'];
} else {
@@ -313,9 +314,9 @@ const Build = new Lang.Class({
previousVcsVersion = null;
}
+ let patchdir;
if (expandedComponent['patches']) {
let patchesRevision = expandedComponent['patches']['revision'];
- let patchdir;
if (this.args.patches_path) {
patchdir = Gio.File.new_for_path(this.args.patches_path);
} else if (this._cachedPatchdirRevision == patchesRevision) {
@@ -326,9 +327,8 @@ const Build = new Lang.Class({
expandedComponent,
cancellable,
{patchesPath: this.args.patches_path});
- this.cachedPatchdirRevision = patchesRevision;
+ this._cachedPatchdirRevision = patchesRevision;
}
- log("patchdir=" + patchdir.get_path());
if ((previousMetadata != null) &&
previousMetadata['patches'] &&
previousMetadata['patches']['revision'] &&
@@ -381,7 +381,7 @@ const Build = new Lang.Class({
if (this.args.patches_path)
childArgs.push('--patches-path=' + this.args.patches_path);
else if (patchdir)
- childArgs.push('--patches-path=' + patchdir);
+ childArgs.push('--patches-path=' + patchdir.get_path());
ProcUtil.runSync(childArgs, cancellable);
GSystem.file_unlink(tempMetadataPath, cancellable);
@@ -428,11 +428,12 @@ const Build = new Lang.Class({
let proc = new GSystem.Subprocess({ context: context });
proc.init(cancellable);
let [res, estatus] = proc.wait_sync(cancellable);
- if (!res) {
+ let [buildSuccess, msg] = ProcUtil.getExitStatusAndString(estatus);
+ if (!buildSuccess) {
buildTaskset.finish(false);
- this._analyzeBuildFailure(t, architecture, component, component_src,
- currentVcsVersion, previousVcsVersion);
- throw new Error("Build failure in component " + buildname);
+ this._analyzeBuildFailure(t, architecture, component, componentSrc,
+ currentVcsVersion, previousVcsVersion, cancellable);
+ throw new Error("Build failure in component " + buildname + " : " + msg);
}
let recordedMetaPath = componentResultdir.get_child('_ostbuild-meta.json');
@@ -479,7 +480,7 @@ const Build = new Lang.Class({
let rootdir = this.workdir.get_child('roots');
let composeRootdir = rootdir.get_child(target['name']);
GSystem.shutil_rm_rf(composeRootdir, cancellable);
- GSystem.file_ensure_directory(composeRootdir, cancellable);
+ GSystem.file_ensure_directory(composeRootdir, true, cancellable);
let relatedRefs = {};
let baseRevision = ProcUtil.runSyncGetOutputUTF8Stripped(['ostree', '--repo=' + this.repo.get_path(),
@@ -517,7 +518,7 @@ const Build = new Lang.Class({
let subtrees = treeContent['trees'];
for (let j = 0; j < subtrees.length; j++) {
let subpath = subtrees[j];
- compose_contents.append([rev, subpath]);
+ composeContents.push([rev, subpath]);
}
}
@@ -536,9 +537,9 @@ const Build = new Lang.Class({
'checkout', '--user-mode', '--no-triggers', '--union',
'--from-file=' + contentsTmpPath.get_path(), composeRootdir.get_path()],
cancellable);
- GSystem.file_unlink(contentsTmppath, cancellable);
+ GSystem.file_unlink(contentsTmpPath, cancellable);
- contentsPath = composeRootdir.get_child('contents.json');
+ let contentsPath = composeRootdir.get_child('contents.json');
JsonUtil.writeJsonFileAtomic(contentsPath, this._snapshot, cancellable);
let treename = 'trees/' + target['name'];
@@ -587,7 +588,7 @@ const Build = new Lang.Class({
this.repo.get_path()];
// We specifically want to kill off any environment variables jhbuild
// may have set.
- env = {};
+ let env = {};
Lang.copyProperties(BuildUtil.BUILD_ENV, env);
env['DL_DIR'] = downloads.get_path();
env['SSTATE_DIR'] = sstateDir.get_path();
@@ -668,7 +669,7 @@ const Build = new Lang.Class({
for (let i = 0; i < args.components.length; i++) {
let name = args.components[i];
let component = Snapshot.getComponent(this._snapshot, name);
- this._forceBuildComponents[name] = true;
+ this.forceBuildComponents[name] = true;
}
let componentsToBuild = [];
@@ -704,15 +705,15 @@ const Build = new Lang.Class({
let architecture = architectures[i];
let target = {};
targetsList.push(target);
- target['name'] = prefix + '-' + architecture + '-' + target_component_type;
+ target['name'] = prefix + '-' + architecture + '-' + targetComponentType;
- let runtimeRef = base_prefix + '-' + architecture + '-runtime';
- let buildrootRef = base_prefix + '-' + architecture + '-devel';
+ let runtimeRef = basePrefix + '-' + architecture + '-runtime';
+ let buildrootRef = basePrefix + '-' + architecture + '-devel';
let baseRef;
if (targetComponentType == 'runtime') {
baseRef = runtimeRef;
} else {
- baseFef = buildrootRef;
+ baseRef = buildrootRef;
}
target['base'] = {'name': baseRef,
'runtime': runtimeRef,
@@ -726,8 +727,8 @@ const Build = new Lang.Class({
}
let contents = [];
- for (let i = 0; i < target_components.length; i++) {
- let component = target_components[i];
+ for (let i = 0; i < targetComponents.length; i++) {
+ let component = targetComponents[i];
if (component['bootstrap']) {
continue;
}
@@ -748,8 +749,8 @@ const Build = new Lang.Class({
}
}
- for (let i = 0; i < targets_list.length; i++) {
- let target = targets_list[i];
+ for (let i = 0; i < targetsList.length; i++) {
+ let target = targetsList[i];
log(Format.vprintf("Composing %s from %d components", [target['name'], target['contents'].length]));
this._composeOneTarget(target, componentBuildRevs, cancellable);
}
@@ -757,8 +758,12 @@ const Build = new Lang.Class({
});
-var app = new Build();
-GLib.idle_add(GLib.PRIORITY_DEFAULT,
- function() { try { app.execute(ARGV); } finally { loop.quit(); }; return false; });
-loop.run();
+function main(argv) {
+ let ecode = 1;
+ var app = new Build();
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ function() { try { app.execute(argv); ecode = 0; } finally { loop.quit(); }; return false; });
+ loop.run();
+ return ecode;
+}
diff --git a/src/ostbuild/js/buildutil.js b/src/ostbuild/js/buildutil.js
index d9273a6..0f3d1c7 100644
--- a/src/ostbuild/js/buildutil.js
+++ b/src/ostbuild/js/buildutil.js
@@ -15,6 +15,10 @@
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
+const Lang = imports.lang;
+
const BUILD_ENV = {
'HOME' : '/',
'HOSTNAME' : 'ostbuild',
diff --git a/src/ostbuild/js/checkout.js b/src/ostbuild/js/checkout.js
index f956f62..291ed4a 100644
--- a/src/ostbuild/js/checkout.js
+++ b/src/ostbuild/js/checkout.js
@@ -1,5 +1,3 @@
-#!/usr/bin/env gjs
-
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
@@ -42,6 +40,7 @@ const Checkout = new Lang.Class({
this.config = Config.get();
this.workdir = Gio.File.new_for_path(this.config.getGlobal('workdir'));
this.mirrordir = Gio.File.new_for_path(this.config.getGlobal('mirrordir'));
+ this.patchdir = this.workdir.get_child('patches');
if (!this.mirrordir.query_exists(cancellable))
throw new Error("Need mirrordir: "+ this.mirrordir.get_path());
this.prefix = args.prefix || this.config.getPrefix();
@@ -98,16 +97,17 @@ const Checkout = new Lang.Class({
}
if (component['patches']) {
+ let patchdir;
if (args.patches_path == null) {
patchdir = Vcs.checkoutPatches(this.mirrordir, this.patchdir, component, cancellable);
} else {
- patchdir = args.patches_path
+ patchdir = Gio.File.new_for_path(args.patches_path);
}
- patches = BuildUtil.getPatchPathsForComponent(patchdir, component)
+ let patches = BuildUtil.getPatchPathsForComponent(patchdir, component)
for (let i = 0; i < patches.length; i++) {
let patch = patches[i];
- ProcUtil.runSync(['git', 'am', '--ignore-date', '-3', patch], cancellable,
- {cwd:checkoutdir.get_path()});
+ ProcUtil.runSync(['git', 'am', '--ignore-date', '-3', patch.get_path()], cancellable,
+ {cwd:checkoutdir});
}
}
@@ -118,9 +118,11 @@ const Checkout = new Lang.Class({
}
});
-let ecode = 1;
-var checkout = new Checkout();
-GLib.idle_add(GLib.PRIORITY_DEFAULT,
- function() { try { checkout.execute(ARGV); ecode = 0; } finally { loop.quit(); }; return false; });
-loop.run();
-ecode;
+function main(argv) {
+ let ecode = 1;
+ var checkout = new Checkout();
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ function() { try { checkout.execute(argv); ecode = 0; } finally { loop.quit(); }; return false; });
+ loop.run();
+ return ecode;
+}
diff --git a/src/ostbuild/js/config.js b/src/ostbuild/js/config.js
index d006387..d1447ba 100644
--- a/src/ostbuild/js/config.js
+++ b/src/ostbuild/js/config.js
@@ -1,5 +1,6 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
+const Lang = imports.lang;
const GSystem = imports.gi.GSystem;
diff --git a/src/ostbuild/js/git_mirror.js b/src/ostbuild/js/git_mirror.js
index 8583e15..adeee0f 100644
--- a/src/ostbuild/js/git_mirror.js
+++ b/src/ostbuild/js/git_mirror.js
@@ -101,7 +101,11 @@ const GitMirror = new Lang.Class({
}
});
-var gitMirror = new GitMirror();
-GLib.idle_add(GLib.PRIORITY_DEFAULT,
- function() { try { gitMirror.execute(ARGV); } finally { loop.quit(); }; return false; });
-loop.run();
+function main(argv) {
+ let ecode = 1;
+ var gitMirror = new GitMirror();
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ function() { try { gitMirror.execute(argv); ecode = 0; } finally { loop.quit(); }; return false; });
+ loop.run();
+ return ecode;
+}
diff --git a/src/ostbuild/js/main.js b/src/ostbuild/js/main.js
new file mode 100755
index 0000000..ee7ae01
--- /dev/null
+++ b/src/ostbuild/js/main.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2011 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.
+
+const Format = imports.format;
+
+const BUILTINS = {'autobuilder': "Run resolve and build",
+ 'checkout': "Check out source tree",
+ 'prefix': "Display or modify \"prefix\" (build target)",
+ 'git-mirror': "Update internal git mirror for one or more components",
+ 'resolve': "Expand git revisions in source to exact targets",
+ 'build': "Build multiple components and generate trees"};
+
+function usage(ecode) {
+ print("Builtins:");
+ for (let builtin in BUILTINS) {
+ let description = BUILTINS[builtin];
+ print(Format.vprintf(" %s - %s", [builtin, description]));
+ }
+ return ecode;
+}
+
+if (ARGV.length < 1) {
+ usage(1);
+} else if (ARGV[0] == '-h' || ARGV[0] == '--help') {
+ usage(0);
+} else {
+ let name = ARGV[0];
+ if (!BUILTINS[name]) {
+ usage(1);
+ }
+ let args = ARGV.concat();
+ args.shift();
+ imports[name.replace(/-/g, '_')].main(args);
+}
+
+
diff --git a/src/ostbuild/js/procutil.js b/src/ostbuild/js/procutil.js
index 6fcfdf2..b58372d 100644
--- a/src/ostbuild/js/procutil.js
+++ b/src/ostbuild/js/procutil.js
@@ -24,7 +24,7 @@ function _setContextFromParams(context, params) {
if (params.env)
context.set_environment(params.env);
- if (params.stderr)
+ if (params.stderr != null)
context.set_stderr_disposition(params.stderr);
}
@@ -33,10 +33,13 @@ function _wait_sync_check_internal(proc, cancellable) {
proc.wait_sync_check(cancellable);
} catch (e) {
if (e.domain == GLib.spawn_exit_error_quark() ||
- e.matches(GLib.SpawnError, GLib.SpawnError.FAILED))
- throw new Error(Format.vprintf("Child process %s: %s", [JSON.stringify(proc.context.argv), e.message]));
- else
+ e.matches(GLib.SpawnError, GLib.SpawnError.FAILED)) {
+ let err = new Error(Format.vprintf("Child process %s: %s", [JSON.stringify(proc.context.argv), e.message]));
+ err.origError = e;
+ throw err;
+ } else {
throw e;
+ }
}
}
@@ -49,7 +52,9 @@ function runSync(args, cancellable, params) {
}
function _runSyncGetOutputInternal(args, cancellable, params, splitLines) {
- params = Params.parse(params, {cwd: null});
+ params = Params.parse(params, {cwd: null,
+ env: null,
+ stderr: null});
let context = new GSystem.SubprocessContext({argv: args});
_setContextFromParams(context, params);
context.set_stdout_disposition(GSystem.SubprocessStreamDisposition.PIPE);
@@ -88,22 +93,21 @@ function runSyncGetOutputUTF8Stripped(args, cancellable, params) {
}
function runSyncGetOutputUTF8StrippedOrNull(args, cancellable, params) {
+ if (!params)
+ params = {};
try {
- params.stderr = Gio.SubprocessStreamDisposition.NULL;
+ params.stderr = GSystem.SubprocessStreamDisposition.NULL;
return runSyncGetOutputUTF8Stripped(args, cancellable, params);
} catch (e) {
- if (e.domain == GLib.spawn_exit_error_quark())
+ if (e.origError && e.origError.domain == GLib.spawn_exit_error_quark())
return null;
throw e;
}
}
-function asyncWaitCheckFinish(process, result) {
- let [waitSuccess, estatus] = process.wait_finish(result);
- let success = false;
- let errorMsg = null;
+function getExitStatusAndString(ecode) {
try {
- GLib.spawn_check_exit_status(estatus);
+ GLib.spawn_check_exit_status(ecode);
return [true, null];
} catch (e) {
if (e.domain == GLib.spawn_exit_error_quark() ||
@@ -113,3 +117,8 @@ function asyncWaitCheckFinish(process, result) {
throw e;
}
}
+
+function asyncWaitCheckFinish(process, result) {
+ let [waitSuccess, ecode] = process.wait_finish(result);
+ return getExitStatusAndString(ecode);
+}
diff --git a/src/ostbuild/js/resolve.js b/src/ostbuild/js/resolve.js
index 025d1a6..4d93f85 100644
--- a/src/ostbuild/js/resolve.js
+++ b/src/ostbuild/js/resolve.js
@@ -142,7 +142,11 @@ const Resolve = new Lang.Class({
}
});
-var resolve = new Resolve();
-GLib.idle_add(GLib.PRIORITY_DEFAULT,
- function() { try { resolve.execute(ARGV); } finally { loop.quit(); }; return false; });
-loop.run();
+function main(argv) {
+ let ecode = 1;
+ var resolve = new Resolve();
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ function() { try { resolve.execute(argv); ecode = 0; } finally { loop.quit(); }; return false; });
+ loop.run();
+ return ecode;
+}
diff --git a/src/ostbuild/js/snapshot.js b/src/ostbuild/js/snapshot.js
index b9dd294..8925aa8 100644
--- a/src/ostbuild/js/snapshot.js
+++ b/src/ostbuild/js/snapshot.js
@@ -16,7 +16,10 @@
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
+const Gio = imports.gi.Gio;
+
const JsonDB = imports.jsondb;
+const Lang = imports.lang;
function _componentDict(snapshot) {
let r = {};
diff --git a/src/ostbuild/js/task.js b/src/ostbuild/js/task.js
index 018aaf8..464e283 100644
--- a/src/ostbuild/js/task.js
+++ b/src/ostbuild/js/task.js
@@ -1,6 +1,7 @@
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const format = imports.format;
+const Lang = imports.lang;
const GSystem = imports.gi.GSystem;
diff --git a/src/ostbuild/ostbuild.in b/src/ostbuild/ostbuild.in
index 81c71a5..bdb923f 100755
--- a/src/ostbuild/ostbuild.in
+++ b/src/ostbuild/ostbuild.in
@@ -1,33 +1,11 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2011 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.
+#!/bin/sh
-import os
-import sys
-import __builtin__
+jsdir= pkgdatadir@/js
-__builtin__.__dict__['DATADIR'] = '@datarootdir@'
-__builtin__.__dict__['LIBDIR'] = '@libdir@'
-# This is a private directory, we don't want to pollute the global
-# namespace.
-path = os.path.join('@libdir@', 'ostbuild')
-sys.path.insert(0, path)
+export GI_TYPELIB_PATH="@pkglibdir@/girepository-1.0${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"
+export LD_LIBRARY_PATH="@pkglibdir@/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+# Don't auto-spawn a session bus
+export GIO_USE_VFS=local
+export OSTBUILD_LIBDIR= pkglibdir@
-from pyostbuild.main import main
-
-sys.exit(main(sys.argv[1:]))
+exec gjs -I "${jsdir}" "${jsdir}/main.js" "$@"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]