$OpenBSD: patch-deps_npm_node_modules_node-gyp_lib_install_js,v 1.1.1.1 2012/05/23 15:11:43 jasper 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	Thu May 10 07:09:14 2012
+++ deps/npm/node_modules/node-gyp/lib/install.js	Thu May 10 07:15:41 2012
@@ -166,10 +166,19 @@ function install (gyp, argv, callback) {
     extracter.on('error', cb)
     extracter.on('end', afterTarball)
 
-    // download the tarball, gunzip and extract!
-    var req = download(tarballUrl, downloadError)
-      .pipe(gunzip)
-      .pipe(extracter)
+	// OpenBSD fix
+	var filePath = '${PREFIX}/lib/node/${DISTFILES}';
+	fs.stat(filePath, function(err, stat) {
+		if (err) {
+			throw err;
+		} else {
+			// use packaged tarball
+			fs.createReadStream(filePath)
+			  .pipe(gunzip)
+			  .pipe(extracter)
+		}
+	});
+	// OpenBSD fix 
 
     // something went wrong downloading the tarball?
     function downloadError (err, res) {
