Files
IronFox/scripts/deglean.sh
celenity 859d60e323 IronFox v143.0.3
ironfox-oss/IronFox!85
____

## Changes

- Enabled [display of built-in add-ons at the `Extensions` fragment](2f382311f9) *(As a result, users can now easily see/control built-in extensions, and disable them if desired)*.
- Ensured that [Android's `Credential Manager` API is always prioritized over Google Play Services/microG on supported devices](9c6bd05707).
- [Exposed `about:translations` at `about:about`](94b73a9ffc).
- [Implemented enterprise policies](304c4e088c) to control various features/functionality in Gecko.
- Rebased onto Firefox [`143.0.3`](https://firefox.com/firefox/android/143.0.3/releasenotes/).
- Removed [the `Mozilla Ad Routing Service` *(`MARS`)* library](b88a4db302).
- Removed [privileged add-on signing status from external Mozilla add-ons](76a6e95f32).
- Updated the default Rust version to [`1.90.0`](https://doc.rust-lang.org/stable/releases.html#version-190-2025-09-18).
- [Updated the setting to enable/disable installation of add-ons](4dc340b4aa) to leverage policies - making it more effective/comprehensive, and improved UX by displaying a pop-up when a user attempts to install an add-on while the setting is disabled.
- [Other minor tweaks and adjustments](https://gitlab.com/ironfox-oss/IronFox/-/merge_requests/85/diffs).

MR-author: celenity <celenity@celenity.dev>
Co-authored-by: Weblate <hosted@weblate.org>
Co-authored-by: Akash Yadav <itsaky01@gmail.com>
Approved-by: Akash Yadav <itsaky01@gmail.com>
Merged-by: celenity <celenity@celenity.dev>
2025-10-01 13:16:45 +00:00

159 lines
7.8 KiB
Bash
Executable File

#!/bin/bash
source "$rootdir/scripts/versions.sh"
if [[ "$env_source" != "true" ]]; then
echo "Use 'source scripts/env_local.sh' before calling prebuild or build"
return 1
fi
function deglean() {
local dir="$1"
local gradle_files=$(find "${dir}" -type f -name "*.gradle")
local kt_files=$(find "${dir}" -type f -name "*.kt")
local yaml_files=$(find "${dir}" -type f -name "metrics.yaml" -o -name "pings.yaml")
if [ -n "$gradle_files" ]; then
for file in $gradle_files; do
local modified=false
python3 "$rootdir/scripts/deglean.py" "$file"
if grep -q 'apply plugin.*glean' "$file"; then
$SED -i -r 's/^(.*apply plugin:.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'classpath.*glean' "$file"; then
$SED -i -r 's/^(.*classpath.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'compileOnly.*glean' "$file"; then
$SED -i -r 's/^(.*compileOnly.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'implementation.*glean' "$file"; then
$SED -i -r 's/^(.*implementation.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'testImplementation.*glean' "$file"; then
$SED -i -r 's/^(.*testImplementation.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if [ "$modified" = true ]; then
echo "De-gleaned $file."
fi
done
else
echo "No *.gradle files found in $dir."
fi
if [ -n "$kt_files" ]; then
for file in $kt_files; do
local modified=false
if grep -q 'import mozilla.telemetry.*' "$file"; then
$SED -i -r 's/^(.*import mozilla.telemetry.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'import .*GleanMetrics' "$file"; then
$SED -i -r 's/^(.*GleanMetrics.*)$/\/\/ \1/' "$file"
modified=true
fi
if [ "$modified" = true ]; then
echo "De-gleaned $file."
fi
done
else
echo "No *.kt files found in $dir."
fi
if [ -n "$yaml_files" ]; then
for yaml_file in $yaml_files; do
rm -vf "$yaml_file"
echo "De-gleaned $yaml_file."
done
else
echo "No metrics.yaml or pings.yaml files found in $dir."
fi
}
function deglean_fenix() {
local dir="$1"
local gradle_files=$(find "${dir}" -type f -name "*.gradle")
if [ -n "$gradle_files" ]; then
for file in $gradle_files; do
local modified=false
if grep -q 'implementation.*service-glean' "$file"; then
$SED -i -r 's/^(.*implementation.*service-glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if grep -q 'testImplementation.*glean' "$file"; then
$SED -i -r 's/^(.*testImplementation.*glean.*)$/\/\/ \1/' "$file"
modified=true
fi
if [ "$modified" = true ]; then
echo "De-gleaned $file."
fi
done
else
echo "No *.gradle files found in $dir."
fi
}
deglean "${application_services}"
deglean "${mozilla_release}/mobile/android/android-components"
deglean "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/gecko"
deglean "${mozilla_release}/mobile/android/geckoview"
deglean "${mozilla_release}/mobile/android/gradle"
deglean_fenix "${mozilla_release}/mobile/android/fenix"
$SED -i 's|mozilla-glean|# mozilla-glean|g' "${application_services}/gradle/libs.versions.toml"
$SED -i 's|glean|# glean|g' "${application_services}/gradle/libs.versions.toml"
$SED -i 's|classpath libs.glean.gradle.plugin|// classpath libs.glean.gradle.plugin|g' "${mozilla_release}/build.gradle"
# Remove the Glean service
## https://searchfox.org/firefox-main/source/mobile/android/android-components/components/service/glean/README.md
$SED -i 's|- components:service-glean|# - components:service-glean|g' "${mozilla_release}/mobile/android/fenix/.buildconfig.yml"
rm -rvf "${mozilla_release}/mobile/android/android-components/components/service/glean"
rm -rvf "${mozilla_release}/mobile/android/android-components/samples/glean"
# Remove unused/unnecessary Glean components (Application Services)
rm -vf "${application_services}/components/sync_manager/android/src/main/java/mozilla/appservices/syncmanager/BaseGleanSyncPing.kt"
# Remove unused/unnecessary Glean components (Fenix)
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/Configuration.kt"
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt"
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/GleanUsageReporting.kt"
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/GleanUsageReportingApi.kt"
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/GleanUsageReportingLifecycleObserver.kt"
rm -vf "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/metrics/GleanUsageReportingMetricsService.kt"
# Remove Glean classes (Android Components)
$SED -i -e 's|GleanMessaging|// GleanMessaging|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt"
$SED -i -e 's|Microsurvey.confirmation|// Microsurvey.confirmation|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt"
$SED -i -e 's|Microsurvey.dismiss|// Microsurvey.dismiss|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt"
$SED -i -e 's|Microsurvey.privacy|// Microsurvey.privacy|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt"
$SED -i -e 's|Microsurvey.shown|// Microsurvey.shown|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingController.kt"
$SED -i -e 's|GleanMessaging|// GleanMessaging|' "${mozilla_release}/mobile/android/android-components/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/messaging/NimbusMessagingStorage.kt"
rm -vf "${mozilla_release}/mobile/android/android-components/components/lib/crash/src/main/java/mozilla/components/lib/crash/service/GleanCrashReporterService.kt"
# Remove Glean classes (Application Services)
$SED -i 's|FxaClientMetrics|// FxaClientMetrics|g' "${application_services}/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/FxaClient.kt"
$SED -i 's|LoginsStoreMetrics|// LoginsStoreMetrics|g' "${application_services}/components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt"
$SED -i 's|NimbusEvents.isReady|// NimbusEvents.isReady|g' "${application_services}/components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/NimbusInterface.kt"
$SED -i 's|PlacesManagerMetrics|// PlacesManagerMetrics|g' "${application_services}/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt"
# Remove Glean classes (Gecko)
$SED -i -e 's|Metrics|// Metrics|' "${mozilla_release}/mobile/android/fenix/app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt"