Build Pantheon and elementary applications with JHBuild

JHBuild is a software that download several VCS repositories to build them together. Everything is sandboxed, so it does not interact with the rest of the system. How can elementary applications be built with JHBuild? What are the advantages of JHBuild for a developer or a tester? It is explained below!

JHBuild is not intended as a replacement for the distribution’s package management system. Instead, it makes it easy to build software into a separate install prefix without interfering with the rest of the system.

See this page for more general information about JHBuild.  It is mostly used to build the GNOME plateform, but we wrote a few oncifuration files so as most elementary code can be built automatically with it.

Build

Get JHBuild

As said above, you don’t need any root account, everything is installed in your /home folder. So, first, let’s get JHBuild. The version in Ubuntu 12.04 repositories is too old (it doesn’t support the new system module type). However, since it is installed in ~/.local, it shouldn’t be a problem. But wihle a root account is not required to build JHBuild and the modules, a few dependencies are still needed (make sure you installed yelp-tools from the repositories before compiling JHBuild, for instance):

$ git clone git://git.gnome.org/jhbuild
$ cd jhbuild
$ ./autogen.sh
$ make
$ make install

Now, make sure you can launch it correctly:

$ which jhbuild
/home/user/.local/bin/jhbuild

If this last command does not return anything, add ~/.local/bin/ to your PATH (so as binaries can also be loaded from the command line there).

Open ~/.bashrc, and add, at the end:

export PATH=~/.local/bin:$PATH

Now, the command above should work correctly.

Elementary moduleset

We wrote several configuration files so as everything is compiled directly. Everything is in a bazaar branch so as you don’t have to configure anything.

bzr branch ~elementary-apps/+junk/jhbuild/ elementary
cd elementary
jhbuild -f jhbuild_elementary.rc

Launch an application, or the desktop

Then you can launch an application using jhbuild (it set some environment variable, so it is not a good idea to launch the binaries directly):

jhbuild -f jhbuild_elementary.rc scratch-text-editor

Go further

Build more modules

While building all elementary modules is very interesting to debug and test Pantheon as well as the other elementary applications, JHBuild was usually used to build all GNOME components, including gtk+, glib, etc…

So, if you want to build all your sandboxed applications with the latest gtk+ from git, you can just comment the line skip = [‘gtk+’] in the jhbuild_elementary.rc file. It will also build all gtk+ dependencies, including glib, gdk-pixbuf… So it may be quite long (around 25 modules to build, some with huge git repossitories) and space consuming, that is why we disabled it by default in the configuration file.

Use the dependency management

JHBuild can detect missing dependencies, and it will tell you:

Required packages:
  System installed packages which are too old:
    (none)
  No matching system package installed:
    indicator (indicator3-0.4.pc)
jhbuild build: Required system dependencies not installed. Install using the command 'jhbuild sysdeps --install' or to ignore system dependencies use command-line option --nodeps

However, using directly jhbuild sysdeps –install will not work if you do not have app-file installed.

$ sudo apt-get install apt-file
$ apt-file update # as normal user
$ jhbuild -f jhbuild_elementary.rc sysdeps --install

Using -f jhbuild_elementary.rc is tiring!

To keep everything sandboxed, in this tutorial, we used jhbuild with a custom configuration file, so as if you run jhbuild alone, it will try to run th default configuration file. This behavior is interesting if you want to build elementary, and the GNOME plateform in several sandbox. But it is also tiring to type -f jhbuild_elementary.rc.

Open home_jhbuildrc, and replace the line current_dir = “…” by the appropriate path to your elementary sandbox folder (if you followed this how-to, it should be something like /home/username/elementary). Then do cp home_jhbuildrc ~/.jhbuildrc.

With a GUI, please!

To use the GUI, we strongly recommend you to make elementary the default configuration of JHBuild, so, in the bzr branch you checked out, just do:

cp home_jhbuildrc ~/.jhbuildrc

Then, search in slingshot for JHBuild, or just launch jhbuild gui.

Links

Leave a comment