$OpenBSD: patch-deps_npm_node_modules_node-gyp_lib_install_js,v 1.3 2013/12/04 20:20:52 abieber Exp $

Allow building of sub-packages (ie. node-sqlite3) with USE_SYSTRACE
set, also prevents downloading of the node distfile again.

--- deps/npm/node_modules/node-gyp/lib/install.js.orig	Tue Nov 12 13:22:12 2013
+++ deps/npm/node_modules/node-gyp/lib/install.js	Sat Nov 23 15:02:03 2013
@@ -209,30 +209,18 @@ function install (gyp, argv, callback) {
         return
       }
 
-      var req = download(tarballUrl)
-      if (!req) return
-
-      // something went wrong downloading the tarball?
-      req.on('error', function (err) {
-        badDownload = true
-        cb(err)
-      })
-
-      req.on('close', function () {
-        if (extractCount === 0) {
-          cb(new Error('Connection closed while downloading tarball file'))
+      // OpenBSD fix
+      var filePath = '${PREFIX}/lib/node/${DISTFILES}';
+      fs.stat(filePath, function(err, stat) {
+        if (err) {
+          throw err;
+        } else {
+          fs.createReadStream(filePath)
+            .pipe(gunzip)
+            .pipe(extracter)
         }
       })
-
-      req.on('response', function (res) {
-        if (res.statusCode !== 200) {
-          badDownload = true
-          cb(new Error(res.statusCode + ' status code downloading tarball'))
-          return
-        }
-        // start unzipping and untaring
-        req.pipe(gunzip).pipe(extracter)
-      })
+      // OpenBSD fix
 
       // invoked after the tarball has finished being extracted
       function afterTarball () {
