HOW TO build the Ubuntu Desktop
This tutorial assumes that you have already installed the Ubuntu Desktop dependencies and development tools mentioned in Part 3/5.
In this post I’ll explain what I usually do to build the Ubuntu Desktop in a local directory (let’s call it ubuntu) and test it on my machine. If you need a quick full build using a script (recommended!) please check these steps here: “HOWTO build the Ubuntu desktop using scripts”
First of all, I create the directory:
1 |
$ mkdir ~/ubuntu && cd ~/ubuntu |
and then I follow the steps below:
1. Download the source code from launchpad
Assuming that you have a launchpad account:
1 2 3 |
$ bzr branch lp:nux $ bzr branch lp:unity $ bzr branch lp:compiz |
If you don’t have one you can create by following the instructions here: https://help.launchpad.net/YourAccount/NewAccount
or you can download the source code by running:
1 2 3 |
$ bzr branch https://code.launchpad.net/~unity-team/nux/trunk $ bzr branch https://code.launchpad.net/unity $ bzr branch https://code.launchpad.net/compiz |
At the end of this step, you should have 3 new directories: nux, compiz and unity inside your ubuntu directory:
1 2 3 4 |
ubuntu βββ compiz βββ nux βββ unity |
Since, I usually build the desktop for development, I prefer to compile without optimisations. Therefore, before I begin building the universe I run:
1 2 |
export CFLAGS="-O0 -g" export CXXFLAGS="-O0 -g" |
To be sure I don’t forget these lines I wrote them my ~/.bashrc (but that’s not advisable) π
2. Prerequisites
Before I start, I make sure that all the libraries required by nux, compiz and unity are installed:
1 2 |
# apt-get update # apt-get build-dep nux compiz unity |
3. Build and install nux
Inside the ubuntu directory we create a new “nux_install” directory where nux will be installed.
1 |
$ cd ~/ubuntu && mkdir -p nux_install |
1 2 3 4 5 6 |
ubuntu βββ compiz βββ nux βββ nux_install βββ unity |
Now we have to configure it, compile it and install it to nux_install ($PREFIX):
1 2 3 4 5 6 |
$ cd nux_install $ export PREFIX=`pwd` $ cd ../nux $ ./autogen.sh --prefix=$PREFIX --enable-debug $ make && make install $ cd .. |
Β 4. Build and install compiz
The compiz installation is a little tricky. There are several places to install it locally or system-wide. The method I use is not the best one but it has the advantage that it doesn’t affect your system after you remove this custom build and you don’t have to care much to configure unity to find compiz. For alternative methods you can check the compiz documentation here: http://wiki.compiz.org and the unity documentation here: https://wiki.ubuntu.com/Unity
So, here’s what I do:
First of all I create a build directory inside compiz and I enter this directory:
1 |
$ cd compiz && mkdir -p build && cd build |
1 2 3 4 5 6 7 |
ubuntu/ βββ compiz βΒ Β βββ build βββ nux βββ nux_install βββ unity |
Then, I configure it using cmake:
1 |
$ cmake ~/ubuntu/compiz -DCMAKE_INSTALL_PREFIX=`pwd` -DCMAKE_BUILD_TYPE=Debug |
And I compile it and install it locally into the build directory:
1 |
$ make && make install |
(I usually use the -j option in make, I run something like: $ make -j4 install
because it’s faster)
Done. Compiz is now installed in ~/ubuntu/compiz/build.
Note: In case that although you have installed all the compiz dependencies in your system you still get weird linking errors when you run cmake you might need to run ccmake and turn off some of the options like these: BUILD_TESTING, BUILD_KDE4, BUILD_METACITY:
1 2 |
$ cd ~/ubuntu/compiz/build $ ccmake .. |
You can find information about ccmake here: http://linux.die.net/man/1/ccmake
And that was the standard way to build and install compiz in a local directory in your computer.
If you only need to test compiz (and not the full desktop) you can just set the LD_LIBRARY_PATH (https://en.wikipedia.org/wiki/Environment_variable#Unix) and run:
1 |
$ COMPIZ_CONFIG_VERSION=ubuntu LD_LIBRARY_PATH=~ubuntu/compiz/build/lib ~ubuntu/compiz/build/bin/compiz --replace ccp |
If you need to build the whole desktop, the tricky part is to make the unity scripts find this version of compiz and load these plugin libraries instead of those installed system-wide.
Since I wouldn’t like to set many environment variables, and risk that other things that depend on those won’t work properly, I do a naive trick to solve that problem: I backup the system’s compiz/ directory that contains the plugin libraries (lib*.so for example libopengl.so, libcube.so) to a directory named compiz_backup, I empty the compiz directory and I symlink the lib*.so files from ~/ubuntu/compiz/build/lib/compiz to the system’s compiz directory.
1 2 |
$ cd /usr/lib/x86_64-linux-gnu/ $ sudo mv compiz compiz_backup && mkdir compiz && cd compiz |
Then:
1 |
$ ln -s ~/ubuntu/compiz/build/lib/compiz/lib*.so . |
and then I go to step 5.
A script I use to symlink all the plugins including Unity after Step 5 is the following:
http://paste.ubuntu.com/12109484/
Note: After I finish debugging I just delete the compiz directory and run:
1 |
$ mv compiz_backup compiz |
to restore everything.
5. Build and install unity
And here’s how I build and install unity:
First, I create the installation directory inside the ubuntu directory:
1 |
$ cd ~/ubuntu && mkdir -p install |
1 2 3 4 5 6 7 8 |
ubuntu/ βββ compiz βΒ Β βββ build βββ install βββ nux βββ nux_install βββ unity |
Then, I enter the directory and I start configuring using either cmake or ccmake. I usually prefer ccmake (better ui, less things to remember).
1 2 |
$ cd install $ ccmake ~/ubuntu/unity |
Step by step configuration:
Step 1: Tell unity where to find compiz and nux pkgconfig directories:
1 |
$ export PKG_CONFIG_PATH=/home/eleni/ubuntu/nux_install/lib/pkgconfig:/home/eleni/ubuntu/compiz/build/lib/pkgconfig |
About pkgconfig: https://wiki.freedesktop.org/www/Software/pkg-config/
Step 2: CCmake configuration:
1 2 |
$ cd ~/ubuntu/install $ ccmake ~/ubuntu/unity |
CCmake might show you a help page (exit by pressing e) or ask you to press c to run configure in an empty page, just press the keys until the following screen shows up:
As you can see there are some parameters, environment variables and paths to configure. In this screen, you can optionally enable the BOOT_LOGGER for debugging. The CMAKE_INSTALL_PREFIX shows where unity will be installed. Since I don’t want to mess up my system’s directories (not even the local ones), I replace the /usr/local with the unity installation directory (~/ubuntu/install). The COMPIZ_COMPOSITE_LIB shows where the file libcomposite.so is. In the screenshot above unity autodetected the libcomposite.so inside ~/ubuntu/compiz/build because I’ve previously set the PKG_CONFIG_PATH to include the ~/ubuntu/compiz/build/lib/pkgconfig. If for some reason autodetection doesn’t work for you, you may want to enter the libcomposite.so path manually. The rest remains unchanged.
So, here’s how Page 1/4 looks after the changes, in your case the paths should be /home/yourusername/ubuntu/…:
Page 2/4:
This is how page 2 looks like. Since I’ve already set PKG_CONFIG_PATH the COMPIZ_OPENGL_LIB path where libopengl.so is located is autodetected correctly. The COMPIZ_LIB path points to the libcompiz_core.so that is installed in our system. Since we want to debug the compiz that we just built in ~/ubuntu/compiz/build we have to replace the path to the system’s libcompiz_core.so with the path that points to our libcompiz_core.so which is somewhere inside the ~/ubuntu/compiz/build/lib directory.
Here’s how it will look after the changes:
Page 3/4:
In page 3 the most important setting is GSETTINGS_LOCALINSTALL, it should always be ON. I usually set the I18N_SUPPORT (localization) to OFF to have less things to build…
Here’s how it looks after the change:
Page 4/4:
I usually leave page 4 as it is:
At this point, I press c to configure, e to exit the help page and then g to generate the files and exit.
Step 3: Compile and install unity!
Inside the directory ~/ubuntu/install we type:
1 2 |
$ make $ make install |
(If you have many processors you can use make -jN where N is the number of processors because compiling takes a lot of time…)
At the end of this step you might see this message:
CMake Error at data/pam/cmake_install.cmake:44 (file): file
cannot create directory: /pam.d. Maybe need administrative
privileges.
if you do so, just comment out the line 44 in ~/ubuntu/install/data/pam/cmake_install.cmake and run make install again.
And if everything so far was successful you will have a local installation of nux (in ~/ubuntu/nux_install), compiz (in ~/ubuntu/compiz/build) and unity (in ~/ubuntu/install)!
6. Run and test the Ubuntu Desktop
Finally… πΒ We enter the directory ~/ubuntu/install and run:
1 |
DISPLAY=:0 COMPIZ_CONFIG_VERSION=ubuntu PATH=~/ubuntu/compiz/build/bin:~/ubuntu/install/bin:$PATH LD_LIBRARY_PATH=~/ubuntu/compiz/build/lib/compiz:~/ubuntu/compiz/build/lib/x86_64-linux-gnu:~/ubuntu/install/lib:$LD_LIBRARY_PATH LD_RUN_PATH=~/ubuntu/compiz/build/lib/compiz:~/ubuntu/compiz/build/lib/x86_64-linux-gnu:~/ubuntu/install/lib:$LD_RUN_PATH XDG_DATA_DIRS=~/ubuntu/compiz/build/share:~/ubuntu/install/share:$XDG_DATA_DIRS PKG_CONFIG_PATH=~/ubuntu/nux_install/lib/pkgconfig:~/ubuntu/compiz/build/lib/pkgconfig:~/ubuntu/install/lib/pkgconfig:$PKG_CONFIG_PATH ./bin/unity --compiz-path=~/ubuntu/compiz/build/bin/compiz --replace ccp |
We need to set all the environment variables above to make sure that the unity startup script (~/ubuntu/install/bin/unity) can find all our compiz, nux and unity libraries and files.
If everything was ok we ‘ll see something like that in the terminal:
1 2 3 4 5 6 |
/home/eleni/ubuntu/compiz/build/bin/compiz (core) - Info: Loading plugin: core /home/eleni/ubuntu/compiz/build/bin/compiz (core) - Info: Starting plugin: core /home/eleni/ubuntu/compiz/build/bin/compiz (core) - Info: Loading plugin: ccp /home/eleni/ubuntu/compiz/build/bin/compiz (core) - Info: Starting plugin: ccp compizconfig - Info: Backend : gsettings compizconfig - Info: Integration : true |
Unity will restart and Nux prologue will be printed out.
NOTE: In case that you don’t need much control over everything and you only need to build unity or nux quickly you can follow the instructions here: https://unity.ubuntu.com/getinvolved/development/unity/#build-unity π
NOTE2: After Xenial I had to do a slight modification @the .unity-bash-functions file (see the link @NOTE above) and here’s the modified one:
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 |
recreate-build-dir() { rm -r build mkdir build cd build } function remake-autogen-project() { ./autogen.sh --prefix=$HOME/canonical/staging --enable-debug make clean && make -j4 install } function remake-unity() { recreate-build-dir cmake .. -DCMAKE_BUILD_TYPE=Debug -DCOMPIZ_PLUGIN_INSTALL_TYPE=local -DCMAKE_INSTALL_PREFIX=$HOME/canonical/staging/ -DGSETTINGS_LOCALINSTALL=ON -DCMAKE_SYSCONFDIR=$HOME/canonical/staging/etc -DCOMPIZ_COMPOSITE_LIB=/usr/lib/x86_64-linux-gnu/compiz/libcomposite.so -DCOMPIZ_OPENGL_LIB=/usr/lib/x86_64-linux-gnu/compiz/libopengl.so -DCOMPIZ_LIB=/usr/lib/x86_64-linux-gnu/libcompiz_core.so make -j4 install } function unity-env { export PATH=~/canonical/staging/bin:$PATH export XDG_DATA_DIRS=~/.config/compiz-1/gsettings/schemas:~/canonical/staging/share:/usr/share:/usr/local/share export LD_LIBRARY_PATH=~/canonical/staging/lib:${LD_LIBRARY_PATH} export LD_RUN_PATH=~/canonical/staging/lib:${LD_RUN_PATH} export PKG_CONFIG_PATH=~/canonical/staging/lib/pkgconfig:${PKG_CONFIG_PATH} export PYTHONPATH=~/canonical/staging/lib/python2.7/site-packages:$PYTHONPATH export GI_TYPELIB_PATH=~/canonical/staging/lib/girepository-1.0:$GI_TYPELIB_PATH export XDG_CONFIG_DIRS=~/canonical/staging/etc:$XDG_CONFIG_DIRS } |