Skip to content

Commit 990b49c

Browse files
authored
Merge pull request kivy#838 from brussee/openssl-version
introduce versioning for openssl
2 parents c5f8340 + bd970b4 commit 990b49c

File tree

8 files changed

+50
-16
lines changed

8 files changed

+50
-16
lines changed

pythonforandroid/recipes/cryptography/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class CryptographyRecipe(CompiledComponentsPythonRecipe):
1010

1111
def get_recipe_env(self, arch):
1212
env = super(CryptographyRecipe, self).get_recipe_env(arch)
13-
openssl_dir = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
13+
r = self.get_recipe('openssl', self.ctx)
14+
openssl_dir = r.get_build_dir(arch.arch)
1415
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
1516
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
1617
' -I' + join(openssl_dir, 'include')
@@ -19,7 +20,8 @@ def get_recipe_env(self, arch):
1920
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
2021
' -L' + openssl_dir + \
2122
' -lpython2.7' + \
22-
' -lssl -lcrypto'
23+
' -lssl' + r.version + \
24+
' -lcrypto' + r.version
2325
return env
2426

2527
recipe = CryptographyRecipe()

pythonforandroid/recipes/libtorrent/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def get_recipe_env(self, arch):
6565
# Copy environment from boost recipe
6666
env.update(self.get_recipe('boost', self.ctx).get_recipe_env(arch))
6767
if 'openssl' in recipe.ctx.recipe_build_order:
68-
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
68+
r = self.get_recipe('openssl', self.ctx)
69+
env['OPENSSL_BUILD_PATH'] = r.get_build_dir(arch.arch)
70+
env['OPENSSL_VERSION'] = r.version
6971
return env
7072

7173
recipe = LibtorrentRecipe()

pythonforandroid/recipes/libtorrent/user-config-openssl.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
+<linkflags>-L$(OPENSSL_BUILD_PATH)
2121
<linkflags>-lgnustl_shared
2222
<linkflags>-lpython2.7
23-
+<linkflags>-lcrypto
24-
+<linkflags>-lssl
23+
+<linkflags>-lcrypto$(OPENSSL_VERSION)
24+
+<linkflags>-lssl$(OPENSSL_VERSION)
2525
;

pythonforandroid/recipes/m2crypto/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,32 @@ def build_arch(self, arch):
1515
with current_directory(self.get_build_dir(arch.arch)):
1616
# Build M2Crypto
1717
hostpython = sh.Command(self.hostpython_location)
18+
r = self.get_recipe('openssl', self.ctx)
19+
openssl_dir = r.get_build_dir(arch.arch)
1820
shprint(hostpython,
1921
'setup.py',
2022
'build_ext',
2123
'-p' + arch.arch,
2224
'-c' + 'unix',
23-
'-o' + env['OPENSSL_BUILD_PATH'],
24-
'-L' + env['OPENSSL_BUILD_PATH']
25+
'--openssl=' + openssl_dir
2526
, _env=env)
2627
# Install M2Crypto
2728
super(M2CryptoRecipe, self).build_arch(arch)
2829

2930
def get_recipe_env(self, arch):
3031
env = super(M2CryptoRecipe, self).get_recipe_env(arch)
31-
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
32-
env['CFLAGS'] += ' -I' + join(self.ctx.get_python_install_dir(), 'include/python2.7')
32+
r = self.get_recipe('openssl', self.ctx)
33+
openssl_dir = r.get_build_dir(arch.arch)
34+
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
35+
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
36+
' -I' + join(openssl_dir, 'include')
3337
# Set linker to use the correct gcc
3438
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
35-
env['LDFLAGS'] += ' -lpython2.7'
39+
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
40+
' -L' + openssl_dir + \
41+
' -lpython2.7' + \
42+
' -lssl' + r.version + \
43+
' -lcrypto' + r.version
3644
return env
3745

3846
recipe = M2CryptoRecipe()

pythonforandroid/recipes/openssl/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class OpenSSLRecipe(Recipe):
99
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
1010

1111
def should_build(self, arch):
12-
return not self.has_libs(arch, 'libssl.so', 'libcrypto.so')
12+
return not self.has_libs(arch, 'libssl' + self.version + '.so',
13+
'libcrypto' + self.version + '.so')
1314

1415
def check_symbol(self, env, sofile, symbol):
1516
nm = env.get('NM', 'nm')
@@ -22,6 +23,7 @@ def check_symbol(self, env, sofile, symbol):
2223

2324
def get_recipe_env(self, arch=None):
2425
env = super(OpenSSLRecipe, self).get_recipe_env(arch)
26+
env['OPENSSL_VERSION'] = self.version
2527
env['CFLAGS'] += ' ' + env['LDFLAGS']
2628
env['CC'] += ' ' + env['LDFLAGS']
2729
return env
@@ -45,15 +47,17 @@ def build_arch(self, arch):
4547
buildarch = self.select_build_arch(arch)
4648
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)
4749
self.apply_patch('disable-sover.patch', arch.arch)
50+
self.apply_patch('rename-shared-lib.patch', arch.arch)
4851

49-
check_crypto = partial(self.check_symbol, env, 'libcrypto.so')
50-
# check_ssl = partial(self.check_symbol, env, 'libssl.so')
52+
# check_ssl = partial(self.check_symbol, env, 'libssl' + self.version + '.so')
53+
check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.version + '.so')
5154
while True:
5255
shprint(sh.make, 'build_libs', _env=env)
5356
if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))):
5457
break
5558
shprint(sh.make, 'clean', _env=env)
5659

57-
self.install_libs(arch, 'libssl.so', 'libcrypto.so')
60+
self.install_libs(arch, 'libssl' + self.version + '.so',
61+
'libcrypto' + self.version + '.so')
5862

5963
recipe = OpenSSLRecipe()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- openssl/Makefile.shared 2016-05-03 15:44:42.000000000 +0200
2+
+++ patch/Makefile.shared 2016-07-14 00:08:37.268792948 +0200
3+
@@ -147,11 +147,11 @@
4+
DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
5+
6+
DO_GNU_SO=$(CALC_VERSIONS); \
7+
- SHLIB=lib$(LIBNAME).so; \
8+
+ SHLIB=lib$(LIBNAME)$(OPENSSL_VERSION).so; \
9+
SHLIB_SUFFIX=; \
10+
ALLSYMSFLAGS='-Wl,--whole-archive'; \
11+
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
12+
- SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
13+
+ SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB"
14+
15+
DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"
16+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SSL=
22
_ssl _ssl.c \
33
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
4-
-L$(SSL) -lssl -lcrypto
4+
-L$(SSL) -lssl$(OPENSSL_VERSION) -lcrypto$(OPENSSL_VERSION)

pythonforandroid/recipes/python2/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ def do_python_build(self, arch):
9393
# TODO need to add a should_build that checks if optional
9494
# dependencies have changed (possibly in a generic way)
9595
if 'openssl' in self.ctx.recipe_build_order:
96-
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
96+
r = Recipe.get_recipe('openssl', self.ctx)
97+
openssl_build_dir = r.get_build_dir(arch.arch)
9798
setuplocal = join('Modules', 'Setup.local')
9899
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal)
99100
shprint(sh.sed, '-i', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal)
101+
env['OPENSSL_VERSION'] = r.version
100102

101103
if 'sqlite3' in self.ctx.recipe_build_order:
102104
# Include sqlite3 in python2 build

0 commit comments

Comments
 (0)