Skip to content

Commit

Permalink
Merge pull request #64 from lgeiger/download-node
Browse files Browse the repository at this point in the history
Use Node to download zeromq vs. wget
  • Loading branch information
rgbkrk authored Oct 14, 2016
2 parents fc9c900 + 29ee69d commit da3026a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ clone your fork to your system. Be sure you have [`git-lfs`](https://git-lfs.git
**Prerequisites for Linux**
- `python` (`v2.7` recommended, `v3.x.x` is not supported)
- `make`
- `wget`
- A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org/)

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

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

**Prerequisites for Windows**

Expand Down
2 changes: 1 addition & 1 deletion build_libzmq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export CFLAGS=-fPIC
export CXXFLAGS=-fPIC
export PKG_CONFIG_PATH=$ZMQ_PREFIX/lib/pkgconfig

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
test -f zeromq-$ZMQ.tar.gz || ZMQ=$ZMQ ZMQ_REPO=$ZMQ_REPO node ../download-zmq.js 2>&1 > ../zmq-build.log
test -d $ZMQ_SRC_DIR || tar xzf zeromq-$ZMQ.tar.gz
cd $ZMQ_SRC_DIR

Expand Down
22 changes: 22 additions & 0 deletions download-zmq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var https = require('https');
var fs = require('fs');
var url = require('url');

var TAR_URL = 'https://github.com/' + process.env.ZMQ_REPO + '/releases/download/v' + process.env.ZMQ + '/zeromq-' + process.env.ZMQ + '.tar.gz';
var FILE_NAME = 'zeromq-' + process.env.ZMQ + '.tar.gz';

function writeToFile(response) {
response.pipe(fs.createWriteStream(FILE_NAME));
}

https.get(TAR_URL, function(response) {
if (response.statusCode > 300 && response.statusCode < 400 && response.headers.location) {
if (url.parse(response.headers.location).hostname) {
https.get(response.headers.location, writeToFile);
} else {
https.get(url.resolve(url.parse(TAR_URL).hostname, response.headers.location), writeToFile);
}
} else {
writeToFile(response);
}
});

0 comments on commit da3026a

Please sign in to comment.