~nick-dedekind/unity/phablet-greeter-indicators

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash

TARGET_DIR=$PWD/../unity_build
BUILD_DIR=$TARGET_DIR/build
RARING=false
SETUP=false
UPDATE=false
NUM_JOBS=$(( `grep -c ^processor /proc/cpuinfo` + 1 ))
LENSES="applications mockmusic mockvideos"

usage() {
    echo "usage: build_unity [OPTIONS]\n"
    echo "Script to build Unity on Ubuntu 12.10.\n"
    echo "OPTIONS:"
    echo "  -s, --setup   Setup the build environment and branch Unity"
    echo "  -u, --update  Update Unity's source code"
    exit 1
}

set -- `getopt -n$0 -u -a --longoptions="setup,update,help" "suh" "$@"`

# FIXME: giving incorrect arguments does not call usage and exit
while [ $# -gt 0 ]
do
    case "$1" in
       -s|--setup)   SETUP=true;;
       -u|--update)  UPDATE=true;;
       -h|--help)    usage;;
       --)           shift;break;;
    esac
    shift
done

install_dependencies() {
    echo "Installing build dependencies.."
    if ! $RARING; then sudo apt-get build-dep -y libnux-3.0-dev || exit 3; fi
    sudo apt-get build-dep -y libunity unity || exit 4
    sudo apt-get install -y libgtest-dev gnome-common libfolks-dev libtelepathy-glib-dev || exit 5
    # HUD dependencies
    sudo apt-get install -y bamfdaemon debhelper dh-autoreconf gir1.2-dee-1.0 gnome-common gnome-doc-utils gobject-introspection gtk-doc-tools indicator-application indicator-appmenu indicator-appmenu-tools intltool libappindicator3-dev libbamf3-dev libdbusmenu-glib-dev libdbusmenu-gtk3-dev libdbusmenu-jsonloader-dev libdbustest1-dev libdee-dev libgirepository1.0-dev libgtk-3-dev libncurses5-dev libreadline-dev libsqlite3-dev metacity sqlite3 valac-0.18 libpocketsphinx-dev libsphinxbase-dev  || exit 6
}

branch_nux() {
    echo "Branching Nux.."
    bzr branch lp:nux/phablet $TARGET_DIR/nux
}

branch_libunity() {
    echo "Branching libunity.."
    bzr branch lp:libunity/phablet $TARGET_DIR/libunity
}

branch_unity() {
    echo "Branching Unity.."
    bzr branch lp:unity/phablet-mods $TARGET_DIR/unity
}

branch_people_lens() {
    echo "Branching people lens.."
    bzr branch lp:unity-lens-people $TARGET_DIR/people_lens
}

branch_hud() {
    echo "Branching hud.."
    bzr branch lp:hud/phablet $TARGET_DIR/hud
}

update_nux() {
    if [ -d $TARGET_DIR/nux ]; then
        echo "Updating Nux.."
        bzr pull -d $TARGET_DIR/nux
    fi
}

update_unity() {
    echo "Updating Unity.."
    bzr pull -d $TARGET_DIR/unity
}

update_libunity() {
    echo "Updating libunity.."
    bzr pull -d $TARGET_DIR/libunity
}

update_people_lens() {
    echo "Updating people lens.."
    bzr pull -d $TARGET_DIR/people_lens
}

update_hud() {
    echo "Updating hud"
    bzr pull -d $TARGET_DIR/hud
}

compile_nux() {
    if [ -d $TARGET_DIR/nux ]; then
        echo "Configuring Nux.."
        cd $TARGET_DIR/nux
        ./autogen.sh --prefix $BUILD_DIR --disable-debug --disable-documentation

        echo "Building Nux and installing in " $BUILD_DIR
        make -j$NUM_JOBS install
    fi
}

compile_libunity() {
    echo "Configuring libunity.."
    cd $TARGET_DIR/libunity

    ./autogen.sh --prefix $BUILD_DIR --disable-debug

    echo "Building libunity and installing in " $BUILD_DIR
    make -j$NUM_JOBS install

}

compile_unity_core() {
    echo "Configuring Unity.."
    cd $TARGET_DIR/unity
    mkdir build
    cd build
    PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig:$PKG_CONFIG_PATH cmake .. -DCMAKE_BUILD_TYPE=Debug -DCOMPIZ_PLUGIN_INSTALL_TYPE=local -DGSETTINGS_LOCALINSTALL=ON -DCMAKE_INSTALL_PREFIX=$BUILD_DIR

    echo "Building UnityCore and installing in " $BUILD_DIR
    cd UnityCore
    make -j$NUM_JOBS
    make install

}

compile_people_lens() {
    echo "Configuring people lens.."
    cd $TARGET_DIR/people_lens

    PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig:$PKG_CONFIG_PATH ./autogen.sh --prefix $BUILD_DIR --enable-localinstall

    echo "Building people lens and installing in " $BUILD_DIR
    MAINTAINER_VALAFLAGS="--vapidir=${BUILD_DIR}/share/vala/vapi" make -j$NUM_JOBS install

}

compile_hud() {
    echo "Configuring hud.."
    cd $TARGET_DIR/hud

    ./autogen.sh --prefix $BUILD_DIR --disable-hybris --enable-localinstall

    echo "Building hud and installing in " $BUILD_DIR
    make install

}

link_lenses() {
    echo "Linking system lenses.."
    mkdir -p $BUILD_DIR/share/unity/lenses/
    for LENS in $LENSES; do
        [ -e $BUILD_DIR/share/unity/lenses/$LENS ] || ln -ivs /usr/share/unity/lenses/$LENS $BUILD_DIR/share/unity/lenses/$LENS
    done
}

grep -q raring /etc/lsb-release
if [ $? -eq 0 ]; then
    RARING=true
fi

if $SETUP; then
    echo "Setting up environment for building Unity.."
    install_dependencies
    mkdir -p $TARGET_DIR
    if ! $RARING; then branch_nux; fi
    branch_libunity
    branch_unity
    branch_people_lens
    branch_hud
elif $UPDATE; then
    update_nux
    update_libunity
    update_unity
    update_people_lens
    update_hud
else
    mkdir -p $BUILD_DIR
    compile_nux
    compile_libunity
    compile_unity_core
    compile_people_lens
    compile_hud
    link_lenses
fi