Skip to content
Snippets Groups Projects
Commit b9e2839f authored by Simon McVittie's avatar Simon McVittie
Browse files

Move sysroot manipulation into sysroot/Makefile


This turns Makefile into a relatively ordinary build system to be run
in the target environment, with no weird containers, which will be
necessary when we turn pressure-vessel-wrap into a C program.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 88b805b3
No related branches found
No related tags found
No related merge requests found
......@@ -2,37 +2,6 @@ VERSION := $(shell ./build-aux/git-version-gen .tarball-version)
all: binary
mirror = http://deb.debian.org/debian
security_mirror = http://security.debian.org/debian-security
tarball = _build/sysroot.tar.gz
sysroot = _build/sysroot
_build/sysroot/etc/debian_version: $(tarball)
rm -fr _build/sysroot
mkdir -p _build/sysroot
tar -zxf $(tarball) --exclude="./dev/*" -C _build/sysroot
touch $@
_build/sysroot.tar.gz: $(wildcard sysroot/*)
mkdir -p $(dir $@)
debos -t mirror:$(mirror) -t security_mirror:$(security_mirror) -t ospack:$@ sysroot/debos.yaml
ifeq ($(sysroot),/)
in_sysroot =
else
in_sysroot = \
bwrap \
--ro-bind $(CURDIR)/$(sysroot) / \
--dev-bind /dev /dev \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--tmpfs /tmp \
--tmpfs /home \
--bind $(CURDIR) $(CURDIR) \
--chdir $(CURDIR) \
--setenv LC_ALL C.UTF-8 \
$(NULL)
endif
install:
rm -fr relocatable-install
$(MAKE) install-amd64 install-i386
......@@ -44,13 +13,10 @@ install:
install -m644 /usr/share/doc/zlib1g/copyright relocatable-install/sources/libz.txt
install -m644 /usr/share/doc/libelf1/copyright relocatable-install/sources/libelf.txt
dcmd install -m644 libcapsule*.dsc relocatable-install/sources/
$(in_sysroot) $(MAKE) in-sysroot/install
in-sysroot/install:
cd relocatable-install/sources; \
apt-get --download-only source elfutils zlib
libcapsule/configure: $(sysroot)/etc/debian_version
libcapsule/configure:
rm -fr libcapsule
first=; \
for t in libcapsule*.dsc; do \
......@@ -61,19 +27,12 @@ libcapsule/configure: $(sysroot)/etc/debian_version
exit 1; \
fi; \
done
$(in_sysroot) $(MAKE) in-sysroot/libcapsule/configure
in-sysroot/libcapsule/configure:
dpkg-source -x libcapsule*.dsc
mv libcapsule-*/ libcapsule
set -e; cd libcapsule; NOCONFIGURE=1 ./autogen.sh
_build/%/config.stamp: libcapsule/configure $(sysroot)/etc/debian_version
_build/%/config.stamp: libcapsule/configure
mkdir -p _build/$*/libcapsule
$(in_sysroot) $(MAKE) in-sysroot/configure-$*
touch $@
in-sysroot/configure-%:
set -eu; \
eval "$$(dpkg-architecture -a"$*" --print-set)"; \
case "$${DEB_BUILD_ARCH}/$${DEB_HOST_ARCH}" in \
......@@ -91,16 +50,14 @@ in-sysroot/configure-%:
--disable-gtk-doc \
--without-glib \
$(NULL)
touch $@
_build/%/build.stamp: _build/%/config.stamp $(sysroot)/etc/debian_version
$(in_sysroot) $(MAKE) -C _build/$*/libcapsule
_build/%/build.stamp: _build/%/config.stamp
$(MAKE) -C _build/$*/libcapsule
touch $@
install-%: _build/%/build.stamp
mkdir -p relocatable-install/bin
$(in_sysroot) $(MAKE) in-sysroot/install-$*
in-sysroot/install-%:
set -eu; \
eval "$$(dpkg-architecture -a"$*" --print-set)"; \
mkdir -p "relocatable-install/lib/$${DEB_HOST_MULTIARCH}"; \
......
......@@ -47,28 +47,30 @@ not co-installable.
The simplest way is to do the build in a Debian 8 'jessie' amd64 container
with selected i386 packages available, like `ci/Jenkinsfile` does:
make sysroot=/
make
Alternatively, you can use `bubblewrap` to enter a sysroot prepared
using [debos][] and [qemu-system-x86_64][qemu]. If
you have all those, you can just run:
make
make -C sysroot
which will automatically build and use the sysroot.
Alternatively, prepare a Debian jessie sysroot with `deb`
and `deb-src` sources and an `i386` foreign architecture (see
`sysroot/configure-sources.sh`), and all the packages listed in
`sysroot/install-dependencies.sh`) and use:
`sysroot/install-dependencies.sh`). Then use:
make sysroot=/path/to/sysroot
make -C sysroot sysroot=/path/to/sysroot
or compress a similar chroot into a gzipped tar file (containing `./etc`,
`./usr` and so on, as used by [lxc][] and [pbuilder][]) and use:
make tarball=/path/to/tarball.tar.gz
make -C sysroot tarball=/path/to/tarball.tar.gz
Binaries and source code end up in `relocatable-install/` which can be
copied to wherever you want.
Whichever method you use, binaries and source code end up in
`relocatable-install/` which can be copied to wherever you want.
[debos]: https://github.com/go-debos/debos
[lxc]: https://github.com/lxc/lxc
......
top_srcdir = $(dir $(CURDIR))
top_builddir = $(dir $(CURDIR))
all:
mirror = http://deb.debian.org/debian
security_mirror = http://security.debian.org/debian-security
tarball = $(top_builddir)/_build/sysroot.tar.gz
sysroot = $(top_builddir)/_build/sysroot
$(top_builddir)/_build/sysroot/etc/debian_version: $(tarball)
rm -fr $(top_builddir)/_build/sysroot
mkdir -p $(top_builddir)/_build/sysroot
tar -zxf $(tarball) --exclude="./dev/*" -C $(top_builddir)/_build/sysroot
touch $@
$(top_builddir)/_build/sysroot.tar.gz: $(wildcard *)
mkdir -p $(dir $@)
set -e; \
debos -t mirror:$(mirror) -t security_mirror:$(security_mirror) -t ospack:sysroot.tar.gz --artifactdir=$(top_builddir)/_build debos.yaml
ifeq ($(sysroot),/)
in_sysroot =
else
in_sysroot = \
bwrap \
--ro-bind $(sysroot) / \
--dev-bind /dev /dev \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--tmpfs /tmp \
--tmpfs /home \
--bind $(top_builddir) $(top_builddir) \
--bind $(top_srcdir) $(top_srcdir) \
--chdir $(top_builddir) \
--setenv LC_ALL C.UTF-8 \
$(NULL)
endif
all binary check install: $(sysroot)/etc/debian_version
$(in_sysroot) $(MAKE) -C $(top_builddir) $@
clean:
if [ -e $(sysroot)/etc/debian_version ]; then \
$(in_sysroot) $(MAKE) -C $(top_builddir) $@; \
else \
$(MAKE) -C $(top_builddir) $@; \
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment