Skip to content

Commit da3026a

Browse files
authored
Merge pull request #64 from lgeiger/download-node
Use Node to download zeromq vs. wget
2 parents fc9c900 + 29ee69d commit da3026a

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ clone your fork to your system. Be sure you have [`git-lfs`](https://git-lfs.git
5858
**Prerequisites for Linux**
5959
- `python` (`v2.7` recommended, `v3.x.x` is not supported)
6060
- `make`
61-
- `wget`
6261
- A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org/)
6362

6463
Use your distribution's package manager to install.
@@ -67,7 +66,6 @@ Use your distribution's package manager to install.
6766

6867
- `python` (`v2.7` recommended, `v3.x.x` is not supported): already installed on Mac OS X
6968
- `Xcode Command Line Tools`: Can be installed with `xcode-select --install`
70-
- `wget`: Can be installed via [Homebrew](http://brew.sh) with `brew install wget`
7169

7270
**Prerequisites for Windows**
7371

build_libzmq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export CFLAGS=-fPIC
1717
export CXXFLAGS=-fPIC
1818
export PKG_CONFIG_PATH=$ZMQ_PREFIX/lib/pkgconfig
1919

20-
test -f zeromq-$ZMQ.tar.gz || wget https://github.com/$ZMQ_REPO/releases/download/v$ZMQ/zeromq-$ZMQ.tar.gz -O zeromq-$ZMQ.tar.gz
20+
test -f zeromq-$ZMQ.tar.gz || ZMQ=$ZMQ ZMQ_REPO=$ZMQ_REPO node ../download-zmq.js 2>&1 > ../zmq-build.log
2121
test -d $ZMQ_SRC_DIR || tar xzf zeromq-$ZMQ.tar.gz
2222
cd $ZMQ_SRC_DIR
2323

download-zmq.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var https = require('https');
2+
var fs = require('fs');
3+
var url = require('url');
4+
5+
var TAR_URL = 'https://github.com/' + process.env.ZMQ_REPO + '/releases/download/v' + process.env.ZMQ + '/zeromq-' + process.env.ZMQ + '.tar.gz';
6+
var FILE_NAME = 'zeromq-' + process.env.ZMQ + '.tar.gz';
7+
8+
function writeToFile(response) {
9+
response.pipe(fs.createWriteStream(FILE_NAME));
10+
}
11+
12+
https.get(TAR_URL, function(response) {
13+
if (response.statusCode > 300 && response.statusCode < 400 && response.headers.location) {
14+
if (url.parse(response.headers.location).hostname) {
15+
https.get(response.headers.location, writeToFile);
16+
} else {
17+
https.get(url.resolve(url.parse(TAR_URL).hostname, response.headers.location), writeToFile);
18+
}
19+
} else {
20+
writeToFile(response);
21+
}
22+
});

0 commit comments

Comments
 (0)