From 309240162672d1afa0d3b7f4a65b180cc8258d06 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Mon, 27 Mar 2017 22:32:10 -0400 Subject: [PATCH] Build leveldown if ia32 Fix #7915 Auditors: @aekeus leveldown uses prebuild and installs prebuilt binaries. But it doesn't check the env variable properly, or it was uploaded wrongly. This forces a rebuild if it is ia32 --- tools/cibuild.py | 8 +++---- tools/electronBuilderHack.js | 44 ++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/tools/cibuild.py b/tools/cibuild.py index a8fd25fc5e3..888b159c32f 100755 --- a/tools/cibuild.py +++ b/tools/cibuild.py @@ -4,7 +4,6 @@ import subprocess import sys import os.path - MUON_VERSION = '2.57.6' CHROMEDRIVER_VERSION = '2.27' SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) @@ -21,7 +20,6 @@ def execute(argv, env=os.environ): print e.output raise e - def write_npmrc(): data = 'runtime = node\n' \ 'target_arch = %s\n' \ @@ -72,10 +70,10 @@ def run_script(script, args=[]): npm = 'npm.cmd' if is_windows else 'npm' execute([npm, 'install']) -if is_darwin: - execute(['node', './tools/electronBuilderHack.js']) +execute(['node', './tools/electronBuilderHack.js']) + # For whatever reason on linux pstinstall webpack isn't running -elif is_linux: +if is_linux: execute([npm, 'run', 'webpack']) execute([npm, 'run', 'build-package']) diff --git a/tools/electronBuilderHack.js b/tools/electronBuilderHack.js index 0b9a5fc1408..734f8bcc41f 100644 --- a/tools/electronBuilderHack.js +++ b/tools/electronBuilderHack.js @@ -1,24 +1,40 @@ -var os = require('os') -var path = require('path') -var execute = require('./lib/execute') +const os = require('os') +const path = require('path') +const execute = require('./lib/execute') console.log('Patching electron-builder native modules, please wait...') -var braveGyp = path.join(os.homedir(), '.brave-gyp') -var env = { +const braveGyp = path.join(os.homedir(), '.brave-gyp') +const env = { HOME: braveGyp, APPDATA: braveGyp } -var rebuildCmd = '"../.bin/node-gyp" rebuild' +const rebuildCmd = '"../.bin/node-gyp" rebuild' -var cmds = [ - 'cp .npmrc ./node_modules/macos-alias', - 'cp .npmrc ./node_modules/fs-xattr', - 'cd ./node_modules/macos-alias', - rebuildCmd, - 'cd ../fs-xattr', - rebuildCmd -] +const isDarwin = process.platform === 'darwin' + +const cmds = [] +if (process.env.TARGET_ARCH === 'ia32') { + cmds.push( + 'cp .npmrc ./node_modules/leveldown', + 'cd ./node_modules/leveldown', + // leveldown prebuild isn't respecting the npm_config_arch env + // for some reason, so always compile it. + 'npm run rebuild' + ) +} + +if (isDarwin) { + cmds.push( + 'cd ..', + 'cp .npmrc ./node_modules/macos-alias', + 'cp .npmrc ./node_modules/fs-xattr', + 'cd ./node_modules/macos-alias', + rebuildCmd, + 'cd ../fs-xattr', + rebuildCmd + ) +} execute(cmds, env, console.log.bind(null, 'done'))