Use curl instead of python to download cacerts

Python's https support is broken on OS X while bootstrapping
This commit is contained in:
Kovid Goyal 2016-06-26 12:38:59 +05:30
parent 8b133bac43
commit f2075355b9
2 changed files with 6 additions and 3 deletions

View File

@ -15,7 +15,7 @@ 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 MACOSX_DEPLOYMENT_TARGET=10.7
- 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 SSL_CERT_FILE=$PWD/resources/mozilla-ca-certs.pem
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://download.calibre-ebook.com/travis/sw-linux.tar.xz | tar xJ -C $HOME; fi

View File

@ -6,7 +6,7 @@ __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, cPickle, re, shutil, marshal, zipfile, glob, time, sys, hashlib, json, urllib, errno
import os, cPickle, re, shutil, marshal, zipfile, glob, time, sys, hashlib, json, errno, subprocess
from zlib import compress
from itertools import chain
@ -235,7 +235,10 @@ class CACerts(Command): # {{{
if err.errno != errno.ENOENT:
raise
raw = b''
nraw = urllib.urlopen('https://curl.haxx.se/ca/cacert.pem').read()
# We use curl here as on some OSes (OS X) when bootstrapping calibre,
# python will be unable to validate certificates until after cacerts is
# installed
nraw = subprocess.check_output(['curl', '-L', 'https://curl.haxx.se/ca/cacert.pem'])
if not nraw:
raise RuntimeError('Failed to download CA cert bundle')
if nraw != raw: