Package Forking

From RockWiki

Jump to: navigation, search

NOTE: This is not the same as Package Splitting!

Package forking is a mechanism introduced during the development of ROCK 2.1 and is meant to reduce the overhead of having several packages for different versions of a program. The most prominent program of this kind of behaviour is the Linux kernel which had the following packages:

  • base/linux24
  • base/linux24-src
  • base/linux24-header
  • base/linux26
  • base/linux26-src
  • base/linux26-header

All of these versions are now maintained within a single package:

  • base/linux

This has several advantages:

  • In the package selection you just have to add O linux and the Linux kernel would be disabled in all versions and forms.
  • Reduction of code duplication. Every package used to have the same .conf file or at least sourced the "original" .conf file. This is now only one file.
  • Reduction of information duplication. Every package had the same [I] [T] [U] [V] and other tags.
  • Ease of maintenance. Updating these packages now only needs updating a single file instead of three or more.

This made a change in package naming necessary. Packages used to be addressed by the directory they were contained in. For example:

  • package/base/linux24-header became linux24-header
  • package/blindcoder/wesnoth became wesnoth

When suddenly several packages could be contained in a single directory this was no longer possible. Thus the xpkg variable was introduced. It holds the forked packages name and is passed with the package name: pkg=xpkg. Examples:

  • Linux kernel version 2.4 is contained in package/base/linux and addressed as linux=linux24
  • Linux kernel version 2.6 is contained in package/base/linux and addressed as linux=linux26
  • Automake version 1.8 is contained in package/base/automake and addressed as automake=automake-1.8
  • Wesnoth is not split and can be addressed as wesnoth or wesnoth=wesnoth

The part after the equal sign '=' is put into the variable xpkg. If there is no equal sign '=' then xpkg defaults to the value of pkg.

Contents

Using package forking

Package forking is made up of two parts:

  • Conditional .desc files
  • handling of $xpkg

Conditional .desc files

This is an extension of the Desc file syntax. It adds conditions to the .desc file that are quite similiar to the C Preprocessor Syntax. For example:

#if xpkg == linux24.*
[V] 2.4.28
[D] 83818766 linux-2.4.28.tar.bz2 https://www.kernel.org/pub/linux/kernel/v2.4/
#endif

#if xpkg == linux26.*
[V] 2.6.9
[D] 1893071861 linux-2.6.9.tar.bz2 ftp://ftp.kernel.org/pub/linux/kernel/v2.6/
[D] 1816344469 patch-2.6.9-pa0.gz https://cvs.parisc-linux.org/download/linux-2.6/
#endif

In this case the [V] and [D] are initialised with different values for the linux24 and linux26 packages. These conditions have also to be taken into account in the .conf file if applicable.

Handling of $xpkg

If different forked packages need different treatment by the ROCK build process you must also check for $xpkg in the packages .conf file.

Adding the forked packages in preconfig.in

For packages without a custmain, the forked packages must be added to the package selection. This can be done in a file called preconfig.in. The following examples adds all forked automake packages to the package selection.

if pkgcheck automake X
then
        pkgfork automake automake17
        pkgfork automake automake18
        pkgfork automake automake19
        pkgremove automake
fi

Now the packages automake17, automake18 and automake19 will be found by scripts/Download and scripts/Build-Pkg scripts.

Personal tools