Handhelds.org - Open source for handheld devices

UserPreferences

BuildingIpkgs


Building ipkgs

Here's a short and incomplete guide to building packages for the Ipkg package management system:

Before you start, make sure you have the latest ipkg-utils. As of May, 2004, they're available at ftp://ftp.handhelds.org/packages/ipkg-utils

  1. Create the directory structure and files as you want them appear on the installed system.

  2. Create a directory named CONTROL at the top-level of this directory structure.

  3. Inside CONTROL create a file named "control" with lines of the form "Field: value". Required fields are Package, Version, Architecture, Maintainer, Section, Priority and Description. Optional fields include Depends. The meaning of each of the fields will be given later in this document.

  4. If your package has any configuration files, then create a file CONTROL/conffiles which lists the absolute path of each configuration file, (as it will appear on the installed system), one per line. This will prevent the package management system from automatically overwriting configuration changes when the user upgrades the package.

  5. If needed your package may include some scripts that will be invoked by the package maintenance system. There are four possible times a script will be run: just before your package is installed, just after your package is installed, just before the package is removed, and just after the package is removed. These scripts are named preinst, postinst, prerm, and postrm and should be located in the CONTROL directory. The scripts should return 0 on success, (a non-zero return value from preinst will prevent your package from being installed -- this can be useful in rare situations). The scripts can assume a tty is available so they may prompt the user. Note that the variable PKG_ROOT is set to the root of the package installation and can be used to refer to the packages contents in their installed locations.

  6. Now simply run:

     ipkg-build directory [destination_directory]
    
    where directory is the directory you have created. The destination_directory is optional and defaults to the current directory. The ipkg-build script peforms several sanity checks on the package directory and should guide you through any problems.

If you are not running ipkg-build as root, then provide the -g and -o options:

ipkg-build -o root -g root directory  [destination_directory]

Here is an example control file which you may use as a template:

Package: foo
Priority: optional
Version: 0.0
Architecture: arm
Maintainer: Familiar User <user@somehost.net>
Depends: libc6, grep
Description: foo is the ever-present example program -- it does everything
 foo is not a real package. This is simply an example that you
 may modify if you wish.
 .
 When you modify this example, be sure to change the Package, Version,
 Maintainer, Depends, and Description fields.

The meaning of the various fields in CONTROL/control is as follows:

Also, if your package provides a user-level program, then you should add a menu entry for that program. The top-level menu entries are defined at http://familiar.handhelds.org/policy/menu.html while instructions for adding a menu entry to a program can be found at http://www.handhelds.org/~nelson/menu/

Note (ArBor): There are special actions for BuildingIpkgsFor5600

You can also build an ipkg package from the source tarball using ipkg-buildpackage. This is very similar to dpkg-buildpackage from Debian.

You will find an example rules file in the CVS repository of ipkg.

If you need to change file ownerships when installing, you should run this with fakeroot (1) or as root.

If all went well, you will find a diff file and an *.ipk file in the directory above. If you distribute the ipkg file, you should make the diff available as well, so that others can learn from it, or build packages themselves if something has changed.

JukkaSantala adds:

As of sometime now, an extra header titled "Section:" is required on ipkg control files. Valid values are admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web and x11. In addition, to do this work on another machine, you should check out the scripts at familiar/dist/ipkg on the handhelds.org CVS with CVSROOT :pserver:anoncvs@anoncvs.handhelds.org:/cvs and password anoncvs

Gonz adds:

A common mistake is to depend on a specific version of a single package. This leads to users which are unable to install the ipk, because they have a newer version of either the package itself or a package which provides this pkg. A well known example is not beeing able to install some qpe packages which need qpe-base(1.5.0).

quoted from irc:

 kergoth    spiralman: the problem is.. some packages still fail because 
            said packages Depends on qpe-base(1.5.0) specifically
 spiralman  oh, thats a bitch...
 kergoth    spiralman: and we could not and should not be able to Provide a 
            specific version.. because we obviously are not that version.
 kergoth    spiralman: really, said packages are broken and should Depend 
            on qpe-base (1.5.0+) or something similar

MikEw: see also SteveRedler's section on building .ipk files.