Skip to content

Instantly share code, notes, and snippets.

@manniru
Forked from v3l0c1r4pt0r/pm-multi.sh
Created October 10, 2021 00:50
Show Gist options
  • Save manniru/b1304964cbdb710266a28e31a35e52a0 to your computer and use it in GitHub Desktop.
Save manniru/b1304964cbdb710266a28e31a35e52a0 to your computer and use it in GitHub Desktop.
Script for installing multi-APK applications in Android (requires root)
#!/system/bin/sh
# install multi-file apk with pm
if [ "$(id -u)" -ne 0 ]; then
echo "Access denied!"
exit 1
fi
if [ $# -lt 2 ]; then
echo "Usage: $0 name apk [[[apk] apk] ...]"
exit 1
fi
name="$1"
shift
TOTAL="$(cat $@ | wc -c)"
comm="$(pm install-create -S $TOTAL -i $name -r)"
left="${comm%*]}"
SESS=${left#*\[}
for file in $@; do
SZ="$(wc -c $file | cut -d' ' -f1)"
pm install-write -S $SZ $SESS $file <$file
done
pm install-commit $SESS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment