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

build: Build a sysroot using debos

parent e01c8bfd
No related branches found
No related tags found
No related merge requests found
/_build/ /_build/
/relocatable-install/ /libcapsule/
/libcapsule_*.dsc /libcapsule_*.dsc
/libcapsule_*.tar.[gx]z /libcapsule_*.tar.[gx]z
/relocatable-install/
all: install 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 \ bwrap \
--ro-bind $(chroot) / \ --ro-bind $(CURDIR)/$(sysroot) / \
--dev-bind /dev /dev \ --dev-bind /dev /dev \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--tmpfs /tmp \ --tmpfs /tmp \
--tmpfs /home \ --tmpfs /home \
--bind $(CURDIR) $(CURDIR) \ --bind $(CURDIR) $(CURDIR) \
...@@ -13,7 +26,7 @@ in_chroot = \ ...@@ -13,7 +26,7 @@ in_chroot = \
--setenv LC_ALL C.UTF-8 \ --setenv LC_ALL C.UTF-8 \
$(NULL) $(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/ install pressure-vessel-wrap relocatable-install/bin/
mkdir -p relocatable-install/sources mkdir -p relocatable-install/sources
install -m644 THIRD-PARTY.md relocatable-install/sources/README.txt install -m644 THIRD-PARTY.md relocatable-install/sources/README.txt
...@@ -21,13 +34,13 @@ install: install-amd64 install-i386 libcapsule/configure ...@@ -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/zlib1g/copyright relocatable-install/sources/libz.txt
install -m644 /usr/share/doc/libelf1/copyright relocatable-install/sources/libelf.txt install -m644 /usr/share/doc/libelf1/copyright relocatable-install/sources/libelf.txt
dcmd install -m644 libcapsule*.dsc relocatable-install/sources/ 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; \ cd relocatable-install/sources; \
apt-get --download-only source elfutils zlib apt-get --download-only source elfutils zlib
libcapsule/configure: libcapsule/configure: $(sysroot)/etc/debian_version
rm -fr libcapsule rm -fr libcapsule
first=; \ first=; \
for t in libcapsule*.dsc; do \ for t in libcapsule*.dsc; do \
...@@ -38,18 +51,18 @@ libcapsule/configure: ...@@ -38,18 +51,18 @@ libcapsule/configure:
exit 1; \ exit 1; \
fi; \ fi; \
done 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 dpkg-source -x libcapsule*.dsc
mv libcapsule-*/ libcapsule mv libcapsule-*/ libcapsule
set -e; cd libcapsule; NOCONFIGURE=1 ./autogen.sh 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 mkdir -p _build/$*/libcapsule
$(in_chroot) $(MAKE) in-chroot/configure-$* $(in_sysroot) $(MAKE) in-sysroot/configure-$*
in-chroot/configure-%: in-sysroot/configure-%:
set -eu; \ set -eu; \
eval "$$(dpkg-architecture -a"$*" --print-set)"; \ eval "$$(dpkg-architecture -a"$*" --print-set)"; \
case "$${DEB_BUILD_ARCH}/$${DEB_HOST_ARCH}" in \ case "$${DEB_BUILD_ARCH}/$${DEB_HOST_ARCH}" in \
...@@ -67,14 +80,14 @@ in-chroot/configure-%: ...@@ -67,14 +80,14 @@ in-chroot/configure-%:
--disable-gtk-doc \ --disable-gtk-doc \
$(NULL) $(NULL)
build-%: _build/%/config.status Makefile build-%: _build/%/config.status Makefile $(sysroot)/etc/debian_version
$(in_chroot) $(MAKE) -C _build/$*/libcapsule $(in_sysroot) $(MAKE) -C _build/$*/libcapsule
install-%: build-% Makefile install-%: build-% Makefile $(sysroot)/etc/debian_version
mkdir -p relocatable-install/bin 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; \ set -eu; \
eval "$$(dpkg-architecture -a"$*" --print-set)"; \ eval "$$(dpkg-architecture -a"$*" --print-set)"; \
mkdir -p "relocatable-install/lib/$${DEB_HOST_MULTIARCH}"; \ mkdir -p "relocatable-install/lib/$${DEB_HOST_MULTIARCH}"; \
......
...@@ -39,34 +39,37 @@ for libcapsule 0.20180430.0 or later, on a system with autoconf-archive ...@@ -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 . 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 To make the built version compatible with older systems, you will need a
Debian 8 'jessie' chroot with some extra packages. SteamOS 2 'brewmaster' Debian 8 'jessie' chroot with some extra packages. SteamOS 2 'brewmaster'
is not suitable, because its amd64 and i386 linux-libc-dev packages are is not suitable, because its amd64 and i386 linux-libc-dev packages are
not co-installable. 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 Alternatively, prepare a Debian jessie sysroot with `deb`
echo 'deb-src http://deb.debian.org/debian jessie main' | \ and `deb-src` sources and an `i386` foreign architecture (see
sudo tee -a /srv/jessie/etc/apt/sources.list `build-tools/configure-sources.sh`), and all the packages listed in
sudo chroot /srv/jessie dpkg --add-architecture i386 `build-tools/install-dependencies.sh`) and use:
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
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 Binaries and source code end up in `relocatable-install/` which can be
copied to wherever you want. 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 Instructions for testing
------------------------ ------------------------
......
#!/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:
#!/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:
{{- $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 }}
#!/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:
...@@ -36,6 +36,9 @@ cd "$TOP_SRCDIR" ...@@ -36,6 +36,9 @@ cd "$TOP_SRCDIR"
n=0 n=0
for shell_script in \ for shell_script in \
build-tools/clean-chroot.sh \
build-tools/configure-sources.sh \
build-tools/install-dependencies.sh \
pressure-vessel-wrap \ pressure-vessel-wrap \
t/shellcheck.t \ t/shellcheck.t \
; do ; do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment