10
RUN_OPTIONS=-qmljsdebugger=port:$TARGET_DEBUG_PORT
15
NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
23
echo "usage: run_on_device -a SUDO_PASSWORD [OPTIONS]"
25
echo "Script to setup a build environment for the shell and sync build and run it on the device"
28
echo " -a, --password The sudo password to use"
29
echo " -s, --setup Setup the build environment"
30
echo " -g, --gdb Run with gdb"
31
echo " -p, --pinlock Enable a PIN lock screen when running"
32
echo " -k, --keylock Enable a Keyboard lock screen when running"
35
echo " * Make sure to have networking setup on the device beforehand."
36
echo " * Execute that script from a directory containing unity8 code."
41
if [ $SSH_STARTED -eq 0 ]; then
42
adb_sudo initctl start ssh
49
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT sudo -u $USER -i bash -ic \"$@\"
53
adb shell "SUDO_ASKPASS=${PASSFILE} sudo --askpass $@"
57
HOME_DIR="/home/phablet"
58
adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
59
adb shell chmod 700 $HOME_DIR/.ssh
60
adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys
63
setup_adb_forwarding() {
64
adb forward tcp:$TARGET_SSH_PORT tcp:22
65
adb forward tcp:$TARGET_DEBUG_PORT tcp:$TARGET_DEBUG_PORT
68
install_dependencies() {
69
phablet-config writable-image --remotepassword ${PASSWORD} -p build-essential \
80
[ -e .bzr ] && bzr export --uncommitted --format=dir /tmp/$CODE_DIR
81
[ -e .git ] && git checkout-index -a -f --prefix=/tmp/$CODE_DIR/
83
rsync -crlOzv --delete --exclude builddir -e "ssh -p $TARGET_SSH_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" /tmp/$CODE_DIR/ $USER@$TARGET_IP:$CODE_DIR/
88
exec_with_ssh PATH=/usr/lib/ccache:$PATH "cd $CODE_DIR/ && PATH=/usr/lib/ccache:$PATH ./build.sh"
103
exec_with_ssh "stop unity8"
104
exec_with_ssh "start maliit-server"
105
exec_with_ssh "cd $CODE_DIR/ && ./run.sh $ARGS -- $RUN_OPTIONS"
106
exec_with_ssh "stop maliit-server"
107
exec_with_ssh "start unity8"
110
set -- `getopt -n$0 -u -a --longoptions="password:,setup,gdb,pinlock,keylock,help" "a:sgpkh" "$@"`
112
# FIXME: giving incorrect arguments does not call usage and exit
116
-a|--password) PASSWORD=$2;;
117
-s|--setup) SETUP=true;;
119
-p|--pinlock) PINLOCK=true;;
120
-k|--keylock) KEYLOCK=true;;
127
if [ -z "${PASSWORD}" ]; then
128
echo "ERROR: You need to provide a sudo password..."
133
PASSFILE=$(adb shell 'mktemp' | tr -d '\r')
134
adb shell "echo '#!/bin/sh' > ${PASSFILE}"
135
adb shell "echo \"echo \\\"${PASSWORD}\\\"\" >> ${PASSFILE}"
136
adb shell "chmod +x ${PASSFILE}"
140
status_output=$(adb_sudo initctl status ssh)
141
if [[ $status_output == "ssh start/running, process "* ]]; then
144
SSH_STARTED=$SSH_WAS_STARTED
147
echo "Setting up environment for building shell.."
152
echo "Transferring code.."
160
adb shell "rm ${PASSFILE}"
162
if [ $SSH_WAS_STARTED -eq 0 ]; then
163
adb_sudo initctl stop ssh