on xenial help sign in
Clean up some build script legacy

Approved by: Albert Astals Cid

commit973612aa361c6dd3877494b55cd6183c4a351535 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 11 Aug 2016, 06:22 (10 years ago) parentb02a6f66bdeb4d
4 files changed+26−330
CODING+20−59 build.sh+6−37 run.sh−70 run_on_device.sh−164
CODING+20−59
@@ -15,23 +15,17 @@ download source
1515 $ bzr branch lp:unity8 ~/unity8/trunk
1616 $ cd ~/unity8/trunk
1717
18−install dependencies
18+install dependencies and build Unity 8
1919--------------------
20−If its your first time, install build dependencies
2120
2221$ cd ~/unity8/trunk
23−$ ./build.sh --setup
24−
25− this will:
26− - install the required dependencies to build, as well as run on the desktop
27− - it should also install unity-scope-home and unity-lens-application which
28− are technically "recommends", not strict dependencies
22+$ ./build.sh
2923
30−build Unity 8
31−-------------
24+ If its your first time, this will install the required dependencies to build and
25+ build it.
3226
33−$ cd ~/unity8/trunk
34−$ ./build.sh
27+ You might want to also install unity-scope-home and unity-scope-click which
28+ are technically "recommends", not strict dependencies
3529
3630You may also rebuild with the -c for clean, which just deletes the build
3731directory.
@@ -43,13 +37,15 @@ Running Unity 8 on your desktop
4337run the Unity 8 shell
4438---------------------
4539$ cd ~/unity8/trunk
46−$ ./run.sh
40+$ cd builddir
4741
48−Options can be passed to test the lock screen
49−$ ./run.sh -p OR -k
42+Each component of unity8 can be ran independently for development and testing
43+For example:
44+$ make tryShell
45+$ make tryLauncher
46+$ make tryLockscreen
5047
51−-p is for pin lock, for which the default prompt answer is "1234"
52−-k is for keylock passphrase, for which the default prompt answer is "password"
48+Check out the tests/qmltests/ directory for a list of things that can be ran.
5349
5450Notes
5551-----
@@ -70,50 +66,15 @@ Notes
7066
7167Running Unity 8 on devices
7268==========================
73−- Ubuntu Touch builds are currently only available in 14.04 flavour
74−- supported hardware should match one of those listed here
75− https://wiki.ubuntu.com/Touch/Devices#Running_fine
76−- follow the Ubuntu Touch install instructions for your chosen device
77− https://wiki.ubuntu.com/Touch/Install
78−- make sure your device is connected to a network
79−- also make sure you have your SSH key in ~/.ssh/id_rsa.pub (or install one
80− on the device yourself)
81−
82−$ cd ~/unity/trunk
83−$ ./run_on_device.sh --setup
84− this will:
85− - install your public SSH key on the device
86− - install the needed dependencies
8769
88−$ ./run_on_device.sh
89− this will:
90− - rsync the code to the device
91− - build on the device
92− - replace the running shell
93−
94−Options can be passed to test the lock screen
95−$ ./run_on_device.sh -p OR -k
96−
97−-p is for pin lock, for which the default prompt answer is "1234"
98−-k is for keylock passphrase, for which the default prompt answer is "password"
99−
100−Notes
101−-----
102−- using adb over TCP has some advantages, Google will be of help here
103− - NOTE: this is not yet available for flipped images
104− - TL;DR: `adb tcpip 5555; adb connect $your_device_ip`
105− - you can persist the above via `adb shell setprop persist.adb.tcp.port 5555`
106− - it's unsafe - anyone can connect to your device
107− - with TCP the Nexus 10 doesn't drop the adb connection when locking
108− the screen
109−- exporting ANDROID_SERIAL=$your_device_serial or
110− ANDROID_SERIAL=$your_device_ip:5555 will make adb not complain about
111− multiple devices
112−- you can export TARGET_IP=$your_device_ip TARGET_SSH_PORT=22 for run_on_device.sh
113− to not use adb forwarding - useful if you use multiple devices
114−- using Ninja (package ninja-build - run_on_device.sh -s installs this now)
115− will improve build times (especially in the nothing-to-build case)
70+Running unity8 on a device should be done using crossbuilder.
71+Go to
72+* https://launchpad.net/crossbuilder and
73+* https://wiki.ubuntu.com/Touch/Crossbuilder
74+for more details on crossbuilder.
11675
76+unity8 will automatically restart on the phone once deployment
77+has finished due to post-build-steps set up in this repository.
11778
11879Coding guidelines
11980=================
build.sh+6−37
@@ -9,7 +9,6 @@ usage() {
99 echo "usage: build [OPTIONS] [BUILD_TYPE]\n" >&2
1010 echo "Script to build the shell. If BUILD_TYPE is not specified, it defaults to \"debug\".\n" >&2
1111 echo "OPTIONS:" >&2
12− echo " -s, --setup Setup the build environment and branch Unity" >&2
1312 echo " -c, --clean Clean the build tree before building" >&2
1413 echo >&2
1514 exit 1
@@ -22,7 +21,6 @@ eval set -- "$ARGS"
2221while [ $# -gt 0 ]
2322do
2423 case "$1" in
25− -s|--setup) SETUP=true;;
2624 -c|--clean) CLEAN=true;;
2725 -h|--help) usage;;
2826 --) shift;break;;
@@ -35,31 +33,6 @@ done
3533BUILD_TYPE="debug"
3634[ $# -eq 1 ] && BUILD_TYPE="$1"
3735
38−install_dependencies() {
39− sudo apt-get update || exit 4
40− echo "Installing Unity 8 dependencies.."
41− sudo apt-get install devscripts \
42− equivs \
43− gsettings-desktop-schemas \
44− gsettings-ubuntu-schemas \
45− pay-service \
46− qmenumodel-qml \
47− qml-module-qtquick-layouts \
48− qml-module-qtquick-xmllistmodel \
49− qml-module-ubuntu-components \
50− qml-module-ubuntu-thumbnailer0.1 \
51− qtdeclarative5-gsettings1.0 \
52− qtdeclarative5-ubuntu-settings-components \
53− qtdeclarative5-ubuntu-telephony0.1 \
54− qtdeclarative5-unity-notifications-plugin \
55− qml-module-ubuntu-connectivity \
56− ubuntu-mobile-icons \
57− ubuntu-system-settings \
58− unity-plugin-scopes \
59− xvfb \
60− || exit 5
61−}
62−
6336mk_build_deps() {
6437 if [ ! -f control -o $CODE_DIR/debian/control -nt control ]; then
6538 sed 's/\:native//g' $CODE_DIR/debian/control > control
@@ -85,13 +58,9 @@ else
8558 BUILD_COMMAND="make -j$NUM_JOBS"
8659fi
8760
88−if $SETUP; then
89− install_dependencies
90−else
91− if $CLEAN; then rm -rf builddir; fi
92− mkdir -p builddir
93− cd builddir
94− mk_build_deps
95− cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CODE_DIR ${GENERATOR} || exit 6
96− ${BUILD_COMMAND} || exit 7
97−fi
61+if $CLEAN; then rm -rf builddir; fi
62+mkdir -p builddir
63+cd builddir
64+mk_build_deps
65+cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CODE_DIR ${GENERATOR} || exit 6
66+${BUILD_COMMAND} || exit 7
run.shdeleted−70
@@ -1,70 +0,0 @@
1−#!/bin/sh
2−
3−. /etc/environment
4−export QML2_IMPORT_PATH
5−
6−QML_PHONE_SHELL_PATH=./builddir/src/unity8
7−GDB=false
8−FAKE=false
9−USE_MOCKS=false
10−MOUSE_TOUCH=true
11−
12−usage() {
13− echo "usage: "$0" [OPTIONS]\n" >&2
14− echo "Script to run the shell.\n" >&2
15− echo "OPTIONS:" >&2
16− echo " -f, --fake Force use of fake Qml modules." >&2
17− echo " -g, --gdb Run through gdb." >&2
18− echo " -h, --help Show this help." >&2
19− echo " -m, --nomousetouch Run without -mousetouch argument." >&2
20− echo >&2
21− exit 1
22−}
23−
24−ARGS=`getopt -n$0 -u -a --longoptions="fake,gdb,help:,nomousetouch" -o "fghm" -- "$@"`
25−[ $? -ne 0 ] && usage
26−eval set -- "$ARGS"
27−
28−while [ $# -gt 0 ]
29−do
30− case "$1" in
31− -f|--fake) USE_MOCKS=true;;
32− -g|--gdb) GDB=true;;
33− -h|--help) usage;;
34− -m|--nomousetouch) MOUSE_TOUCH=false;;
35− --) shift;break;;
36− esac
37− shift
38−done
39−
40−if $USE_MOCKS; then
41− export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules
42− export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/LightDM/liblightdm:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/QMenuModel
43−else
44− export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/plugins/LightDM/liblightdm
45−fi
46−
47−QML_PHONE_SHELL_ARGS="-windowgeometry=40gux68gu -devicename=mako"
48−if $MOUSE_TOUCH; then
49− QML_PHONE_SHELL_ARGS="$QML_PHONE_SHELL_ARGS -mousetouch"
50−fi
51−
52−control_c()
53−{
54− /sbin/initctl stop unity8
55− exit $?
56−}
57−
58−trap control_c INT
59−
60−if $GDB; then
61− gdb -ex run --args $QML_PHONE_SHELL_PATH $QML_PHONE_SHELL_ARGS $@
62−else
63− status=`/sbin/initctl status unity8`
64− if [ "$status" != "unity8 stop/waiting" ]; then
65− echo "Unity8 is already running, please stop it first"
66− exit 1
67− fi
68− /sbin/initctl start unity8 BINARY="`readlink -f $QML_PHONE_SHELL_PATH` $QML_PHONE_SHELL_ARGS $@" XDG_DATA_DIRS=$XDG_DATA_DIRS QML2_IMPORT_PATH=$QML2_IMPORT_PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH
69− tailf -n 0 ~/.cache/upstart/unity8.log
70−fi
run_on_device.shdeleted−164
@@ -1,164 +0,0 @@
1−#!/bin/bash
2−CODE_DIR=shell
3−USER=phablet
4−USER_ID=32011
5−PACKAGE=unity8
6−BINARY=unity8
7−TARGET_IP=127.0.0.1
8−TARGET_SSH_PORT=2222
9−TARGET_DEBUG_PORT=3768
10−RUN_OPTIONS=-qmljsdebugger=port:$TARGET_DEBUG_PORT
11−SETUP=false
12−GDB=false
13−PINLOCK=false
14−KEYLOCK=false
15−NUM_JOBS='$(( `grep -c ^processor /proc/cpuinfo` + 1 ))'
16−FLIPPED=false
17−SSH_WAS_STARTED=0
18−SSH_STARTED=0
19−PASSWORD=""
20−PASSFILE=""
21−
22−usage() {
23− echo "usage: run_on_device -a SUDO_PASSWORD [OPTIONS]"
24− echo
25− echo "Script to setup a build environment for the shell and sync build and run it on the device"
26− echo
27− echo "OPTIONS:"
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"
33− echo
34− echo "IMPORTANT:"
35− echo " * Make sure to have networking setup on the device beforehand."
36− echo " * Execute that script from a directory containing unity8 code."
37− exit 1
38−}
39−
40−start_ssh() {
41− if [ $SSH_STARTED -eq 0 ]; then
42− adb_sudo initctl start ssh
43− SSH_STARTED=1
44− fi
45−}
46−
47−exec_with_ssh() {
48− 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 \"$@\"
50−}
51−
52−adb_sudo() {
53− adb shell "SUDO_ASKPASS=${PASSFILE} sudo --askpass $@"
54−}
55−
56−install_ssh_key() {
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
61−}
62−
63−setup_adb_forwarding() {
64− adb forward tcp:$TARGET_SSH_PORT tcp:22
65− adb forward tcp:$TARGET_DEBUG_PORT tcp:$TARGET_DEBUG_PORT
66−}
67−
68−install_dependencies() {
69− phablet-config writable-image --remotepassword ${PASSWORD} -p build-essential \
70− -p rsync \
71− -p bzr \
72− -p ccache \
73− -p gdb \
74− -p ninja-build \
75− -p devscripts \
76− -p equivs
77−}
78−
79−sync_code() {
80− [ -e .bzr ] && bzr export --uncommitted --format=dir /tmp/$CODE_DIR
81− [ -e .git ] && git checkout-index -a -f --prefix=/tmp/$CODE_DIR/
82− start_ssh
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/
84− rm -rf /tmp/$CODE_DIR
85−}
86−
87−build() {
88− exec_with_ssh PATH=/usr/lib/ccache:$PATH "cd $CODE_DIR/ && PATH=/usr/lib/ccache:$PATH ./build.sh"
89−}
90−
91−run() {
92− ARGS="--nomousetouch"
93− if $GDB; then
94− ARGS="$ARGS --gdb"
95− fi
96− if $PINLOCK; then
97− ARGS="$ARGS -p"
98− fi
99− if $KEYLOCK; then
100− ARGS="$ARGS -k"
101− fi
102−
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"
108−}
109−
110−set -- `getopt -n$0 -u -a --longoptions="password:,setup,gdb,pinlock,keylock,help" "a:sgpkh" "$@"`
111−
112−# FIXME: giving incorrect arguments does not call usage and exit
113−while [ $# -gt 0 ]
114−do
115− case "$1" in
116− -a|--password) PASSWORD=$2;;
117− -s|--setup) SETUP=true;;
118− -g|--gdb) GDB=true;;
119− -p|--pinlock) PINLOCK=true;;
120− -k|--keylock) KEYLOCK=true;;
121− -h|--help) usage;;
122− --) shift;break;;
123− esac
124− shift
125−done
126−
127−if [ -z "${PASSWORD}" ]; then
128− echo "ERROR: You need to provide a sudo password..."
129− echo
130− usage
131−fi
132−
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}"
137−
138−setup_adb_forwarding
139−
140−status_output=$(adb_sudo initctl status ssh)
141−if [[ $status_output == "ssh start/running, process "* ]]; then
142− SSH_WAS_STARTED=1
143−fi
144−SSH_STARTED=$SSH_WAS_STARTED
145−
146−if $SETUP; then
147− echo "Setting up environment for building shell.."
148− install_ssh_key
149− install_dependencies
150− sync_code
151−else
152− echo "Transferring code.."
153− sync_code
154− echo "Building.."
155− build
156− echo "Running.."
157− run
158−fi
159−
160−adb shell "rm ${PASSFILE}"
161−
162−if [ $SSH_WAS_STARTED -eq 0 ]; then
163− adb_sudo initctl stop ssh
164−fi