CrossCompile

Differences between revisions 8 and 9
Revision 8 as of 2014-04-02 22:27:22
Size: 1398
Editor: 209-6-88-107
Comment: added a note how to disable sbuild's build-log email feature
Revision 9 as of 2014-06-03 10:28:40
Size: 3164
Editor: xnox
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Trusty click chroot == == One-time setup ==
Line 3: Line 3:
TODO {{{#!sh
$ 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.
Line 5: Line 12:
== Trusty sbuild chroot ==

One time setup:
== Building the package ==
Build the package:
Line 9: Line 15:
$ mk-sbuild --skip-proposed --target armhf trusty $ sbuild -A -d utopic --host armhf package*.dsc
Line 12: Line 18:
Build the package:
{{{#!sh
$ sbuild -A -d trusty --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:

{{{#!perl
# 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;
Line 17: Line 40:
'''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.  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)
 1. setting distribution makes that distribution the default, thus no need to pass `-d utopic` all the time
 1. build_arch_all / build_arch_any makes sure that _all.deb and _arch.deb packages are build, thus no need to pass `-A` option
 1. resolve_alternatives makes sure that alternative build-dependencies are resolved, instead of always taking just the first one
 1. 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.
 1. 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)
Line 19: Line 50:
== Saucy chroot ==
Here is a quick how-to, cross-compiling with cmake to build a qml extension.
With above tricks, one can build packages with simply:
Line 23: Line 53:
# Create chroot with cross-compiler
$ mk-sbuild --target armhf --name cmake saucy
$ sudo schroot -c source:cmake-amd64-armhf -u root
$ sbuild --host armhf *.dsc
}}}
Line 27: Line 56:
# Install build-dependencies
$ apt-get install libqt5svg5-dev:armhf libqt5v8-5-dev:armhf libqt5xmlpatterns5-dev:armhf qt3d5-dev:armhf qtbase5-dev:armhf qtdeclarative5-dev:armhf qtscript5-dev:armhf qtsensors5-dev:armhf qttools5-dev:armhf
$ apt-get install cmake
== Common resolutions ==
Line 31: Line 58:
# Change into your sources
$ cd src/
$ mkdir armhf-build
$ cd armhf-build
 1. Build-Depend on "python3:any"
 1. Multi-arch all of your libraries
 1. 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)
Line 36: Line 62:
# Prepare environment
$ export $(dpkg-architecture -aarmhf)
$ export CMAKE_TOOLCHAIN_FILE=/etc/dpkg-cross/cmake/CMakeCross.txt
== If you have questions ==
Line 40: Line 64:
# Build
$ cmake ../

# Fix up paths to moc
$ find . -name AutomocInfo.cmake | xargs sed -i 's;AM_QT_MOC_EXECUTABLE .*;AM_QT_MOC_EXECUTABLE "/usr/lib/'$DEB_BUILD_MULTIARCH'/qt5/bin/moc");'

$ make
$ find . -name '*.so'
}}}
 Ping Saviq, xnox, or just ask on #ubuntu-devel

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;
  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)

  2. setting distribution makes that distribution the default, thus no need to pass -d utopic all the time

  3. build_arch_all / build_arch_any makes sure that _all.deb and _arch.deb packages are build, thus no need to pass -A option

  4. resolve_alternatives makes sure that alternative build-dependencies are resolved, instead of always taking just the first one
  5. 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.

  6. 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

  1. Build-Depend on "python3:any"
  2. Multi-arch all of your libraries
  3. 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)

If you have questions

  • Ping Saviq, xnox, or just ask on #ubuntu-devel

Touch/CrossCompile (last edited 2016-03-22 06:51:23 by localhost)