π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add F-Droid source overlay
Neeraj Gupta8950c38b9bc1
diff --git a/mobile/apps/photos/android/app/src/fdroid/AndroidManifest.xml b/mobile/apps/photos/android/app/src/fdroid/AndroidManifest.xmlindex 41bed3f0ba..8a16e73571 100644--- a/mobile/apps/photos/android/app/src/fdroid/AndroidManifest.xml+++ b/mobile/apps/photos/android/app/src/fdroid/AndroidManifest.xml@@ -6,6 +6,12 @@main/AndroidManifest.xml oncehttps://github.com/flutter/flutter/issues/38965 is fixed. --><application>+ <meta-data android:name="io.sentry.dsn" tools:node="remove"/>+ <meta-data+ android:name="io.sentry.auto-init"+ android:value="false"+ tools:replace="android:value"/>+<activity android:name=".MainActivity"android:launchMode="singleTask"android:theme="@style/LaunchTheme"diff --git a/mobile/apps/photos/docs/release.md b/mobile/apps/photos/docs/release.mdindex c7b4f50819..6aef6e961d 100644--- a/mobile/apps/photos/docs/release.md+++ b/mobile/apps/photos/docs/release.md@@ -30,3 +30,12 @@ Set "Previous tag" to the last release of auth and press "Generate releasenotes". The generated release note will contain all PRs and new contributorsfrom all the releases in the monorepo, so you'll need to filter them to keeponly the things that relate to the Photos mobile app.++## F-Droid++For F-Droid, create an `fdroid-v` tag with the same pubspec version.++```sh+./scripts/create_tag.sh fdroid-v1.2.3+git push origin fdroid-v1.2.3+```diff --git a/mobile/apps/photos/fdroid/overlay/lib/services/account/purchase_update_listener.dart b/mobile/apps/photos/fdroid/overlay/lib/services/account/purchase_update_listener.dartnew file mode 100644index 0000000000..666f76f20d--- /dev/null+++ b/mobile/apps/photos/fdroid/overlay/lib/services/account/purchase_update_listener.dart@@ -0,0 +1,5 @@+void listenForPurchaseUpdates({+ required bool Function() isOnSubscriptionPage,+ required Future<void> Function(String productID, String verificationData)+ verifySubscription,+}) {}diff --git a/mobile/apps/photos/fdroid/overlay/lib/services/push_service.dart b/mobile/apps/photos/fdroid/overlay/lib/services/push_service.dartnew file mode 100644index 0000000000..d378539974--- /dev/null+++ b/mobile/apps/photos/fdroid/overlay/lib/services/push_service.dart@@ -0,0 +1,11 @@+typedef BackgroundPushHandler = Future<void> Function(Object message);++class PushService {+ static final PushService instance = PushService._privateConstructor();++ PushService._privateConstructor();++ Future<void> init({BackgroundPushHandler? onBackgroundPush}) async {}++ static bool shouldSync(Object message) => false;+}diff --git a/mobile/apps/photos/fdroid/overlay/lib/ui/payment/store_subscription_page.dart b/mobile/apps/photos/fdroid/overlay/lib/ui/payment/store_subscription_page.dartnew file mode 100644index 0000000000..981f612396--- /dev/null+++ b/mobile/apps/photos/fdroid/overlay/lib/ui/payment/store_subscription_page.dart@@ -0,0 +1,18 @@+import "package:flutter/widgets.dart";++class StoreSubscriptionPage extends StatefulWidget {+ final bool isOnboarding;++ const StoreSubscriptionPage({+ this.isOnboarding = false,+ super.key,+ });++ @override+ State<StoreSubscriptionPage> createState() => _StoreSubscriptionPageState();+}++class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {+ @override+ Widget build(BuildContext context) => const SizedBox.shrink();+}diff --git a/mobile/apps/photos/fdroid/overlay/lib/ui/payment/subscription.dart b/mobile/apps/photos/fdroid/overlay/lib/ui/payment/subscription.dartnew file mode 100644index 0000000000..e344847624--- /dev/null+++ b/mobile/apps/photos/fdroid/overlay/lib/ui/payment/subscription.dart@@ -0,0 +1,6 @@+import "package:flutter/widgets.dart";+import "package:photos/ui/payment/stripe_subscription_page.dart";++StatefulWidget getSubscriptionPage({bool isOnBoarding = false}) {+ return StripeSubscriptionPage(isOnboarding: isOnBoarding);+}diff --git a/mobile/apps/photos/scripts/check_fdroid_overlay.sh b/mobile/apps/photos/scripts/check_fdroid_overlay.shnew file mode 100755index 0000000000..65cdff7561--- /dev/null+++ b/mobile/apps/photos/scripts/check_fdroid_overlay.sh@@ -0,0 +1,66 @@+#!/usr/bin/env bash+set -euo pipefail++cd "$(dirname "$0")/.."+app_root=$(pwd)++fail() {+ echo "check_fdroid_overlay: $*" >&2+ exit 1+}++repo_root=$(git rev-parse --show-toplevel)+app_rel=${app_root#"$repo_root"/}+tmp_root=$(mktemp -d "${TMPDIR:-/tmp}/ente-photos-fdroid.XXXXXX")+worktree="$tmp_root/worktree"++cleanup() {+ local status=$?+ git -C "$repo_root" worktree remove --force "$worktree" >/dev/null 2>&1 || true+ rm -rf "$tmp_root"+ exit "$status"+}+trap cleanup EXIT++git -C "$repo_root" worktree add --detach "$worktree" HEAD >/dev/null++git -C "$repo_root" diff --binary HEAD -- "$app_rel" .github/workflows/mobile-release.yml > "$tmp_root/current.patch"+if [[ -s "$tmp_root/current.patch" ]]; then+ git -C "$worktree" apply "$tmp_root/current.patch"+fi++while IFS= read -r -d "" file; do+ mkdir -p "$worktree/$(dirname "$file")"+ cp -p "$repo_root/$file" "$worktree/$file"+done < <(+ git -C "$repo_root" ls-files \+ --others \+ --exclude-standard \+ -z \+ -- "$app_rel"+)++cd "$worktree/mobile/apps/photos"++./scripts/prepare_fdroid_source.sh+flutter pub get++if rg -n "firebase_core|firebase_messaging|in_app_purchase" pubspec.yaml pubspec.lock; then+ fail "restricted dependencies remain after flutter pub get"+fi++command -v flutter_rust_bridge_codegen >/dev/null \+ || fail "flutter_rust_bridge_codegen is required; install it with cargo install flutter_rust_bridge_codegen"++pushd ../../packages/rust >/dev/null+flutter_rust_bridge_codegen generate+popd >/dev/null+flutter_rust_bridge_codegen generate++flutter analyze --no-pub+flutter build apk \+ --config-only \+ --flavor fdroid \+ -t lib/main.dart \+ --dart-define=cronetHttpNoPlay=true \+ --no-pubdiff --git a/mobile/apps/photos/scripts/create_tag.sh b/mobile/apps/photos/scripts/create_tag.shindex 0190afa886..77f98323ae 100755--- a/mobile/apps/photos/scripts/create_tag.sh+++ b/mobile/apps/photos/scripts/create_tag.sh@@ -1,66 +1,26 @@-#!/bin/sh+#!/usr/bin/env bash+set -euo pipefail-#!/bin/bash+cd "$(dirname "$0")/.."-# Function to display usage-usage() {- echo "Usage: $0 tag"+[[ $# -eq 1 ]] || {+ echo "Usage: $0 fdroid-vX.Y.Z" >&2exit 1}-# Ensure a tag was provided-[[ $# -eq 0 ]] && usage--# Exit immediately if a command exits with a non-zero status-set -e--# Go to the project root directory-cd "$(dirname "$0")/.."--# Get the tag from the command line argument-TAG=$1--# Get the current branch-BRANCH=$(git rev-parse --abbrev-ref HEAD)--# Get the version from the pubspec.yaml file and cut everything after the +-VERSION=$(grep "^version:" pubspec.yaml | awk '{ print $2 }' | cut -d '+' -f 1)+tag="$1"+version=$(awk '/^version:/ { print $2 }' pubspec.yaml | cut -d "+" -f 1)--# Check the current branch and set the tag prefix-if [[ $BRANCH == "independent" ]]; then- PREFIX="v"-elif [[ $BRANCH == "f-droid" ]]; then- PREFIX="fdroid-"- # Additional checks for f-droid branch- # Verify that the pubspec.yaml doesn't contain certain words- WORDS=("in_app_purchase" "firebase")- for word in ${WORDS[@]}; do- if grep -q $word pubspec.yaml; then- echo "The pubspec.yaml file dependency on '$word', which is not allowed on the f-droid branch."- exit 1- fi- done-else- echo "Tags can only be created on the independent or f-droid branches."- exit 1-fi--# Ensure the tag has the correct prefix-if [[ $TAG != $PREFIX* ]]; then- echo "Invalid tag. On the $BRANCH branch, tags must start with '$PREFIX'."+[[ "$tag" == fdroid-v* ]] || {+ echo "create_tag: expected fdroid-v tag" >&2exit 1-fi+}-# Ensure the tag version is in the pubspec.yaml file-if [[ $TAG != *$VERSION ]]; then- echo "Invalid tag."- echo "The version $VERSION in pubspec doesn't match the version in tag $TAG."+[[ "${tag#fdroid-v}" == "$version" ]] || {+ echo "create_tag: pubspec version $version does not match $tag" >&2exit 1-fi--## If all checks pass, create the tag-git tag $TAG-echo "Tag $TAG created."+}-exit 0+./scripts/check_fdroid_overlay.sh+git tag "$tag"+echo "Tag $tag created."diff --git a/mobile/apps/photos/scripts/prepare_fdroid_source.sh b/mobile/apps/photos/scripts/prepare_fdroid_source.shnew file mode 100755index 0000000000..f8b83dedd4--- /dev/null+++ b/mobile/apps/photos/scripts/prepare_fdroid_source.sh@@ -0,0 +1,34 @@+#!/usr/bin/env bash+set -euo pipefail++cd "$(dirname "$0")/.."++fail() {+ echo "prepare_fdroid_source: $*" >&2+ exit 1+}++remove_direct_dependencies() {+ local count+ count=$(rg -c "^ (firebase_core|firebase_messaging|in_app_purchase):" pubspec.yaml || true)+ [[ "$count" == "3" ]] || fail "expected three restricted dependencies in pubspec.yaml"+ perl -0pi -e 's/^ (firebase_core|firebase_messaging|in_app_purchase):[^\n]*\n//mg' pubspec.yaml+}++copy_fdroid_overlay() {+ cp -R fdroid/overlay/lib/. lib/+}++assert_fdroid_source() {+ if rg -n "package:(firebase_core|firebase_messaging|in_app_purchase)" lib pubspec.yaml; then+ fail "restricted package imports or direct dependencies remain"+ fi++ if rg -n "FirebaseMessaging|Firebase\\.initializeApp|RemoteMessage|InAppPurchase|PurchaseStatus" lib; then+ fail "restricted Firebase or in-app purchase references remain"+ fi+}++remove_direct_dependencies+copy_fdroid_overlay+assert_fdroid_source