diff --git a/README.md b/README.md index a874eef..370b79d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,64 @@ -# MinMicroG -Sources and scripts for MinMicroG installers +# Minimal MicroG Installer +### By MOVZX and FatherJony and FriendlyNeighborhoodShane +*A simple, flexible MicroG Installer* + +### Links +* [GitHub](https://github.com/FriendlyNeighborhoodShane/MicroG_Packs) +* [Support](https://t.me/joinchat/FyFlS0X2D7f6YNvdxhEsfw) +### Description +This is a simple MicroG installer. It can install MicroG into your system partition or as a Magisk module. It supports virtually all mobile architectures (arm/64, x86/64, mips/64) and fully supports KitKat and above. It can also (mostly) support much older versions, but sync adapters and some location providers won't work. It can even uninstall itself from your device, just rename it and flash it again. + +It contains an unofficial fork of MicroG (GMSCore, GSFProxy, Droidguard) (Compiled by MOVZX) with bumped version numbers so that apps don't complain about updating playstore. + +The things included in the Standard Edition zip are: +- MicroG (GMSCore, GSFProxy, Droidguard, Maps APIv1) +- Google Play store (modded for IAPs by Setialpha) +- UNLP backends (Dejá vu, LocalGSM, LocalWiFi, Mozilla, Nominatim) +- AuroraDroid +- AuroraServices +- Swype libs for AOSP keyboard +- Some Google DRM jars +- Google Sync adapters for KK to O +- Permission files for all of this +- An addon.d file to backup/restore everything on a rom flash + +The things included in the NoGoolag Edition zip are: +- MicroG (GMSCore, GSFProxy, Droidguard, Maps APIv1) +- FakeStore +- AuroraStore +- AuroraDroid +- AuroraServices +- UNLP backends (Dejá vu, LocalGSM, LocalWiFi, Mozilla, Nominatim) +- Permission files for all of this +- An addon.d file to backup/restore everything on a rom flash + +The things included in the UNLP Edition zip are: +- UNLP +- UNLP backends (Dejá vu, LocalGSM, LocalWiFi, Mozilla, Nominatim) +- Permission files for all of this +- An addon.d file to backup/restore everything on a rom flash + +The zip debloats 3 Google apps from your phone (GmsCore, GoogleServicesFramework, Phonesky and their MicroG counterparts) and 4 NLP providers. In Magisk mode, they won't be removed from system, and if you uninstall the pack, they'll come back. If you install in system, the debloated stuff will be stored in internal-storage/MinMicroG/Backup. +WARNING: This zip does not and never will debloat anything else because that is the minimum coming in MicroG's way. I have had my own share of PTSD with debloating. I believe (through guesswork) that it should work even on flashes over gapped ROMs, but don't take my word for it. Debloat before you flash. + +For support: +If you flashed through recovery, provide its logs. +If you used Magisk Manager, provide its logs. + +How to control the zip by changing its name: +NOTE: Control by name is not possible in magisk manager, since it copies the zip to a cache directory and renames it install.zip. This is unavoidable behaviour. + +- Add 'system' to its filename to force it to install/uninstall from system. Otherwise, it looks for magisk, and if not found, installs to system. Obviously, if you flash it through Magisk manager, you want to install it to Magisk. If not, you have to flash it through recovery. + +- Add 'uninstall' to its filename to uninstall it from your device, whether in magisk mode or system mode. If you use Magisk Manager, your preffered method of uninstallation is from there. + +Just rename it and flash it again for the intended effect. + +NOTE: +- MicroG showing wrong signature for Phonesky? Lemme guess... System mode? Dirty flashed? Go to shell and type (ofcourse with su): +pm grant com.android.vending android.permission.FAKE_PACKAGE_SIGNATURE +- Dirty flashing not recommended. you'll mess up all your permissions and may even cause conflicts in app data, leading to crashes. +The maker does not support or endorse dirty flashing. It will harm you and your loved ones. Don't come complaining to me. + +Thanks to @osm0sis for the base magisk/recovery code and inspiration and guidance on the majority of the stuff in here. You're awesome. +Thanks to @Setialpha, the creator of NanoDroid, and ale5000 for the lib installation code and permissions code. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..41c5691 --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +# Script to build a package with $1 variant + +# Check if $1 conf exists + +# Copy neccesary files + +# Zip + +# Sign + diff --git a/conf/conf-readme.md b/conf/conf-readme.md new file mode 100644 index 0000000..8dd9f16 --- /dev/null +++ b/conf/conf-readme.md @@ -0,0 +1 @@ +All the config files \ No newline at end of file diff --git a/conf/defconf-nogoolag.txt b/conf/defconf-nogoolag.txt new file mode 100644 index 0000000..ff9b6c3 --- /dev/null +++ b/conf/defconf-nogoolag.txt @@ -0,0 +1,390 @@ +# Config + +variant="NoGoolag"; +ver="2.4-MAYBE"; +verc="240" +date="27th September, 2019"; +minsdk=21; + +modprop="id=MinMicroG +name=Minimal MicroG Pack $variant Edition +version=$ver +versionCode=$verc +author=MOVZX and FatherJony and FriendlyNeighborhoodShane +description=A Minimal MicroG installer with just the essentials +support=https://t.me/joinchat/FyFlS0X2D7f6YNvdxhEsfw +donate= +minMagisk=1900 +"; + +stuff=" + /system/app/AppleNLPBackend/AppleNLPBackend.apk + /system/app/AuroraDroid/AuroraDroid.apk + /system/app/AuroraStore/AuroraStore.apk + /system/app/DejaVuNLPBackend/DejaVuNLPBackend.apk + /system/app/LocalGSMNLPBackend/LocalGSMNLPBackend.apk + /system/app/LocalWiFiNLPBackend/LocalWiFiNLPBackend.apk + /system/app/MicroGGSFProxy/MicroGGSFProxy.apk + /system/app/MozillaUnifiedNLPBackend/MozillaUnifiedNLPBackend.apk + /system/app/NominatimNLPBackend/NominatimNLPBackend.apk + + /system/etc/default-permissions/microg-permissions.xml + /system/etc/permissions/com.android.vending.xml + /system/etc/permissions/com.aurora.services.xml + /system/etc/permissions/com.google.android.gms.xml + /system/etc/permissions/com.google.android.maps.xml + /system/etc/sysconfig/nogoolag.xml + + /system/framework/com.google.android.maps.jar + + /system/priv-app/AuroraServices/AuroraServices.apk + /system/priv-app/FakeStore/FakeStore.apk + /system/priv-app/MicroGDroidGuard/MicroGDroidGuard.apk + /system/priv-app/MicroGGMSCore/MicroGGMSCore.apk +"; + +stuff_arch=" +"; + +stuff_sdk=" +"; + +stuff_arch_sdk=" +"; + +stuff_other=" + /system/etc/permissions/com.google.android.media.effects.xml + /system/etc/permissions/com.google.widevine.software.drm.xml + /system/framework/com.google.android.media.effects.jar + /system/framework/com.google.widevine.software.drm.jar + /system/priv-app/PatchPhonesky/PatchPhonesky.apk + /system/lib/libjni_latinimegoogle.so + /system/lib64/libjni_latinimegoogle.so + /system/app/GoogleCalendarSyncAdapter/GoogleCalendarSyncAdapter.apk + /system/app/GoogleContactsSyncAdapter/GoogleContactsSyncAdapter.apk + /system/etc/permissions/gsync.xml + /system/priv-app/GoogleBackupTransport/GoogleBackupTransport.apk + /system/priv-app/MicroGUNLP/MicroGUNLP.apk +"; + +stuff_old=" + /system/addon.d/01-nogoolag.sh + /system/app/FDroid/FDroid.apk + /system/etc/permissions/org.fdroid.fdroid.privileged.xml + /system/priv-app/AuroraStore/AuroraStore.apk + /system/priv-app/DejaVuLocationService/DejaVuLocationService.apk + /system/priv-app/DejaVuNLPBackend/DejaVuNLPBackend.apk + /system/priv-app/FDroidPrivileged/FDroidPrivileged.apk + /system/priv-app/LocalGSMNLPBackend/LocalGSMNLPBackend.apk + /system/priv-app/LocalWiFiNLPBackend/LocalWiFiNLPBackend.apk + /system/priv-app/MicroGGSFProxy/MicroGGSFProxy.apk + /system/priv-app/MozillaUnifiedNLPBackend/MozillaUnifiedNLPBackend.apk + /system/priv-app/NominatimNLPBackend/NominatimNLPBackend.apk +"; + + +stuff_uninstall="$stuff $stuff_arch $stuff_sdk $stuff_arch_sdk $stuff_other $stuff_old $initdfile $addondfile"; + +stuff_debloat=" + /system/app/GmsCore/GmsCore.apk + /system/app/GooglePlay/GooglePlay.apk + /system/app/GoogleServicesFramework/GoogleServicesFramework.apk + /system/app/Phonesky/Phonesky.apk + /system/app/PlayStore/PlayStore.apk + /system/app/PrebuiltGmsCore/PrebuiltGmsCore.apk + /system/app/Vending/Vending.apk + /system/priv-app/GmsCore/GmsCore.apk + /system/priv-app/GooglePlay/GooglePlay.apk + /system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk + /system/priv-app/Phonesky/Phonesky.apk + /system/priv-app/PlayStore/PlayStore.apk + /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk + /system/priv-app/Vending/Vending.apk + + /system/app/AMAPNetworkLocation/AMAPNetworkLocation.apk + /system/app/BaiduNetworkLocation/BaiduNetworkLocation.apk + /system/app/LegacyNetworkLocation/LegacyNetworkLocation.apk + /system/app/NetworkLocation/NetworkLocation.apk + /system/priv-app/AMAPNetworkLocation/AMAPNetworkLocation.apk + /system/priv-app/BaiduNetworkLocation/BaiduNetworkLocation.apk + /system/priv-app/LegacyNetworkLocation/LegacyNetworkLocation.apk + /system/priv-app/NetworkLocation/NetworkLocation.apk + + /system/app/BlankStore/BlankStore.apk + /system/app/DroidGuard/DroidGuard.apk + /system/app/GmsCore/GmsCore.apk + /system/app/GmsDroidGuard/GmsDroidguard.apk + /system/app/GsfProxy/GsfProxy.apk + /system/app/UnifiedNlp/UnifiedNlp.apk + /system/priv-app/BlankStore/BlankStore.apk + /system/priv-app/DroidGuard/DroidGuard.apk + /system/priv-app/GmsCore/GmsCore.apk + /system/priv-app/GmsDroidGuard/GmsDroidguard.apk + /system/priv-app/GsfProxy/GsfProxy.apk + /system/priv-app/UnifiedNlp/UnifiedNlp.apk +"; + +stuff_perm=" + /system/addon.d + /system/app + /system/etc + /system/framework + /system/lib + /system/lib64 + /system/priv-app +"; + +service='#!/system/bin/sh +# MinMicroG bootup script +{ +sleep 30; +dg="$(find /system -name MicroGDroidGuard.apk -type f | head -n1)"; +for i in 1 2 3; do + # Fixes wrong signature for Phonesky in self-check + /system/bin/pm grant com.android.vending android.permission.FAKE_PACKAGE_SIGNATURE; + sleep 5; + # Fixes GroidGuard crash on safetynet check + /system/bin/pm install -r "$dg"; + sleep 5; + # Fixes the motherfuckery caused by MagicGApps + rm -rf "/magisk/.core/service.d/MagicGApps.sh" "/sbin/.core/img/.core/service.d/MagicGApps.sh"; + pm enable "com.google.android.gms"; + sleep 5; +done; +} +'; + +addona="#!/sbin/sh +# +# MinMicroG addon.d + +save_files() { +cat < + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/system/etc/default-permissions/microg-permissions.xml b/res/system/etc/default-permissions/microg-permissions.xml new file mode 100755 index 0000000..ba7aa88 --- /dev/null +++ b/res/system/etc/default-permissions/microg-permissions.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/system/etc/permissions/-19-21-22-23-24-25-26-27-28-/gsync.xml b/res/system/etc/permissions/-19-21-22-23-24-25-26-27-28-/gsync.xml new file mode 100755 index 0000000..3b5a979 --- /dev/null +++ b/res/system/etc/permissions/-19-21-22-23-24-25-26-27-28-/gsync.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/system/etc/permissions/com.android.vending.xml b/res/system/etc/permissions/com.android.vending.xml new file mode 100755 index 0000000..9f1ebb1 --- /dev/null +++ b/res/system/etc/permissions/com.android.vending.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/system/etc/permissions/com.aurora.services.xml b/res/system/etc/permissions/com.aurora.services.xml new file mode 100755 index 0000000..d2dc6ce --- /dev/null +++ b/res/system/etc/permissions/com.aurora.services.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/res/system/etc/permissions/com.google.android.backuptransport.xml b/res/system/etc/permissions/com.google.android.backuptransport.xml new file mode 100755 index 0000000..6804977 --- /dev/null +++ b/res/system/etc/permissions/com.google.android.backuptransport.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/res/system/etc/permissions/com.google.android.gms.xml b/res/system/etc/permissions/com.google.android.gms.xml new file mode 100755 index 0000000..7c18fec --- /dev/null +++ b/res/system/etc/permissions/com.google.android.gms.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/res/system/etc/permissions/com.google.android.maps.xml b/res/system/etc/permissions/com.google.android.maps.xml new file mode 100755 index 0000000..5be5c2c --- /dev/null +++ b/res/system/etc/permissions/com.google.android.maps.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/res/system/etc/permissions/com.google.android.media.effects.xml b/res/system/etc/permissions/com.google.android.media.effects.xml new file mode 100755 index 0000000..ea82b9d --- /dev/null +++ b/res/system/etc/permissions/com.google.android.media.effects.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/res/system/etc/permissions/com.google.widevine.software.drm.xml b/res/system/etc/permissions/com.google.widevine.software.drm.xml new file mode 100755 index 0000000..f75abf9 --- /dev/null +++ b/res/system/etc/permissions/com.google.widevine.software.drm.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/res/system/etc/permissions/org.fdroid.fdroid.privileged.xml b/res/system/etc/permissions/org.fdroid.fdroid.privileged.xml new file mode 100755 index 0000000..3a7d442 --- /dev/null +++ b/res/system/etc/permissions/org.fdroid.fdroid.privileged.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/res/system/etc/sysconfig/nogoolag-unlp.xml b/res/system/etc/sysconfig/nogoolag-unlp.xml new file mode 100755 index 0000000..7841a6e --- /dev/null +++ b/res/system/etc/sysconfig/nogoolag-unlp.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/system/etc/sysconfig/nogoolag.xml b/res/system/etc/sysconfig/nogoolag.xml new file mode 100755 index 0000000..becbb4d --- /dev/null +++ b/res/system/etc/sysconfig/nogoolag.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resdl/resdl-readme.md b/resdl/resdl-readme.md new file mode 100644 index 0000000..3557f94 --- /dev/null +++ b/resdl/resdl-readme.md @@ -0,0 +1,3 @@ +Script downloads all updateable assets in system here + +All static or manually updated assets go in res/system \ No newline at end of file diff --git a/src/META-INF/com/google/android/update-binary b/src/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..364b4cf --- /dev/null +++ b/src/META-INF/com/google/android/update-binary @@ -0,0 +1,515 @@ +#!/sbin/sh +# Minimal MicroG installer +# By FriendlyNeighborhoodShane +# Based on work by osm0sis @ xda-developers (Thanks!) + +exec 3>&1; +exec 1>&2; + +outfd="/proc/self/fd/$2"; +zipfile="$3"; + +ps | grep zygote | grep -v grep >/dev/null && bootmode=true || bootmode=false; +$bootmode || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && bootmode=true; + +$bootmode && ui_print() { echo "$1" >&3; } || ui_print() { echo -e "ui_print $1\nui_print" >> $outfd; } + +log() { echo "$1"; } + +$bootmode || mount -o bind /dev/urandom /dev/random; + +file_getprop() { + grep "^$2" "$1" | head -n1 | awk '{ print $1 }' | cut -d= -f2; +} + +abort() { + ui_print " "; + ui_print "!!! FATAL ERROR: $1"; + ui_print " "; + ui_print "Stopping installation and Uninstalling..."; + uninstall_pack; + [ -d "$filedir" ] && rm -rf "$filedir"; + $bootmode || { [ "$sysroot" ] && umount /$sysroot || umount /system; } + sync; + ui_print " "; + ui_print "Installation failed!"; + ui_print " "; + exit 1; +} + +ui_print " "; +ui_print "-- Minimal MicroG Installer --"; +ui_print "-- The Essentials only MicroG pack --"; +ui_print "-- From the MicroG Telegram group --"; +ui_print "-- No, not the Official one --"; +modname="MinMicroG"; + +log " "; +log "Zip File is $zipfile"; +log "Bootmode is $bootmode"; + +$bootmode || { mount /data; mount /cache; } +for bb in /magisk/.core/busybox /sbin/.core/busybox /sbin/.magisk/busybox; do + [ -e "$bb" ] && magiskbb="$bb"; +done; +[ "$magiskbb" ] && export PATH="$magiskbb:$PATH"; +[ -e "/system_root" ] && { + mount -o ro /system_root; + sysroot="system_root"; +} || { + mount -o ro /system; + [ -e "/system/system/build.prop" ] && sysroot="system"; +} +[ -f "/$sysroot/system/build.prop" ] || abort "Could not find a ROM in /$sysroot"; +for bin in awk cat chcon chmod chown cp cut df du echo find grep head losetup ls mkdir mount ps rm sed tail touch umount unzip; do + [ "$(which "$bin")" ] || abort "No $bin available"; +done; + +$bootmode && filedir="/dev/tmp/$modname" || filedir="/tmp/$modname"; +tmplibdir="$filedir/tmplibdir"; +moddir="/data/media/0/$modname"; +backupdir="$moddir/Backup"; +initdfile="/system/etc/init.d/10-$modname"; +addondfile="/system/addon.d/10-$modname.sh"; + +$bootmode && forcesys=no; +case "$(basename "$zipfile")" in + *system*|*System*|*SYSTEM*) + forcesys=yes; + ui_print " "; + ui_print "WARNING: Forcing a system action!"; + ;; +esac; +case "$(basename "$zipfile")" in + *uninstall*|*Uninstall*|*UNINSTALL*) + action=uninstallation; + ;; + *) + action=installation; + ;; +esac; + +abi="$(file_getprop /$sysroot/system/build.prop ro.product.cpu.abi)"; +case "$abi" in + arm64*) + arch=arm64; + libarches="arm64-v8a armeabi-v7a armeabi"; + ;; + arm*) + arch=arm; + libarches="armeabi-v7a armeabi"; + ;; + x86_64*) + arch=x86_64; + libarches="x86_64 x86 armeabi-v7a armeabi"; + ;; + x86*) + arch=x86; + libarches="x86 armeabi-v7a armeabi"; + ;; + mips64*) + arch=mips64; + libarches="mips64 mips"; + ;; + mips*) + arch=mips; + libarches="mips"; + ;; + *) + abort "Could not recognise architecture: $abi"; + ;; +esac; + +sdk="$(file_getprop /$sysroot/system/build.prop ro.build.version.sdk)"; +[ "$sdk" ] || abort "Could not find SDK"; +[ "$sdk" -gt 0 ] || abort "Could not recognise SDK: $sdk"; + +sizecheck() { + for realsizeobject in $1; do + sizeobject="$realsizeobject"; + break; + done; + [ -e "$sizeobject" ] || { echo 0; return 0; } + objectsize="$(du -s "$sizeobject" | awk '{ print $1 }')"; + libsize=0; + case "$sizeobject" in + *.apk) + apkunzip="$(unzip -l "$sizeobject" "lib/*/lib*.so")"; + if [ "$(echo "$apkunzip" | grep lib/.*/lib.*.so)" ]; then + for archlib in $libarches; do + if [ "$(echo "$apkunzip" | grep lib/$archlib/lib.*.so)" ]; then + libsizeb=0; + for entry in $(echo "$apkunzip" | grep lib/$archlib/lib.*.so | awk '{ print $1 }'); do + libsizeb="$(($libsizeb + $entry))"; + done; + libsize="$(($libsizeb / 1024 + 1))"; + break; + fi; + done; + fi; + ;; + esac; + echo "$(($objectsize + $libsize))"; +} + +remove() { + removalobject="$1"; + backupobject="$2"; + if [ "$sdk" -lt 21 ]; then + [ "$(basename "$(dirname "$removalobject")").apk" == "$(basename "$removalobject")" ] && { + removalobject="$(dirname "$(dirname "$removalobject")")/$(basename "$removalobject")"; + backupobject="$(dirname "$(dirname "$backupobject")")/$(basename "$backupobject")"; + } + fi; + [ "$(basename "$(dirname "$removalobject")").apk" == "$(basename "$removalobject")" ] && { removalobject="$(dirname "$removalobject")"; backupobject="$(dirname "$backupobject")"; } + [ -e "$removalobject" ] || return 0; + mkdir -p "$(dirname "$backupobject")"; + cp -rf "$removalobject" "$backupobject"; + [ -e "$backupobject" ] && log "BACKUPER: Object backed up ($removalobject)" || log "ERROR: Could not backup ($removalobject)"; + rm -rf "$removalobject" || { log "ERROR: Could not remove ($removalobject)"; return 1; } + [ -e "$removalobject" ] && { log "ERROR: Could not remove ($removalobject)"; return 1; } || log "REMOVER: Object removed ($removalobject)"; +} + +debloat() { + debloatobject="$1"; + debloatingobject="$2"; + if [ "$sdk" -lt 21 ]; then + [ "$(basename "$(dirname "$debloatobject")").apk" == "$(basename "$debloatobject")" ] && { + debloatobject="$(dirname "$(dirname "$debloatobject")")/$(basename "$debloatobject")"; + debloatingobject="$(dirname "$(dirname "$debloatingobject")")/$(basename "$debloatingobject")"; + } + fi; + [ "$(basename "$(dirname "$debloatobject")").apk" == "$(basename "$debloatobject")" ] && debloatobject="$(dirname "$debloatobject")"; + [ -e "$debloatobject" ] || return 0; + mkdir -p "$(dirname "$debloatingobject")"; + if [ "$(basename "$(dirname "$debloatingobject")").apk" == "$(basename "$debloatingobject")" ]; then + touch "$(dirname $debloatingobject)/.replace" && log "DEBLOATER: Object directory debloated ($debloatobject)" || { log "ERROR: Could not create replace file for object $debloatobject"; return 1; } + elif [ -d "$debloatobject" ]; then + touch "$debloatingobject/.replace" && log "DEBLOATER: directory debloated ($debloatobject)" || { log "ERROR: Could not create replace file for directory $debloatobject"; return 1; } + else + echo "# This is a dummy for debloating" > "$debloatingobject" && log "DEBLOATER: Object dummy debloated ($debloatobject)" || { log"ERROR: Could not create dummy file for $debloatobject"; return 1; } + fi; +} + +uninstall() { + uninstallobject="$1"; + if [ "$sdk" -lt 21 ]; then + [ "$(basename "$(dirname "$uninstallobject")").apk" == "$(basename "$uninstallobject")" ] && uninstallobject="$(dirname "$(dirname "$uninstallobject")")/$(basename "$uninstallobject")"; + fi; + [ "$(basename "$(dirname "$uninstallobject")").apk" == "$(basename "$uninstallobject")" ] && uninstallobject="$(dirname "$uninstallobject")"; + [ -e "$uninstallobject" ] || return 0; + rm -rf "$uninstallobject" || { log "ERROR: Object not uninstalled ($uninstallobject)"; return 1; } + [ -e "$uninstallobject" ] && { log "ERROR: Object not uninstalled ($uninstallobject)"; return 1; } || log "UNINSTALLER: Object uninstalled ($uninstallobject)"; +} + +install_dest() { + for realobject in $1; do + object="$realobject"; + break; + done; + destobject="$2"; + [ -e "$object" ] || { log "ERROR: Object not found ($object)"; return 1; } + if [ "$sdk" -lt 21 ]; then + [ "$(basename "$(dirname "$destobject")").apk" == "$(basename "$destobject")" ] && destobject="$(dirname "$(dirname "$destobject")")/$(basename "$destobject")"; + fi; + mkdir -p "$(dirname "$destobject")"; + cp -rf "$object" "$destobject" || abort "Could not install $destobject"; + [ -e "$destobject" ] && log "INSTALLER: Object installed ($object to $destobject)" || abort "Could not install $destobject"; + case "$destobject" in + *.apk) + install_lib "$destobject"; + ;; + esac; +} + +install_lib() { + libobject="$1"; + mkdir -p "$tmplibdir"; + unzipout="$(unzip -l "$libobject" "lib/*/lib*.so")"; + [ "$(echo "$unzipout" | grep lib/.*/lib.*.so)" ] || return 0; + for archlib in $libarches; do + if [ "$(echo "$unzipout" | grep lib/$archlib/lib.*.so)" ]; then + case "$archlib" in + *arm64*) + log "INSTALLER: Installing arm64 libs ($libobject)"; + libdir=lib64; + libarch=arm64; + ;; + *arm*) + log "INSTALLER: Installing arm libs ($libobject)"; + libdir=lib; + libarch=arm; + ;; + *x86_64*) + log "INSTALLER: Installing x86_64 libs ($libobject)"; + libdir=lib64; + libarch=x86_64; + ;; + *x86*) + log "INSTALLER: Installing x86 libs ($libobject)"; + libdir=lib; + libarch=x86; + ;; + *mips64*) + log "INSTALLER: Installing mips64 libs ($libobject)"; + libdir=lib64; + libarch=mips64; + ;; + *mips*) + log "INSTALLER: Installing mips libs ($libobject)"; + libdir=lib; + libarch=mips; + ;; + esac; + if [ "$sdk" -lt 21 ]; then + libdest="$(dirname $(dirname $libobject))/$libdir"; + else + libdest="$(dirname $libobject)/lib/$libarch"; + fi; + unzip -oq "$libobject" "lib/$archlib/lib*.so" -d "$tmplibdir"; + mkdir -p "$libdest"; + for lib in $tmplibdir/lib/$archlib/lib*.so; do + cp -rf "$lib" "$libdest/$(basename "$lib")" || abort "Could not Install $lib for $libobject"; + [ -f "$libdest/$(basename "$lib")" ] && log "INSTALLER: Installed library ($lib to $libdest)" || abort "Could not Install $lib for $libobject"; + done; + break; + fi; + done; + rm -rf "$tmplibdir"; +} + +uninstall_pack() { + if [ "$magisk" == "yes" ]; then + rm -rf "$root" || { log " "; log "Could not delete Magisk root ($root)"; } + else + for thing in $stuff_uninstall; do + [ "$thing" ] && uninstall "$root/$thing"; + done; + uninstall "$initdfile"; + uninstall "$addondfile"; + [ "$sysprop" ] && { + for line in $sysprop; do + if [ "$(grep "^$line #$modname" "/$sysroot/system/build.prop")" ]; then + sed -i "s|^$line #$modname||g" "/$sysroot/system/build.prop"; + fi; + if [ "$(grep "^#$modname $(echo $line | cut -d= -f1)" "/$sysroot/system/build.prop")" ]; then + sed -i "s|^#$modname $(echo $line | cut -d= -f1)|$(echo $line | cut -d= -f1)|g" "/$sysroot/system/build.prop"; + fi; + done; + } + fi; +} + +perm() { + uid="$1"; + gid="$2"; + dmod="$3"; + fmod="$4"; + permobject="$5"; + [ -e "$permobject" ] || return 0; + chown -R $uid:$gid "$permobject" || chown -R $uid.$gid "$permobject"; + find "$permobject" -type d -exec chmod $dmod {} +; + find "$permobject" -type f -exec chmod $fmod {} +; +} + +rm -rf "$filedir"; +mkdir -p "$filedir"; +unzip -o "$zipfile" "defconf" -d "$filedir/"; +[ -f "$filedir/defconf" ] || abort "Could not find a default config"; +chmod 0777 "$filedir/defconf"; +. "$filedir/defconf" || abort "Could not execute default config"; + +ui_print " "; +ui_print "Package: $variant"; +ui_print "Version: $ver"; +ui_print "Release date: $date"; +ui_print " "; +ui_print "Using architecture: $arch"; +ui_print "Using SDK level: $sdk"; +ui_print "Sysroot is on /$sysroot"; +if [ "$sdk" -lt "$minsdk" ]; then + ui_print " "; + ui_print "WARNING: Using an old Android"; + ui_print "Full compatibility not guaranteed"; +fi; + +ui_print " "; +ui_print "Mounting..."; +if [ -e "/data/adb/magisk" -a "$forcesys" != "yes" ]; then + $bootmode && modulesdir="/data/adb/modules_update" || modulesdir="/data/adb/modules"; + root="$modulesdir/$modname"; + magisk=yes; + log "Using $modulesdir"; + [ -d "$modulesdir" ] || { + mkdir -p "$modulesdir"; + perm 0 0 0755 0644 "$modulesdir"; + } +else + [ "$sysroot" ] && { + mount -o rw,remount /$sysroot; + mount -o rw,remount /$sysroot /$sysroot; + } || { + mount -o rw,remount /system; + mount -o rw,remount /system /system; + } + root="/$sysroot"; + magisk=no; + log "Mounted /$sysroot/system RW"; +fi; + +if [ "$action" == "installation" ]; then + + pre_install_actions; + + ui_print " "; + ui_print "Cleaning up..."; + log "Removing duplicates"; + uninstall_pack; + log "Debloating"; + if [ "$magisk" == "yes" ]; then + for thing in $stuff_debloat; do + [ "$thing" ] && debloat "/$sysroot/$thing" "$root/$thing"; + done; + else + for thing in $stuff_debloat; do + [ "$thing" ] && remove "/$sysroot/$thing" "$backupdir/$thing"; + done; + fi; + [ -d "$backupdir" ] && { perm 1023 1023 775 664 "$backupdir"; chcon -hR 'u:object_r:media_rw_data_file:s0' "$backupdir"; } + + ui_print " "; + ui_print "Extracting files..."; + rm -rf "$filedir"; + mkdir -p "$filedir"; + unzip -o "$zipfile" -d "$filedir" || abort "Could not unzip $zipfile"; + + ui_print " "; + ui_print "Doing size checks..."; + packsize=0; + for thing in defconf $stuff; do + [ "$thing" ] && packsize="$(($packsize + $(sizecheck "$filedir/$thing")))"; + done; + for thing in $stuff_arch; do + [ "$thing" ] && packsize="$(($packsize + $(sizecheck "$filedir/$(dirname $thing)/*-$arch-*/$(basename $thing)")))"; + done; + for thing in $stuff_sdk; do + [ "$thing" ] && packsize="$(($packsize + $(sizecheck "$filedir/$(dirname $thing)/*-$sdk-*/$(basename $thing)")))"; + done; + for thing in $stuff_arch_sdk; do + [ "$thing" ] && packsize="$(($packsize + $(sizecheck "$filedir/$(dirname $thing)/*-$arch-*-$sdk-*/$(basename $thing)")))"; + done; + packsizem="$(($packsize / 1024 + 1))"; + log "Pack size is $packsizem"; + if [ "$magisk" == "yes" ]; then + datfreem="$(($(df -Pk "/data" | tail -n 1 | awk '{ print $4 }') / 1024))"; + log "Free data space is $datfreem"; + [ "$datfreem" -lt "$packsizem" ] && abort "Not enough free space in your data!"; + else + sysfreem="$(($(df -Pk "/$sysroot/system" | tail -n 1 | awk '{ print $4 }') / 1024))"; + log "Free system space is $sysfreem"; + [ "$sysfreem" -lt "$packsizem" ] && abort "Not enough free space in your system!"; + fi; + + ui_print " "; + ui_print "Installing $modname to $root..."; + mkdir -p "$root"; + + log " "; + log "Installing generic stuff"; + for thing in $stuff; do + [ "$thing" ] && install_dest "$filedir/$thing" "$root/$thing"; + done; + + log " "; + log "Installing Arch dependant stuff for $arch"; + for thing in $stuff_arch; do + [ "$thing" ] && install_dest "$filedir/$(dirname $thing)/*-$arch-*/$(basename $thing)" "$root/$thing"; + done; + + log " "; + log "Installing SDK dependant stuff for SDK $sdk"; + for thing in $stuff_sdk; do + [ "$thing" ] && install_dest "$filedir/$(dirname $thing)/*-$sdk-*/$(basename $thing)" "$root/$thing"; + done; + + log " "; + log "Installing Arch and SDK dependant stuff for $arch and SDK $sdk"; + for thing in $stuff_arch_sdk; do + [ "$thing" ] && install_dest "$filedir/$(dirname $thing)/*-$arch-*-$sdk-*/$(basename $thing)" "$root/$thing"; + done; + + log " "; + log "Executing other actions"; + if [ "$magisk" == "yes" ]; then + [ "$postfs" ] && { echo "$postfs" > "$root/post-fs-data.sh" || abort "Could not create post-fs-data.sh in $root"; } + [ "$service" ] && { echo "$service" > "$root/service.sh" || abort "Could not create service.sh in $root"; } + [ "$sysprop" ] && { echo "$sysprop" > "$root/system.prop" || abort "Could not create system.prop in $root"; } + [ "$modprop" ] && { echo "$modprop" > "$root/module.prop" || abort "Could not create module.prop in $root"; } + touch "$root/auto_mount" || abort "Could not create auto_mount in $root"; + if $bootmode && [ "$modulesdir" == "/data/adb/modules_update" ]; then + modmnt="/data/adb/modules"; + mkdir -p "$modmnt/$modname"; + touch "$modmnt/$modname/update" || abort "Could not create update in $modmnt/$modname"; + [ "$modprop" ] && { echo "$modprop" > "$modmnt/$modname/module.prop" || abort "Could not create module.prop in $modmnt/$modname"; } + fi; + else + [ "$postfs" ] && { mkdir -p $(dirname "$root/$initdfile"); echo "$postfs" > "$root/$initdfile" || abort "Could not create $initdfile in $root"; } + [ "$service" ] && { mkdir -p $(dirname "$root/$initdfile"); echo "$service" > "$root/$initdfile" || abort "Could not create $initdfile in $root"; } + [ "$addond" ] && { mkdir -p $(dirname "$root/$addondfile"); echo "$addond" > "$root/$addondfile" || abort "Could not create $addondfile in $root"; } + [ "$sysprop" ] && { + for line in $sysprop; do + if [ "$(grep "^$line" "/$sysroot/system/build.prop")" ]; then + continue; + fi; + if [ "$(grep "^$(echo $line | cut -d= -f1)" "/$sysroot/system/build.prop")" ]; then + sed -i "s|^$(echo $line | cut -d= -f1)|#$modname $(echo $line | cut -d= -f1)|g" "/$sysroot/system/build.prop"; + fi; + echo -e "$line #$modname" >> "/$sysroot/system/build.prop"; + done; + } + fi; + + ui_print " "; + ui_print "Setting permissions..."; + if [ "$magisk" == "yes" ]; then + find "$root" -maxdepth 1 -exec chmod 0755 {} +; + fi; + for thing in $stuff_perm; do + case "$thing" in + */bin*|*/xbin*) + perm 0 2000 0755 0777 "$root/$thing"; + ;; + *) + perm 0 0 0755 0644 "$root/$thing"; + ;; + esac; + chcon -hR 'u:object_r:system_file:s0' "$root/$thing"; + done; + + post_install_actions; + +fi; + +if [ "$action" == "uninstallation" ]; then + + pre_uninstall_actions; + + ui_print " "; + ui_print "Uninstalling $modname from $root..."; + uninstall_pack; + + post_uninstall_actions; + +fi; + +ui_print " "; +ui_print "Unmounting..."; +$bootmode || { [ "$sysroot" ] && umount /$sysroot || umount /system; } +rm -rf "$filedir"; +sync; + +ui_print " "; +ui_print "Done!"; +ui_print "Join us on Telegram: @NoGooLag"; +ui_print " "; +exit 0; diff --git a/src/META-INF/com/google/android/updater-script b/src/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..f9233b8 --- /dev/null +++ b/src/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +#MAGISK# Dummy file; update-binary is a shell script. diff --git a/src/src-readme.md b/src/src-readme.md new file mode 100644 index 0000000..bd3abe8 --- /dev/null +++ b/src/src-readme.md @@ -0,0 +1 @@ +The main scripts \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..c60568e --- /dev/null +++ b/update.sh @@ -0,0 +1,5 @@ +# Update all binary assets + +# Delete all assets + +# Download new ones \ No newline at end of file