some infrastructure for 'roku lt' subcommand

This commit is contained in:
2023-06-08 19:13:38 +01:00
parent 950656d25d
commit eb085da965
7 changed files with 399 additions and 123 deletions

View File

@@ -1,19 +1,16 @@
#!/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}
if [ -z "$_ROKU_SHELL_DIR" ]; then
_ROKU_SHELL_DIR=$(dirname $(realpath $(readlink -f "${BASH_SOURCE[0]}" )))
fi
_ROKU_SHELL=$_ROKU_SHELL_DIR/_roku.sh
export DEVPASSWORD=aaaa
_roku_device()
{
if [ "$1" != "" ]; then
export ROKU_DEV_TARGET="$1"
export ROKU_DEV_PLATFORM="$(_roku.sh device_platform)"
export ROKU_DEV_PLATFORM="$($_ROKU_SHELL device_platform)"
fi
echo "device: $ROKU_DEV_TARGET"
echo "platform: $ROKU_DEV_PLATFORM"
@@ -26,7 +23,7 @@ _roku_wget_pass()
export ROKU_CORP_PASSWORD
}
_ROKU_DEFAULT_DISPATCH_FUNC=_roku.sh
_ROKU_DEFAULT_DISPATCH_FUNC=$_ROKU_SHELL
_roku_dispatch()
{
local DISPATCH_FUNC=$_ROKU_DEFAULT_DISPATCH_FUNC
@@ -47,114 +44,3 @@ 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
}