Fredrik Fornwall
9 years ago
8 changed files with 210 additions and 0 deletions
@ -0,0 +1,59 @@ |
|||
# From https://github.com/etiago/termux-nodejs-lts |
|||
TERMUX_PKG_HOMEPAGE=http://nodejs.org/ |
|||
TERMUX_PKG_DESCRIPTION="Platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications" |
|||
TERMUX_PKG_VERSION=4.4.3 |
|||
TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.gz |
|||
TERMUX_PKG_DEPENDS="openssl, libuv" |
|||
TERMUX_PKG_RM_AFTER_INSTALL="lib/node_modules/npm/html lib/node_modules/npm/make.bat share/systemtap lib/dtrace" |
|||
TERMUX_PKG_BUILD_IN_SRC=yes |
|||
TERMUX_PKG_CONFLICTS=nodejs |
|||
|
|||
termux_step_configure () { |
|||
#XXX: node.js build does not handle already installed headers |
|||
# https://github.com/nodejs/node/issues/2637 |
|||
# So we remove them here and restore afterwards. |
|||
rm -Rf $TERMUX_PKG_CACHEDIR/gtest-include-dir $TERMUX_PKG_CACHEDIR/ares-includes |
|||
test -d $TERMUX_PREFIX/include/gtest && |
|||
mv $TERMUX_PREFIX/include/gtest $TERMUX_PKG_CACHEDIR/gtest-include-dir |
|||
test -f $TERMUX_PREFIX/include/ares.h && |
|||
mkdir $TERMUX_PKG_CACHEDIR/ares-includes/ && |
|||
mv $TERMUX_PREFIX/include/ares* $TERMUX_PKG_CACHEDIR/ares-includes/ |
|||
|
|||
# https://github.com/nodejs/build/issues/266: "V8 can handle cross compiling of |
|||
# snapshots if the {CC,CXX}_host variables are defined, by compiling the |
|||
# mksnapshot executable with the host compiler". But this currently fails |
|||
# due to the host build picking up targets flags. |
|||
export CC_host=gcc |
|||
export CXX_host=g++ |
|||
|
|||
if [ $TERMUX_ARCH = "arm" ]; then |
|||
DEST_CPU="arm" |
|||
elif [ $TERMUX_ARCH = "i686" ]; then |
|||
DEST_CPU="ia32" |
|||
elif [ $TERMUX_ARCH = "aarch64" ]; then |
|||
DEST_CPU="arm64" |
|||
elif [ $TERMUX_ARCH = "x86_64" ]; then |
|||
DEST_CPU="x64" |
|||
else |
|||
echo "Unsupported arch: $TERMUX_ARCH" |
|||
exit 1 |
|||
fi |
|||
|
|||
#LDFLAGS+=" -lstlport_static" |
|||
|
|||
./configure \ |
|||
--prefix=$TERMUX_PREFIX \ |
|||
--dest-cpu=$DEST_CPU \ |
|||
--dest-os=android \ |
|||
--shared-openssl --shared-zlib --shared-libuv \ |
|||
--without-snapshot |
|||
} |
|||
|
|||
termux_step_post_massage () { |
|||
test -d $TERMUX_PKG_CACHEDIR/gtest-include-dir && |
|||
mv $TERMUX_PKG_CACHEDIR/gtest-include-dir $TERMUX_PREFIX/include/gtest |
|||
test -d $TERMUX_PKG_CACHEDIR/ares-includes && |
|||
mv $TERMUX_PKG_CACHEDIR/ares-includes/* $TERMUX_PREFIX/include/ |
|||
# Exit with success to avoid aborting script due to set -e: |
|||
true |
|||
} |
@ -0,0 +1,31 @@ |
|||
etiago: Backported this from fornwall's patch. |
|||
|
|||
XXX: Revert https://github.com/nodejs/node/pull/3135 since it causes |
|||
problems when trying to compile on Android with shared libuv, zlib |
|||
and openssl due to v8 not using stlport correctly. |
|||
|
|||
diff -u -r ../node-v4.4.3/configure ./configure > configure.patch
|
|||
--- ../node-v4.4.3/configure 2016-04-12 19:42:04.000000000 +0000
|
|||
+++ ./configure 2016-04-19 09:09:06.036762598 +0000
|
|||
@@ -760,15 +760,15 @@
|
|||
if pkg_cflags: |
|||
output['include_dirs'] += ( |
|||
filter(None, map(str.strip, pkg_cflags.split('-I')))) |
|||
- elif options.__dict__[shared_lib + '_includes']:
|
|||
- output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
|
|||
+ #elif options.__dict__[shared_lib + '_includes']:
|
|||
+ # output['include_dirs'] += [options.__dict__[shared_lib + '_includes']]
|
|||
|
|||
# libpath needs to be provided ahead libraries |
|||
if pkg_libpath: |
|||
- output['libraries'] += [pkg_libpath]
|
|||
- elif options.__dict__[shared_lib + '_libpath']:
|
|||
- output['libraries'] += [
|
|||
- '-L%s' % options.__dict__[shared_lib + '_libpath']]
|
|||
+ output['libraries'] += filter(None, map(str.strip, pkg_cflags.split('-L')))
|
|||
+ #elif options.__dict__[shared_lib + '_libpath']:
|
|||
+ # output['libraries'] += [
|
|||
+ # '-L%s' % options.__dict__[shared_lib + '_libpath']]
|
|||
|
|||
default_libs = getattr(options, shared_lib + '_libname') |
|||
default_libs = map('-l{0}'.format, default_libs.split(',')) |
@ -0,0 +1,12 @@ |
|||
diff -u -r ../node-v4.4.3/deps/npm/lib/build.js ./deps/npm/lib/build.js > deps-npm-lib-build.js.patch
|
|||
--- ../node-v4.4.3/deps/npm/lib/build.js 2016-04-12 19:42:04.000000000 +0000
|
|||
+++ ./deps/npm/lib/build.js 2016-04-19 09:24:57.262100886 +0000
|
|||
@@ -208,6 +208,8 @@
|
|||
|
|||
function linkBin (from, to, gently, cb) { |
|||
if (process.platform !== "win32") { |
|||
+ // Fix shebang paths in binary scripts:
|
|||
+ require('child_process').spawn('termux-fix-shebang', [from])
|
|||
return linkIfExists(from, to, gently, cb) |
|||
} else { |
|||
return cmdShimIfExists(from, to, cb) |
@ -0,0 +1,13 @@ |
|||
diff -u -r ../node-v4.4 |
|||
.3/deps/npm/scripts/install.sh ./deps/npm/scripts/install.sh > deps-npm-scripts-install.sh.patch |
|||
--- ../node-v4.4.3/deps/npm/scripts/install.sh 2016-04-12 19:42:06.000000000 +0000
|
|||
+++ ./deps/npm/scripts/install.sh 2016-04-20 13:14:30.572016130 +0000
|
|||
@@ -69,7 +69,7 @@
|
|||
# set the temp dir |
|||
TMP="${TMPDIR}" |
|||
if [ "x$TMP" = "x" ]; then |
|||
- TMP="/tmp"
|
|||
+ TMP="@TERMUX_PREFIX@/tmp"
|
|||
fi |
|||
TMP="${TMP}/npm.$$" |
|||
rm -rf "$TMP" || true |
@ -0,0 +1,12 @@ |
|||
diff -u -r ../node-v4.4.3/lib/os.js ./lib/os.js > lib-os.js.patch
|
|||
--- ../node-v4.4.3/lib/os.js 2016-04-12 19:42:14.000000000 +0000
|
|||
+++ ./lib/os.js 2016-04-19 09:27:26.330140690 +0000
|
|||
@@ -36,7 +36,7 @@
|
|||
path = process.env.TMPDIR || |
|||
process.env.TMP || |
|||
process.env.TEMP || |
|||
- '/tmp';
|
|||
+ '@TERMUX_PREFIX@/tmp';
|
|||
if (path.length > 1 && path.endsWith('/')) |
|||
path = path.slice(0, -1); |
|||
} |
@ -0,0 +1,17 @@ |
|||
Termux is effectively a single-user system so chown:ing |
|||
does not make much sense. |
|||
|
|||
Without this patch npm fails with EPERM on chown |
|||
for cache.json when first building the local index. |
|||
diff -u -r ../node-v4.4.3/deps/npm/lib/cache/update-index.js ./deps/npm/lib/cache/update-index.js > npm-avoid-chown.patch
|
|||
--- ../node-v4.4.3/deps/npm/lib/cache/update-index.js 2016-04-12 19:42:04.000000000 +0000
|
|||
+++ ./deps/npm/lib/cache/update-index.js 2016-04-19 09:29:54.634171804 +0000
|
|||
@@ -4,7 +4,7 @@
|
|||
var assert = require('assert') |
|||
var path = require('path') |
|||
var mkdir = require('mkdirp') |
|||
-var chownr = require('chownr')
|
|||
+var chownr = function(path, uid, gid, cb) { cb(null); }
|
|||
var npm = require('../npm.js') |
|||
var log = require('npmlog') |
|||
var cacheFile = require('npm-cache-filename') |
@ -0,0 +1,12 @@ |
|||
diff -u -r ../node-v4.4.3/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js ./deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js > npm-tmp-patch.patch
|
|||
--- ../node-v4.4.3/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js 2016-04-12 19:42:05.000000000 +0000
|
|||
+++ ./deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js 2016-04-19 09:33:06.883412631 +0000
|
|||
@@ -14,7 +14,7 @@
|
|||
path = process.env.TMPDIR || |
|||
process.env.TMP || |
|||
process.env.TEMP || |
|||
- '/tmp';
|
|||
+ '@TERMUX_PREFIX@/tmp';
|
|||
} |
|||
|
|||
if (trailingSlashRe.test(path)) { |
@ -0,0 +1,54 @@ |
|||
etiago: Backported this from fornwall's patch. |
|||
|
|||
Without this patch functions such as process.getgroups |
|||
are not built on Android, which breaks things such as |
|||
npm/node_modules/which/which.js. |
|||
|
|||
diff -u -r ../node-v4.4.3/src/node.cc ./src/node.cc > src-node.cc.patch
|
|||
--- ../node-v4.4.3/src/node.cc 2016-04-12 19:42:14.000000000 +0000
|
|||
+++ ./src/node.cc 2016-04-19 07:42:50.984256666 +0000
|
|||
@@ -74,7 +74,7 @@
|
|||
#include <unistd.h> // setuid, getuid |
|||
#endif |
|||
|
|||
-#if defined(__POSIX__) && !defined(__ANDROID__)
|
|||
+#if defined(__POSIX__)
|
|||
#include <pwd.h> // getpwnam() |
|||
#include <grp.h> // getgrnam() |
|||
#endif |
|||
@@ -1718,7 +1718,7 @@
|
|||
} |
|||
|
|||
|
|||
-#if defined(__POSIX__) && !defined(__ANDROID__)
|
|||
+#if defined(__POSIX__)
|
|||
|
|||
static const uid_t uid_not_found = static_cast<uid_t>(-1); |
|||
static const gid_t gid_not_found = static_cast<gid_t>(-1); |
|||
@@ -2038,7 +2038,7 @@
|
|||
} |
|||
} |
|||
|
|||
-#endif // __POSIX__ && !defined(__ANDROID__)
|
|||
+#endif // __POSIX__
|
|||
|
|||
|
|||
void Exit(const FunctionCallbackInfo<Value>& args) { |
|||
@@ -3028,7 +3028,7 @@
|
|||
|
|||
env->SetMethod(process, "umask", Umask); |
|||
|
|||
-#if defined(__POSIX__) && !defined(__ANDROID__)
|
|||
+#if defined(__POSIX__)
|
|||
env->SetMethod(process, "getuid", GetUid); |
|||
env->SetMethod(process, "geteuid", GetEUid); |
|||
env->SetMethod(process, "setuid", SetUid); |
|||
@@ -3042,7 +3042,7 @@
|
|||
env->SetMethod(process, "getgroups", GetGroups); |
|||
env->SetMethod(process, "setgroups", SetGroups); |
|||
env->SetMethod(process, "initgroups", InitGroups); |
|||
-#endif // __POSIX__ && !defined(__ANDROID__)
|
|||
+#endif // __POSIX__
|
|||
|
|||
env->SetMethod(process, "_kill", Kill); |
|||
|
Loading…
Reference in new issue