OpenSSL & FFmpeg as submodules & Different versionCode for each ABI

This commit is contained in:
Matéo Duparc 2024-07-18 22:09:21 +02:00
parent 33d565bf22
commit bb49501403
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A
9 changed files with 57 additions and 69 deletions

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule "app/libcryfs"]
path = app/libcryfs
url = https://forge.chapril.org/hardcoresushi/libcryfs.git
[submodule "app/ffmpeg/ffmpeg"]
path = app/ffmpeg/ffmpeg
url = https://git.ffmpeg.org/ffmpeg.git

View File

@ -38,31 +38,17 @@ __Don't continue if the verification fails!__
Initialize submodules:
```
$ git submodule update --depth=1 --init
$ git submodule update --init
```
[FFmpeg](https://ffmpeg.org) is needed to record encrypted video:
If you want Gocryptfs support, initliaze libgocryptfs submodules:
```
$ cd app/ffmpeg
$ git clone --depth=1 https://git.ffmpeg.org/ffmpeg.git
$ cd app/libgocryptfs
$ git submodule update --init
```
If you want Gocryptfs support, you need to download OpenSSL:
```
$ cd ../libgocryptfs
$ wget https://openssl.org/source/openssl-3.3.1.tar.gz
```
Verify OpenSSL signature:
```
$ wget https://openssl.org/source/openssl-3.3.1.tar.gz.asc
$ gpg --verify openssl-3.3.1.tar.gz.asc openssl-3.3.1.tar.gz
```
Continue **ONLY** if the signature is **VALID**.
```
$ tar -xzf openssl-3.3.1.tar.gz
```
If you want CryFS support, initialize libcryfs:
If you want CryFS support, initialize libcryfs submodules:
```
$ cd app/libcryfs
$ git submodule update --depth=1 --init
$ git submodule update --init
```
# Build
@ -70,31 +56,33 @@ Retrieve your Android NDK installation path, usually something like `/home/\<use
```
$ export ANDROID_NDK_HOME="<your ndk path>"
```
If you know your CPU ABI, you can specify it to build scripts in order to speed up compilation time. If you don't know it, or want to build for all ABIs, just leave the field blank.
Start by compiling FFmpeg:
```
$ cd app/ffmpeg
$ ./build.sh ffmpeg
$ ./build.sh [<ABI>]
```
## libgocryptfs
This step is only required if you want Gocryptfs support.
```
$ cd app/libgocryptfs
$ ANDROID_NDK_ROOT="$ANDROID_NDK_HOME" OPENSSL_PATH="./openssl-3.3.1" ./build.sh
$ ./build.sh [<ABI>]
```
## Compile APKs
Gradle build libgocryptfs and libcryfs by default.
To build DroidFS without Gocryptfs support, run:
```
$ ./gradlew assembleRelease -PdisableGocryptfs=true
$ ./gradlew assembleRelease [-Pabi=<ABI>] -PdisableGocryptfs=true
```
To build DroidFS without CryFS support, run:
```
$ ./gradlew assembleRelease -PdisableCryFS=true
$ ./gradlew assembleRelease [-Pabi=<ABI>] -PdisableCryFS=true
```
If you want to build DroidFS with support for both Gocryptfs and CryFS, just run:
```
$ ./gradlew assembleRelease
$ ./gradlew assembleRelease [-Pabi=<ABI>]
```
# Sign APKs

View File

@ -13,12 +13,6 @@ if (hasProperty("disableGocryptfs")) {
ext.disableGocryptfs = false
}
if (hasProperty("nosplits")) {
ext.splits = false
} else {
ext.splits = true
}
android {
compileSdk 34
ndkVersion '25.2.9519653'
@ -33,6 +27,8 @@ android {
jvmTarget = "17"
}
def abiCodes = [ "arm64-v8a": 1, "armeabi-v7a": 2, "x86_64": 3, "x86": 4]
defaultConfig {
applicationId "sushi.hardcore.droidfs"
minSdkVersion 21
@ -40,8 +36,17 @@ android {
versionCode 36
versionName "2.1.3"
ndk {
abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
splits {
abi {
enable true
reset() // fix unknown bug (https://ru.stackoverflow.com/questions/1557805/abis-armeabi-mips-mips64-riscv64-are-not-supported-for-platform)
if (project.hasProperty("abi")) {
include project.getProperty("abi")
} else {
abiCodes.keySet().each { abi -> include abi }
universalApk !project.hasProperty("nouniversal")
}
}
}
externalNativeBuild.cmake {
@ -54,20 +59,20 @@ android {
}
}
if (project.ext.splits) {
splits {
abi {
enable true
reset() // fix unknown bug (https://ru.stackoverflow.com/questions/1557805/abis-armeabi-mips-mips64-riscv64-are-not-supported-for-platform)
universalApk true
}
}
}
applicationVariants.configureEach { variant ->
variant.resValue "string", "versionName", variant.versionName
buildConfigField "boolean", "CRYFS_DISABLED", "${project.ext.disableCryFS}"
buildConfigField "boolean", "GOCRYPTFS_DISABLED", "${project.ext.disableGocryptfs}"
variant.outputs.each { output ->
def abi = output.getFilter(com.android.build.OutputFile.ABI)
if (abi == null) { // universal
output.versionCodeOverride = variant.versionCode*10
output.outputFileName = "DroidFS-v${variant.versionName}-${variant.name}-universal.apk"
} else {
output.versionCodeOverride = variant.versionCode*10 + abiCodes[abi]
output.outputFileName = "DroidFS-v${variant.versionName}-${variant.name}-${abi}.apk"
}
}
}
buildFeatures {

View File

@ -1,2 +1 @@
ffmpeg
build

View File

@ -1,13 +1,13 @@
#!/bin/bash
set -e
if [ -z ${ANDROID_NDK_HOME+x} ]; then
echo "Error: \$ANDROID_NDK_HOME is not defined." >&2
exit 1
elif [ $# -lt 1 ]; then
echo "Usage: $0 <FFmpeg source directory> [<ABI>]" >&2
exit 1
else
FFMPEG_DIR=$1
cd "$(dirname "$0")"
FFMPEG_DIR="ffmpeg"
compile_for_arch() {
echo "Compiling for $1..."
case $1 in
@ -29,7 +29,8 @@ else
ARCH="arm"
;;
esac
(cd $FFMPEG_DIR && make clean;
(cd $FFMPEG_DIR
make clean || true
./configure \
--cc="$CFN" \
--cxx="$CFN++" \
@ -73,22 +74,19 @@ else
--disable-audiotoolbox \
--disable-appkit \
--disable-alsa \
--disable-debug \
&&
make -j $(nproc --all) >/dev/null) &&
mkdir -p build/$1/libavformat build/$1/libavcodec build/$1/libavutil &&
cp $FFMPEG_DIR/libavformat/*.h $FFMPEG_DIR/libavformat/libavformat.so build/$1/libavformat &&
cp $FFMPEG_DIR/libavcodec/*.h $FFMPEG_DIR/libavcodec/libavcodec.so build/$1/libavcodec &&
cp $FFMPEG_DIR/libavutil/*.h $FFMPEG_DIR/libavutil/libavutil.so build/$1/libavutil ||
exit 1
--disable-debug
make -j "$(nproc --all)" >/dev/null)
mkdir -p "build/$1/libavformat" "build/$1/libavcodec" "build/$1/libavutil"
cp $FFMPEG_DIR/libavformat/*.h $FFMPEG_DIR/libavformat/libavformat.so "build/$1/libavformat"
cp $FFMPEG_DIR/libavcodec/*.h $FFMPEG_DIR/libavcodec/libavcodec.so "build/$1/libavcodec"
cp $FFMPEG_DIR/libavutil/*.h $FFMPEG_DIR/libavutil/libavutil.so "build/$1/libavutil"
}
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
if [ $# -eq 2 ]; then
compile_for_arch $2
if [ $# -eq 1 ]; then
compile_for_arch "$1"
else
declare -a ABIs=("x86_64" "x86" "arm64-v8a" "armeabi-v7a")
for abi in ${ABIs[@]}; do
for abi in "x86_64" "x86" "arm64-v8a" "armeabi-v7a"; do
compile_for_arch $abi
done
fi

1
app/ffmpeg/ffmpeg Submodule

@ -0,0 +1 @@
Subproject commit af25a4bfd2503caf3ee485b27b99b620302f5718

@ -1 +1 @@
Subproject commit 4f32853ae5ac70811b451cac60ed36fd5b93cbc8
Subproject commit b221d4cf3c70edc711169a769a476802d2577b2b

View File

@ -16,9 +16,3 @@
-keep class sushi.hardcore.droidfs.VolumeData$* {
static public android.os.Parcelable$Creator CREATOR;
}
-keep class sushi.hardcore.droidfs.filesystems.EncryptedVolume {
public int describeContents();
}
-keep class sushi.hardcore.droidfs.filesystems.EncryptedVolume$* {
static public android.os.Parcelable$Creator CREATOR;
}

@ -1 +1 @@
Subproject commit 48631380a7a8b5f0932078e2b643e06c3f433890
Subproject commit 8df8522088b095de23d4de95c73320a91b111a8d