mobile: Extract versions for f-droid

This commit is contained in:
PaddiM8 2023-07-20 20:48:06 +02:00
parent 0573a1e9f4
commit cdb55f0ebd
3 changed files with 36 additions and 0 deletions

12
mobile/extract-version.py Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/python3
import json
with open("package.json", "r") as f:
version = json.load(f)["version"]
with open("version.txt", "w") as f:
f.write("version: {}\n".format(version))
versionCode = sum([int(x) if len(x) > 1 else int(x) * 10
for x in version.split(".")])
f.write("versionCode: {}\n".format(versionCode))

22
mobile/fdroid-prepare.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
dir="./node_modules/@capacitor/android/capacitor"
# remove lines related to play service/firebase dependencies
sed -i '/playServices/d' "$dir/build.gradle"
sed -i '/firebase/d' "$dir/build.gradle"
# remove the files that rely on the proprietary services
rm -f "$dir/src/main/java/com/getcapacitor/plugin/Geolocation.java"
rm -f "$dir/src/main/java/com/getcapacitor/plugin/PushNotifications.java"
rm -f "$dir/src/main/java/com/getcapacitor/CapacitorFirebaseMessagingService.java"
# remove the references to the plugins in Bridge.java
sed -i '/Geolocation/d' "$dir/src/main/java/com/getcapacitor/Bridge.java"
sed -i '/PushNotifications/d' "$dir/src/main/java/com/getcapacitor/Bridge.java"
# remove unecessary permissions and now redundant lines from manifest
sed -i '/WAKE_LOCK/d' "$dir/src/main/AndroidManifest.xml"
sed -i '/RECEIVE_BOOT_COMPLETED/d' "$dir/src/main/AndroidManifest.xml"
i=$(grep -n "firebase_messaging_auto_init_enabled" "$dir/src/main/AndroidManifest.xml" | cut -d : -f 1)
sed -i "$i,$(($i+12))d" "$dir/src/main/AndroidManifest.xml" 2> /dev/null

2
mobile/version.txt Normal file
View File

@ -0,0 +1,2 @@
version: 2.0.3
versionCode: 50