| 1 | Emdebian Bootstrapping |
|---|
| 2 | ====================== |
|---|
| 3 | |
|---|
| 4 | Cross-building can get very confusing at times. The confusion only increases |
|---|
| 5 | when dealing with a chroot. This document tries to cover some of the reasons, |
|---|
| 6 | some of the problems and tries to provide some clarity, at least as far as how |
|---|
| 7 | chroots can be used in Emdebian. |
|---|
| 8 | |
|---|
| 9 | There are multiple ways that Emdebian can relate to bootstrapping and chroots. |
|---|
| 10 | The most common method of using a chroot within Debian is pbuilder and the |
|---|
| 11 | pdebuild wrapper and this is the primary inspiration for using chroots in |
|---|
| 12 | Emdebian. Other methods revolve around QEMU or scratchbox and whilst this code |
|---|
| 13 | may be able to support such uses later, there are key differences in how and |
|---|
| 14 | why this method is separate. |
|---|
| 15 | |
|---|
| 16 | EMDEBIAN PBUILDER CHROOT MODEL |
|---|
| 17 | ============================== |
|---|
| 18 | |
|---|
| 19 | The Debian pbuilder package exists to ensure package dependencies are complete |
|---|
| 20 | and to provide an environment to automate package building on all supported |
|---|
| 21 | Debian architectures without cluttering the build machine with every library |
|---|
| 22 | and dev package in the entire archive. This is particularly useful when |
|---|
| 23 | building GUI packages that can have two dozen dependencies or more. In |
|---|
| 24 | Emdebian, this separation between the build system packages and the chroot |
|---|
| 25 | packages becomes even more useful because cross-building often involves not |
|---|
| 26 | only installing the library and -dev package for the build architecture (e.g. |
|---|
| 27 | i386/amd64) but also building and installing the same library and -dev package |
|---|
| 28 | (with dependencies) in the TARGET architecture, e.g. arm, with apt-cross and |
|---|
| 29 | dpkg-cross. The chaos that could result from trying to upgrade the packages on |
|---|
| 30 | an Emdebian buildd system with a duplicate set of cross dependencies is truly |
|---|
| 31 | scary. |
|---|
| 32 | |
|---|
| 33 | In the pbuilder model, an Emdebian chroot is the SAME architecture as the |
|---|
| 34 | buildd - i386 on i386 etc. This mimics how emdebian-tools normally work. |
|---|
| 35 | Packages are then downloaded, patched and cross-built for the target |
|---|
| 36 | architecture, just as outside the chroot. This model, the pbuilder model of an |
|---|
| 37 | emdebian chroot, concentrates on dependencies rather than the actual |
|---|
| 38 | cross-building process. Inside such a chroot, cache files are used as normal to |
|---|
| 39 | avoid having to run the cross-compiled code during the build. |
|---|
| 40 | |
|---|
| 41 | The Emdebian chroot is similar in size to a normal Debian pbuilder chroot, |
|---|
| 42 | mainly because it is a full build environment, not an installation environment. |
|---|
| 43 | |
|---|
| 44 | This directory contains my experiments with debootstrap, using this pbuilder |
|---|
| 45 | model, trying to make a complete Emdebian cross-building environment that can |
|---|
| 46 | be compressed to a base.tgz. Changes to the chroot can be discarded, just as |
|---|
| 47 | with pbuilder, allowing dependencies to be tested. The main benefit is that |
|---|
| 48 | packages can be built without having to install long chains of cross |
|---|
| 49 | dependencies via apt-cross or dpkg-cross on the main system. To me, it's the |
|---|
| 50 | only way to cross-build GUI suites like GPE against a background of changing |
|---|
| 51 | dependencies. |
|---|
| 52 | |
|---|
| 53 | In the pbuilder model, Emdebian builds a chroot for the build architecture |
|---|
| 54 | (amd64/i386 etc.) - except that it will run emdebian-tools instead of pbuilder |
|---|
| 55 | to create the arm binaries (or whichever architecture is the dpkg-cross |
|---|
| 56 | default). I expect the same code to work for arm chroots on amd64 etc, but |
|---|
| 57 | mechanisms already exist for those so it's not the priority. |
|---|
| 58 | |
|---|
| 59 | In order to make best use of the existing pbuilder code, these are shell scripts |
|---|
| 60 | whereas the rest of emdebian-tools uses perl. |
|---|
| 61 | |
|---|
| 62 | DEPENDENCIES |
|---|
| 63 | ------------ |
|---|
| 64 | |
|---|
| 65 | To emdebianise and cross-build packages, the chroot needs to install |
|---|
| 66 | emdebian-tools. This brings in the majority of dependencies to support building |
|---|
| 67 | Debian and Emdebian packages. This (current sample) code uses part of the |
|---|
| 68 | pbuilder source so that the eventual chroots behave as similarly as possible to |
|---|
| 69 | pbuilder and pdebuild in Debian. Therefore, the emdebian pbuilder chroot is NOT |
|---|
| 70 | designed or intended to be installed on any embedded device - it is intended for |
|---|
| 71 | cross-building packages for Emdebian only. See the SLIND installer for more |
|---|
| 72 | information or the emsandbox script in emdebian-tools. |
|---|
| 73 | |
|---|
| 74 | empdebuild depends on pbuilder and installing emdebian-tools within a chroot |
|---|
| 75 | causes pbuilder to be installed inside the chroot. Whilst empdebuild and emsandbox |
|---|
| 76 | could be split out into a separate package to prevent pbuilder being needed inside |
|---|
| 77 | the chroot, there are corner cases where this can be useful providing sufficient |
|---|
| 78 | care is taken. |
|---|
| 79 | |
|---|
| 80 | DIFFERENCES TO PBUILDER |
|---|
| 81 | ----------------------- |
|---|
| 82 | |
|---|
| 83 | 1. emdebian-tools handles the 'installaptlines' subroutine. |
|---|
| 84 | 2. emdebian-tools dependencies handle the installation of build-essential dpkg-dev |
|---|
| 85 | and apt that pbuilder normally does separately. |
|---|
| 86 | 3. emdebian-tools handles the BUILDPLACE via debconf. |
|---|
| 87 | 4. Other embootstrap options are hardcoded - BUILDRESULT is placed in BUILDPLACE, |
|---|
| 88 | APTCACHE also and APTCACHEHARDLINK is set to yes. |
|---|
| 89 | 5. emdebian-tools provides the emdebianised source package and patches. |
|---|
| 90 | |
|---|
| 91 | EMDEBIAN NATIVE CHROOT MODEL |
|---|
| 92 | ============================ |
|---|
| 93 | |
|---|
| 94 | The same code should also be able to create a native chroot so that the |
|---|
| 95 | cross-built packages can be installed alongside each other for more testing. |
|---|
| 96 | These chroots have already been tested and instructions exist in the Wiki: |
|---|
| 97 | http://wiki.debian.org/EmDebian/CrossDebootstrap |
|---|
| 98 | |
|---|
| 99 | Trying to cross-build inside scratchbox limits you to where scratchbox will |
|---|
| 100 | install which is only certain architectures. emdebian-tools is about |
|---|
| 101 | cross-building Debian packages using normal Debian tools on a normal Debian |
|---|
| 102 | system. Emdebian and emdebian-tools are designed to make building inside |
|---|
| 103 | scratchbox redundant because it simply isn't sufficiently flexible. A |
|---|
| 104 | scratchbox2 has been mooted but nothing has happened yet. |
|---|
| 105 | |
|---|
| 106 | Cross-build using normal tools (maybe using the chroot as above) and then test |
|---|
| 107 | either on a native device or via scratchbox if you really have to. |
|---|
| 108 | |
|---|
| 109 | An Emdebian native chroot would be an arm chroot running on an amd64 system - |
|---|
| 110 | indeed it would need to support creation of a chroot *for* any supported Debian |
|---|
| 111 | architecture and be able to create and run that chroot *on* any supported |
|---|
| 112 | Debian architecture. |
|---|
| 113 | |
|---|
| 114 | This is only the first draft - if there are areas that need further clarification |
|---|
| 115 | or updating, please email the debian-embedded mailing list. |
|---|