summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2018-06-19 21:49:31 +0200
committerChristian Heimes <cheimes@redhat.com>2018-07-12 15:38:01 +0200
commitdf95ba598313b8b03a492a3c89af151ef0faa08d (patch)
tree11876c10d858a50d3f3e201ce6029053db37c3e3
parentca7cece13303b3610a71b9e2a0adcb462006382b (diff)
downloadfreeipa-df95ba598313b8b03a492a3c89af151ef0faa08d.tar.gz
freeipa-df95ba598313b8b03a492a3c89af151ef0faa08d.tar.xz
freeipa-df95ba598313b8b03a492a3c89af151ef0faa08d.zip
WebUI build: use NodeJS instead of Rhino
Rhino is no longer mainstream, nor is Nashorn. In addition it is quite slow (about 10x) in comparison to NodeJS. Over the years NodeJS became common part of OSes, thus one of the original reasons why use Rhino went away. The change in 01-Make-dojo-builder-buildable-by-itself.patch fixes an incorrect change of the patch (it was not processing input options well). Removing configRhino.js and adding configNode.js are prerequisites for Dojo Builder. These files are copied from Dojo project. Without them it doesn̈́'t run. In long run, it would be good to replace Dojo builder with something else but that is outside of this commit/PR. Last changes are preparation for update to latest stable version of Dojo 1. The updated Dojo and Dojo builder are in subsequent commit. Reviewed-By: Armando Neto <abiagion@redhat.com>
-rw-r--r--freeipa.spec.in4
-rw-r--r--install/ui/src/build.profile.js4
-rwxr-xr-xinstall/ui/util/build.sh3
-rw-r--r--install/ui/util/build/_base/configNode.js108
-rw-r--r--install/ui/util/build/_base/configRhino.js121
-rw-r--r--install/ui/util/build/patches/01-Make-dojo-builder-buildable-by-itself.patch20
-rwxr-xr-xinstall/ui/util/prepare-dojo.sh2
7 files changed, 123 insertions, 139 deletions
diff --git a/freeipa.spec.in b/freeipa.spec.in
index 5fff89ee3..014d373d4 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -156,7 +156,7 @@ BuildRequires: libsss_idmap-devel
BuildRequires: libsss_certmap-devel
# 1.15.3: sss_nss_getlistbycert (https://pagure.io/SSSD/sssd/issue/3050)
BuildRequires: libsss_nss_idmap-devel >= 1.15.3
-BuildRequires: rhino
+BuildRequires: nodejs
BuildRequires: uglify-js
BuildRequires: libverto-devel
BuildRequires: libunistring-devel
@@ -925,8 +925,6 @@ ln -sr %{_builddir}/freeipa-%{version}-python2 %{_builddir}/freeipa-%{version}
%endif
%build
-# UI compilation segfaulted on some arches when the stack was lower (#1040576)
-export JAVA_STACK_SIZE="8m"
# PATH is workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1005235
export PATH=/usr/bin:/usr/sbin:$PATH
diff --git a/install/ui/src/build.profile.js b/install/ui/src/build.profile.js
index aebe9b18f..40e988b56 100644
--- a/install/ui/src/build.profile.js
+++ b/install/ui/src/build.profile.js
@@ -17,9 +17,9 @@ var profile = (function(){
selectorEngine: "lite",
staticHasFeatures: {
- "host-rhino":1,
+ "host-rhino":0,
"host-browser":0,
- "host-node":0,
+ "host-node":1,
"dom":0,
"dojo-has-api":1,
"dojo-xhr-factory":0,
diff --git a/install/ui/util/build.sh b/install/ui/util/build.sh
index e7f6172ab..478b96200 100755
--- a/install/ui/util/build.sh
+++ b/install/ui/util/build.sh
@@ -32,6 +32,5 @@ if [[ ! $profile ]] ; then
exit 1
fi
-RHINO="java -Xss${JAVA_STACK_SIZE:-512k} -classpath /usr/share/java/js.jar org.mozilla.javascript.tools.shell.Main"
-$RHINO $DIR/build/build.js baseUrl=$DIR/build load=build profile=$DIR/../src/$profile.profile.js
+node $DIR/build/build.js load=build profile=$DIR/../src/$profile.profile.js
exit $?
diff --git a/install/ui/util/build/_base/configNode.js b/install/ui/util/build/_base/configNode.js
new file mode 100644
index 000000000..9982cd6a6
--- /dev/null
+++ b/install/ui/util/build/_base/configNode.js
@@ -0,0 +1,108 @@
+exports.config = function(config){
+ // summary:
+ // This module provides bootstrap configuration for running dojo in node.js
+
+ // any command line arguments with the load flag are pushed into deps
+ for(var deps = [], args = [], i = 0; i < process.argv.length; i++){
+ var arg = (process.argv[i] + "").split("=");
+ if(arg[0] == "load"){
+ deps.push(arg[1]);
+ }else if(arg[0] == "mapPackage") {
+ var parts = arg[1].split(":"),
+ name = parts[0],
+ location=parts[1],
+ isPrexisting = false;
+
+ for (var j = 0; j < config.packages.length; j++) {
+ var pkg = config.packages[j];
+ if (pkg.name === name) {
+ pkg.location = location;
+ isPrexisting = true;
+ break;
+ }
+ }
+
+ if (!isPrexisting) {
+ config.packages.push({
+ name: name,
+ location: location
+ });
+ }
+ }else{
+ args.push(arg);
+ }
+ }
+
+ var fs = require("fs");
+
+ // make sure global require exists
+ //if (typeof global.require=="undefined"){
+ // global.require= {};
+ //}
+
+ // reset the has cache with node-appropriate values;
+ var hasCache = {
+ "host-node":1,
+ "host-browser":0,
+ "dom":0,
+ "dojo-has-api":1,
+ "dojo-xhr-factory":0,
+ "dojo-inject-api":1,
+ "dojo-timeout-api":0,
+ "dojo-trace-api":1,
+ "dojo-dom-ready-api":0,
+ "dojo-publish-privates":1,
+ "dojo-sniff":0,
+ "dojo-loader":1,
+ "dojo-test-xd":0,
+ "dojo-test-sniff":0
+ };
+ for(var p in hasCache){
+ config.hasCache[p] = hasCache[p];
+ }
+
+ var vm = require('vm'),
+ path = require('path');
+
+ // reset some configuration switches with node-appropriate values
+ var nodeConfig = {
+ baseUrl: path.dirname(process.argv[1]),
+ commandLineArgs:args,
+ deps:deps,
+ timeout:0,
+
+ // TODO: really get the locale
+ locale:"en-us",
+
+ loaderPatch: {
+ log:function(item){
+ // define debug for console messages during dev instead of console.log
+ // (node's heavy async makes console.log confusing sometimes)
+ var util = require("util");
+ util.debug(util.inspect(item));
+ },
+
+ eval: function(__text, __urlHint){
+ return vm.runInThisContext(__text, __urlHint);
+ },
+
+ injectUrl: function(url, callback){
+ try{
+ vm.runInThisContext(fs.readFileSync(url, "utf8"), url);
+ callback();
+ }catch(e){
+ this.log("failed to load resource (" + url + ")");
+ this.log(e);
+ }
+ },
+
+ getText: function(url, sync, onLoad){
+ // TODO: implement async and http/https handling
+ onLoad(fs.readFileSync(url, "utf8"));
+ }
+ }
+ };
+ for(p in nodeConfig){
+ config[p] = nodeConfig[p];
+ }
+};
diff --git a/install/ui/util/build/_base/configRhino.js b/install/ui/util/build/_base/configRhino.js
deleted file mode 100644
index f337d9d24..000000000
--- a/install/ui/util/build/_base/configRhino.js
+++ /dev/null
@@ -1,121 +0,0 @@
-function rhinoDojoConfig(config, baseUrl, rhinoArgs){
- // summary:
- // This module provides bootstrap configuration for running dojo in rhino.
-
- // TODO: v1.6 tries to set dojo.doc and dojo.body in rhino; why?
-
- // get a minimal console up
- var log = function(hint, args){
- print((hint ? hint + ":" : "") + args[0]);
- for(var i = 1; i < args.length; i++){
- print(", " + args[i]);
- }
- };
- // intentionally define console in the global namespace
- console= {
- log: function(){ log(0, arguments); },
- error: function(){ log("ERROR", arguments); },
- warn: function(){ log("WARN", arguments); }
- };
-
- // any command line arguments with the load flag are pushed into deps
- for(var deps = [], i = 0; i < rhinoArgs.length; i++){
- var arg = (rhinoArgs[i] + "").split("=");
- if(arg[0] == "load"){
- deps.push(arg[1]);
- }
- }
-
- // provides timed callbacks using Java threads
- if(typeof setTimeout == "undefined" || typeof clearTimeout == "undefined"){
- var timeouts = [];
- clearTimeout = function(idx){
- if(!timeouts[idx]){ return; }
- timeouts[idx].stop();
- };
-
- setTimeout = function(func, delay){
- var def = {
- sleepTime:delay,
- hasSlept:false,
-
- run:function(){
- if(!this.hasSlept){
- this.hasSlept = true;
- java.lang.Thread.currentThread().sleep(this.sleepTime);
- }
- try{
- func();
- }catch(e){
- console.debug("Error running setTimeout thread:" + e);
- }
- }
- };
-
- var runnable = new java.lang.Runnable(def);
- var thread = new java.lang.Thread(runnable);
- thread.start();
- return timeouts.push(thread) - 1;
- };
- }
-
- var isLocal = function(url){
- return (new java.io.File(url)).exists();
- };
-
- // reset the has cache with node-appropriate values;
- var hasCache = {
- "host-rhino":1,
- "host-browser":0,
- "dom":0,
- "dojo-has-api":1,
- "dojo-xhr-factory":0,
- "dojo-inject-api":1,
- "dojo-timeout-api":0,
- "dojo-trace-api":1,
- "dojo-loader-catches":1,
- "dojo-dom-ready-api":0,
- "dojo-publish-privates":1,
- "dojo-sniff":0,
- "dojo-loader":1,
- "dojo-test-xd":0,
- "dojo-test-sniff":0
- };
- for(var p in hasCache){
- config.hasCache[p] = hasCache[p];
- }
-
- // reset some configuration switches with rhino-appropriate values
- var rhinoConfig = {
- baseUrl:baseUrl,
- commandLineArgs:rhinoArgs,
- deps:deps,
- timeout:0,
- locale:String(java.util.Locale.getDefault().toString().replace('_', '-').toLowerCase()),
-
- loaderPatch:{
- injectUrl: function(url, callback){
- try{
- if(isLocal(url)){
- load(url);
- }else{
- require.eval(readUrl(url, "UTF-8"));
- }
- callback();
- }catch(e){
- console.log("failed to load resource (" + url + ")");
- console.log(e);
- }
- },
-
- getText: function(url, sync, onLoad){
- // TODO: test https://bugzilla.mozilla.org/show_bug.cgi?id=471005; see v1.6 hostenv_rhino
- // note: async mode not supported in rhino
- onLoad(isLocal(url) ? readFile(url, "UTF-8") : readUrl(url, "UTF-8"));
- }
- }
- };
- for(p in rhinoConfig){
- config[p] = rhinoConfig[p];
- }
-} \ No newline at end of file
diff --git a/install/ui/util/build/patches/01-Make-dojo-builder-buildable-by-itself.patch b/install/ui/util/build/patches/01-Make-dojo-builder-buildable-by-itself.patch
index 69160cd86..0e4d7d62c 100644
--- a/install/ui/util/build/patches/01-Make-dojo-builder-buildable-by-itself.patch
+++ b/install/ui/util/build/patches/01-Make-dojo-builder-buildable-by-itself.patch
@@ -1,7 +1,7 @@
-From c0962cfb520d25c367689243b71e43af1dcc0601 Mon Sep 17 00:00:00 2001
+From be32e8039fca859a8fc9202c50dcd8663023dd53 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Thu, 8 Nov 2012 13:22:30 +0100
-Subject: [PATCH] Make dojo builder buildable by itself
+Subject: [PATCH 1/2] Make dojo builder buildable by itself
Dojo builder is now buildable by itself. It just needed a packackage information,
profile and separating of internal definition of commanLineArgs module to separate
@@ -22,7 +22,7 @@ get rid of this dependency.
create mode 100644 build/package.json
diff --git a/build/argv.js b/build/argv.js
-index 18bda74b0eb80e37d9c83cb23a10f29f8ffe91d9..997576687eb74cbb6a6a293b3a855a6d15142368 100644
+index c6589afb..98d95bf8 100644
--- a/build/argv.js
+++ b/build/argv.js
@@ -5,7 +5,7 @@ define([
@@ -36,7 +36,7 @@ index 18bda74b0eb80e37d9c83cb23a10f29f8ffe91d9..997576687eb74cbb6a6a293b3a855a6d
"./messages",
diff --git a/build/build.profile.js b/build/build.profile.js
new file mode 100644
-index 0000000000000000000000000000000000000000..507728c283c5703106fe029c0fd282cb864c994d
+index 00000000..507728c2
--- /dev/null
+++ b/build/build.profile.js
@@ -0,0 +1,32 @@
@@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..507728c283c5703106fe029c0fd282cb
\ No newline at end of file
diff --git a/build/commandLineArgs.js b/build/commandLineArgs.js
new file mode 100644
-index 0000000000000000000000000000000000000000..41df62e31a05ef2c00e1eb609c0fabe8641e2d03
+index 00000000..41df62e3
--- /dev/null
+++ b/build/commandLineArgs.js
@@ -0,0 +1,7 @@
@@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..41df62e31a05ef2c00e1eb609c0fabe8
+});
\ No newline at end of file
diff --git a/build/main.js b/build/main.js
-index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74d54939a3 100644
+index 131ed644..c0eb36e9 100644
--- a/build/main.js
+++ b/build/main.js
@@ -33,16 +33,14 @@
@@ -105,7 +105,7 @@ index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74
- return process.argv.slice(2);
- });
+ //arg[0] is node; argv[1] is dojo.js; therefore, start with argv[2]
-+ commandLineArgs.push(process.argv.slice(2));
++ commandLineArgs.push.apply(commandLineArgs, process.argv.slice(2));
- // helps during dev or heavily async node...
+ // helps during dev or heavily async node
@@ -137,13 +137,13 @@ index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74
}else{
diff --git a/build/package.json b/build/package.json
new file mode 100644
-index 0000000000000000000000000000000000000000..568101cb1a182d3415c73d02e151359e1ce3e27d
+index 00000000..576030f2
--- /dev/null
+++ b/build/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "build",
-+ "version":"1.8.1",
++ "version":"1.13.0",
+ "directories": {
+ "lib": "."
+ },
@@ -165,5 +165,5 @@ index 0000000000000000000000000000000000000000..568101cb1a182d3415c73d02e151359e
+ "dojoBuild": "build.profile.js"
+}
--
-1.7.11.7
+2.14.3
diff --git a/install/ui/util/prepare-dojo.sh b/install/ui/util/prepare-dojo.sh
index 398e9b070..e6d7594c2 100755
--- a/install/ui/util/prepare-dojo.sh
+++ b/install/ui/util/prepare-dojo.sh
@@ -76,7 +76,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOJO_DIR=$DIR/../../../../dojo
# working version of Dojo toolkit
-BRANCH='1.8.3'
+BRANCH='1.13.0'
YES='YES'
args=`getopt -q -u -l help,checkout,clone,patches,links,dojo,util,all,branch:,dir: a $*`