Skip to content

Instantly share code, notes, and snippets.

@isao
Created June 5, 2018 23:14
Show Gist options
  • Save isao/0396537b4844f948fa4c1c146b35de62 to your computer and use it in GitHub Desktop.
Save isao/0396537b4844f948fa4c1c146b35de62 to your computer and use it in GitHub Desktop.
push-apk.sh
#!/bin/bash -eu
#
# Config.
#
# Arg 1: file to install on the Android OTT STB, which must be connected, and
# mounted read/write as root. See connect-remount-as-root.sh
apkpath=${1:-''}
# Arg 2 (optional): OTT destination path
destdir=${2:-'/system/priv-app/EricssonTVApp'}
# Path to the *.so files withinin the unzipped apk.
apklibs="lib/armeabi"
#
# Preflight.
#
hash adb unzip || {
echo "Stopping. Required executable not found in \$PATH."
exit 1
}
[[ -n "$apkpath" ]] || {
echo "Usage: $(basename "$0") <tvxpackage.apk>"
exit 3
}
[[ -r "$apkpath" ]] || {
echo "Error: apk not readable: $apkpath"
exit 5
}
function cleanup() {
[[ -n "$apktemp" && -d "$apktemp" ]] && rm -rfv "$apktemp"
}
#
# Main.
#
# Make a temp directory to unzip the apk into.
apkname=$(basename "$apkpath" .apk)
apktemp=$(mktemp -d -t "$apkname-tmp.XXXX")
trap cleanup EXIT
set -x
# Clean up old stuff
adb shell rm -rf "$destdir"
adb shell mkdir "$destdir"
# Extract and install lib*.so
unzip "$apkpath" -d "$apktemp"
adb push "$apktemp/$apklibs"/*.so "$destdir"
# Install apk.
adb push "$apkpath" "$destdir"
adb reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment