terl / lazysodium-android

An Android implementation of the Libsodium cryptography library. For the lazy dev.
https://github.com/terl/lazysodium-java/wiki
Mozilla Public License 2.0
106 stars 25 forks source link

LazySodium compilation from scratch for F-Droid #38

Open alexamiryan opened 4 years ago

alexamiryan commented 4 years ago

Hello. I am founder and main dev of Stingle Photos (https://github.com/stingle/stingle-photos-android). We want to publish Stingle Photos on F-Droid and as you know their requirement is that everything should be built from sources on their side, no precompiled binaries allowed. I am struggling to build a CI script for F-Droid to compile LazySodium from scratch. Is there any chance you guys had similar experience and can help me with that?

Thanks in advance.

MuntashirAkon commented 4 years ago

You can use the build_libsodium.sh script from my fork: https://github.com/MuntashirAkon/lazysodium-android It'll build the libsodium.so files and move them to the corresponding ABI directories inside jniLibs. You can edit the jni_dir inside the script to copy them anywhere you want. I've also used -j command for make which will use all the available CPUs to build the binaries which takes about 2 minutes on my device.

Usage:

./build_libsodium.sh ndk_path [api]

api is set to 21 if not given.

NB: It will only build for arm-v7a, arm-v8a, x86, x86_64 because latest NDK only supports these variants.

gurpreet- commented 3 years ago

Hi @alexamiryan and @MuntashirAkon,

I had been contacted a few months back for a similar thing. In fact, I am increasingly seeing F-Droid mentioned. Do you know if it would be worthwhile to have a script inside Lazysodium to build sources from scratch?

MuntashirAkon commented 3 years ago

I had been contacted a few months back for a similar thing. In fact, I am increasingly seeing F-Droid mentioned. Do you know if it would be worthwhile to have a script inside Lazysodium to build sources from scratch?

I've implemented it on my repo already (but modified it a bit for my own use). I can make a PR with just this modification if you're interested. It takes less than 2 minutes to build libsodium on my 7 gen i3 dual core (4 threads) processor with 8 GB RAM. On JitPack, it takes less than a minute.

gurpreet- commented 3 years ago

Can F-Droid invoke it's own build steps? Something like ./gradlew f-droid-build?

I don't want to rebuild libsodium binaries over and over again because:

  1. I'd like to keep testing time low.
  2. It adds extra complexity.
MuntashirAkon commented 3 years ago

I don't want to rebuild libsodium binaries over and over again because:

  1. I'd like to keep testing time low.

You don't have to build it over and over again. If you're using CI, you can cache the binaries and put a check in the build script (already done in my repo). Same can be done in other cases as well. F-Droid never cache anything. So, they'll simply rebuild it instead.

  1. It adds extra complexity.

No, it doesn't. You'll simply need a script (which I've already done on my end) and two tasks in the build.gradle: one for building the binaries and the other for cleaning up the binaries.

gurpreet- commented 3 years ago

Thank you for the advice. OK, let me see if this can be integrated.

gurpreet- commented 3 years ago

@MuntashirAkon do I have permission to use and/or modify your script here? https://github.com/MuntashirAkon/lazysodium-android/blob/master/build_libsodium.sh

MuntashirAkon commented 3 years ago

do I have permission to use and/or modify your script here? https://github.com/MuntashirAkon/lazysodium-android/blob/master/build_libsodium.sh

Sure! Just add a credit line at the top of the file (should be MPL-2.0 dated 28 Oct 2020).

MuntashirAkon commented 1 year ago

Is there any update? The repository still seems to be using non-free binaries/blobs. If you cannot manage the time, maybe I can help.