diff --git a/.gitignore b/.gitignore index 5c192a2..8863179 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -nuke.sh +*.zip +nuke*.sh \ No newline at end of file diff --git a/gen.sh b/gen.sh index d2fa5f6..98e3f81 100755 --- a/gen.sh +++ b/gen.sh @@ -1,10 +1,13 @@ #!/bin/bash # File paths +WKDIR="$PWD" DEBLOATED_PACKAGES_FILE="debloated_rom_packages" PACKAGES_TO_REMOVE_FILE="packages_to_remove" STOCK_PACKAGES_FILE="stock_rom_packages" REMOVE_SCRIPT="nuke.sh" +PACKAGE_DIR="package" +REMOVE_SCRIPT_TWRP="$PACKAGE_DIR/nuke_twrp.sh" PACKAGES_TO_REPLACE_FILE="packages_to_replace" # Source the blacklist definitions @@ -33,7 +36,7 @@ is_blacklisted_dir() { } # Clean up previous files -rm -rf $REMOVE_SCRIPT $PACKAGES_TO_REMOVE_FILE $PACKAGES_TO_REPLACE_FILE +rm -rf $REMOVE_SCRIPT $PACKAGES_TO_REMOVE_FILE $PACKAGES_TO_REPLACE_FILE $REMOVE_SCRIPT_TWRP $PACKAGE_DIR/twrpdblt*.zip # Get the list of installed packages from the stock phone if [ "$SPG" = "1" ]; then @@ -54,6 +57,9 @@ fi cat << 'EOF' > $REMOVE_SCRIPT #!/system/bin/sh +echo 'GENERATED BY universal-debloat-script-generator' +echo 'AUTHOR : @ghzzor (github)' +echo ' ' echo 'WARNING: This script will remove packages from your device.' echo ' I am not responsible for bricked devices.' echo ' Ensure you have backed up your data.' @@ -82,15 +88,18 @@ EOF # Add commands to remove packages to the script echo 'packages_to_nuke=(' >> $REMOVE_SCRIPT +echo 'packages_to_nuke=(' >> $REMOVE_SCRIPT_TWRP while IFS= read -r package_path; do if [[ -n "$package_path" ]] && ! is_blacklisted_apk "$package_path" && ! is_blacklisted_dir "$package_path"; then if [[ $package_path == /system/* ]]; then echo "$package_path" >> $PACKAGES_TO_REPLACE_FILE echo "\"\$systempath$package_path\"" >> $REMOVE_SCRIPT + echo "\"/system_root$package_path\"" >> $REMOVE_SCRIPT_TWRP else echo "/system$package_path" >> $PACKAGES_TO_REPLACE_FILE echo "\"$package_path\"" >> $REMOVE_SCRIPT + echo "\"$package_path\"" >> $REMOVE_SCRIPT_TWRP fi fi @@ -98,6 +107,7 @@ while IFS= read -r package_path; do done < $PACKAGES_TO_REMOVE_FILE echo ')' >> $REMOVE_SCRIPT +echo ')' >> $REMOVE_SCRIPT_TWRP cat << 'EOF' >> $REMOVE_SCRIPT for bloat in "${packages_to_nuke[@]}"; do @@ -117,3 +127,11 @@ echo "$PACKAGES_TO_REPLACE_FILE has been generated." chmod +x $REMOVE_SCRIPT echo "$REMOVE_SCRIPT has been generated." +echo "$REMOVE_SCRIPT_TWRP has been generated." + +export TIME="$(date "+%Y%m%d")" +cd $PACKAGE_DIR +zip -r9 twrpdblt-${TIME}.zip * -x .git README.md *placeholder +cd $WKDIR + +echo "twrpdblt-${TIME}.zip has been generated." \ No newline at end of file diff --git a/package/META-INF/com/google/android/update-binary b/package/META-INF/com/google/android/update-binary new file mode 100644 index 0000000..4896f66 --- /dev/null +++ b/package/META-INF/com/google/android/update-binary @@ -0,0 +1,47 @@ +#!/sbin/sh + +OUTFD=$2 +ZIP=$3 + +ui_print() { + echo -n -e "ui_print $1\n" > /proc/self/fd/$OUTFD + echo -n -e "ui_print\n" > /proc/self/fd/$OUTFD +} + +cd /tmp +rm -rf tmpdir +mkdir tmpdir +cd tmpdir +unzip -o "$ZIP" + +zipdir=/tmp/tmpdir + +echo 'GENERATED BY universal-debloat-script-generator' +echo 'AUTHOR : @ghzzor (github)' +echo ' ' +echo 'WARNING: This script will remove packages from your device.' +echo ' I am not responsible for bricked devices.' +echo ' Ensure you have backed up your data.' +echo ' ' + +# mount stuff +mount /system_root +mount /product +mount /prism + +mount -o rw,remount -t auto /system_root +mount -o rw,remount -t auto /product +mount -o rw,remount -t auto /prism + +# source the package list +. $zipdir/nuke_twrp.sh + +# Remove bloat if it exists +for bloat in "${packages_to_nuke[@]}"; do + if [ -e "$bloat" ]; then + rm -rf "$bloat" + ui_print "Removed $bloat" + else + ui_print "Skipping $bloat (NOT FOUND)" + fi +done diff --git a/package/META-INF/com/google/android/updater-script b/package/META-INF/com/google/android/updater-script new file mode 100644 index 0000000..028ff5c --- /dev/null +++ b/package/META-INF/com/google/android/updater-script @@ -0,0 +1 @@ +# this is a dummy file, the magic is in update-binary, which is a shell script