Skip to content

Instantly share code, notes, and snippets.

@cyrus-and
Last active January 27, 2016 23:43
Show Gist options
  • Save cyrus-and/6d509e1e22a7acdc016f to your computer and use it in GitHub Desktop.
Save cyrus-and/6d509e1e22a7acdc016f to your computer and use it in GitHub Desktop.
Stupid ADB wrapper for APK retrival
#!/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