Add support for SQLCipher on Android

Plus some cleanup
This commit is contained in:
Gioacchino Mazzurco 2018-01-30 18:24:03 +01:00
parent ebfe50f814
commit 00125864ff
4 changed files with 31 additions and 28 deletions

View File

@ -46,6 +46,7 @@ export HOST_NUM_CPU=1
./android-prepare-toolchain.sh ./android-prepare-toolchain.sh
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
== Preparing Qt Creator == Preparing Qt Creator
Now that your environement is set up you should configure Qt Creator for Android Now that your environement is set up you should configure Qt Creator for Android
@ -81,15 +82,13 @@ and add the following configurations
CONFIG+=no_retroshare_gui CONFIG+=no_retroshare_nogui CONFIG+=no_retroshare_plugins CONFIG+=retroshare_android_service CONFIG+=libresapilocalserver CONFIG+=no_libresapihttpserver CONFIG+=retroshare_qml_app CONFIG+=no_retroshare_gui CONFIG+=no_retroshare_nogui CONFIG+=no_retroshare_plugins CONFIG+=retroshare_android_service CONFIG+=libresapilocalserver CONFIG+=no_libresapihttpserver CONFIG+=retroshare_qml_app
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
WARNING: SQLCipher is not supported yet on RetroShare for Android. This poses a
major security concern, we are working to fix this ASAP.
TIP: Some versions of QtCreator try to find the Android SDK in TIP: Some versions of QtCreator try to find the Android SDK in
+/opt/android/sdk+. A workaround to this is to make a symbolic link there +/opt/android/sdk+. A workaround to this is to make a symbolic link there
pointing to your SDK installation path, like pointing to your SDK installation path, like
+mkdir -p /opt/android/sdk && ln -s /home/user/android-sdk-linux +mkdir -p /opt/android/sdk && ln -s /home/user/android-sdk-linux
/opt/android/sdk+ /opt/android/sdk+
== Quircks == Quircks
On some Android devices like +Huawei ALE-L21+ background applications are On some Android devices like +Huawei ALE-L21+ background applications are
@ -106,6 +105,7 @@ To enable enable _protection_: +Android menu -> Settings -> Privacy & security
Other devices may offer similar _features_ please report them. Other devices may offer similar _features_ please report them.
== Debugging with GDB == Debugging with GDB
QtCreator actually support debugging only for the foreground activity, so to QtCreator actually support debugging only for the foreground activity, so to

View File

@ -11,6 +11,7 @@
[ -z ${OPENSSL_SOURCE_VERSION+x} ] && export OPENSSL_SOURCE_VERSION="1.0.2n" [ -z ${OPENSSL_SOURCE_VERSION+x} ] && export OPENSSL_SOURCE_VERSION="1.0.2n"
[ -z ${SQLITE_SOURCE_YEAR+x} ] && export SQLITE_SOURCE_YEAR="2018" [ -z ${SQLITE_SOURCE_YEAR+x} ] && export SQLITE_SOURCE_YEAR="2018"
[ -z ${SQLITE_SOURCE_VERSION+x} ] && export SQLITE_SOURCE_VERSION="3220000" [ -z ${SQLITE_SOURCE_VERSION+x} ] && export SQLITE_SOURCE_VERSION="3220000"
[ -z ${SQLCIPHER_SOURCE_VERSION+x} ] && export SQLCIPHER_SOURCE_VERSION="3.4.2"
[ -z ${LIBUPNP_SOURCE_VERSION+x} ] && export LIBUPNP_SOURCE_VERSION="1.6.24" [ -z ${LIBUPNP_SOURCE_VERSION+x} ] && export LIBUPNP_SOURCE_VERSION="1.6.24"
@ -105,11 +106,18 @@ build_sqlite()
build_sqlcipher() build_sqlcipher()
{ {
echo "sqlcipher not supported yet on android" B_dir="sqlcipher-${SQLCIPHER_SOURCE_VERSION}"
return 0 T_file="${B_dir}.tar.gz"
[ -f $T_file ] || wget -O $T_file https://github.com/sqlcipher/sqlcipher/archive/v${SQLCIPHER_SOURCE_VERSION}.tar.gz
cd sqlcipher rm -rf $B_dir
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="${SYSROOT}/usr/lib/libcrypto.a" tar -xf $T_file
cd $B_dir
./configure --build=$(sh ./config.guess) \
--host=${ANDROID_NDK_ARCH}-linux \
--prefix="${SYSROOT}/usr" --with-sysroot="${SYSROOT}" \
--enable-tempstore=yes \
--disable-tcl --disable-shared \
CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="${SYSROOT}/usr/lib/libcrypto.a"
make -j${HOST_NUM_CPU} make -j${HOST_NUM_CPU}
make install make install
cd .. cd ..
@ -153,6 +161,7 @@ build_toolchain
build_bzlib build_bzlib
build_openssl build_openssl
build_sqlite build_sqlite
build_sqlcipher
build_libupnp build_libupnp
echo NDK_TOOLCHAIN_PATH=${NDK_TOOLCHAIN_PATH} echo NDK_TOOLCHAIN_PATH=${NDK_TOOLCHAIN_PATH}

View File

@ -920,21 +920,25 @@ test_bitdht {
android-* { android-* {
## ifaddrs is missing on Android to add them don't use the one from ## ifaddrs is missing on Android to add them don't use the one from
## https://github.com/morristech/android-ifaddrs ## https://github.com/morristech/android-ifaddrs
## because they crash, use QNetworkInterface from Qt instead ## because it crash, use QNetworkInterface from Qt instead
CONFIG *= qt CONFIG *= qt
QT *= network QT *= network
## Add this here and not in retroshare.pri because static library are very DEFINES *= "fopen64=fopen"
## sensible to order in command line, has to be in the end of file for the DEFINES *= "fseeko64=fseeko"
## same reason DEFINES *= "ftello64=ftello"
LIBS *= -lbz2 -lupnp -lixml -lthreadutil -lsqlite3
## Static library are verysensible to order in command line, has to be in the
## end of file for this reason
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lsqlcipher
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libsqlcipher.a
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lssl LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lssl
INCLUDEPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include
DEPENDPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libssl.a PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libssl.a
LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lcrypto LIBS += -L$$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/ -lcrypto
INCLUDEPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include
DEPENDPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include
PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libcrypto.a PRE_TARGETDEPS += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libcrypto.a
HEADERS += util/androiddebug.h HEADERS += util/androiddebug.h

View File

@ -119,21 +119,11 @@ android-* {
CONFIG -= no_retroshare_android_notify_service CONFIG -= no_retroshare_android_notify_service
CONFIG *= retroshare_android_notify_service CONFIG *= retroshare_android_notify_service
} }
CONFIG *= no_libresapihttpserver no_sqlcipher upnp_libupnp CONFIG *= no_libresapihttpserver upnp_libupnp
CONFIG -= libresapihttpserver sqlcipher upnp_miniupnpc CONFIG -= libresapihttpserver upnp_miniupnpc
QT *= androidextras QT *= androidextras
DEFINES *= "fopen64=fopen"
DEFINES *= "fseeko64=fseeko"
DEFINES *= "ftello64=ftello"
INCLUDEPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include INCLUDEPATH += $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/include
LIBS *= -L$$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/ LIBS *= -L$$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/
LIBS *= -lbz2 -lupnp -lixml -lthreadutil -lsqlite3
ANDROID_EXTRA_LIBS *= $$NATIVE_LIBS_TOOLCHAIN_PATH/sysroot/usr/lib/libsqlite3.so
# message(LIBS: $$LIBS)
# message(ANDROID_EXTRA_LIBS: $$ANDROID_EXTRA_LIBS)
# message(ANDROID_PLATFORM: $$ANDROID_PLATFORM)
# message(ANDROID_PLATFORM_ROOT_PATH: $$ANDROID_PLATFORM_ROOT_PATH)
# message(NATIVE_LIBS_TOOLCHAIN_PATH: $$NATIVE_LIBS_TOOLCHAIN_PATH)
} }
win32 { win32 {