mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Merge commit '84ad2a289f33a43dd71276cc494f337d0fbb3ed6' into feature/update-dependencies
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import os, re
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
|
||||
from utils import *
|
||||
|
||||
@@ -14,26 +16,33 @@ def compile_one_file(parms, srcfile, incdirs):
|
||||
|
||||
def build_asio(parms):
|
||||
print "**************** ASIO"
|
||||
with Cd(build_dir(parms)) as cd:
|
||||
with Cd(build_dir(parms)):
|
||||
asio_ver = parms["ASIO_VERSION"]
|
||||
url = "https://github.com/chriskohlhoff/asio/archive/%s.tar.gz" % asio_ver
|
||||
arch_path = os.path.join(build_dir(parms), download(url))
|
||||
checksum = sha256_checksum(arch_path)
|
||||
if checksum != parms["ASIO_CSUM"]:
|
||||
sys.exit("Checksum mismatch, expected %s, actual %s" % (parms["ASIO_CSUM"], checksum))
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
dist = os.path.realpath('asio')
|
||||
rmtree(dist)
|
||||
d = expand('asio', parms['DEP'], parms.get('LIB_VERSIONS'))
|
||||
os.rename(d, dist)
|
||||
extract(arch_path, "gz")
|
||||
rmtree("asio")
|
||||
os.rename("asio-%s" % asio_ver, "asio")
|
||||
rm(arch_path)
|
||||
|
||||
def build_mbedtls(parms):
|
||||
print "**************** MBEDTLS"
|
||||
with Cd(build_dir(parms)) as cd:
|
||||
with Cd(build_dir(parms)):
|
||||
url = "https://tls.mbed.org/download/%s-apache.tgz" % parms["MBEDTLS_VERSION"]
|
||||
arch_path = os.path.join(build_dir(parms), download(url))
|
||||
checksum = sha256_checksum(arch_path)
|
||||
if checksum != parms["MBEDTLS_CSUM"]:
|
||||
sys.exit("Checksum mismatch, expected %s, actual %s" % (parms["MBEDTLS_CSUM"], checksum))
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
extract(arch_path, "gz")
|
||||
dist = os.path.realpath('mbedtls')
|
||||
rmtree(dist)
|
||||
d = expand('mbedtls', parms['DEP'], parms.get('LIB_VERSIONS'))
|
||||
if d.endswith("-apache"):
|
||||
d = d[:-7]
|
||||
elif d.endswith("-gpl"):
|
||||
d = d[:-4]
|
||||
|
||||
os.rename(d, dist)
|
||||
os.rename(parms["MBEDTLS_VERSION"], dist)
|
||||
rm(arch_path)
|
||||
|
||||
# edit mbedTLS config.h
|
||||
conf_fn = os.path.join(dist, 'include', 'mbedtls', 'config.h')
|
||||
@@ -43,6 +52,17 @@ def build_mbedtls(parms):
|
||||
with open(conf_fn, 'w') as f:
|
||||
f.write(conf)
|
||||
|
||||
# apply patches
|
||||
unapplicable_patches = ["0005-data_files-pkcs8-v2-add-keys-generated-with-PRF-SHA1.patch"]
|
||||
|
||||
for patch_file in glob.glob(os.path.join(parms.get('OVPN3'), "core", "deps", "mbedtls", "patches", "*.patch")):
|
||||
for unapplicable_patch in unapplicable_patches:
|
||||
if patch_file.endswith(unapplicable_patch):
|
||||
print "Skipping %s, 'git apply' doesn't apply it on Windows" % patch_file
|
||||
break
|
||||
else:
|
||||
call(["git", "apply", "--whitespace=nowarn", "--ignore-space-change", "--verbose", patch_file], cwd=dist)
|
||||
|
||||
# compile the source files
|
||||
os.chdir(os.path.join(dist, "library"))
|
||||
obj = []
|
||||
@@ -58,30 +78,56 @@ def build_mbedtls(parms):
|
||||
|
||||
def build_lz4(parms):
|
||||
print "**************** LZ4"
|
||||
with Cd(build_dir(parms)) as cd:
|
||||
with Cd(build_dir(parms)):
|
||||
url = "https://github.com/lz4/lz4/archive/v%s.tar.gz" % parms["LZ4_VERSION"][4:]
|
||||
arch_name = download(url)
|
||||
checksum = sha256_checksum(arch_name)
|
||||
if checksum != parms["LZ4_CSUM"]:
|
||||
sys.exit("Checksum mismatch, expected %s, actual %s" % (parms["LZ4_CSUM"], checksum))
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
extract(arch_name, "gz")
|
||||
dist = os.path.realpath('lz4')
|
||||
rmtree(dist)
|
||||
d = expand('lz4', parms['DEP'], parms.get('LIB_VERSIONS'))
|
||||
os.rename(d, dist)
|
||||
os.rename(parms["LZ4_VERSION"], dist)
|
||||
rm(arch_name)
|
||||
os.chdir(os.path.join(dist, "lib"))
|
||||
compile_one_file(parms, "lz4.c", ())
|
||||
vc_cmd(parms, r"lib /OUT:lz4.lib lz4.obj")
|
||||
|
||||
def build_tap(parms):
|
||||
print "**************** Windows-TAP"
|
||||
with Cd(build_dir(parms)):
|
||||
url = "https://github.com/OpenVPN/tap-windows6/archive/%s.zip" % parms["TAP_VERSION"]
|
||||
arch_name = download(url)
|
||||
checksum = sha256_checksum(arch_name)
|
||||
if checksum != parms["TAP_CSUM"]:
|
||||
sys.exit("Checksum mismatch, expected %s, actual %s" % (parms["TAP_CSUM"], checksum))
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
extract(arch_name, "zip")
|
||||
dist = os.path.realpath('tap-windows')
|
||||
rmtree(dist)
|
||||
os.rename("tap-windows6-%s" % parms["TAP_VERSION"], dist)
|
||||
rm(arch_name)
|
||||
|
||||
def build_jsoncpp(parms):
|
||||
if 'jsoncpp' in parms['LIB_VERSIONS']:
|
||||
print "**************** JSONCPP"
|
||||
with Cd(build_dir(parms)) as cd:
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
dist = os.path.realpath('jsoncpp')
|
||||
rmtree(dist)
|
||||
d = expand('jsoncpp', parms['DEP'], parms.get('LIB_VERSIONS'))
|
||||
os.rename(d, dist)
|
||||
os.chdir(dist)
|
||||
call(["python", "amalgamate.py"])
|
||||
os.chdir(os.path.join(dist, "dist"))
|
||||
compile_one_file(parms, "jsoncpp.cpp", (".",))
|
||||
vc_cmd(parms, r"lib /OUT:jsoncpp.lib jsoncpp.obj")
|
||||
print "**************** JSONCPP"
|
||||
with Cd(build_dir(parms)):
|
||||
url = "https://github.com/open-source-parsers/jsoncpp/archive/%s.tar.gz" % parms["JSONCPP_VERSION"]
|
||||
arch_name = download(url)
|
||||
checksum = sha256_checksum(arch_name)
|
||||
if checksum != parms["JSONCPP_CSUM"]:
|
||||
sys.exit("Checksum mismatch, expected %s, actual %s" % (parms["JSONCPP_CSUM"], checksum))
|
||||
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
||||
dist = os.path.realpath('jsoncpp')
|
||||
rmtree(dist)
|
||||
extract(arch_name, "gz")
|
||||
rm(arch_name)
|
||||
os.rename("jsoncpp-%s" % parms["JSONCPP_VERSION"], dist)
|
||||
os.chdir(dist)
|
||||
call(["python", "amalgamate.py"])
|
||||
os.chdir(os.path.join(dist, "dist"))
|
||||
compile_one_file(parms, "jsoncpp.cpp", (".",))
|
||||
vc_cmd(parms, r"lib /OUT:jsoncpp.lib jsoncpp.obj")
|
||||
|
||||
def build_all(parms):
|
||||
wipetree(build_dir(parms))
|
||||
@@ -89,13 +135,7 @@ def build_all(parms):
|
||||
build_mbedtls(parms)
|
||||
build_lz4(parms)
|
||||
build_jsoncpp(parms)
|
||||
build_tap(parms)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from parms import PARMS
|
||||
|
||||
# some parameters might be redefined, like in Jenkins multibranch pipeline case
|
||||
PARMS['BUILD'] = os.environ.get('BUILD', PARMS['BUILD'])
|
||||
PARMS['OVPN3'] = os.environ.get('OVPN3', PARMS['OVPN3'])
|
||||
PARMS['ARCH'] = os.environ.get('ARCH', PARMS['ARCH'])
|
||||
|
||||
build_all(PARMS)
|
||||
build_all(read_params())
|
||||
|
||||
Reference in New Issue
Block a user