From 823fa125227caeb069fe634f387e45b28fcb0468 Mon Sep 17 00:00:00 2001 From: Karol Baraniecki Date: Fri, 3 Nov 2017 12:12:21 +0100 Subject: [PATCH] nodejs-current: Fix #1192 by removing useless link() (#1701) As it turns out, npm does an "optimisation" by instead of doing a simple rename(), it link()s the source file to its destination, and unlink()s the source file. Reverse that if process.platform is 'android'. --- packages/nodejs-current/npm-link-patch.patch | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/nodejs-current/npm-link-patch.patch diff --git a/packages/nodejs-current/npm-link-patch.patch b/packages/nodejs-current/npm-link-patch.patch new file mode 100644 index 00000000..36cdf23e --- /dev/null +++ b/packages/nodejs-current/npm-link-patch.patch @@ -0,0 +1,29 @@ +--- ../node/deps/npm/node_modules/cacache/lib/util/move-file.js 2017-10-22 19:30:25.778456404 +0200 ++++ ./deps/npm/node_modules/cacache/lib/util/move-file.js 2017-10-22 20:41:18.021337095 +0200 +@@ -4,6 +4,7 @@ + const BB = require('bluebird') + const chmod = BB.promisify(fs.chmod) + const unlink = BB.promisify(fs.unlink) ++const access = BB.promisify(fs.access) + let move + let pinflight + +@@ -18,6 +19,18 @@ + // content their own way. + // + // Note that, as the name suggests, this strictly only supports file moves. ++ ++ ++ // Calling link() on android is not allowed, we get a SELinux security exception ++ if(process.platform === 'android') { ++ return access(dest, fs.constants.F_OK) ++ .catch(err => { ++ if (!move) { move = require('move-concurrently') } ++ return move(src, dest, { BB, fs }) ++ .then(() => chmod(dest, '0444')) ++ }) ++ } ++ + return BB.fromNode(cb => { + fs.link(src, dest, err => { + if (err) { -- 2.11.0