summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/node-gyp/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-03-19 09:25:40 -0700
committerisaacs <i@izs.me>2014-03-19 09:26:05 -0700
commita65c1aaf3afe21a34cae7b4ad266a6f2723704d1 (patch)
tree61e4c2a3b069f78d8ef5ae635a887cda13ec1c15 /deps/npm/node_modules/node-gyp/lib
parent43a29f53ca11ab48e1d1ef6b2a0e673ae43a42a0 (diff)
downloadnode-npm-1.4.6.tar.gz
npm: upgrade to 1.4.6npm-1.4.6
Diffstat (limited to 'deps/npm/node_modules/node-gyp/lib')
-rw-r--r--deps/npm/node_modules/node-gyp/lib/configure.js11
-rw-r--r--deps/npm/node_modules/node-gyp/lib/install.js87
2 files changed, 92 insertions, 6 deletions
diff --git a/deps/npm/node_modules/node-gyp/lib/configure.js b/deps/npm/node_modules/node-gyp/lib/configure.js
index e101a315a..268c33625 100644
--- a/deps/npm/node_modules/node-gyp/lib/configure.js
+++ b/deps/npm/node_modules/node-gyp/lib/configure.js
@@ -1,4 +1,3 @@
-
module.exports = exports = configure
/**
@@ -14,6 +13,7 @@ var fs = require('graceful-fs')
, semver = require('semver')
, mkdirp = require('mkdirp')
, cp = require('child_process')
+ , extend = require('util')._extend
, spawn = cp.spawn
, execFile = cp.execFile
, win = process.platform == 'win32'
@@ -73,7 +73,9 @@ function configure (gyp, argv, callback) {
}
function checkPythonVersion () {
- var env = { TERM: 'dumb', PATH: process.env.PATH };
+ var env = extend({}, process.env);
+ env.TERM = 'dumb';
+
execFile(python, ['-c', 'import platform; print(platform.python_version());'], { env: env }, function (err, stdout) {
if (err) {
return callback(err)
@@ -88,7 +90,7 @@ function configure (gyp, argv, callback) {
log.silly('stripping "rc" identifier from version')
version = version.replace(/rc(.*)$/ig, '')
}
- var range = semver.Range('>=2.5.0 <3.0.0');
+ var range = semver.Range('>=2.5.0 <3.0.0')
if (range.test(version)) {
getNodeDir()
} else {
@@ -210,7 +212,7 @@ function configure (gyp, argv, callback) {
variables.copy_dev_lib = !gyp.opts.nodedir
// disable -T "thin" static archives by default
- variables.standalone_static_library = gyp.opts.thin ? 0 : 1;
+ variables.standalone_static_library = gyp.opts.thin ? 0 : 1
// loop through the rest of the opts and add the unknown ones as variables.
// this allows for module-specific configure flags like:
@@ -311,6 +313,7 @@ function configure (gyp, argv, callback) {
argv.push('-Dnode_root_dir=' + nodeDir)
argv.push('-Dmodule_root_dir=' + process.cwd())
argv.push('--depth=.')
+ argv.push('--no-parallel')
// tell gyp to write the Makefile/Solution files into output_dir
argv.push('--generator-output', output_dir)
diff --git a/deps/npm/node_modules/node-gyp/lib/install.js b/deps/npm/node_modules/node-gyp/lib/install.js
index 60dc3cd63..a9a18bcc7 100644
--- a/deps/npm/node_modules/node-gyp/lib/install.js
+++ b/deps/npm/node_modules/node-gyp/lib/install.js
@@ -12,6 +12,7 @@ var fs = require('graceful-fs')
, tar = require('tar')
, rm = require('rimraf')
, path = require('path')
+ , crypto = require('crypto')
, zlib = require('zlib')
, log = require('npmlog')
, semver = require('semver')
@@ -151,6 +152,15 @@ function install (gyp, argv, callback) {
return req
}
+ function getContentSha(res, callback) {
+ var shasum = crypto.createHash('sha1')
+ res.on('data', function (chunk) {
+ shasum.update(chunk)
+ }).on('end', function () {
+ callback(null, shasum.digest('hex'))
+ })
+ }
+
function go () {
log.verbose('ensuring nodedir is created', devDir)
@@ -171,13 +181,16 @@ function install (gyp, argv, callback) {
}
// now download the node tarball
- var tarPath = gyp.opts['tarball'];
+ var tarPath = gyp.opts['tarball']
var tarballUrl = tarPath ? tarPath : distUrl + '/v' + version + '/node-v' + version + '.tar.gz'
, badDownload = false
, extractCount = 0
, gunzip = zlib.createGunzip()
, extracter = tar.Extract({ path: devDir, strip: 1, filter: isValid })
+ var contentShasums = {}
+ var expectShasums = {}
+
// checks if a file to be extracted from the tarball is valid.
// only .h header files and the gyp files get extracted
function isValid () {
@@ -230,6 +243,13 @@ function install (gyp, argv, callback) {
cb(new Error(res.statusCode + ' status code downloading tarball'))
return
}
+ // content sha1
+ getContentSha(res, function (_, sha1) {
+ var filename = path.basename(tarballUrl).trim()
+ contentShasums[filename] = sha1
+ log.verbose('content sha1', filename, sha1)
+ })
+
// start unzipping and untaring
req.pipe(gunzip).pipe(extracter)
})
@@ -254,6 +274,10 @@ function install (gyp, argv, callback) {
var installVersionPath = path.resolve(devDir, 'installVersion')
fs.writeFile(installVersionPath, gyp.package.installVersion + '\n', deref)
+ // download SHASUMS.txt
+ async++
+ downloadShasums(deref)
+
if (async === 0) {
// no async tasks required
cb()
@@ -261,10 +285,59 @@ function install (gyp, argv, callback) {
function deref (err) {
if (err) return cb(err)
- --async || cb()
+
+ async--
+ if (!async) {
+ log.verbose('download contents shasums', JSON.stringify(contentShasums))
+ // check content shasums
+ for (var k in contentShasums) {
+ log.verbose('validating download shasum for ' + k, '(%s == %s)', contentShasums[k], expectShasums[k])
+ if (contentShasums[k] !== expectShasums[k]) {
+ cb(new Error(k + ' local sha1 ' + contentShasums[k] + ' not match remote ' + expectShasums[k]))
+ return
+ }
+ }
+ cb()
+ }
}
}
+ function downloadShasums(done) {
+ log.verbose('check download content sha1, need to download `SHASUMS.txt`...')
+ var shasumsPath = path.resolve(devDir, 'SHASUMS.txt')
+ , shasumsUrl = distUrl + '/v' + version + '/SHASUMS.txt'
+
+ log.verbose('`SHASUMS.txt` url', shasumsUrl)
+ var req = download(shasumsUrl)
+ if (!req) return
+ req.on('error', done)
+ req.on('response', function (res) {
+ if (res.statusCode !== 200) {
+ done(new Error(res.statusCode + ' status code downloading SHASUMS.txt'))
+ return
+ }
+
+ var chunks = []
+ res.on('data', function (chunk) {
+ chunks.push(chunk)
+ })
+ res.on('end', function () {
+ var lines = Buffer.concat(chunks).toString().trim().split('\n')
+ lines.forEach(function (line) {
+ var items = line.trim().split(/\s+/)
+ if (items.length !== 2) return
+
+ // 0035d18e2dcf9aad669b1c7c07319e17abfe3762 ./node-v0.11.4.tar.gz
+ var name = items[1].replace(/^\.\//, '')
+ expectShasums[name] = items[0]
+ })
+
+ log.verbose('`SHASUMS.txt` data', JSON.stringify(expectShasums))
+ done()
+ })
+ })
+ }
+
function downloadNodeLib (done) {
log.verbose('on Windows; need to download `node.lib`...')
var dir32 = path.resolve(devDir, 'ia32')
@@ -293,6 +366,11 @@ function install (gyp, argv, callback) {
return
}
+ getContentSha(res, function (_, sha1) {
+ contentShasums['node.lib'] = sha1
+ log.verbose('content sha1', 'node.lib', sha1)
+ })
+
var ws = fs.createWriteStream(nodeLibPath32)
ws.on('error', cb)
req.pipe(ws)
@@ -314,6 +392,11 @@ function install (gyp, argv, callback) {
return
}
+ getContentSha(res, function (_, sha1) {
+ contentShasums['x64/node.lib'] = sha1
+ log.verbose('content sha1', 'x64/node.lib', sha1)
+ })
+
var ws = fs.createWriteStream(nodeLibPath64)
ws.on('error', cb)
req.pipe(ws)