Differences between revisions 17 and 18
Revision 17 as of 2007-04-18 01:44:26
Size: 6922
Comment:
Revision 18 as of 2007-04-18 01:49:01
Size: 7002
Comment:
Deletions are marked like this. Additions are marked like this.
Line 71: Line 71:
For example, 10_relocate_build , 20_relocate_install, 30_correct_env_variable.

How to split a package into several smaller packages

You want to create multiple binaries packages from one source package.

This page will be worked soon. (TM)

While you wait, please examine the php-java-bridge /debian/* files, as this source package contains many tricks and hints leveraging debhelper scripts and avoiding pitfalls.

Ideas collected from other package sources, discussion lists, Debian Policy, maintainers guide, man pages.

Special attention to /debian/rules and subpackage_name.* files, like php-java-bridge-j2ee.install , php-java-bridge-j2ee.dirs and so on.

Also, see the README.Debian file, containing many hints and instructions.

Please, note that this source package is a dynamic work in progress, constantly evolving. All suggestions are welcome at the users mailing list.

Readings

Splitting a Debian source package into several smaller binary packages is not trivial.

Before you start, you must read the essential guides [1] to [7], [10] to [12] and feeling already comfortable creating single binary packages.

Variables in rules makefile

You must remember that /debian/rules is a makefile, not a shell batch script.

Read the following code:

        BUILDDIR := debian/php-java-bridge
        DESTDIR := ${CURDIR}/${BUILDDIR}
  • Variables MUST be set outside target rules
  • Target rules MUST start at column 1, then followed by ":"
  • Actions MUST start after a TAB, not blank spaces

The BUILDDIR was set to allow use of dh_install for .war files.

The Debian package makefile must be fully relocatable.

The build directory must be at a package tool discretion (usually at some source temporary subdirectory) and must not need root privileges.

For the installation, the destination directory MUST NOT be hard coded into the source.

If the upstream source has hardcoded directories, you must apply patches even before the configure target rule.

You must know the different types of makefile variables reading [20].

The effects of using a simply expanded variable ( := ) or a recursively expanded variable ( = ) are very different in a rules makefile.

At our example we want the simply expanded variable behaviour.

Shell command output into rules makefile

We want also collect some shell command output into some variables. [21]

There are some misconceptions that you should avoid [27].

        PHP_EXT_DIR := $(shell /usr/bin/php-config --extension-dir)
        PHP_INCLUDE_DIR := $(shell /usr/bin/php-config --include-dir)

Leveraging dpatch

dpatch is a clever development tool.

If you must apply some modifications to the upstream code before packaging for Debian, then one of the easiest modes is to use dpatch.

When you execute dpatch in a shell prompt, it opens a session and from now on until you exit the session, all you do will be recorded and converted to a patch for your upstream code into /debian/patches directory.

A good practice is to create small patches with clear, self explanatory and different names. For example, 10_relocate_build , 20_relocate_install, 30_correct_env_variable.

You must read the dpatch man page.

The following code snippet will apply the patches to source, walking through all patches into /debian/patches directory in the ascendant patchnamefile order.

And then stamp the configure step.

configure: patchsource configure-stamp

patchsource: patch-stamp

patch-stamp:
        dpatch apply-all
        dpatch cat-all >patch-stamp

configure-stamp:
        dh_testdir
        phpize
        ./configure --with-java=/usr/lib/jvm/java-1.5.0-sun --prefix=${DESTDIR}
        touch configure-stamp

Cleaning and deapplying patches

You must have a clean rule. Also, if you applied patches, you must deapply them in reverse order.

The dpatch helper will take care of this if you created the patches in a planned naming convention.

clean: clean-patched unpatch

clean-patched:
        dh_testdir
        dh_testroot
        rm -f build-stamp configure-stamp
        -$(MAKE) clean
        dh_clean 

unpatch:
        dpatch deapply-all
        rm -rf patch-stamp debian/patched

(to be continued)

http://lists.debian.org/debian-mentors/2007/04/msg00031.html