diff --git a/Makefile b/Makefile index bddbba29d79110f262474b6cb56a34a4355a0f98..979b23c790f8352277d1ba2e61d9c05ffbb5d619 100644 --- a/Makefile +++ b/Makefile @@ -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}"; \ diff --git a/README.md b/README.md index 7575ce8b5530286af5183260a2e3bdbfc0225ce5..b17f3d5eeb498db92aad6ef37f45424f681bda67 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/sysroot/Makefile b/sysroot/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..48c712070e38ddd1bc176304e1860d4adc2cc117 --- /dev/null +++ b/sysroot/Makefile @@ -0,0 +1,47 @@ +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