mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 23:12:22 +00:00
Multi arch builds
This commit is contained in:
parent
ffacbdb733
commit
d520918071
@ -1,31 +0,0 @@
|
||||
var binary = require('node-binary');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var nodeVersion = require('../package.json').bundled_engine;
|
||||
var destination = './bin/node';
|
||||
|
||||
var os = process.env.RESIN_OS || process.platform;
|
||||
var arch = process.env.RESIN_ARCH || process.arch;
|
||||
|
||||
console.log('Downloading node-' + nodeVersion + '-' + os + '-' + arch);
|
||||
|
||||
binary.download({
|
||||
os: os,
|
||||
arch: arch,
|
||||
version: nodeVersion
|
||||
}, destination, function(error, binaryPath) {
|
||||
if(error) {
|
||||
console.error(error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var output = path.join(destination, 'node-' + os + '-' + arch);
|
||||
|
||||
if(process.platform === 'win32') {
|
||||
output += '.exe';
|
||||
}
|
||||
|
||||
fs.renameSync(binaryPath, output);
|
||||
|
||||
console.log('NodeJS downloaded to ' + output);
|
||||
});
|
76
lib/install-node.coffee
Normal file
76
lib/install-node.coffee
Normal file
@ -0,0 +1,76 @@
|
||||
async = require('async')
|
||||
binary = require('node-binary')
|
||||
fs = require('fs')
|
||||
path = require('path')
|
||||
|
||||
DESTINATION = process.argv[2]
|
||||
|
||||
if not DESTINATION?
|
||||
console.error('Missing destination argument')
|
||||
process.exit(1)
|
||||
|
||||
NODE_VERSION = require('../package.json').bundled_engine
|
||||
RESIN_BUNDLE = process.env.RESIN_BUNDLE
|
||||
|
||||
# This will install only the correct node version for the current system,
|
||||
if not RESIN_BUNDLE? or RESIN_BUNDLE is 'current'
|
||||
|
||||
bundles = [
|
||||
os: process.platform
|
||||
arch: process.arch
|
||||
version: NODE_VERSION
|
||||
]
|
||||
|
||||
else if RESIN_BUNDLE is 'darwin'
|
||||
|
||||
bundles = [
|
||||
{ os: 'darwin', arch: 'x86', version: NODE_VERSION }
|
||||
{ os: 'darwin', arch: 'x64', version: NODE_VERSION }
|
||||
]
|
||||
|
||||
else if RESIN_BUNDLE is 'linux'
|
||||
|
||||
bundles = [
|
||||
{ os: 'linux', arch: 'x86', version: NODE_VERSION }
|
||||
{ os: 'linux', arch: 'x64', version: NODE_VERSION }
|
||||
]
|
||||
|
||||
else if RESIN_BUNDLE is 'win32'
|
||||
|
||||
bundles = [
|
||||
{ os: 'win32', arch: 'x86', version: NODE_VERSION }
|
||||
{ os: 'win32', arch: 'x64', version: NODE_VERSION }
|
||||
]
|
||||
|
||||
else
|
||||
console.error("Unknown RESIN_BUNDLE value: #{RESIN_BUNDLE}")
|
||||
process.exit(1)
|
||||
|
||||
getNodeName = (options) ->
|
||||
result = "node-#{options.os}-#{options.arch}"
|
||||
result += '.exe' if options.os is 'win32'
|
||||
return result
|
||||
|
||||
console.info 'Installing the following NodeJS bundles:'
|
||||
for bundle in bundles
|
||||
console.info "- #{getNodeName(bundle)}"
|
||||
|
||||
nodeDownload = (destination, options, callback) ->
|
||||
binary.download options, destination, (error, binaryPath) ->
|
||||
return callback(error) if error?
|
||||
output = path.join(destination, getNodeName(options))
|
||||
fs.rename binaryPath, output, (error) ->
|
||||
return callback(error) if error?
|
||||
return callback(null, output)
|
||||
|
||||
async.eachLimit bundles, 2, (bundle, callback) ->
|
||||
console.info("Downloading: #{getNodeName(bundle)} to #{DESTINATION}")
|
||||
return nodeDownload DESTINATION, bundle, (error, output) ->
|
||||
return callback(error) if error?
|
||||
console.info("Downloaded: #{getNodeName(bundle)} to #{output}")
|
||||
return callback(null, output)
|
||||
, (error) ->
|
||||
if error?
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
console.info('All NodeJS bundles downloaded')
|
3318
npm-shrinkwrap.json
generated
Normal file
3318
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@
|
||||
"scripts": {
|
||||
"prepublish": "gulp build",
|
||||
"test": "gult test",
|
||||
"install": "node bin/install-node.js"
|
||||
"install": "coffee lib/install-node.coffee bin/node"
|
||||
},
|
||||
"keywords": [
|
||||
"resin",
|
||||
|
@ -19,32 +19,27 @@ function print_banner() {
|
||||
|
||||
function distribute() {
|
||||
local os=$1
|
||||
local arch=$2
|
||||
|
||||
local package="$NAME-$VERSION-$os-$arch"
|
||||
local package="$NAME-$VERSION-$os"
|
||||
|
||||
print_banner "Copying necessary files"
|
||||
|
||||
# Copy all needed files
|
||||
mkdir -p build/$package
|
||||
|
||||
cp -vrf bin build/$package
|
||||
cp -rf bin build/$package
|
||||
|
||||
# TODO: Omit bin/node in a better way
|
||||
rm -vrf build/$package/bin/node
|
||||
rm -rf build/$package/bin/node
|
||||
|
||||
cp -vrf lib build/$package
|
||||
cp -vrf package.json build/$package
|
||||
cp -rf lib build/$package
|
||||
cp -rf package.json build/$package
|
||||
|
||||
print_banner "Running npm install"
|
||||
|
||||
cd build/$package
|
||||
|
||||
RESIN_OS=$os RESIN_ARCH=$arch npm install --production --force
|
||||
|
||||
# Leaving this enabled causes
|
||||
# Path too long issues in Windows.
|
||||
# npm dedupe
|
||||
RESIN_BUNDLE=$os npm install --production --force
|
||||
|
||||
cd ..
|
||||
|
||||
@ -55,23 +50,16 @@ function distribute() {
|
||||
if [ "$os" == "win32" ]; then
|
||||
zip -r distrib/$package.zip $package
|
||||
else
|
||||
tar fvcz distrib/$package.tar.gz $package
|
||||
tar fvcj distrib/$package.tar.bz2 $package
|
||||
tar fcz distrib/$package.tar.gz $package
|
||||
tar fcj distrib/$package.tar.bz2 $package
|
||||
fi
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
# distribute "darwin" "x64"
|
||||
# distribute "darwin" "x86"
|
||||
|
||||
# distribute "linux" "x64"
|
||||
# distribute "linux" "x86"
|
||||
|
||||
distribute "win32" "x64"
|
||||
distribute "win32" "x86"
|
||||
|
||||
# distribute "sunos" "x64"
|
||||
# distribute "sunos" "x86"
|
||||
# distribute "darwin"
|
||||
# distribute "linux"
|
||||
distribute "win32"
|
||||
# distribute "sunos"
|
||||
|
||||
tree build/distrib
|
||||
|
Loading…
Reference in New Issue
Block a user