CrossCompile
One-time setup
$ sudo apt-get install ubuntu-dev-tools $ mk-sbuild --skip-proposed --target armhf utopic
Replace "utopic" by appropriate target distribution. If you are missing packages, mk-sbuild on first invocation will install them and add your user account to the right group. If that happens, you may need to relogin & rerun above command. Run mk-sbuild for each distribution series you want to target.
Building the package
Build the package:
$ sbuild -A -d utopic --host armhf package*.dsc
Note - you may want to use -n to disable sbuild's automatic build log email feature which is enabled by default, but usually not properly configured. See man sbuild for more information.
Tips & Tricks
In ~/.sbuildrc one can set a few options:
# Mail address where logs are sent to (mandatory, no default!)
$mailto = '';
# We develop $dev
$distribution = "utopic";
# Build arch all packages
$build_arch_all = 1;
# Build arch any packages
$build_arch_any = 1;
# Resolve | Other packages
$resolve_alternatives = 1;
$build_environment = { 'NO_PKG_MANGLE' => '1', 'DEB_BUILD_OPTIONS' => 'parallel=12', 'HOME' => '/build/' };
$run_lintian = 1;
# don't remove this, Perl needs it:
1;mailto setting makes sure no emails are sent-out by sbuild, which is typically what one wants on a dev machine. (thus no need to pass -n option)
setting distribution makes that distribution the default, thus no need to pass -d utopic all the time
build_arch_all / build_arch_any makes sure that _all.deb and _arch.deb packages are build, thus no need to pass -A option
- resolve_alternatives makes sure that alternative build-dependencies are resolved, instead of always taking just the first one
- build_environment settings allow doing fancy things:
NO_PKG_MANGLE -> do not generate -dbgsym packages, do not run PNG/SVG optimisations, do not strip translations (these are typically done in launchpad for main packages, but are time consuming and not needed on local builds)
DEB_BUILD_OPTIONS -> set various DEB_BUILD_OPTIONS see Debian Policy for available flags, but e.g. parallel=X makes builds parallelized, "nocheck" skips running unit tests, "nostrip" keeps debug symbols on all binaries
HOME -> by default mk-sbuild sets $HOME to a non-existing directory, but on launchpad, $HOME is set to /build/ which does exist and is writable. So this makes local sbuild match launchpad's one more closely.
run_lintian -> executes lintian against generated packages at the end of the build, using that distribution's lintian (e.g. utopic's lintian when building in utopic chroot)
With above tricks, one can build packages with simply:
$ sbuild --host armhf *.dsc
Common resolutions
If you need python3 interpreter -> Build-Depend on "python3:any"
- Multi-arch all of your libraries
- Make sure that your builds pass without building/running test-suite (as during cross-compilation it will not be possible to execute e.g. compiled test binaries)
- At the moment, it's not possible to cross-compile and generate gobject bindings (gir-* packages)
If you have questions
- Ping Saviq, xnox, or just ask on #ubuntu-devel