3 # Fast push/pull with Tizen device (or emulator).
4 # Uses rsync which means faster reupload of libraries after recompilation as only the diff has to be uploaded.
8 usage: $0 (push|pull) src dst
19 trap 'die $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT
21 if echo "$@" | grep -Eqw "\-h|\-\-help"; then
30 if [ "$1" == "push" ]; then
31 src=$(readlink -f $src)
33 elif [ "$1" == "pull" ]; then
34 # NOTE: dirname "" is .
35 [ -d $(dirname "$dst") ]
40 SCRIPT_PATH=$(readlink -f "$(dirname $0)")
42 # Hard-coded, live with it!
47 sdb root on >/dev/null
48 sdb shell "change-booting-mode.sh --update" >/dev/null
50 # Start sshd on device if not running.
51 function startSSHD() {
53 if [ ! -f "/var/run/sshd.pid" ]; then
54 mkdir -m 700 /var/run/sshd &>/dev/null
63 fileExistsOnDevice() {
64 lsout=$(sdb shell "ls $1 2>/dev/null")
65 ([ -n "$lsout" ] && echo 1) || echo 0
68 if [ "$(fileExistsOnDevice /root/.ssh/authorized_keys)" -eq 0 ]; then
69 echo "setting up /root/.ssh/authorized_keys"
70 sdb shell "mkdir /root/.ssh" &>/dev/null
71 sdb push "$HOME/.ssh/id_rsa.pub" "/root/.ssh/authorized_keys"
73 if [ "$(fileExistsOnDevice /usr/local/bin/rsync)" -eq 0 ]; then
74 echo "installing rsync on device"
75 PREBUILD_PATH=$(readlink -f $SCRIPT_PATH/../build/prebuild)
76 sdb push "$PREBUILD_PATH/rsync" /usr/local/bin
79 # It's ok to do the forwarding multiple times.
80 sdb forward tcp:$PORT tcp:22 || (\
81 >&2 echo "ERROR: sdb port forward failed"; \
82 >&2 echo "Hint: if you have /root/.ssh/authorized_keys file on your device make sure it contains your public key."; \
86 rsync -axzH -e "ssh -oStrictHostKeyChecking=no -p $PORT" $1 $2
89 if [ "$1" == "push" ]; then
90 do_rsync $src $USER@localhost:$dst
92 do_rsync $USER@localhost:$src $dst