@@ -4,8 +4,8 @@ USER=phablet
4USER_ID=32011
4USER_ID=32011
5PACKAGE=unity8
5PACKAGE=unity8
6BINARY=unity8
6BINARY=unity8
7−TARGET_IP=${TARGET_IP-127.0.0.1}
7+TARGET_IP=127.0.0.1
8−TARGET_SSH_PORT=${TARGET_SSH_PORT-2222}
8+TARGET_SSH_PORT=2222
9TARGET_DEBUG_PORT=3768
9TARGET_DEBUG_PORT=3768
10RUN_OPTIONS=-qmljsdebugger=port:$TARGET_DEBUG_PORT
10RUN_OPTIONS=-qmljsdebugger=port:$TARGET_DEBUG_PORT
11SETUP=false
11SETUP=false
@@ -14,18 +14,23 @@ PINLOCK=false
14KEYLOCK=false
14KEYLOCK=false
15NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
15NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
16FLIPPED=false
16FLIPPED=false
17−CHROOT_PREFIX="/data/ubuntu"
18SSH_WAS_STARTED=0
17SSH_WAS_STARTED=0
19SSH_STARTED=0
18SSH_STARTED=0
22− echo "usage: run_on_device [OPTIONS]\n"
23+ echo "usage: run_on_device -a SUDO_PASSWORD [OPTIONS]"
23− echo "Script to setup a build environment for the shell and sync build and run it on the device\n"
25+ echo "Script to setup a build environment for the shell and sync build and run it on the device"
24 echo "OPTIONS:"
27 echo "OPTIONS:"
28+ echo " -a, --password The sudo password to use"
25− echo " -s, --setup Setup the build environment"
29+ echo " -s, --setup Setup the build environment"
30+ echo " -g, --gdb Run with gdb"
26− echo " -p, --pinlock Enable a PIN lock screen when running"
31+ echo " -p, --pinlock Enable a PIN lock screen when running"
27− echo " -k, --keylock Enable a Keyboard lock screen when running"
32+ echo " -k, --keylock Enable a Keyboard lock screen when running"
29 echo "IMPORTANT:"
34 echo "IMPORTANT:"
30 echo " * Make sure to have networking setup on the device beforehand."
35 echo " * Make sure to have networking setup on the device beforehand."
31 echo " * Execute that script from a directory containing unity8 code."
36 echo " * Execute that script from a directory containing unity8 code."
@@ -34,7 +39,7 @@ usage() {
35start_ssh() {
40start_ssh() {
36 if [ $SSH_STARTED -eq 0 ]; then
41 if [ $SSH_STARTED -eq 0 ]; then
37− exec_with_adb initctl start ssh
42+ adb_sudo initctl start ssh
38 SSH_STARTED=1
43 SSH_STARTED=1
@@ -44,25 +49,13 @@ exec_with_ssh() {
44 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT sudo -u $USER -i bash -ic \"$@\"
49 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT sudo -u $USER -i bash -ic \"$@\"
47−exec_with_adb() {
52+adb_sudo() {
48− if $FLIPPED; then
53+ adb shell "SUDO_ASKPASS=${PASSFILE} sudo --askpass $@"
51− adb shell chroot /data/ubuntu /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"
60install_ssh_key() {
56install_ssh_key() {
61− ssh-keygen -R $TARGET_IP
62− HOME_DIR="${CHROOT_PREFIX}/home/phablet"
57+ HOME_DIR="/home/phablet"
63 adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
58 adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
64− adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh
65− adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh/authorized_keys
66 adb shell chmod 700 $HOME_DIR/.ssh
59 adb shell chmod 700 $HOME_DIR/.ssh
67 adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys
60 adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys
@@ -73,8 +66,14 @@ setup_adb_forwarding() {
75install_dependencies() {
68install_dependencies() {
76− exec_with_adb apt-get update
69+ phablet-config writable-image --remotepassword ${PASSWORD} -p build-essential \
77− exec_with_adb apt-get -y --force-yes install build-essential rsync bzr ccache gdb ninja-build devscripts equivs unity-plugin-scopes
70+ -p rsync \
80sync_code() {
79sync_code() {
@@ -108,12 +107,13 @@ run() {
108 exec_with_ssh "start unity8"
107 exec_with_ssh "start unity8"
111−set -- `getopt -n$0 -u -a --longoptions="setup,gdb,pinlock,keylock,help" "sgpkh" "$@"`
110+set -- `getopt -n$0 -u -a --longoptions="password:,setup,gdb,pinlock,keylock,help" "a:sgpkh" "$@"`
113# FIXME: giving incorrect arguments does not call usage and exit
112# FIXME: giving incorrect arguments does not call usage and exit
114while [ $# -gt 0 ]
113while [ $# -gt 0 ]
116 case "$1" in
115 case "$1" in
116+ -a|--password) PASSWORD=$2;;
117 -s|--setup) SETUP=true;;
117 -s|--setup) SETUP=true;;
118 -g|--gdb) GDB=true;;
118 -g|--gdb) GDB=true;;
119 -p|--pinlock) PINLOCK=true;;
119 -p|--pinlock) PINLOCK=true;;
@@ -124,21 +124,21 @@ do
127+if [ -z "${PASSWORD}" ]; then
128+ echo "ERROR: You need to provide a sudo password..."
128−adb_root
133+PASSFILE=$( adb shell "FILE=\`mktemp\`
129−[ "${TARGET_IP}" = "127.0.0.1" ] && setup_adb_forwarding
134+ echo \"#!/bin/sh\" > \$FILE
135+ echo \"echo \\\"${PASSWORD}\\\"\" >> \$FILE
137+ echo \$FILE" | tr -d '\r' )
131−if [ "`adb shell 'grep -q Ubuntu /etc/lsb-release 2> /dev/null && echo -n FLIPPED'`" = "FLIPPED" ]; then
139+setup_adb_forwarding
134− if [ "${TARGET_IP}" != "127.0.0.1" ]; then
135− echo "ERROR: Flipped image detected, adb over TCP/IP isn't supported, yet :/"
136− echo "Unset TARGET_IP and try again."
141−status_output=$(exec_with_adb initctl status ssh)
141+status_output=$(adb_sudo initctl status ssh)
142if [[ $status_output == "ssh start/running, process "* ]]; then
142if [[ $status_output == "ssh start/running, process "* ]]; then
143 SSH_WAS_STARTED=1
143 SSH_WAS_STARTED=1
@@ -158,6 +158,8 @@ else
161+adb shell "rm ${PASSFILE}"
161if [ $SSH_WAS_STARTED -eq 0 ]; then
163if [ $SSH_WAS_STARTED -eq 0 ]; then
162− exec_with_adb initctl stop ssh
164+ adb_sudo initctl stop ssh