$OpenBSD: patch-deps_npm_node_modules_node-gyp_lib_install_js,v 1.2 2012/08/23 17:29:44 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 Aug 21 18:58:33 2012
+++ deps/npm/node_modules/node-gyp/lib/install.js	Tue Aug 21 19:00:06 2012
@@ -212,31 +212,18 @@ function install (gyp, argv, callback) {
       extracter.on('error', cb)
       extracter.on('end', afterTarball)
 
-      // download the tarball, gunzip and extract!
-      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 () {
