[buildd-tools-devel] Bug#610689: sbuild: cross support

Wookey wookey at wookware.org
Wed Dec 7 20:17:27 UTC 2011


I'm looking at adding multiarch-style cross-building support to sbuild.

I've taken the work done in this bugrep so far (thanks to hector and
Roger for that), which essentially makes sbuild BUILD/HOST aware andd
the xapt resolver, and moved that forward to the current 0.62.5 sbuild
release.

However, the procedure for multiarch crossbuilding is not the same as
for xapt+dpkg-cross, so we need some slightly different changes.

Essentially what needs to happen is:

0) get a chroot containing the usual build-essential stuff

1) Install cross-tools. (A build-essential-$arch package would be
useful for this, to gloss over variations between distros and changes
over time, but in the meantime we know what want and can add the
packages to the config in $core-depends)
this means: g++-arm-linux-gnueabi libc6-dev-armel-cross

1b) ensure that arm-linux-gnueabi-pkg-config wrapper link exists (will
come with toolchain if toolchain is new enough)

1c) Add qemu-static support to chroot. Best done by schroot?

2) Configure dpkg for multiarch:
add 
foreign-architecture armel
to /etc/dpkg/dpkg.cfg.d/multiarch

3) configure a $arch source for apt: in /etc/apt/sources.list.d/foo
deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports oneiric main universe

4) to resolve the dependencies we need to run 
apt-get build-dep -aarmel $package 
instead of 
apt-get build-dep $package

5) Do the build by setting some environment variables:
'CONFIG_SITE' => '/etc/dpkg-cross/cross-config.$host_arch'
'DEB_BUILD_OPTIONS' => 'nocheck'
'DH_VERBOSE' => '1'
(easily done by setting $build_environment in config)
and run dpkg-buildpackage -aarmel 


So, all of this is straightforward in principle, but I'm not familiar
with sbuild internals so it's not clear to me what the best method
might be in each case.

1) seems easy enough. Add needed packages to add-depends. To write a
generic config needs some way to set $DEB_HOST_GNU_TYPE in the config
file. Does such functionaility exist already? We have $host_arc, which
could be set to 'armel', but then somewhere we need to do
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE -a$host_arch
to get arm-linux-gnueabi.

Does sbuild do any of this already? If not where might be a good place?

1b) needs a little script to be run. Along the lines of
if [ ! -L /usr/bin/${host_triplet}-pkg-config ]; then
 ln -s /usr/share/pkg-config-crosswrapper ${host_triplet}pkg-config
fi
We have chroot-setup-commands
which can presumably run any command which already exists in the
chroot, but doesn't look like it lends itself to little scripts like
that, so the chroot would have to be pre-populated with a suitable
script?

Same considerations apply to 2 and 3. chroot-setup-commands and
pre-build-commands don't look like they support commands of the form
echo foo > file

Can these scripts be supplied by sbuild (in the same way that pbuilder
hook-scripts are), or do they need to come from somewhere else? If the
latter can they be in a package specified by add-depends or do those
get pulled in too late?

4) I thought this would be a simple matter of adding -a$host_arch in
lib/Sbuild/AptResolver.pm but it doesn't run apt-get build-dep
directly, it just installs sbuild-build-depends-foo-dummy which has
been prepared elsewhere. ResolverBase seems to generate this but
nowhere does apt-get build-dep seem to get run so I'm not quite sure
where to go poking. 

Clues welcome. 

5) I think this can be done by just adding 
$debbuildopt = '-a$host_arch' to the config
should if there is a better way.

I'm happy to go prodding about but if there are obvious 'right ways'
to do these things then direction is very welcome.

Wookey
-- 
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/





More information about the Buildd-tools-devel mailing list