How to build a source package using upkg (the paldo package system)
written by Nicolas Christener in jan 2006
 A concrete problem
I like the Paldo philosophy of having one tool for every task. But I don't want to install k3b (and its dependencies) for making 1:1 copies of a CD. Therefore I checked the availability of Gnome Baker in the Paldo package repository. Unfortunately Gnome Baker is not in the main repository. Thus I decided to build Gnome Baker from source. Because I want a clean filesystem I don't want to just run "./configure, make and make install". It would be nicer to install the binaries, the docs... using the package manager after building everything from source. Read on to find out what I did to achieve this.
 Create a local Paldo repository
First of all we need to create a place for all our source packages. It doesn't matter where you create this local repository. I put mine in my home folder:
[nicolas@gandalf:~]$mkdir PaldoRepo [nicolas@gandalf:~]$mkdir PaldoRepo/binaries [nicolas@gandalf:~]$mkdir PaldoRepo/sources [nicolas@gandalf:~]$mkdir PaldoRepo/specs
Now we need to tell upkg about the new local repository. Open /etc/upkg.conf as root and add your repository. The content of the file then looks something like the following:
<?xml version="1.0" encoding="UTF-8"?> <local> <cachedir>/var/cache/upkg</cachedir> <repositories> <repository>http://www.paldo.org/paldo</repository> <repository>/home/nicolas/PaldoRepo/</repository> </repositories> <branch>testing</branch> <arch>x86</arch> </local>
 Get the source
Now download the source code of the application you want to install. In my case I downloaded the zipped source-tarball from http://gnomebaker.sourceforge.net/ . Upkg needs the source distribution as tar (tar file), or tar.bz2 file (bzip2 compressed tar file). Please ensure that your source package is in a supported file format, then copy or move it into the sources dir of your repository. Take care, that the file has the same name which you will later use as the package-name. See the <package name>-tag in the spec file chapter later.
upkg will only find the source package if you save it under $REPODIR/sources/$PACKAGENAME
[nicolas@gandalf:~/temp/gnome-baker]ls gnome-baker-0.5.0.tar.bz2 [nicolas@gandalf:~/temp/gnome-baker]mv gnome-baker-0.5.0.tar.bz2 ~/PaldoRepo/sources/gnome-baker/
btw: If you like to use a tar.gz file, you need to add the following to your spec file: <archive name="...." compression="gz">
 Create spec file for upkg
Now we need to tell upkg how it has to handle the source code. This is done using a simple XML File. You need to create this file in the specs dir in your repository. The filename (and therefore the package name) should fit the following rules:
- use the pkg-config name if available
- for packages without a pkg-config file use the source tarball name (at least if there is no clear reason to use a different name)
Often you can find a pkg-config file in the source directory (also check subdirs) of the source package. Such a pkg-config file is called packagename.pc.in. For example redland.pc.in. However gnome-baker does not provide such a file. Therefore I use the name of the source tarball and call the file gnome-baker.xml. The content of the file then looks something like the following:
<?xml version="1.0"?> <package name="gnome-baker"> <description>gnome cd burning application</description> <releases> <release version="0.5.0" revision="1" branch="testing"> <deps> <dep name="libgnomeui-2.0"/> <dep name="gtk+-2.0"/> <dep name="glib-2.0"/> <dep name="libglade-2.0"/> <dep name="gstreamer-0.8"/> </deps> <build> <script> <archive name="gnome-baker-$VERSION"> <cmd>./configure</cmd> <cmd>make</cmd> <cmd>make install</cmd> </archive> </script> </build> </release> </releases> </package>
Most parts of this file are self describing. I think I just need to describe the dep-fields as well as the configure/make part. In order to let upkg automatically resolve the dependencies you need to tell upkg which packages your tool needs to get compiled. To find out which other packages are needed, you can try the following approaches:
- Read configure.in or configure.ac in the source distribution. You will probably find something like: PKG_CHECK_MODULES(GNOME, libgnomeui-2.0 gtk+-2.0 >= 2.4.0 glib-2.0 >= 2.4.0 libglade-2.0 gstreamer-0.8,,exit) in this case it's probably easy to find the needed packages. Just use the libraries that are listed in the PKG_CHECK_MODULES-list. In most cases Paldo uses exactly these names. For example libgnomeui-2.0 is also called libgnomeui-2.0 in the paldo repository. However use http://www.paldo.org/index-section-packages.html to get the right name.
- Check the README, INSTALL,... files in the source distribution. Some projects list the dependencies in one of these files.
- Copy from an other distribution. If nothing helps, you can still take alook at what other distributions list as dependencies.
Here is a somewhat unofficial list of build essentials:
You don't need to mention this dependencies because those packages are installed on every paldo installation.
In the <script> section you define the steps needed to build the source. The ./configure command is somewhat special, as some default parameters are defined system wide (you can find them in /usr/lib/config.site). There fore you don't need to pass the following parameters:
The make command also uses some system wide default parameters. They are defined in the global.xml file in your paldo repositories. The following values are set:
<environment name="MAKEFLAGS">-j 2</environment>
 How Paldo handles branches
