Last active
January 27, 2016 23:43
-
-
Save cyrus-and/6d509e1e22a7acdc016f to your computer and use it in GitHub Desktop.
Stupid ADB wrapper for APK retrival
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
usage() { | |
echo "Usage: | |
apk list | |
apk path <package> | |
apk fetch <package> | |
" | |
} | |
die() { | |
echo "$@" 1>&2 | |
exit 1 | |
} | |
case "$1" in | |
list) | |
adb shell pm list packages | while IFS=: read -r -d $'\r\n' _ package; do | |
echo $package | |
done | |
;; | |
path) | |
if [[ -z "$2" ]]; then | |
usage | |
die 'Which package?' | |
fi | |
adb shell pm path "$2" | while IFS=: read -r -d $'\r\n' _ path; do | |
echo $path | |
done | |
;; | |
fetch) | |
if [[ -z "$2" ]]; then | |
usage | |
die 'Which package?' | |
fi | |
adb pull "$("$0" path "$2")" | |
;; | |
'') | |
usage | |
die 'Which command?' | |
;; | |
*) | |
usage | |
die "Invalid command '$1'" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment