Subject: sbuild, crossbuilds, and Mir [1/3]: sbuild setup

From: Robert Carr <[email-masked]>
Date: Fri, 19 Sep 2014 11:02:19 -0700

Hi all!

I've been investigating sbuild for a crossbuild workflow for Mir.
Accumulated some hacks, secret env variables, etc...and just want share the
tips and tricks. In the end, this makes it possible to do reproducible full
stack (mir, usc, qtmir [once cmake lands...]) cross-compiled mir builds for
testing/development purposes in under 10 minutes!

I'd like to collect all this information in a wiki format, or consolidate
it all in one tool! Heres a first dump though.

This first email is on the basic sbuild setup!

The short story is this is what you want:
https://wiki.ubuntu.com/SimpleSbuild

Follow the "Creating the chroots" steps, careful to replace trusty with
utopic. At the step "mk-sbuild trusty" use "mk-sbuild --target=armhf
utopic".. If you have more than 4 gigs of ram or so I recommend setting up
the shm overlays step.

To build mir in this chroot we first have to work around an issue with
explicit G++ dependencies (
https://wiki.debian.org/CrossTranslatableBuildDeps). There is no solution
with the current dpkg chain so we have to break the explicit 4.9 dep...this
could cause issues with this work-flow around G++ release time.

$ src/mir: sed "/g++-4.9/d" debian/control
$ src/mir: bzr bd -S --native -- -uc -us (generate source, from source
tree, pass uc and us to debbuild to skip signing)

This will generate a source package (../FOO.dsc), which can be built by
sbuild:

DEB_BUILD_OPTIONS=nocheck sbuild --build=amd64 --host=armhf -j5 <FOO.dsc>

In order to avoid accidentally committing this change to debian control,
and to support other options in preparing the source package (e.g....dont
build tests to save time), I've been using a small script (called bs, for
build-source):

http://pastebin.ubuntu.com/8381485/

This way you can cross compile a branch in just a few steps:
bzr branch lp:mir/devel
bs devel
DEB_BUILD_OPTIONS=nocheck sbuild --build=amd64 --host=armhf -j5 *.dsc

It will still take quite some time though! Next email will discuss some
optimizations.