diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-02-14 19:30:32 +0800 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-02-22 16:25:24 +0800 |
| commit | 9e45a7de25f01975bd5a5baf63f35b35421ab619 (patch) | |
| tree | 8552ed1cfa207fc0976d4dbd2e39d1af95a243e0 | |
| parent | 34d295949afff7eb04650d3467d3c23457668125 (diff) | |
| download | mullvadvpn-9e45a7de25f01975bd5a5baf63f35b35421ab619.tar.xz mullvadvpn-9e45a7de25f01975bd5a5baf63f35b35421ab619.zip | |
Address review problems
| -rw-r--r-- | .travis.yml | 12 | ||||
| -rw-r--r-- | Cargo.lock | 57 | ||||
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rwxr-xr-x | build-deps/install-build-deps-osx.sh | 8 | ||||
| -rwxr-xr-x | build-deps/install-build-deps-ubuntu.sh | 43 | ||||
| -rwxr-xr-x | build-deps/install-build-deps.sh | 23 | ||||
| -rw-r--r-- | build-deps/zmq/.gitignore | 2 | ||||
| -rwxr-xr-x | build-deps/zmq/build-for-linux-with-apt.sh | 36 | ||||
| -rwxr-xr-x | build-deps/zmq/build.sh | 60 | ||||
| -rw-r--r-- | build-deps/zmq/install-build-deps-apt.sh | 6 | ||||
| -rw-r--r-- | build-deps/zmq/install-build-deps-osx.sh | 6 |
11 files changed, 161 insertions, 95 deletions
diff --git a/.travis.yml b/.travis.yml index 914cd01baf..fea5d88f36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,7 @@ language: rust cache: cargo: true directories: - - $HOME/Library/Caches/Homebrew - - $HOME/build-deps-linux - - $HOME/build-deps-osx + - $HOME/build-deps rust: - stable @@ -13,11 +11,9 @@ os: - linux - osx -sudo: required - before_script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then $(./build-deps/install-build-deps-ubuntu.sh $HOME/build-deps-linux) ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then $(./build-deps/install-build-deps-osx.sh $HOME/build-deps-osx) ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p $HOME/.local/bin && ln -s /usr/local/bin/greadlink $HOME/.local/bin/readlink ; fi + - $(./build-deps/install-build-deps.sh $HOME/build-deps) - (cargo install rustfmt || true) - export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH - rustfmt --version @@ -31,7 +27,7 @@ script: - cargo build --verbose - cargo test --all --verbose - - find src/ tests/ benches/ -iname "*.rs" -print0 | xargs -0 -n1 rustfmt --write-mode=diff + - find . -iname "*.rs" -not -path "*/target/*" -print0 | xargs -0 -n1 rustfmt --write-mode=diff notifications: email: diff --git a/Cargo.lock b/Cargo.lock index 4fb8fb2009..302fcf47dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,6 +84,11 @@ dependencies = [ [[package]] name = "error-chain" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "error-chain" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -115,6 +120,26 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "log" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "metadeps" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pkg-config" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "rustc-demangle" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -140,6 +165,7 @@ dependencies = [ "assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "clonablechild 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "zmq 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -153,6 +179,11 @@ dependencies = [ ] [[package]] +name = "toml" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "unicode-segmentation" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -177,6 +208,25 @@ name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "zmq" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "zmq-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zmq-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum assert_matches 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9aa85694f8820620d0df15526544e1c3fbbac7ba3874781d874d7d6499a53724" @@ -187,16 +237,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum clap 2.20.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f89819450aa94325998aa83ce7ea142db11ad24c725d6bc48459845e0d6d9f18" "checksum clonablechild 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4a4946a850c1e921fbdd9a1f92bf1298c41a301c0f6e9bacbabf95ea7d6d0225" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" +"checksum error-chain 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "318cb3c71ee4cdea69fdc9e15c173b245ed6063e1709029e8fd32525a881120f" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum gcc 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "291055c78f59ca3d84c99026c9501c469413d386bb46be1e1cf1d285cd1db3b0" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5" +"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" +"checksum metadeps 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829fffe7ea1d747e23f64be972991bc516b2f1ac2ae4a3b33d8bea150c410151" +"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum rustc-demangle 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1430d286cadb237c17c885e25447c982c97113926bb579f4379c0eca8d9586dc" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum term_size 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71662702fe5cd2cf95edd4ad655eea42f24a87a0e44059cbaa4e55260b7bc331" +"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum unicode-segmentation 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7baebdc1df1363fa66161fca2fe047e4f4209011cc7e045948298996afdf85df" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum vec_map 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cac5efe5cb0fa14ec2f84f83c701c562ee63f6dcc680861b21d65c682adfb05f" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum zmq 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9623581b345b8a85fb72cae9b2cb67116d73ccb141e6c02f689e311962b74f9c" +"checksum zmq-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ecf3aafc58984279d9b8f776703ef569d32ae386353192a267cd6e711da70dde" diff --git a/Cargo.toml b/Cargo.toml index abce286414..c6f0ad6ee7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,9 @@ description = "Core backend functionality of the Mullvad VPN client" clonablechild = "0.1" error-chain = "0.8" +[target.'cfg(not(windows))'.dependencies] +zmq = "0.8" + [dev-dependencies] assert_matches = "1.0" diff --git a/build-deps/install-build-deps-osx.sh b/build-deps/install-build-deps-osx.sh deleted file mode 100755 index bd0a0e0cbe..0000000000 --- a/build-deps/install-build-deps-osx.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env bash -set -e - -## Everything printed to stdout will be run by travis. So only print -## stuff that needs to be set, e.g. environment variables. - -brew update > /dev/stderr -brew install czmq > /dev/stderr diff --git a/build-deps/install-build-deps-ubuntu.sh b/build-deps/install-build-deps-ubuntu.sh deleted file mode 100755 index f7f891ef11..0000000000 --- a/build-deps/install-build-deps-ubuntu.sh +++ /dev/null @@ -1,43 +0,0 @@ -#! /usr/bin/env bash -set -eu - -## Everything printed to stdout will be run by travis. So only print -## stuff that needs to be set, e.g. environment variables. - -USE_CACHE=${USE_CACHE:-"1"} -SCRIPT_DIR=$(readlink -f $(dirname $0)) -INSTALL_DIR=$(readlink -f ${1:-"$SCRIPT_DIR"}) - -################################################################################ -################################## ZMQ ######################################### - -### TEST IF ZMQ IS BUILT ### -F1=$INSTALL_DIR/zmq/linux/include/zmq.h -F2=$INSTALL_DIR/zmq/linux/lib/libzmq.so -if [[ -f $F1 && -f $F2 ]]; then - ZMQ_IS_BUILT=1 -else - ZMQ_IS_BUILT=0 -fi - -if [[ $USE_CACHE == 1 && $ZMQ_IS_BUILT == 1 ]]; then - >&2 echo "Using a cached version of ZeroMQ" -else - >&2 echo "Building ZeroMQ" - >&2 echo "" - ( - $(dirname $0)/zmq/build-for-linux-with-apt.sh - ) > stderr - - if [[ "$SCRIPT_DIR" != "$INSTALL_DIR" ]]; then - mkdir -p $INSTALL_DIR/zmq/linux - sudo mv ${SCRIPT_DIR}/zmq/linux/* $INSTALL_DIR/zmq/linux/ - fi -fi - ->&2 echo "# deps installed, now run" -echo "export LIBZMQ_PREFIX=$INSTALL_DIR/zmq/linux" | tee /dev/stderr -echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_DIR/zmq/linux/lib" | tee /dev/stderr - -################################## ZMQ ######################################### -################################################################################ diff --git a/build-deps/install-build-deps.sh b/build-deps/install-build-deps.sh new file mode 100755 index 0000000000..fd72129b69 --- /dev/null +++ b/build-deps/install-build-deps.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env bash +set -eu + +## Everything printed to stdout will be run by travis. So only print +## stuff that needs to be set, e.g. environment variables. + +SCRIPT_DIR=$(readlink -f $(dirname $0)) +INSTALL_DIR=$(readlink -f ${1:-"$SCRIPT_DIR"}) + +################################################################################ +################################## ZMQ ######################################### + +mkdir -p $INSTALL_DIR/zmq/unix +$(dirname $0)/zmq/build.sh $INSTALL_DIR/zmq/unix >&2 + +echo "# ZeroMQ is installed, now run" >&2 +echo "export LIBZMQ_PREFIX=$INSTALL_DIR/zmq/unix" | tee /dev/stderr +set +u +echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INSTALL_DIR/zmq/unix/lib" | tee /dev/stderr +set -u + +################################## ZMQ ######################################### +################################################################################ diff --git a/build-deps/zmq/.gitignore b/build-deps/zmq/.gitignore new file mode 100644 index 0000000000..d5ef630613 --- /dev/null +++ b/build-deps/zmq/.gitignore @@ -0,0 +1,2 @@ +libzmq-git +linux diff --git a/build-deps/zmq/build-for-linux-with-apt.sh b/build-deps/zmq/build-for-linux-with-apt.sh deleted file mode 100755 index ad009a37ac..0000000000 --- a/build-deps/zmq/build-for-linux-with-apt.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env bash -set -eu - -WD=$(pwd)/$(dirname $0) -GIT_DIR=libzmq-git -INSTALL_DIR=linux - -### Install build deps ### -sudo apt-get update -sudo apt-get -y install git build-essential libtool autoconf automake uuid-dev pkg-config - -### Get the code ### -if [ -e "$WD/$GIT_DIR/.git" ]; then - cd "$WD/$GIT_DIR" - git fetch - git checkout origin/master - cd - -else - git clone --depth=1 git@github.com:zeromq/zeromq4-1.git "$WD/$GIT_DIR" -fi - -### Build ### -## We skip running the tests here as we trust the zmq maintainers to publish -## working code :) Living life on the wild side -trap "cd -" EXIT -cd "$WD/$GIT_DIR" - -set -x -./autogen.sh -./configure --prefix="$WD/$INSTALL_DIR" # add other options here -make -sudo make install -sudo ldconfig -set +x - -echo "WOOWZ, it's built now. All the good stuff is in $WD/$INSTALL_DIR" diff --git a/build-deps/zmq/build.sh b/build-deps/zmq/build.sh new file mode 100755 index 0000000000..dc8cc49a84 --- /dev/null +++ b/build-deps/zmq/build.sh @@ -0,0 +1,60 @@ +#! /usr/bin/env bash +set -eu + +WD=$(pwd)/$(dirname $0) +GIT_DIR=libzmq-git +INSTALL_DIR=$(readlink -f $1) +USE_CACHE=${USE_CACHE:-"1"} + + + + +### TEST IF ZMQ IS BUILT ### +F1=$INSTALL_DIR/include/zmq.h +F2=$INSTALL_DIR/lib/libzmq.so +if [[ -f $F1 && -f $F2 ]]; then + ZMQ_IS_BUILT=1 +else + ZMQ_IS_BUILT=0 + echo "Cannot find $F1 or $F2, will rebuild ZeroMQ" +fi + +if [[ $USE_CACHE == 1 && $ZMQ_IS_BUILT == 1 ]]; then + echo "Using a cached version of ZeroMQ" + exit 0 +fi + + +echo "If this fails, make sure that you have installed the packages needed to \ +build zmq, for ubuntu and OS X they can be found in\ +$WD/install-build-deps-{apt|osx}.sh" +echo "" + + + + +### Get the code ### +if [ -e "$WD/$GIT_DIR/.git" ]; then + ( + cd "$WD/$GIT_DIR" + git fetch + git checkout origin/master + ) +else + git clone --depth=1 git@github.com:zeromq/zeromq4-1.git "$WD/$GIT_DIR" +fi + +### Build ### +## We skip running the tests here as we trust the zmq maintainers to publish +## working code :) Living life on the wild side +trap "cd -" EXIT +cd "$WD/$GIT_DIR" + +set -x +./autogen.sh +./configure --prefix="$INSTALL_DIR" # add other options here +make +make install +set +x + +echo "WOOWZ, it's built now. All the good stuff is in $INSTALL_DIR" diff --git a/build-deps/zmq/install-build-deps-apt.sh b/build-deps/zmq/install-build-deps-apt.sh new file mode 100644 index 0000000000..6a762f603c --- /dev/null +++ b/build-deps/zmq/install-build-deps-apt.sh @@ -0,0 +1,6 @@ +#! /usr/bin/env bash + +set -eux + +apt-get update +apt-get -y install git build-essential libtool autoconf automake uuid-dev pkg-config diff --git a/build-deps/zmq/install-build-deps-osx.sh b/build-deps/zmq/install-build-deps-osx.sh new file mode 100644 index 0000000000..c52dc026e8 --- /dev/null +++ b/build-deps/zmq/install-build-deps-osx.sh @@ -0,0 +1,6 @@ +#! /usr/bin/env bash + +set -eux + +brew update +brew install libtool autoconf automake pkg-config |
