Info
Upkg version1.4.0
Packages1144
Package Search

How to apply patches using upkg

written by Nicolas Christener in mar 2006


Abstract

This howto should help you to get a patch applied to a source package using upkg. Upkg is the package management and build system used in the Paldo Linux distribution.

A concrete problem

I have a PCI TV card in my paldo workstation. Unfortunately there is no standalone gnome tv application in the the paldo main repository. (I don't want do use MythTV only for watching TV) Thus I decided to build zapping from source. Sadly I got the following error during "make".

    In file included from io-v4l2k.c:55:
    videodev2k.h:19:46: error: linux/compiler.h: No such file or directory
    make[4]: *** [io-v4l2k.lo] Error 1
    make[4]: Leaving directory `/home/nicolas/temp/zvbi-0.2.19.orig/src'
    make[3]: *** [all-recursive] Error 1
    make[3]: Leaving directory `/home/nicolas/temp/zvbi-0.2.19.orig/src'
    make[2]: *** [all] Error 2
    make[2]: Leaving directory `/home/nicolas/temp/zvbi-0.2.19.orig/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/nicolas/temp/zvbi-0.2.19.orig'
    make: *** [all] Error 2


An easy workaround was to comment out the line, which included linux/compiler.h. However we would like to upload upstream source packages into the paldo repository. That's why upkg is able to apply a patch during the build process. Read on to find out how you can create a patch and apply it to a upkg spec file.

Read the package build howto if you want to get an overview of how upkg works.

Create the diff file

First download the upstream source package of your application and untar/unzip it. I add the suffix ".orig" to the folder and make a copy of the whole folder without this suffix. My directory now looks like:

    [nicolas@gandalf:~/temp]$ ls -la
    [...]
    drwxr-xr-x  9 nicolas users   4096 2006-03-29 17:01 zvbi-0.2.19
    drwxr-xr-x  9 nicolas users   4096 2006-03-29 17:03 zvbi-0.2.19.orig


Now change into the work-folder (the one without the suffix) and fix the bug(s). After this is done. Leave the work-folder and create a diff-file using the diff command. In my example I had to change the file videodev2k.h which could be found in the src folder in my work-folder (zvbi-0.2.19/src/videodev2k.h). Now I created a diff-file using the following command:

    [nicolas@gandalf:~/temp]$ diff -puNr zvbi-0.2.19.orig zvbi-0.2.19 > zvbi-0.2.19-compiler.h-1.patch


Compress the file

Now use bzip2 to compress your patch(es) then copy the original (upstream) source package and the compressed patch file into your repository. My repository folder then looks like:

    [nicolas@gandalf:~/]$ ls -la PaldoRepo/sources/zvbi-0.2/
    [...]
    -rw-r--r-- 1 nicolas users    344 2006-03-29 16:30 zvbi-0.2.19-compiler.h-1.patch.bz2
    -rw-r--r-- 1 nicolas users 722143 2006-03-29 15:55 zvbi-0.2.19.tar.bz2


Inform upkg about the patch

Now create a upkg spec file (as described in the package build howto).
The important part is adding a patch-directive between the archive- tag (<patch name="zvbi-0.2.19-compiler.h-1"/>). As you can see, you dont have to add the ".patch.bz2" suffix. In this case upkg would search for a file called zvbi-0.2.19-compiler.h-1.patch.bz2 and automatically apply it during the build process.

    <?xml version="1.0"?>
    <package name="zvbi-0.2">
          <description>the vertical blanking interval (VBI) library</description>
          <releases>
                  <release version="0.2.19" revision="1" branch="testing">
                          <deps>
                            <dep name="libpng"/>
                          </deps>
                          <build>
                                  <script>
                                          <archive name="zvbi-$VERSION">
                                                  <patch name="zvbi-$VERSION-compiler.h-1"/>
                                                  <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>


Start compiling and installation

Now you're ready to compile and install your application. The patch will automatically be added during this process. The following command will invoke everything:

    [root@gandalf:~]# upkg-build zvbi-0.2
    Generating script...
    Writing script...
    Executing script...
    The following extra packages will be installed:
    zvbi-0.2

    The following packages will be built from source:
    zvbi-0.2

    Do you want to continue? [Y/n]
    Building zvbi-0.2-0.2.19-1 (testing)...
    [root@gandalf:~]#


If you want to see verbose output, you can pass --verbose to upkg-build:

    [root@gandalf:~]# upkg-build --verbose zvbi-0.2


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/zvbi-0.2-x86-glibc-2.4-gcc-4.1-1-0.2.19-1.log.bz2