Automatically detect and falsh acramfs from the working dir.

This commit is contained in:
2023-06-23 18:28:38 +01:00
parent 4820605201
commit 927208a677
2 changed files with 77 additions and 66 deletions

133
_roku.sh
View File

@@ -7,6 +7,22 @@ source $_ROKU_SHELL_DIR/_roku_shared.sh
source $_ROKU_SHELL_DIR/_roku_lt.sh source $_ROKU_SHELL_DIR/_roku_lt.sh
source $_ROKU_SHELL_DIR/_roku_build.sh source $_ROKU_SHELL_DIR/_roku_build.sh
###############################################################################
#
# Web server related
#
_roku_webserver_ip()
{
ip route get "$1" | sed -n "s/.* src \([\.0-9]*\) .*/\1/p"
}
_roku_webserver_relative_path()
{
[ -z "$ROKU_WEB_DIR" ] && echo "ROKU_WEB_DIR must be defined" >&2 && exit 1
realpath --relative-to="$ROKU_WEB_DIR" "$1"
}
############################################################################### ###############################################################################
# #
# Helper functions # Helper functions
@@ -14,7 +30,7 @@ source $_ROKU_SHELL_DIR/_roku_build.sh
__set_master_ip() __set_master_ip()
{ {
MASTER_IP=$(ip route get "${ROKU_DEV_TARGET}" | sed -n "s/.* src \([\.0-9]*\) .*/\1/p") MASTER_IP=$(_roku_webserver_ip $ROKU_DEV_TARGET)
} }
__netcat() __netcat()
@@ -39,10 +55,16 @@ __device_cmd()
_roku_device_platform() _roku_device_platform()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" >&2 && exit 1
__device_cmd "echo \$ROKU_PLATFORM" | tail -1 | tr -d '\r\n' __device_cmd "echo \$ROKU_PLATFORM" | tail -1 | tr -d '\r\n'
} }
_check_roku_env()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined. Run 'roku device' to setup." >&2 && exit 1
[ -z "$ROKU_DEV_PLATFORM" ] && echo "ROKU_DEV_PLATFORM must be defined. Run 'roku device' to setup." >&2 && exit 1
}
############################################################################### ###############################################################################
# #
@@ -50,15 +72,28 @@ _roku_device_platform()
# #
_roku_telnet() _roku_telnet()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
telnet "$ROKU_DEV_TARGET" $1 telnet "$ROKU_DEV_TARGET" $1
} }
_roku_flash() _roku_flash()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__set_master_ip
__device_cmd ". /nvram/san; export MASTER_IP=$MASTER_IP; rokuflash $1" [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" >&2 && exit 1
[ -z "$ROKU_DEV_PLATFORM" ] && echo "ROKU_DEV_PLATFORM must be defined. Run 'roku device' to setup." >&2 && exit 1
local ACRAMFS_WEB_PATH=$1
local WEBSERVER_IP=$(_roku_webserver_ip $ROKU_DEV_TARGET)
if [ -z "$ACRAMFS_WEB_PATH" ]; then
local REPO_ROOT=$(_roku_repo_root .)
local ACRAMFS=$(_roku_repo_acramfs_location $REPO_ROOT $ROKU_DEV_PLATFORM)
[ ! -f "$ACRAMFS" ] && echo "No acramfs found: $ACRAMFS" >&2 && exit 1
ACRAMFS_WEB_PATH=$(_roku_webserver_relative_path $ACRAMFS)
[ -z "$ACRAMFS_WEB_PATH" ] && exit 1
fi
echo "Flashing $ACRAMFS_WEB_PATH"
__device_cmd ". /nvram/san; export MASTER_IP=$WEBSERVER_IP; rokuflash $ACRAMFS_WEB_PATH"
} }
# Side loaded applications: # Side loaded applications:
@@ -76,27 +111,36 @@ _roku_flash()
# 8889 voice_adapter_console # 8889 voice_adapter_console
_roku_log() _roku_log()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__device_cmd "setconsole /dev/pts/0" __device_cmd "setconsole /dev/pts/0"
} }
_roku_loglog() _roku_loglog()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__netcat $1 __netcat $1
} }
_roku_reboot() _roku_reboot()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__device_cmd "reboot" __device_cmd "reboot"
} }
_roku_san_update() _roku_san_update()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__set_master_ip [ -z "$ROKU_WEB_PREFIX" ] && echo "ROKU_WEB_PREFIX must be defined." >&2 && exit 1
__device_cmd "wget -O /nvram/san http://${MASTER_IP}/roku/san/san; source /nvram/san; setup_san"
local SAN_LOCATION=$_ROKU_SHELL_DIR/san
[ ! -f "$SAN_LOCATION" ] && echo "SAN script is not found: $SAN_LOCATION" >&2 && exit 1
local WEBSERVER_IP=$(_roku_webserver_ip $ROKU_DEV_TARGET)
local SAN_URL="http://$WEBSERVER_IP/$ROKU_WEB_PREFIX/$(_roku_webserver_relative_path $SAN_LOCATION)"
__device_cmd "wget -O /nvram/san $SAN_URL; source /nvram/san; setup_san"
} }
############################################################################### ###############################################################################
@@ -105,8 +149,9 @@ _roku_san_update()
# #
_roku_audcap() _roku_audcap()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
[ -z "$1" ] && echo "Syntax: roku audcap <filename>" && return 0 [ -z "$1" ] && echo "Syntax: roku audcap <filename>" >&2 && exit 1
__set_master_ip __set_master_ip
__app_cmd "audcap record start 00" __app_cmd "audcap record start 00"
echo -n "Press Enter to stop capture." echo -n "Press Enter to stop capture."
@@ -122,14 +167,15 @@ _roku_audcap()
# #
_roku_gdb_attach() _roku_gdb_attach()
{ {
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 _check_roku_env
__device_cmd "/nvram/tools/gdbserver :5555 --attach \$(pgrep Application)" __device_cmd "/nvram/tools/gdbserver :5555 --attach \$(pgrep Application)"
} }
_roku_gdb() _roku_gdb()
{ {
echo $ROKU_DEV_PLATFORM >> test.txt _check_roku_env
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# __device_cmd "/tmp/tools/gdbserver :5555 --attach \$(pgrep Application)" & # __device_cmd "/tmp/tools/gdbserver :5555 --attach \$(pgrep Application)" &
# sleep 2 # sleep 2
gdb-multiarch \ gdb-multiarch \
@@ -150,65 +196,20 @@ _roku_gdb()
# #
_roku_token_install() _roku_token_install()
{ {
_check_roku_env
[ ! -f "$1" ] && echo "usage: install_auth_toke <auth token file> \n ROKU_DEV_TARGET=${ROKU_DEV_TARGET}" && return 0 [ ! -f "$1" ] && echo "usage: install_auth_toke <auth token file> \n ROKU_DEV_TARGET=${ROKU_DEV_TARGET}" && return 0
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
curl --data-binary @$1 http://${ROKU_DEV_TARGET}:8060/token/install curl --data-binary @$1 http://${ROKU_DEV_TARGET}:8060/token/install
} }
_roku_sideload() _roku_sideload()
{ {
_check_roku_env
[ ! -f "$1" ] && echo "usage: sideload <file> \n ${ROKU_DEV_TARGET}=${ROKU_DEV_TARGET}" && return 0 [ ! -f "$1" ] && echo "usage: sideload <file> \n ${ROKU_DEV_TARGET}=${ROKU_DEV_TARGET}" && return 0
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
curl --anyauth --user "rokudev:${DEVPASSWORD}" -F "mysubmit=Install_Netflix" -F "archive=@$1" http://${ROKU_DEV_TARGET}/plugin_install curl --anyauth --user "rokudev:${DEVPASSWORD}" -F "mysubmit=Install_Netflix" -F "archive=@$1" http://${ROKU_DEV_TARGET}/plugin_install
} }
###############################################################################
#
# 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
}
############################################################################### ###############################################################################
# #
# Misc # Misc

View File

@@ -5,6 +5,16 @@ _roku_build_completion()
: :
} }
_roku_repo_root()
{
eval "cd $1; git rev-parse --show-toplevel"
}
_roku_repo_acramfs_location()
{
echo "$1/port/realtek/stark/$2/dist/image/acramfs/acramfs.bin"
}
_roku_build() _roku_build()
{ {
__build "$@" __build "$@"