10
TARGET_DEBUG_PORT=3768
11
RUN_OPTIONS="--startup-timer --desktop_file_hint=/usr/share/applications/gallery-app.desktop"
12
# -qmljsdebugger=port:$TARGET_DEBUG_PORT"
14
SUDO="echo $PASSWORD | sudo -S"
17
echo "usage: run_on_device [OPTIONS]\n"
18
echo "Script to setup a build environment for the gallery and sync build and run it on the device\n"
20
echo " -s, --setup Setup the build environment"
23
echo " * Make sure to have the networking and PPAs setup on the device beforehand (phablet-deploy-networking && phablet-ppa-fetch)."
24
echo " * Execute that script from a directory containing a branch the shell code."
29
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT "bash -ic \"$@\""
33
adb shell chroot /data/ubuntu /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"
42
adb shell "apt-get install openssh-server"
43
ssh-keygen -R $TARGET_IP
44
HOME_DIR=/data/ubuntu/home/phablet
45
adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
46
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh
47
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh/authorized_keys
48
adb shell chmod 700 $HOME_DIR/.ssh
49
adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys
52
install_dependencies() {
53
exec_with_adb apt-get -y install openssh-server
54
exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb libglib2.0-bin
55
exec_with_ssh $SUDO add-apt-repository -y ppa:canonical-qt5-edgers/qt5-proper
56
exec_with_ssh $SUDO add-apt-repository -s -y ppa:phablet-team/ppa
57
exec_with_ssh $SUDO apt-get update
58
exec_with_ssh $SUDO apt-get -y build-dep $PACKAGE
61
reset_screen_powerdown() {
62
exec_with_ssh $SUDO dbus-launch gsettings set com.canonical.powerd activity-timeout 600
63
exec_with_ssh $SUDO sudo initctl restart powerd
66
setup_adb_forwarding() {
67
adb forward tcp:$TARGET_SSH_PORT tcp:22
68
adb forward tcp:$TARGET_DEBUG_PORT tcp:$TARGET_DEBUG_PORT
72
bzr export --uncommitted --format=dir /tmp/$CODE_DIR
73
rsync -crlOzv -e "ssh -p $TARGET_SSH_PORT -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" /tmp/$CODE_DIR/ $USER@$TARGET_IP:$CODE_DIR/
78
exec_with_ssh PATH=/usr/lib/ccache:$PATH "cd $CODE_DIR/ && PATH=/usr/lib/ccache:$PATH cmake -DCMAKE_BUILD_TYPE=debug . && PATH=/usr/lib/ccache:$PATH make -j 2"
82
adb shell pkill $BINARY
83
exec_with_ssh "cd $CODE_DIR/src && ./$BINARY $RUN_OPTIONS"
86
set -- `getopt -n$0 -u -a --longoptions="setup,help" "sh" "$@"`
88
# FIXME: giving incorrect arguments does not call usage and exit
92
-s|--setup) SETUP=true;;
103
echo "Setting up environment for building shell.."
106
reset_screen_powerdown
109
echo "Transferring code.."