diff --git a/.gitignore b/.gitignore index e9badd54e3ea8721257d6a1d61083a28125ed75f..828518db887baf4c92cdbc28a36af5087e3dd18d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /_build/ -/relocatable-install/ +/libcapsule/ /libcapsule_*.dsc /libcapsule_*.tar.[gx]z +/relocatable-install/ diff --git a/Makefile b/Makefile index 9a4c951a1d24b10cfc08c9002c4141bba4c19417..d01b2becadbf75a5e5afd96d606e8c3e73a87598 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,24 @@ all: install -chroot = /srv/jessie +mirror = http://deb.debian.org/debian +tarball = _build/sysroot.tar.gz +sysroot = _build/sysroot -in_chroot = \ +_build/sysroot/etc/debian_version: $(tarball) Makefile + rm -fr _build/sysroot + mkdir -p _build/sysroot + tar -zxf $(tarball) --exclude="./dev/*" -C _build/sysroot + touch $@ + +_build/sysroot.tar.gz: build-tools/debos.yaml Makefile + mkdir -p $(dir $@) + debos -t mirror:$(mirror) -t ospack:$@ build-tools/debos.yaml + +in_sysroot = \ bwrap \ - --ro-bind $(chroot) / \ + --ro-bind $(CURDIR)/$(sysroot) / \ --dev-bind /dev /dev \ + --ro-bind /etc/resolv.conf /etc/resolv.conf \ --tmpfs /tmp \ --tmpfs /home \ --bind $(CURDIR) $(CURDIR) \ @@ -13,7 +26,7 @@ in_chroot = \ --setenv LC_ALL C.UTF-8 \ $(NULL) -install: install-amd64 install-i386 libcapsule/configure +install: install-amd64 install-i386 libcapsule/configure $(sysroot)/etc/debian_version install pressure-vessel-wrap relocatable-install/bin/ mkdir -p relocatable-install/sources install -m644 THIRD-PARTY.md relocatable-install/sources/README.txt @@ -21,13 +34,13 @@ install: install-amd64 install-i386 libcapsule/configure 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_chroot) $(MAKE) in-chroot/install + $(in_sysroot) $(MAKE) in-sysroot/install -in-chroot/install: +in-sysroot/install: cd relocatable-install/sources; \ apt-get --download-only source elfutils zlib -libcapsule/configure: +libcapsule/configure: $(sysroot)/etc/debian_version rm -fr libcapsule first=; \ for t in libcapsule*.dsc; do \ @@ -38,18 +51,18 @@ libcapsule/configure: exit 1; \ fi; \ done - $(in_chroot) $(MAKE) in-chroot/libcapsule/configure + $(in_sysroot) $(MAKE) in-sysroot/libcapsule/configure -in-chroot/libcapsule/configure: +in-sysroot/libcapsule/configure: dpkg-source -x libcapsule*.dsc mv libcapsule-*/ libcapsule set -e; cd libcapsule; NOCONFIGURE=1 ./autogen.sh -_build/%/config.status: libcapsule/configure Makefile +_build/%/config.status: libcapsule/configure Makefile $(sysroot)/etc/debian_version mkdir -p _build/$*/libcapsule - $(in_chroot) $(MAKE) in-chroot/configure-$* + $(in_sysroot) $(MAKE) in-sysroot/configure-$* -in-chroot/configure-%: +in-sysroot/configure-%: set -eu; \ eval "$$(dpkg-architecture -a"$*" --print-set)"; \ case "$${DEB_BUILD_ARCH}/$${DEB_HOST_ARCH}" in \ @@ -67,14 +80,14 @@ in-chroot/configure-%: --disable-gtk-doc \ $(NULL) -build-%: _build/%/config.status Makefile - $(in_chroot) $(MAKE) -C _build/$*/libcapsule +build-%: _build/%/config.status Makefile $(sysroot)/etc/debian_version + $(in_sysroot) $(MAKE) -C _build/$*/libcapsule -install-%: build-% Makefile +install-%: build-% Makefile $(sysroot)/etc/debian_version mkdir -p relocatable-install/bin - $(in_chroot) $(MAKE) in-chroot/install-$* + $(in_sysroot) $(MAKE) in-sysroot/install-$* -in-chroot/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 ba583d4972b39251139d3d7e549dae404c379241..0a3ca1eaf419692e38dca5fc5e5be267f9917b96 100644 --- a/README.md +++ b/README.md @@ -39,34 +39,37 @@ for libcapsule 0.20180430.0 or later, on a system with autoconf-archive dcmd cp ../build-area/libcapsule_0.20180430.0-0co1.dsc . -The build system also needs `bubblewrap` and `debootstrap`. - To make the built version compatible with older systems, you will need a Debian 8 'jessie' chroot with some extra packages. SteamOS 2 'brewmaster' is not suitable, because its amd64 and i386 linux-libc-dev packages are not co-installable. -To prepare the chroot: +The build also needs `bubblewrap`. To make the relocatable installation, +by default it relies on [debos][] and [qemu-system-x86_64][qemu]. If +you have that, you can just run: + + make - sudo debootstrap jessie /srv/jessie http://deb.debian.org/debian - echo 'deb-src http://deb.debian.org/debian jessie main' | \ - sudo tee -a /srv/jessie/etc/apt/sources.list - sudo chroot /srv/jessie dpkg --add-architecture i386 - sudo chroot /srv/jessie apt update - sudo chroot /srv/jessie apt update - sudo chroot /srv/jessie apt install \ - autoconf automake build-essential chrpath gcc-multilib git \ - gtk-doc-tools libelf-dev libelf-dev:i386 libipc-run-perl \ - libjpeg62-turbo libjpeg62-turbo:i386 perl xsltproc zlib1g zlib1g:i386 - sudo chroot /srv/jessie apt install -t jessie-backports autoconf-archive +Alternatively, prepare a Debian jessie sysroot with `deb` +and `deb-src` sources and an `i386` foreign architecture (see +`build-tools/configure-sources.sh`), and all the packages listed in +`build-tools/install-dependencies.sh`) and use: -To build the relocatable install: + make chroot=/path/to/sysroot - make chroot=/srv/jessie +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 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 +[pbuilder]: https://pbuilder.alioth.debian.org/ +[qemu]: https://www.qemu.org/ + Instructions for testing ------------------------ diff --git a/build-tools/clean-sysroot.sh b/build-tools/clean-sysroot.sh new file mode 100755 index 0000000000000000000000000000000000000000..346442c81d2dacc8b9d14b0e0eb2ea80f488705d --- /dev/null +++ b/build-tools/clean-sysroot.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# Copyright © 2017-2018 Collabora Ltd. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +set -e +set -u + +rm -fr /usr/share/doc +rm -fr /usr/share/info +rm -fr /usr/share/lintian +rm -fr /usr/share/locale +rm -fr /var/cache/apt/archives/*.deb +rm -fr /var/cache/man + +# vim:set sw=4 sts=4 et: diff --git a/build-tools/configure-sources.sh b/build-tools/configure-sources.sh new file mode 100755 index 0000000000000000000000000000000000000000..400bad0e735c7730d54b9b252171a08dd26d0db4 --- /dev/null +++ b/build-tools/configure-sources.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# Copyright © 2018 Collabora Ltd. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +set -e +set -u + +mirror="$1" +shift + +cat > /etc/apt/sources.list <<EOF +deb ${mirror} jessie main +deb-src ${mirror} jessie main +EOF +rm -fr /etc/apt/sources.list.d +dpkg --add-architecture i386 +apt-get -q -y update + +# vim:set sw=4 sts=4 et: diff --git a/build-tools/debos.yaml b/build-tools/debos.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8e8517b65df5673e4c460d2f4afbd26f3132d542 --- /dev/null +++ b/build-tools/debos.yaml @@ -0,0 +1,28 @@ +{{- $mirror := or .mirror "http://deb.debian.org/debian" -}} +{{- $version := or .version "0" -}} +{{- $ospack := or .ospack "sysroot.tar.gz" -}} + +architecture: amd64 +actions: + - action: debootstrap + suite: jessie + components: + - main + mirror: {{ $mirror }} + merged-usr: false + + - action: run + chroot: true + script: configure-sources.sh {{ $mirror }} + + - action: run + chroot: true + script: install-dependencies.sh + + - action: run + chroot: true + script: clean-sysroot.sh + + - action: pack + compression: gz + file: {{ $ospack }} diff --git a/build-tools/install-dependencies.sh b/build-tools/install-dependencies.sh new file mode 100755 index 0000000000000000000000000000000000000000..a0e20b1cbb1ec8cce04912fe4199ca81ce52c45b --- /dev/null +++ b/build-tools/install-dependencies.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Copyright © 2017-2018 Collabora Ltd. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +set -e +set -u +NULL= + +apt-get -q -y update +apt-get -q -y upgrade +apt-get -q -y install \ + autoconf \ + automake \ + build-essential \ + chrpath \ + gcc-multilib \ + git \ + gtk-doc-tools \ + libelf-dev libelf-dev:i386 \ + libipc-run-perl \ + libjpeg62-turbo libjpeg62-turbo:i386 \ + perl \ + xsltproc \ + zlib1g zlib1g:i386 \ + ${NULL} + +# vim:set sw=4 sts=4 et: diff --git a/t/shellcheck.t b/t/shellcheck.t index 819f725f474b59ad811944fbf0b69740d1e778a1..10a1474c48c8418114ebfbb57408f56b1f59896b 100755 --- a/t/shellcheck.t +++ b/t/shellcheck.t @@ -36,6 +36,9 @@ cd "$TOP_SRCDIR" n=0 for shell_script in \ + build-tools/clean-chroot.sh \ + build-tools/configure-sources.sh \ + build-tools/install-dependencies.sh \ pressure-vessel-wrap \ t/shellcheck.t \ ; do