[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: WG: Speedup when using qemu to cross-build packages.

Hi Chris,

Quoting Warlich, Christof (2022-09-08 21:12:20)
> So far, I'm really quite a bit under shock w.r.t. how complicated it seems to
> be to get the remaining work done, but I certainly do understand why
> cross-building is essential for porting.
> W.r.t the packages I've tried to build: I did the exercise today for Debian
> Bullseye, so maybe I would have had more success for Bookworm or even Sid?!

yes, many improvements have been made since the bullseye release.

> Anyhow, this is what I did:
> 1) Get the list of basic source packages:
> $ apt-cache show $(sudo debootstrap --arch=armhf --print-debs bullseye /tmp/be) | awk '$1~/^Package:/{n=$2} $1~/^Source:/{n=$2} /^$/{print n}' | sort -u
> 2) For each of these packages, I start a fresh docker container "FROM scratch", that I fill with the rootfs that I got from:
> $ debootstrap --arch=amd64 --include="gpg.dirmngr.gpg-agent.ca-certificates.crossbuild-essential-armhf" --variant=buildd bullseye /tmp/amd64
> Furthermore, I add the additional architecture ...
> $ dpkg --add-architecture armhf 
> ... and the source packages:
> echo "deb-src deb.debian.org/debian bullseye main" >>/etc/apt/sources.list && apt-get update
> 3) Finally, I run the following commands for each package, always starting with a fresh container instance as described so far:
> $ apt-get build-dep --yes --host-architecture=armhf $package

This will not do the right thing. That command will also attempt to install
Build-Depends-Indep (even though you correctly only want to build architecture
dependent packages) and it also does not know about the cross build profile.
This command also potentially installs foreign architecture Multi-Arch:foreign
packages that will also make your builds fail. Due to #815172 you also need
libc-dev:armhf and libstdc++-dev:armhf.

> $ apt-get source $package
> $ cd ${package}* && DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --no-check-builddeps --jobs=$(nproc) -us -uc --jobs-try=$(nproc) --build=binary --host-arch=armhf

You also should set DEB_BUILD_PROFILES="cross nocheck". The
--no-check-builddeps should not be necessary.

> > > To me, the major problem is that cross-building seems to be not even a
> > > second-class citizen to package maintainers: When cross-building only the
> > > most basic packages, i.e. those being reported by "debootstrap
> > > --print-debs", less than a third build sucessfully, the rest fail for various
> > > reasons, many of them (e.g. bash, glibc, apparmor, ...) even fail already to
> > > install their required build dependencies!
> > Maybe you are not cross-building them correctly? How are you cross-building
> > Debian packages? Above you say that less than a third cross-build successfully.
> > I cannot confirm this observation. Using crossqa.d.n, the situation for the
> > packages shown by debootstrap --print-debs is not too bad. The only source
> > packages in that selection that never succeeded to cross-build in the last runs
> > on crossqa.d.n are db5.3, gcc-12, libselinux, libsemanage and vim. So only five
> > source packages out of your selection of 109.
> So I exaggerated a bit: It's less than half (not less than a third) of the
> packages that successfully build (for bullseye). Besides building for
> bullseye instead of sid, is there any other obvious reason for the
> discrepancy?

I think you would have a much better out-of-the-box experience if you would
build your package like everybody else does when doing builds inside a fresh
chroot: using pbuilder or sbuild. Those tools already take care of all the
things I pointed out above.

I'm the current sbuild maintainer so I can help you with using sbuild for this
purpose. If you want to build inside a chroot with unshared namespaces like
docker you can use the sbuild unshare backend for the same effect but without
needing docker. This should work:

sudo apt install sbuild mmdebstrap
mmdebstrap --variant=buildd unstable ~/.cache/sbuild/unstable-amd64.tar
sbuild --chroot-mode=unshare -d unstable \
    --extra-repository='deb-src http://deb.debian.org/debian/ unstable main' \
    --no-arch-all --host=armhf $yourpkg


cheers, josch

Attachment: signature.asc
Description: signature

Reply to: