diff --git a/.travis.yml b/.travis.yml index bd3cb5f1b0..bfbf6f2c4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,12 @@ matrix: - os: osx env: # On OS X the frameworks/dylibs contain hard coded paths, so we have to re-create the paths in the VM exactly - - SWBASE=/Users/kovid SW=$SWBASE/sw PATH=$SW/bin:$SW/qt/bin:$SW/python/Python.framework/Versions/2.7/bin:$PWD/node_modules/.bin:$PATH CFLAGS=-I$SW/include LDFLAGS=-L$SW/lib QMAKE=$SW/qt/bin/qmake QT_PLUGIN_PATH=$SW/qt/plugins + - SWBASE=/Users/kovid SW=$SWBASE/sw PATH=$SW/bin:$SW/qt/bin:$SW/python/Python.framework/Versions/2.7/bin:$PWD/node_modules/.bin:$PATH CFLAGS=-I$SW/include LDFLAGS=-L$SW/lib QMAKE=$SW/qt/bin/qmake QT_PLUGIN_PATH=$SW/qt/plugins before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://download.calibre-ebook.com/travis/sw-linux.tar.xz | tar xJ -C $HOME; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then python setup/ci-download.py https://download.calibre-ebook.com/travis/sw-linux.tar.xz J $HOME; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo mkdir -p $SWBASE && sudo chown $USER $SWBASE; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl https://download.calibre-ebook.com/travis/sw-osx.tar.bz2 | tar xj -C $SWBASE; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python setup/ci-download.py https://download.calibre-ebook.com/travis/sw-osx.tar.bz2 j $SWBASE; fi - npm install --no-optional rapydscript-ng && echo $PATH && which rapydscript && rapydscript --version - python setup.py bootstrap --ephemeral - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export SSL_CERT_FILE=$PWD/resources/mozilla-ca-certs.pem; fi diff --git a/setup/ci-download.py b/setup/ci-download.py new file mode 100644 index 0000000000..d89a5069e2 --- /dev/null +++ b/setup/ci-download.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +# License: GPLv3 Copyright: 2017, Kovid Goyal + +from __future__ import absolute_import, division, print_function, unicode_literals + +import sys, subprocess +from tempfile import NamedTemporaryFile + +url, compression, dest = sys.argv[-3:] + + +def decompress(path): + raise SystemExit( + subprocess.Popen(['tar', 'x' + compression + 'f', path, '-C', dest]).wait() + ) + + +if __name__ == '__main__': + for i in range(5): + if i: + print('Failed to download', url, 'retrying...'.format(url)) + else: + print('Downloading', url, '...') + with NamedTemporaryFile() as f: + ret = subprocess.Popen(['curl', url], stdout=f).wait() + if ret == 0: + decompress(f.name) + break