(Deprecated: paldo is now a rolling release distribution consolidated into testing and stable branches.)
Paldo knows four different branches:
They have the following meaning/purpose:
This is the place for bleeding edge tools,libs,... which will probably break some stuff. This could for example be a svn,git.. snapshot of a tool,lib,...
More tested but still not as "stable" released software gets placed here. For example a beta version of a tool,lib,... could be added to unstable.
If a tool,lib,... gets released as "stable" by the developers, we put it into the testing branch.
All tools,libs,... from testing are moved to stable when a new paldo stable version gets released
You can use arbitrary branches in principle, they are just considered even more unstable than experimental.
If you add a package to your testing branch, it will also be available in the "higher" branches ("unstable" & "experimental" in this case). Therefore you don't need to add a <release>...</release> for every branch. Just add one for the "lowest" branch.
 Start compiling and installation
Now you're ready to compile and install your application. The following command will invoke everything:
[root@gandalf:~]# upkg-build gnome-baker Generating script... Writing script... Executing script... The following extra packages will be installed: gnome-baker The following packages will be built from source: gnome-baker Do you want to continue? [Y/n] Building gnome-baker-0.5.0-1 (testing)... [root@gandalf:~]#
If you want to see verbose output, you can pass --verbose to upkg-build:
[root@gandalf:~]# upkg-build --verbose gnome-baker
You should now be able to run your application.
 Log Files of upkg-build
If you want to see, what upkg exactly did, take a look at /var/lib/upkg/logs/PACKAGE-VERSION.log.bz2. In my case I see all the steps upkg took in /var/lib/upkg/logs/gnome-baker-x86-glibc-2.3-gcc-4.0-1-0.5.0-1.log.bz2
 Remove the package again
If you would like to delete the self made package, just run the following command:
[root@gandalf:~]# upkg-remove gnome-baker
This will delete all installed files properly from your filesystem.
 Tips / tricks
- In some cases errors of specific commands are not fatal to the package build and should be ignored. In such situations you can use <cmd check="no">...</cmd> which will ensure, that upkg won't stop if one of the commands fail.
<?xml version="1.0"?> <package name="PACKAGE NAME"> <description>PACKAGE DESCRIPTION</description> <releases> <release version="RLS VERSIONS NUMBER" revision="1" branch="testing"> <deps> <dep name="DEPENDENCY NAME"/> <dep name="DEPENDENCY NAME"/> </deps> <build> <script> <archive name="PACKAGE NAME-$VERSION"> <cmd>./configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc</cmd> <cmd>make -j 2</cmd> <cmd>make install</cmd> </archive> </script> </build> </release> </releases> </package>
 Spec gen
kim88 wrote us a spec gen. This speeds it up: http://upkg.kim88.ch/