[Soc-coordination] Bootstrappable Debian - Report 3
P. J. McDermott
pjm at nac.net
Tue Jul 3 01:06:58 UTC 2012
This is report three for the "Bootstrappable Debian" project 
mentored by Wookey and co-mentored by Jonathan Austin.
Copies of this report are sent to the debian-bootstrap  and
Staged Build Support in dpkg-dev
Working to support "Build-Depends-StageN" fields for any value of "N" in
dpkg-dev, I added %FIELDS_RE, field_exists(), and field_get() to
Dpkg::Control::Fields and started changing the module's subroutines to
use the new additions . Then I realized that the field names are
used in other modules and in scripts, e.g. to match fields in
dpkg-gencontrol. I took some notes  on these uses of %FIELDS but
didn't get farther than dpkg-gencontrol.
Perl Cross Building Support
I've been investigating what needs done to refresh the src:perl cross
building patch that Steve McIntyre proposed in bug #633884  so that
it applies to the newer versions of src:perl in sid and experimental. I
looked at the differences  between the 5.12.4-1 package, the
5.14.2-11 package, the 5.16.0-1 package, and the patch that Steve
I found that refreshing the Debian packaging part of the patch will be
trivial. Refreshing the upstream build system part, however, will be
much more involved. Between versions of Perl there are several hundreds
of lines of changes to the build system (which is generated using the
"metaconfig" tool in the long-unmaintained "dist" package , then
changed/fixed by hand because "metaconfig is hard to change" ).
New Domain and Package Archive
In an effort to better organize my published work on this project, I set
up a new domain, bootstrap.pehjota.net, and copied many of my files into
the new document root . Old hyperlinks will continue to work, but I
am no longer pushing files into my personal home directory on my server.
I also set up a package archive  using reprepro to serve all the
source and binary packages that I produce throughout this project.
Currently there are two components in this archive:
* main: This component provides support packages for things like cross
building. (See below for more information.)
* cross: This component provides base build system and loop-breaking
packages that have been cross built. In cases where a package has
to be modified to successfully cross build, a source package is
provided. (See below for more information.)
Support Packages for Cross Building
I noticed  that sbuild (>= 0.63.0) installs packages necessary for
cross building through a package named "crossbuild-essential-<target>".
However, this package does not yet exist in the Debian archive.
So, I forked src:build-essential into a new source package named
"cross-build-essential"  that builds arch:all packages named
"crossbuild-essential-<target>". Once Thibaut Girka's multiarch cross
toolchains move into the Debian archive, src:build-essential and
src:cross-build-essential can be merged back together  and the
Debian archive can provide packages that list and depend upon packages
that are necessary for cross building.
I also noticed that the sbuild source code lists pkg-config-<triplet>
(also not in Debian) as an essential package for cross building. Wookey
explained that this package is supposed to simply provide a link at
/usr/bin/<triplet>-pkg-config to /usr/share/pkg-config-crosswrapper.
After finishing src:cross-build-essential, I made from scratch a
src:pkg-config-cross package  that builds arch:all packages
Finally, I realized that we'll need gcc-<triplet>, cpp-<triplet>,
g++-<triplet>, etc. binary packages that depend on and provide symbolic
links to default versions of cross tools built from GCC sources. These
packages would be similar to the gcc, cpp, g++, etc. packages built from
src:gcc-defaults. Working around the lack of such packages is easy
enough, so I just noted  this as an item to be done eventually. The
discussion continued between the debian-bootstrap and debian-embedded
 lists with update-alternatives offered as an alternative to default
sbuild Chroot for Cross Building
On my wheezy amd64 system I set up a sid i386 chroot with sbuild/schroot
and installed in it Thibaut's multiarch cross toolchain packages and my
cross building support packages.
I experienced a couple of rather significant setbacks in this vain.
First, when I tried to install a C cross compiler, APT in its default
configuration tried to remove the build-essential, cpp, g++, and gcc
metapackages, all of which are necessary for building anything with
sbuild. I traced the problem to libc6-dev:armhf and its Recommends
relationship with gcc. Configuring APT to not install recommended
packages solved this issue.
Second, Thibaut's g++-4.7-<target> packages can't be installed until bug
#678623  against libstdc++6-4.7-dev is resolved; in the meantime, I
used equivs to generate a fake g++-4.7-arm-linux-gnueabihf package 
to satisfy the dependency of my crossbuild-essential-armhf package.
I documented  the whole setup procedure for my own reference and
in case it is of interest to anyone else. Eventually, this information
should be added to the Debian Wiki.
Base Build System Cross Building
With cross building support packages built and a cross-building chroot
setup, I've finally begun to attempt to cross build the packages that
comprise a base system that is capable of natively building other
I started with a fairly simple arch:any package: src:base-files. This
package cross built successfully  as it was.
Then I moved on to a simple package that used a compiler: src:dash.
This package initially failed  to cross build because it executed
"strip" instead of "<triplet>-strip" when cross building. So I patched
 the source package and built binaries  for armhf. Finally,
I found a report of this problem  submitted by Marcin Juszkiewicz,
followed up on it, and categorized it with the cross build usertag .
See also the armhf Packages file  in my archive that describes my
Overall, src:base-files and src:dash have been good proof-of-concept
packages to test my cross building chroot and to help me adjust to the
cross building, patching, and bug reporting workflow.
Finally, I've begun development of a (not yet published) shell script in
an attempt to partially automate and speed up my workflow of:
* Downloading a Debian source package,
* Editing it if necessary,
* Building it with sbuild, and
* Pushing my work to my server.
I don't except the script to be very useful beyond this project and my
own cross building workflow, as it's not designed for an automated
bootstrap (rather it's designed for one in which many packages need to
be fixed manually). But its use can be scripted, so it may be of
interest someday for at least semi-automated cross building.
Perl Cross Building Support
I will continue to investigate Perl's build system in my efforts to
refresh the existing cross building patch to apply to the newer versions
Base Build System Cross Building
I will attempt to cross build the rest of the base build system packages
and try to fix packages that don't yet cross build. This is the first
major component of a full architecture bootstrap.
Also, I plan to spend another day or two finishing the aforementioned
workflow automation script. It should make my cross building work a
little more efficient and deterministic. I should have it published
sometime within the next few days; mostly I just need to figure out
where I want to put it – e.g. in a Git repository accessible through
odin1.pehjota.net and/or on Gitorious.
P. J. McDermott (_/@\_) ,--.
http://www.pehjota.net/ o < o o > / oo \
http://www.pehjota.net/contact.html o \ `-/ | <> |.
o o o "~v /_\--/_/
More information about the Soc-coordination