Cómo crear un paquete

From Paldo

Jump to: navigation, search

Contents

[edit] Traducciones

[edit] Cómo crear un paquete usando upkg (el sistema de paquetes de paldo)

escrito por Nicolas Christener en Ene 2006

[edit] Abstract

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

[edit] Un problema concreto

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.

[edit] Crear un repositorio Paldo local

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>

[edit] Obtener el código fuente

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

[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] Cómo Paldo maneja las ramas

Paldo conoce cuatro ramas diferentes:

  • experimental
  • unstable (inestable)
  • testing (de prueba)
  • stable (estable)

Ellas tienen el siguiente propósito:

[edit] experimental

Este es el lugar para libs, herramientas, ... de vanguardia que probablemente rompan alguna cosa. Por ejemplo, esto podría ser un svn, git... instantánea de una herramienta, lib, ...

[edit] unstable

Aquí se ubica un software más probado pero aún no tan estable. Por ejemplo, una versión beta de una herramienta, lib, ... podría agregarse a inestable.

[edit] testing

Cuando los desarrolladores liberan como estable una herramienta, lib, ... la ponemos en la rama de prueba.

[edit] stable

Todas las herramientas, libs, ... se mueven de prueba a estable cuando se libera una nueva versión de paldo.

You can use arbitrary branches in principle, they are just considered even more unstable than experimental.

Si agrega un paquete a su rama de prueba, también estará disponible en las ramas "más altas" ("unstable" & "experimental" en este caso). Por lo tanto, no necesita agregar <release>...</release> para cada rama. Solamente agregue una para la rama "más baja".

[edit] Comenzar la compilación e instalación

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] Archivos de registro de upkg-build

Si quiere ver lo que upkg hizo exactamente, eche un vistazo a /var/lib/upkg/logs/PACKAGE-VERSION.log.bz2. En mi caso, veo todos los pasos que upkg realizó en /var/lib/upkg/logs/gnome-baker-x86-glibc-2.3-gcc-4.0-1-0.5.0-1.log.bz2

[edit] Eliminar los paquetes nuevamente

Si desea eliminar un paquete realizado por Ud mismo, basta con que ejecute el siguiente comando:

    [root@gandalf:~]# upkg-remove gnome-baker

Esto eliminará todos los paquetes instalados correctamente en su sistema de archivos.

[edit] Consejos/trucos

  • En algunos casos, los errores de comandos específicos no son fatales para la creación del paquete y se deberían ignorar. En tales situaciones se puede usar <cmd check="no">...</cmd> que asegurará que upkg no se detendrá si falla uno de los comandos.

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

[edit] Spec gen

kim88 wrote us a spec gen. This speeds it up:

Personal tools