This feed contains the 10 most recent pages in the "debian" category.

It seems there's an annoying fault in dpkg-buildpackage, it doesn't support build-arch and build-indep in the file debian/rules. This blog entry talks about an easy way to solve this.

It seems there's an annoying fault in dpkg-buildpackage, it doesn't support build-arch and build-indep in the file debian/rules. Even when given the options to create architecture dependent binary packages only (-B) or architecture independent packages only (-A), it still insists on using the build target.

People have been annoyed at this for quite a while, considering there are a number of bug reports that have still not been resolved although this has been around for years (See bugs #218893 and #229357, but also more recently, #604397).

Debian Policy Manual, section 4.9 (debian/rules) seems to say, however, that it's perfectly acceptable to have the package built via binary / binary-indep / binary-arch:

For some packages, notably ones where the same source tree is compiled in different ways to produce two binary packages, the build target does not make much sense. For these packages it is good enough to provide two (or more) targets (build-a and build-b or whatever) for each of the ways of building the package, and a build target that does nothing. The binary target will have to build the package in each of the possible ways and make the binary package out of each.

Unfortunately, those targets are run via fakeroot, which is not recommended for configure, and sometimes not build building or testing.

So, how to solve that? There are some convoluted half ass ways to resolve this, but can it be made cleaner? Here's my attempt, entirely based on using debhelper and the script dh.

In debian/rules, disable the build target entirely, by having this as early as possible (and most definitely before the % target that's usually seen in a debian/rules that uses the command dh):

build:
    @echo 'The build target is disabled, please use the appropriate binary target.'

Add the script nofakeroot in the debian/ directory, and don't forget to make it executable. Here's what the script looks like:

#! /bin/sh

# Usage:
#   nofakeroot [command ...]
#
# Runs command after removing any trace of fakeroot from the environment it
# receives.

my_PRELOAD=
for l in $LD_PRELOAD; do
    if ! echo $l | grep "libfakeroot[-a-z]*\\.so" > /dev/null; then
    if [ -n "$my_PRELOAD" ]; then
        my_PRELOAD="$my_PRELOAD $l"
    else
        my_PRELOAD="$l"
    fi
    fi
done

was_IFS="$IFS" IFS=:
my_LIBRARY_PATH=
for p in $LD_LIBRARY_PATH; do
    if ! echo $p | grep "/libfakeroot\$" > /dev/null; then
    if [ -n "$my_LIBRARY_PATH" ]; then
        my_LIBRARY_PATH="${my_LIBRARY_PATH}:$p"
    else
        my_LIBRARY_PATH="$p"
    fi
    fi
done
IFS="$was_IFS"

LD_PRELOAD="$my_PRELOAD" LD_LIBRARY_PATH="$my_LIBRARY_PATH" eval "$@"

Finally, add a few overrides in debian/rules:

override_dh_auto_configure:
    debian/nofakeroot dh_auto_configure

override_dh_auto_build:
    debian/nofakeroot dh_auto_build

override_dh_auto_test:
    debian/nofakeroot dh_auto_test

The entire debian/rules looks like this:

build:
    @echo 'The build target is disabled, please use the appropriate binary target.'

%:
    dh $@

override_dh_auto_configure:
    debian/nofakeroot dh_auto_configure

override_dh_auto_build:
    debian/nofakeroot dh_auto_build

override_dh_auto_test:
    debian/nofakeroot dh_auto_test

Posted Feb 26, 2011 9:38:52 AM +0100 | Tags: debian

To see all of them, check the archive-debian.

blog comments powered by Disqus