1

There are two ways to get rid of apps to debloat a ROM:

  • adb shell pm uninstall -k --user 0 <package-name> (run on PC)
  • rm -rf <package folder> (on device, in Terminal of TWRP)

The first method has one big advantage - deleted apps can be restored by

  • adb shell cmd package install-existing <package_name> But the diasadvantage - it still consumes memory.

So best would be to do the first method until you see is is all fine - not debloated to much. To not manually do the "rm" and selection of packages - is there a good way to list the uninstalled packages and generate a list for the "rm" command? Thanks for your attention.

0

1 Answer 1

1

I guess you mean only uninstalled system packages.

Here is a little bash script doing what you want:

#!/usr/bin/env bash

set -euo pipefail

declare -a PACKAGES=()

readarray -t PACKAGES < <(comm -3 <(adb shell 'pm list packages -s -u -f' | sort -i) \
                                  <(adb shell 'pm list packages -s -f'    | sort -i))

for package in "${PACKAGES[@]}"; do
    echo "rm -rf $package" | sed -r 's/package://g' | sed -r 's/=.*//g' >> root_debloat.txt
done
echo "root_debloat.txt generated."

Then, you just need to run the commands through adb shell as root:

adb shell su < root_debloat.txt

What the script does :

  1. Put the list of uninstalled system packages in the array PACKAGES.

Why this complicated command ? Because pm list packages -s -u returns installed and uninstalled system packages. So you need to take the difference of this list and the list of installed system packages.

Each element of the array will have this form (because of the use of the -f option) : package:/path/to/apk=package.name

  1. Generate the list of rm commands and write them one by one, for each package, in the root_debloat.txt file.

You only want the path. The sed commands are here to remove the rest.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .