#!/bin/sh # I have my automake export ACLOCAL_PATH=/usr/share/aclocal export ROKU_NFS_ROOT=$HOME/roku/nfs export ROKU_NFS_IP=192.168.0.64 export EXPORTROOT=${ROKU_NFS_ROOT} export DEVPASSWORD=aaaa _roku_device() { if [ "$1" != "" ]; then export ROKU_DEV_TARGET="$1" export ROKU_DEV_PLATFORM="$(_roku.sh device_platform)" fi echo "device: $ROKU_DEV_TARGET" echo "platform: $ROKU_DEV_PLATFORM" } _roku_wget_pass() { echo "Set ROKU_CORP_PASSWORD:" read -sr ROKU_CORP_PASSWORD export ROKU_CORP_PASSWORD } _ROKU_DEFAULT_DISPATCH_FUNC=_roku.sh _roku_dispatch() { local DISPATCH_FUNC=$_ROKU_DEFAULT_DISPATCH_FUNC if [ "$(type -t _roku_$1_$2)" == "function" ]; then DISPATCH_FUNC=_roku_$1_$2 shift shift elif [ "$(type -t _roku_$1)" == "function" ]; then DISPATCH_FUNC=_roku_$1 shift fi $DISPATCH_FUNC "$@" } roku() { _roku_dispatch "$@" } ############################################################################### # # Build Completion # __roku_completion_contains() { # Platforms for WORD in "$@"; do if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then return 1 fi done return 0 } __roku_completion_add_if() { __roku_completion_contains "$@" if [[ $? == 0 ]]; then CANDIDATES+=" $@" fi } # complete -F __build_completion roku # __build_completion() # { # local CANDIDATES="help clobber tests addon-checksums" # # Docker # __build_completion_add_if docker make # # Build hosts # __build_completion_add_if icecc local # # Port dir # __build_completion_add_if port-only # # Platforms # __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb # COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) # } complete -F __roku_completion roku __roku_completion() { local CANDIDATES="device get log flash gdb gdb_attach telnet reboot audcap san_update sideload token_install" # # Docker # __build_completion_add_if docker make # # Build hosts # __build_completion_add_if icecc local # # Port dir # __build_completion_add_if port-only # # Platforms # __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}")) } ############################################################################### # # Logging # LOGDIR="${HOME}/roku/logs" dcapture() { nc minicom "$@" -C $LOGDIR/.log.$(date +%Y-%m-%d--%H-%M-%S) } dfile() { local Nth="-1" if [ $# -gt 0 ]; then Nth="$1" fi echo $(ls -tr -1 ${LOGDIR}/minicom.log.* | tail ${Nth} | head -1) } dless() { less $(lfile "$@") } dcat() { cat $(lfile "$@") } dgrep() { lcat | grep -a --color "$@" } dtail() { if [ $# -gt 0 ]; then tail -f $(lfile) | grep "$@" else tail -f $(lfile) fi }