Skip to content

Recipes #459

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 2 commits into from
Oct 31, 2015
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
10 changes: 10 additions & 0 deletions pythonforandroid/recipes/enum34/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

from pythonforandroid.toolchain import PythonRecipe


class Enum34Recipe(PythonRecipe):
version = '1.0.4'
url = 'https://pypi.python.org/packages/source/e/enum34/enum34-{version}.tar.gz'
depends = ['python2']

recipe = Enum34Recipe()
23 changes: 23 additions & 0 deletions pythonforandroid/recipes/openssl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

from pythonforandroid.toolchain import Recipe, shprint, current_directory
from os.path import exists, join
import sh


class OpenSSLRecipe(Recipe):
version = '1.0.2d'
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'

def should_build(self):
return not exists(join(self.get_build_dir('armeabi'), 'libssl.a'))

def build_arch(self, arch):
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
# sh fails with code 255 trying to execute ./Configure
# so instead we manually run perl passing in Configure
perl = sh.Command('perl')
shprint(perl, 'Configure', 'no-dso', 'no-krb5', 'linux-armv4', _env=env)
shprint(sh.make, 'build_libs', _env=env)

recipe = OpenSSLRecipe()
10 changes: 10 additions & 0 deletions pythonforandroid/recipes/pyasn1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

from pythonforandroid.toolchain import PythonRecipe


class PyASN1Recipe(PythonRecipe):
version = '0.1.8'
url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz'
depends = ['python2']

recipe = PyASN1Recipe()
51 changes: 51 additions & 0 deletions pythonforandroid/recipes/pycrypto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

from pythonforandroid.toolchain import (
CompiledComponentsPythonRecipe,
Recipe,
current_directory,
info,
shprint,
)
from os.path import exists, join, realpath
import sh
import glob


class PyCryptoRecipe(CompiledComponentsPythonRecipe):
version = '2.6.1'
url = 'https://pypi.python.org/packages/source/p/pycrypto/pycrypto-{version}.tar.gz'
depends = ['openssl', 'python2']

def prebuild_arch(self, arch):
super(PyCryptoRecipe, self).prebuild_arch(arch)
build_dir = self.get_build_dir(arch.arch)
if exists(join(build_dir, '.patched')):
print('pycrypto already patched, skipping')
return
self.apply_patch('add_length.patch')
shprint(sh.touch, join(build_dir, '.patched'))

def get_recipe_env(self, arch):
env = super(PyCryptoRecipe, self).get_recipe_env(arch)
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include'))
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
self.ctx.get_libs_dir(arch.arch) +
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
openssl_build_dir)
env['EXTRA_CFLAGS'] = '--host linux-armv'
env['ac_cv_func_malloc_0_nonnull'] = 'yes'
return env

def build_compiled_components(self, arch):
info('Configuring compiled components in {}'.format(self.name))

env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
configure = sh.Command('./configure')
shprint(configure, '--host=arm-eabi',
'--prefix={}'.format(self.ctx.get_python_install_dir()),
'--enable-shared', _env=env)
super(PyCryptoRecipe, self).build_compiled_components(arch)

recipe = PyCryptoRecipe()
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/pycrypto/add_length.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- pycrypto-2.6.1/src/hash_SHA2_template.c.orig 2013-10-14 14:38:10.000000000 -0700
+++ pycrypto-2.6.1/src/hash_SHA2_template.c 2014-05-19 10:15:51.000000000 -0700
@@ -87,7 +87,7 @@
* return 1 on success
* return 0 if the length overflows
*/
-int add_length(hash_state *hs, sha2_word_t inc) {
+static int add_length(hash_state *hs, sha2_word_t inc) {
sha2_word_t overflow_detector;
overflow_detector = hs->length_lower;
hs->length_lower += inc;
38 changes: 38 additions & 0 deletions pythonforandroid/recipes/pyopenssl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

from pythonforandroid.toolchain import (
CompiledComponentsPythonRecipe,
Recipe,
current_directory,
info,
shprint,
)
from os.path import exists, join
import sh
import glob


class PyOpenSSLRecipe(CompiledComponentsPythonRecipe):
version = '0.13'
url = 'https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-{version}.tar.gz'
depends = ['openssl', 'python2']

def prebuild_arch(self, arch):
super(PyOpenSSLRecipe, self).prebuild_arch(arch)
build_dir = self.get_build_dir(arch.arch)
if exists(join(build_dir, '.patched')):
print('pyOpenSSL already patched, skipping')
return
self.apply_patch('fix-dlfcn.patch')
shprint(sh.touch, join(build_dir, '.patched'))

def get_recipe_env(self, arch):
env = super(PyOpenSSLRecipe, self).get_recipe_env(arch)
openssl_build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch)
env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include'))
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
self.ctx.get_libs_dir(arch.arch) +
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
openssl_build_dir)
return env

recipe = PyOpenSSLRecipe()
22 changes: 22 additions & 0 deletions pythonforandroid/recipes/pyopenssl/fix-dlfcn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- pyOpenSSL-0.13.orig/OpenSSL/__init__.py 2011-09-02 17:46:13.000000000 +0200
+++ pyOpenSSL-0.13/OpenSSL/__init__.py 2013-07-29 17:20:15.750079894 +0200
@@ -12,6 +12,11 @@
except AttributeError:
from OpenSSL import crypto
else:
+ # XXX android fix
+ # linux: RTLD_NOW (0x2) | RTLD_GLOBAL (0x100 / 256)
+ # android: RTLD_NOW (0x0) | RTLD_GLOBAL (0x2)
+ flags = 0x2
+ '''
try:
import DLFCN
except ImportError:
@@ -31,6 +36,7 @@
else:
flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL
del DLFCN
+ '''

sys.setdlopenflags(flags)
from OpenSSL import crypto
14 changes: 12 additions & 2 deletions pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Python2Recipe(Recipe):

depends = ['hostpython2']
conflicts = ['python3']
opt_depends = ['openssl']

def prebuild_armeabi(self):
build_dir = self.get_build_container_dir('armeabi')
Expand Down Expand Up @@ -74,8 +75,8 @@ def build_armeabi(self):
# return

def do_python_build(self):
if 'sqlite' in self.ctx.recipe_build_order or 'openssl' in self.ctx.recipe_build_order:
print('sqlite or openssl support not yet enabled in python recipe')
if 'sqlite' in self.ctx.recipe_build_order:
print('sqlite support not yet enabled in python recipe')
exit(1)

hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)
Expand All @@ -99,6 +100,15 @@ def do_python_build(self):
env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.split('\n')[0]
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO'])

# 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('armeabi')
env['CFLAGS'] = ' '.join([env['CFLAGS'],
'-I{}'.format(join(openssl_build_dir, 'include'))])
env['LDFLAGS'] = ' '.join([env['LDFLAGS'],
'-L{}'.format(openssl_build_dir)])

configure = sh.Command('./configure')
# AND: OFLAG isn't actually set, should it be?
shprint(configure,
Expand Down
10 changes: 10 additions & 0 deletions pythonforandroid/recipes/six/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

from pythonforandroid.toolchain import PythonRecipe


class SixRecipe(PythonRecipe):
version = '1.9.0'
url = 'https://pypi.python.org/packages/source/s/six/six-{version}.tar.gz'
depends = ['python2']

recipe = SixRecipe()