Skip to content

Commit 63e0a29

Browse files
John Haleytbranyen
authored andcommitted
Included libssh2 in the build
1 parent d6f7ffb commit 63e0a29

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/node_modules/
22
/vendor/libgit2/
3+
/vendor/libssh2/
34
/build/
45
/coverage/
56
/test/repos/

install.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var rimraf = require('rimraf');
1515
// ENV variables:
1616
//
1717
// PKG: Location of `package.json` sans `.json`.
18-
// LIBGIT2: Location of libgit2 source.
18+
// LIBGIT2: Location of libgit2 source.
1919
// BUILD: Location of nodegit build directory.
2020
function envOverride(obj) {
2121
// Look through all keys.
@@ -45,6 +45,7 @@ var local = path.join.bind(path, __dirname);
4545
var paths = envOverride({
4646
pkg: local('package'),
4747
libgit2: local('vendor/libgit2/'),
48+
libssh2: local('vendor/libssh2/'),
4849
sys: {
4950
include: local('include/sys/'),
5051
src: local('src/sys/'),
@@ -75,7 +76,7 @@ var dependencies = Q.allSettled([
7576
if (!python) {
7677
throw new Error('Python is required to build libgit2.');
7778
}
78-
79+
7980
// Now lets check the Python version to ensure it's < 3.
8081
return Q.nfcall(exec, python + ' --version').then(function(version) {
8182
if (version[1].indexOf('Python 3') === 0) {
@@ -94,7 +95,7 @@ var dependencies = Q.allSettled([
9495
}).fail(function() {
9596
console.info('[nodegit] Removing outdated vendor/libgit2.');
9697

97-
// This directory is outdated, remove.
98+
// This directory is outdated, remove.
9899
throw Q.ninvoke(rimraf, null, paths.libgit2);
99100
});
100101
})
@@ -105,7 +106,7 @@ var dependencies = Q.allSettled([
105106
console.info('[nodegit] Fetching vendor/libgit2.');
106107

107108
var url = 'https://github.com/libgit2/libgit2/tarball/' + pkg.libgit2.sha;
108-
109+
109110
var extract = tar.Extract({
110111
path: paths.libgit2,
111112
strip: true
@@ -120,6 +121,41 @@ var dependencies = Q.allSettled([
120121
});
121122
})
122123

124+
// Grab libssh2 if needed
125+
.then(function() {
126+
console.info('[nodegit] Detecting vendor/libssh2.');
127+
128+
return Q.ninvoke(fs, 'stat', paths.libssh2).then(function() {
129+
return Q.ninvoke(fs, 'stat', paths.libssh2 + pkg.libssh2.version);
130+
}).fail(function() {
131+
console.info('[nodegit] Removing outdated vendor/libssh2.');
132+
133+
// This directory is outdated, remove.
134+
throw Q.ninvoke(rimraf, null, paths.libssh2);
135+
});
136+
})
137+
138+
// If the directory already exists, no need to refetch.
139+
.fail(function() {
140+
// Otherwise fetch the libssh2 source.
141+
console.info('[nodegit] Fetching vendor/libssh2.');
142+
143+
var url = pkg.libssh2.url;
144+
145+
var extract = tar.Extract({
146+
path: paths.libssh2,
147+
strip: true
148+
});
149+
150+
// First extract from Zlib and then extract from Tar.
151+
var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract);
152+
153+
return Q.ninvoke(expand, 'on', 'end').then(function() {
154+
// Write out a sha file for testing in the future.
155+
return Q.ninvoke(fs, 'writeFile', paths.libssh2 + pkg.libssh2.version, '');
156+
});
157+
})
158+
123159
// Build the native module using node-gyp.
124160
.then(function() {
125161
console.info('[nodegit] Building native node module.');

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"sha": "b4d00c1d2466de3558a7cc6983dce4eb2ee98431",
77
"version": "0.21.1"
88
},
9+
"libssh2": {
10+
"url": "http://www.libssh2.org/download/libssh2-1.4.3.tar.gz",
11+
"version": "1.4.3"
12+
},
913
"homepage": "https://github.com/tbranyen/nodegit",
1014
"keywords": [
1115
"libgit2",

vendor/libgit2.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@
333333
"libgit2/include",
334334
"libgit2/src",
335335
"libgit2/deps/regex",
336+
"libssh2/include",
337+
"libssh2/src"
336338
],
337339
"direct_dependent_settings": {
338340
"include_dirs": [

0 commit comments

Comments
 (0)