add google apps debloat
authorGuillaume Castagnino <casta@xwing.info>
Fri, 30 Jun 2017 07:48:30 +0000 (09:48 +0200)
committerGuillaume Castagnino <casta@xwing.info>
Fri, 30 Jun 2017 07:48:30 +0000 (09:48 +0200)
Makefile
cm-data-google/99-perso-google-clean.sh.addon [new file with mode: 0755]
cm-data/99-perso.sh.addon
cm-google.sh [new file with mode: 0755]

index 9feb9fc006dae745e5c0db8f34c7f6a5037e89ce..0f8740388ec4f615d9b6cbd2e982197835e064cf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,23 @@
 ZIPFILE = cm-custom.zip
 ZIPFILE_SIGNED = cm-custom-signed.zip
+ZIPFILE_GOOGLE = cm-custom-google.zip
+ZIPFILE_GOOGLE_SIGNED = cm-custom-google-signed.zip
 PRIVKEY = tools/testkey.pk8
 PUBKEY = tools/testkey.x509.pem
 
 DIRS = META-INF cm-data
+DIRS_GOOGLE = META-INF cm-data-google
 FILES = cm.sh $(shell find $(DIRS) -type f)
+FILES_GOOGLE = cm-google.sh $(shell find $(DIRS_GOOGLE) -type f)
 
 .PHONY: clean
 
 all: zip
 
-zip: $(ZIPFILE)
+zip: $(ZIPFILE) $(ZIPFILE_GOOGLE)
 
 clean:
-       rm -f "$(ZIPFILE)" "$(ZIPFILE_SIGNED)"
+       rm -f "$(ZIPFILE)" "$(ZIPFILE_SIGNED)" "$(ZIPFILE_GOOGLE)" "$(ZIPFILE_GOOGLE_SIGNED)"
 
 $(ZIPFILE): clean $(FILES:%=%.zipped)
        java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $(ZIPFILE) $(ZIPFILE_SIGNED)
@@ -22,3 +26,9 @@ $(ZIPFILE): clean $(FILES:%=%.zipped)
 $(FILES:%=%.zipped): %.zipped : %
        @zip "$(ZIPFILE)" "$<"
 
+$(ZIPFILE_GOOGLE): clean $(FILES_GOOGLE:%=%.zipped)
+       java -jar tools/SignApk.jar -w -a 4 $(PUBKEY) $(PRIVKEY) $(ZIPFILE_GOOGLE) $(ZIPFILE_GOOGLE_SIGNED)
+       @echo "$(ZIPFILE_GOOGLE) / $(ZIPFILE_GOOGLE_SIGNED) are ready"
+
+$(FILES_GOOGLE:%=%.zipped): %.zipped : %
+       @zip "$(ZIPFILE_GOOGLE)" "$<"
diff --git a/cm-data-google/99-perso-google-clean.sh.addon b/cm-data-google/99-perso-google-clean.sh.addon
new file mode 100755 (executable)
index 0000000..8730497
--- /dev/null
@@ -0,0 +1,44 @@
+#!/sbin/sh
+#
+# $S/addon.d/99-perso-google-clean.sh
+#
+
+# we partially use the script at install, we need to have some fallback
+# if backuptool functions are not present
+if [ -e /tmp/backuptool.functions ]
+then
+  . /tmp/backuptool.functions
+else
+  S=/system
+fi
+
+# path is needed when running from recovery (at install)
+export PATH="${PATH}:$S/bin:$S/xbin"
+
+case "$1" in
+  backup)
+    # Stub
+  ;;
+  restore)
+    # Stub
+  ;;
+  pre-backup)
+    # Stub
+  ;;
+  post-backup)
+    # Stub
+  ;;
+  pre-restore)
+    # Stub
+  ;;
+  post-restore)
+    # remove google bloat from pico opengapps
+    rm -rf $S/priv-app/GooglePartnerSetup
+    rm -rf $S/priv-app/GooglePackageInstaller
+    rm -rf $S/app/GoogleContactsSyncAdapter
+    rm -rf $S/app/GoogleCalendarSyncAdapter
+    rm -rf $S/app/GoogleTTS
+    rm -f $S/etc/permissions/com.google.android.dialer.support.xml
+    rm -f $S/framework/com.google.android.dialer.support.jar
+  ;;
+esac
index 331bf56f63ea14fb628b88352cab351559d844a1..b0acfb61a1f6e215c8297311bd141dac31b9da0e 100755 (executable)
@@ -20,7 +20,6 @@ cat <<EOF
 etc/init.d/10-perso.sh
 etc/init.d/afwallstart
 lib/libjni_latinimegoogle.so
-priv-app/FDroidPrivileged/FDroidPrivileged.apk
 usr/share/zoneinfo/tzdata
 EOF
 }
@@ -50,8 +49,6 @@ case "$1" in
   post-restore)
     # mute camera
     chmod 000 $S/media/audio/ui/camera_*.ogg
-    # fix dir permissions
-    chmod 755 $S/priv-app/FDroidPrivileged || echo "FDroidPrivileged not installed as a system app"
     # remove bloat
     rm -rf $S/priv-app/AudioFX
     rm -rf $S/priv-app/CMAccount
diff --git a/cm-google.sh b/cm-google.sh
new file mode 100755 (executable)
index 0000000..78331ae
--- /dev/null
@@ -0,0 +1,20 @@
+#!/sbin/sh
+
+set -e
+
+cd "$(dirname $0)"
+
+export PATH="${PATH}:/system/bin:/system/xbin"
+
+# install restore script
+echo "Installing restore script"
+cp cm-data/99-perso-google-clean.sh.addon /system/addon.d/99-perso-google-clean.sh
+chown root:root /system/addon.d/99-perso-google-clean.sh
+chmod 755 /system/addon.d/99-perso-google-clean.sh
+
+# call restore script post to remove bloat
+/system/addon.d/99-perso-google-clean.sh post-restore
+
+echo "Done"
+echo "Do not forget to WIPE Cache/Dalvik"
+