diff options
Diffstat (limited to 'ota-upload.sh')
-rwxr-xr-x | ota-upload.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/ota-upload.sh b/ota-upload.sh new file mode 100755 index 0000000..cc47fdb --- /dev/null +++ b/ota-upload.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +set -e + +DIR="$(dirname "$(realpath "$0")")" +PROGNAME="$0" + +OTA_DIR="~/LineageOTA/builds/full" +OTA_USER="lineage" +OTA_HOST="lineageos-ota.ch1p.io" +OTA_PORT=60011 + +BOLD=$(tput bold) +RST=$(tput sgr0) +RED=$(tput setaf 1) +CYAN=$(tput setaf 6) + +echoinfo() { + >&2 echo "${CYAN}$@${RST}" +} + +echoerr() { + >&2 echo "${RED}${BOLD}error:${RST}${RED} $@${RST}" +} + +die() { + echoerr "$@" + exit 1 +} + +usage() { + cat <<-_EOF + usage: $PROGNAME OPTIONS DEVICE + + Options: + --root DIR LineageOS root + + _EOF + exit 1 +} + +ROOT= +DEVICE= + +while [[ $# -gt 0 ]]; do + case $1 in + --root) + ROOT="$2" + shift + ;; + *) + if [ -n "$DEVICE" ]; then + die "unexpected extra argument: $1" + fi + DEVICE="$1" + esac + shift +done + +[ -z "$DEVICE" ] && die "no device specified" +[ -z "$ROOT" ] && die "lineageos root device not specified" +[ -d "$ROOT" ] || die "$ROOT: no such directory" + +PRODUCT_DIR="$ROOT/out/target/product/$DEVICE" +[ -d "$PRODUCT_DIR" ] || die "product directory for device \"$DEVICE\" not found" + +ZIP="$(realpath "$(find "$PRODUCT_DIR" -type f -samefile "$PRODUCT_DIR/lineage_${DEVICE}-ota-eng.user.zip" | grep -v "lineage_${DEVICE}-ota-eng.user.zip" | sort -r | head -1)")" +ZIP_NAME="$(basename "$ZIP")" + +PROP="$PRODUCT_DIR/system/build.prop" +PROP_NAME="${ZIP_NAME}.prop" + +echo +echo " Device: ${BOLD}${DEVICE}${RST}" +echo " ZIP: ${BOLD}${ZIP_NAME}${RST}" +echo + +echo -n "Press enter to confirm or Ctrl+C to cancel." +read + +echoinfo "uploading zip (${BOLD}${ZIP_NAME}${RST}${CYAN})${RST}" +scp -P$OTA_PORT "$ZIP" $OTA_USER@$OTA_HOST:$OTA_DIR/ + +echoinfo "uploading prop file (${BOLD}${PROP_NAME}${RST}${CYAN})${RST}" +scp -P$OTA_PORT "$PROP" $OTA_USER@$OTA_HOST:$OTA_DIR/$PROP_NAME |