blob: f8c504e7c9bec3fe7652b1f7e80ccf54ed36de62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/sh
SBOX_HOME=/scratchbox/users/$USER/home/$USER
PROJECTFOLDER_HOST=$(pwd -P)
# Options
PROJECTFOLDER=$(basename $PROJECTFOLDER_HOST)-tmp
IP=192.168.2.15
# Flags
BUILD_ONLY=0
DEBIAN=0
RUN=0
CLEAN=0
HELP="Usage: ./build-deploy [options]\n
Copies the current directory to scratchbox, build, send and run Snowshoe on the N9.\n
Alternatively, a debian package can be generated and installed.\n
\n
Options:\n
\n
-b\t\t\tonly build the project, do not send to the device\n
-c\t\t\tmake distclean before building (only without -d)\n
-d\t\t\tgenerate debian package instead of single executable\n
-h\t\t\tshows this help message.\n
-i IP\t\t\tip of the target N9/N950 device\n
-p FOLDER\t\tname of the temporary folder\n
-r\t\t\trun the executable after copying (without -b)
"
while getopts p:i:bdrch ARG
do case "$ARG" in
p) PROJECTFOLDER="$OPTARG";;
i) IP="$OPTARG";;
b) BUILD_ONLY=1;;
d) DEBIAN=1;;
r) RUN=1;;
c) CLEAN=1;;
h) echo $HELP && exit 0;;
?) echo $HELP && exit 1;;
esac
done
# N9 configuration. This is the default ip for USB connections.
N9=developer@$IP
N9HOME=/home/developer
# Sync with build folder
echo "rsync $PROJECTFOLDER_HOST to $SBOX_HOME/$PROJECTFOLDER"
rsync -azrptL --progress --exclude-from=".gitignore" --exclude ".git" $PROJECTFOLDER_HOST/ $SBOX_HOME/$PROJECTFOLDER
if test $DEBIAN -eq 1; then
BUILD_COMMAND="dpkg-buildpackage -rfakeroot -uc -us -B"
else
BUILD_COMMAND="qmake && make -j 3"
if test $CLEAN -eq 1;then
BUILD_COMMAND="make distclean; $BUILD_COMMAND"
fi
fi
LOGFILE=/tmp/$PROJECTFOLDER-build.txt
# Build project
/scratchbox/login -s <<EOF
cd $PROJECTFOLDER
export PATH=/opt/qt5/bin:\$PATH
$BUILD_COMMAND 2>&1 | tee $LOGFILE
EOF
if test $BUILD_ONLY -eq 1; then
exit 0;
fi
if test $DEBIAN -eq 0; then
TARGET=$SBOX_HOME/$PROJECTFOLDER/snowshoe
scp $TARGET $N9:$N9HOME
else
DEBFILE=$(grep -o [-a-z0-9]*_[.0-9a-z-]*_armel\.deb $LOGFILE)
TARGET=$SBOX_HOME/$DEBFILE
scp $TARGET $N9:$N9HOME
stty -echo # do not show the password
ssh $N9 "devel-su -c \"dpkg -i $N9HOME/$DEBFILE\""
stty echo
fi
if test $RUN -eq 1 && test $DEBIAN -eq 0; then
ssh $N9 "DISPLAY=:0 PATH=/opt/qt5/bin:$PATH ./snowshoe --mobile"
fi
|