PackageBuildingHowTo

Note: Reading and understanding the following description is important to gain process knowledge, however nowadays the preferred method to package software is to write a .oe file for usage with the OpenEmbedded build system.

For windows users, there is a well written Guide on how to build or modify .ipk packages under windows.

= Software Requirements =
 * A Linux computer or a PDA running Linux
 * tar
 * gzip
 * ar (optional)
 * A text editor

= Structure of an .ipk file = An .ipk file is a tar.gz or ar compressed archive containing two .tar.gz compressed files and one text file:
 * control.tar.gz
 * data.tar.gz
 * debian-binary

= The Content of control.tar.gz = The control.tar.gz contains all meta-data required for the installation of the .ipk archive. The main component is the control ACSII text file. A typical control file looks like this: Package: mhconf2 Source: mhconf2 Version: 0.0.1-7 Section: base Priority: optional Maintainer: Matthias Hentges  Architecture: arm Depends: bash Installed-Size: 67703 Description: ssh, WLAN and ppp configuration

== All fields in detail: == Custom built packages should always be optional.
 * Package: This is the name of the package.
 * Source: FIXME: what does source do?
 * Version: The full version number of the package
 * Section: (optional) Describes the Section the package is placed in.
 * Priority: The priority of the package. Valid entries are required, standard, important, optional, and extra.
 * Maintainer: (optional) The person responsible for the package.
 * Architecture: The required CPU for the package.
 * Depends: The dependencies of the package. Programs listed here must be present to install this package.
 * Installed-Size: (optional) The space beeing used if the package is installed.
 * Description: A short text describing the function of the package.

Beside control there can be a few other files in control.tar.gz:
 * postinst: This is a script which is run after the package has been installed.
 * postrm: This is a script which is run after the package has been removed.
 * preinst: This script is run before the package is installed.
 * prerm: This script is run before the package is removed.

= The Content of data.tar.gz = This archive contains all files which will be installed by the package with absolute path. ./ ./etc/ ./etc/ssh/ ./etc/ssh/ssh_host_dsa_key.pub ./etc/ssh/ssh_host_rsa_key.pub ./etc/ssh/ssh_host_key ./etc/ssh/ssh_host_key.pub ./etc/ssh/ssh_host_dsa_key ./etc/ssh/ssh_host_rsa_key ./etc/ppp/ ./etc/ppp/peers/ ./etc/ppp/peers/d2gprs ./etc/ppp/peers/d2gsm [...]

= The Content of debian-binary = The answer this time is not 42, it's 2.0. No, really. The file just contains the string 2.0 FIXME: why do we need this file?

= Building an example .ipk containing our ssh keys = cd /tmp/ipkg mkdir CONTROL mkdir DATA mkdir IPK
 * 1) First change to some temporary directory like /tmp/ipkg
 * 2) Then create the required directory tree:

cd DATA tar -cvzf data.tar.gz *
 * Now copy the directories /root/.ssh and /etc/ssh from your PDA to /tmp/ipkg/DATA. Remember to copy the directories, and not just the files within!
 * It's time to create data.tar.gz:

Package: mysshkeys Source: mysshkeys Version: 0.0.1-0 Section: base Priority: optional Maintainer: YOUR NAME  Architecture: arm Description: My ssh keys
 * Create a control file in /tmp/ipkg/CONTROL with the following content:

cd /tmp/ipkg/CONTROL tar -cvzf control.tar.gz *
 * Create control.tar.gz

cd /tmp/ipkg/IPKG tar -cvzf mysshkeys_0.0.1-0_arm.ipk data.tar.gz control.tar.gz debian-binary
 * Create debian-binary:
 * Copy data.tar.gz and control.tar.gz into /tmp/DATA/IPKG, then build the .ipk with

It is a good idea to follow the naming convention for .ipk files which is: $NameOfPackage_$Version_$Architecture.ipk

The result of our work is a shiny new .ipk in /tmp/ipkg/IPKG which can be installed onto every PDA using the ipkg package management tools.