Skip to content

introduce versioning for openssl #838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pythonforandroid/recipes/cryptography/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class CryptographyRecipe(CompiledComponentsPythonRecipe):

def get_recipe_env(self, arch):
env = super(CryptographyRecipe, self).get_recipe_env(arch)
openssl_dir = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
r = self.get_recipe('openssl', self.ctx)
openssl_dir = r.get_build_dir(arch.arch)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
' -I' + join(openssl_dir, 'include')
Expand All @@ -19,7 +20,8 @@ def get_recipe_env(self, arch):
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
' -L' + openssl_dir + \
' -lpython2.7' + \
' -lssl -lcrypto'
' -lssl' + r.version + \
' -lcrypto' + r.version
return env

recipe = CryptographyRecipe()
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/libtorrent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def get_recipe_env(self, arch):
# Copy environment from boost recipe
env.update(self.get_recipe('boost', self.ctx).get_recipe_env(arch))
if 'openssl' in recipe.ctx.recipe_build_order:
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
r = self.get_recipe('openssl', self.ctx)
env['OPENSSL_BUILD_PATH'] = r.get_build_dir(arch.arch)
env['OPENSSL_VERSION'] = r.version
return env

recipe = LibtorrentRecipe()
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/libtorrent/user-config-openssl.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
+<linkflags>-L$(OPENSSL_BUILD_PATH)
<linkflags>-lgnustl_shared
<linkflags>-lpython2.7
+<linkflags>-lcrypto
+<linkflags>-lssl
+<linkflags>-lcrypto$(OPENSSL_VERSION)
+<linkflags>-lssl$(OPENSSL_VERSION)
;
18 changes: 13 additions & 5 deletions pythonforandroid/recipes/m2crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,32 @@ def build_arch(self, arch):
with current_directory(self.get_build_dir(arch.arch)):
# Build M2Crypto
hostpython = sh.Command(self.hostpython_location)
r = self.get_recipe('openssl', self.ctx)
openssl_dir = r.get_build_dir(arch.arch)
shprint(hostpython,
'setup.py',
'build_ext',
'-p' + arch.arch,
'-c' + 'unix',
'-o' + env['OPENSSL_BUILD_PATH'],
'-L' + env['OPENSSL_BUILD_PATH']
'--openssl=' + openssl_dir
, _env=env)
# Install M2Crypto
super(M2CryptoRecipe, self).build_arch(arch)

def get_recipe_env(self, arch):
env = super(M2CryptoRecipe, self).get_recipe_env(arch)
env['OPENSSL_BUILD_PATH'] = self.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
env['CFLAGS'] += ' -I' + join(self.ctx.get_python_install_dir(), 'include/python2.7')
r = self.get_recipe('openssl', self.ctx)
openssl_dir = r.get_build_dir(arch.arch)
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \
' -I' + join(openssl_dir, 'include')
# Set linker to use the correct gcc
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
env['LDFLAGS'] += ' -lpython2.7'
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
' -L' + openssl_dir + \
' -lpython2.7' + \
' -lssl' + r.version + \
' -lcrypto' + r.version
return env

recipe = M2CryptoRecipe()
12 changes: 8 additions & 4 deletions pythonforandroid/recipes/openssl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class OpenSSLRecipe(Recipe):
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'

def should_build(self, arch):
return not self.has_libs(arch, 'libssl.so', 'libcrypto.so')
return not self.has_libs(arch, 'libssl' + self.version + '.so',
'libcrypto' + self.version + '.so')

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

def get_recipe_env(self, arch=None):
env = super(OpenSSLRecipe, self).get_recipe_env(arch)
env['OPENSSL_VERSION'] = self.version
env['CFLAGS'] += ' ' + env['LDFLAGS']
env['CC'] += ' ' + env['LDFLAGS']
return env
Expand All @@ -45,15 +47,17 @@ def build_arch(self, arch):
buildarch = self.select_build_arch(arch)
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)
self.apply_patch('disable-sover.patch', arch.arch)
self.apply_patch('rename-shared-lib.patch', arch.arch)

check_crypto = partial(self.check_symbol, env, 'libcrypto.so')
# check_ssl = partial(self.check_symbol, env, 'libssl.so')
# check_ssl = partial(self.check_symbol, env, 'libssl' + self.version + '.so')
check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.version + '.so')
while True:
shprint(sh.make, 'build_libs', _env=env)
if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))):
break
shprint(sh.make, 'clean', _env=env)

self.install_libs(arch, 'libssl.so', 'libcrypto.so')
self.install_libs(arch, 'libssl' + self.version + '.so',
'libcrypto' + self.version + '.so')

recipe = OpenSSLRecipe()
16 changes: 16 additions & 0 deletions pythonforandroid/recipes/openssl/rename-shared-lib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- openssl/Makefile.shared 2016-05-03 15:44:42.000000000 +0200
+++ patch/Makefile.shared 2016-07-14 00:08:37.268792948 +0200
@@ -147,11 +147,11 @@
DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null

DO_GNU_SO=$(CALC_VERSIONS); \
- SHLIB=lib$(LIBNAME).so; \
+ SHLIB=lib$(LIBNAME)$(OPENSSL_VERSION).so; \
SHLIB_SUFFIX=; \
ALLSYMSFLAGS='-Wl,--whole-archive'; \
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
- SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
+ SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB"

DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"

2 changes: 1 addition & 1 deletion pythonforandroid/recipes/python2/Setup.local-ssl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SSL=
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL) -lssl -lcrypto
-L$(SSL) -lssl$(OPENSSL_VERSION) -lcrypto$(OPENSSL_VERSION)
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ def do_python_build(self, arch):
# TODO need to add a should_build that checks if optional
# dependencies have changed (possibly in a generic way)
if 'openssl' in self.ctx.recipe_build_order:
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
r = Recipe.get_recipe('openssl', self.ctx)
openssl_build_dir = r.get_build_dir(arch.arch)
setuplocal = join('Modules', 'Setup.local')
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal)
shprint(sh.sed, '-i', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal)
env['OPENSSL_VERSION'] = r.version

if 'sqlite3' in self.ctx.recipe_build_order:
# Include sqlite3 in python2 build
Expand Down