wiki:Packages

Packages

This page describe how to create and patch packages in SHR.

As SHR is based on OpenEmbedded, SHR use bitbake to produce package. Bitbake use its own build concept and its own terminology, so the first term you must know is recipe. Recipe, in bitbake words, is a file that describe how to retrieve source code and produce one or more packages with this one. On some points, it can be compared with packages Makefiles in OpenWrt, ebuilds in Gentoo, etc.

First you must have a good setup, see Building SHR.

Create package

This section explain how to package an non-existing application/library in SHR.

Move to recipes folder:

cd shr-unstable/openembedded/recipes

Create a directory named like your application and move to, ie. pcsc-tools:

mkdir pcsc-tools && cd pcsc-tools

Create a new file named application-name_version.bb, ie. pcsc-tools_1.4.15.bb which contains:

DESCRIPTION = "PC/SC Lite smart card framework and applications"
HOMEPAGE = "http://ludovic.rousseau.free.fr/softwares/pcsc-tools/"
LICENSE = "GPL-2"

DEPENDS = "pcsc-lite"

SRC_URI = "http://ludovic.rousseau.free.fr/softwares/pcsc-tools/pcsc-tools-${PV}.tar.gz"

inherit autotools

PACKAGES = "pcsc-scan"

FILES_pcsc-scan = "${base_bindir}/pcsc_scan"

All theses fields, and a lot more, are described in the  Recipes chapter of  OpenEmbedded documentation. But there are some points you must care:

  • DEPENDS must list application/library dependencies using bitbake recipe name, not individual package. (ie. if your application, like pcsc-tools, depends on libpcsclite which is produce by pcsc-lite recipe, you must put pcsc-lite in DEPENDS and NOT libpcsclite.)
  • If your application/library use a simply Makefile, it should be simpliest to inherit autotools even there are no autotools related files.

Patch existing package

This section explain how to patch a already existing package in SHR.

As concret example, we will patch libusb package to add 2 patches (first will make libusb use packed structures and second will make libusb use ANSI types).

Move to application recipe folder, ie. libusb:

cd shr-unstable/openembedded/recipes/libusb

Put your patches into files/ subdir:

mv /tmp/libusb-packed-struct.patch files/
mv /tmp/libusb-ansi-types.patch files/

Note: The step is required only if your modifications need externals patches. If you just want to enable/disable configuration script option, you don't need to put any files there, of course.

In case of using external patched: edit your application recipe (ie. libusb_0.1.12.bb) to tell bitbake to apply your patches:

...
SRC_URI = "${SOURCEFORGE_MIRROR}/libusb/libusb-${PV}.tar.gz \
          file://configure_fix.patch;patch=1"
SRC_URI_append_shr = "\
                file://libusb-packed-struct.patch;patch=1 \
                file://libusb-ansi-types.patch;patch=1"
...

Warning: SRC_URI and SRC_URI_append_shr will be concatenate at build time without putting any whitespaces between two variables, so please don't forget to put a whitespace (' ') or better, start with newline ("\").

In any others cases, just modify the recipe.

Now, you need to test package building. To do that, you need to use bitbake like this:

bitbake -c clean -b libusb/libusb_0.1.12.bb
bitbake -c build -b libusb/libusb_0.1.12.bb

Once you have a succefully build package this way, you need to test package building again with the whole repository. It will calculate dependencies, so it can be long:

cd ../..
# you are now in shr-unstable top dir.
bitbake -c clean libusb && bitbake -c build libusb

Done.

Tips

This section provide some useful tips related to packaging software.

If you want your newly packaged application to be referenced in packages index, simply do (in top directory):

bitbake package-index

If you want to package a new version of an application/library which is already packaged and if corresponding recipe is well written, you can just copy bitbake recipe. ie. if myapp_0.1.bb exists and you want to package myapp 0.2:

cp myapp/myapp_0.1.bb myapp/myapp_0.2.bb

Be sure that source uri is correct and PR (Package Release) variable doesn't exist or is set at PR = "r0" in bitbake recipe.

Have fun !