Compiz Introduction and Demo Part 4/5: Build the Ubuntu Desktop

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:

and then I follow the steps below:

1. Download the source code from launchpad

Assuming that you have a launchpad account:

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:

At the end of this step, you should have 3 new directories: nux, compiz and unity inside your ubuntu directory:

Since, I usually build the desktop for development, I prefer to compile without optimisations. Therefore, before I begin building the universe I run:

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:

3. Build and install nux

Inside the ubuntu directory we create a new “nux_install” directory where nux will be installed.

Now we have to configure it, compile it and install it to nux_install ($PREFIX):

Β 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:

Then, I configure it using cmake:

And I compile it and install it locally into the build directory:

(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:

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:

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.

Then:

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:

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:

Then, I enter the directory and I start configuring using either cmake or ccmake. I usually prefer ccmake (better ui, less things to remember).

Step by step configuration:

Step 1: Tell unity where to find compiz and nux pkgconfig directories:

About pkgconfig: https://wiki.freedesktop.org/www/Software/pkg-config/

Step 2: CCmake configuration:

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:

fkclcvh

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/…:

xwkddfo

Page 2/4:

me1c2fu

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:

wr4rb9l

Page 3/4:

fbl0aln

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:

e6y9us5

Page 4/4:

I usually leave page 4 as it is:

tjyraqy

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:

(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:

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:

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:

Leave a Reply

Your email address will not be published. Required fields are marked *