HowtoBuildPackage (français)

From Paldo

Jump to: navigation, search

Article pas complètement traduit

Contents

[edit] Traduction

[edit] Comment créer un paquet source avec upkg (le gestionnaire de paquets de paldo)

écrit par Nicolas Christener en janvier 2006

[edit] Résumé

Ce document devrait vous aider à obtenir un paquet source créé avec upkg. Upkg est le gestionnaire et créateur de paquets utilisé par la distribution Linux Paldo.

[edit] Problème concret

J'aime la philosophie de Paldo qui est d'avoir un seul programme pour chaque tâche. Mais je ne veux pas installer k3b (et ses dépendances) pour faire une seule copie d'un CD. J'ai donc vérifié la disponibilité de Gnome Baker dans le repository de Paldo. Et malheureusement, Gnome Baker n'est pas dans le répo principal. J'ai donc décidé de compiler Gnome Baker à partir des sources. Comme je veux un système propre, je ne veux pas juste faire ".configure, make et make install". Ce serait mieux d'installer les binaires, la documentation... avec le gestionnaire de paquets après la compilation. Ce texte explique comment faire un paquet.

[edit] Créer un répo Paldo local

Avant tout nous devons créer un répertoire où tous les paquets sources arriveront. L'endroit où vous le mettez n'a aucune importance. J'ai mis le mien dans mon répertoire personnel:

    [nicolas@gandalf:~]$mkdir PaldoRepo
    [nicolas@gandalf:~]$mkdir PaldoRepo/binaries
    [nicolas@gandalf:~]$mkdir PaldoRepo/sources
    [nicolas@gandalf:~]$mkdir PaldoRepo/specs

Maintenant nous devons informer upkg du nouveau répo local. Ouvrez /etc/upkg.conf en root et ajoutez votre répo. Le contenu de ce fichier devrait ressembler à cela:

    <?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>

[edit] Récupérer les sources

Maintenant téléchargez le code source de l'application que vous voulez installer. Dans mon cas j'ai téléchargé le fichier source tarball sur http://gnomebaker.sourceforge.net/. Upkg a besoin que la source soit un tar (fichier tar), ou un fichier tar.bz2 (fichier tar compressé). Merci de vérifier que le fichier source est dans un format supporté, copiez le et déplacez le dans le répertoire sources de votre répo. Faites attention que le fichier ait le même nom que vous voudrez utiliser plus tard dans le nom du paquet. Voir <package name>-tag dans le fichier spec au chapitre suivant.

  upkg ne trouvera les sources du paquet que si vous les sauvegardez dans $REPODIR/sources/$PACKAGENAME

a traduire

  [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">

[edit] 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 --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>

Most parts of this file are self describing. I think I just need to describe the dep-fields. 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 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:

  • glibc
  • gcc
  • binutils
  • make
  • coreutils
  • bzip2
  • gzip
  • patch
  • tar
  • bash

You don't need to mention this dependencies because those packages are installed on every paldo installation.

[edit] How Paldo handles branches

Paldo knows four different branches:

  • experimental
  • unstable
  • testing
  • stable

They have the following meaning/purpose:

[edit] experimental

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,...

[edit] unstable

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.

[edit] testing

If a tool,lib,... gets released as "stable" by the developers, we put it into the testing branch.

[edit] stable

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.

[edit] 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.

[edit] 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

[edit] 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.

[edit] 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.

[edit] Spec-Template

  <?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>
Personal tools