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

pressure-vessel: Add bwrap and its dependencies (x86_64 only)

parent 2573602b
No related branches found
No related tags found
No related merge requests found
...@@ -8,18 +8,29 @@ same place as pressure-vessel, or from ...@@ -8,18 +8,29 @@ same place as pressure-vessel, or from
<https://gitlab.collabora.com/vivek/libcapsule/>. <https://gitlab.collabora.com/vivek/libcapsule/>.
Binary releases of pressure-vessel include the following third-party Binary releases of pressure-vessel include the following third-party
libraries: programs and libraries:
- bubblewrap: [LGPL-2.0-or-later][]. See bubblewrap.txt.
- libcap.so.2 from libcap: dual-licensed under [GPL-2.0-only][] and
a [BSD-3-Clause][] variant. See libcap2.txt.
- libelf.so.1 from Red Hat elfutils: [GPL-2.0-or-later][] with linking - libelf.so.1 from Red Hat elfutils: [GPL-2.0-or-later][] with linking
exception. See elfutils.txt. exception. See elfutils.txt.
- libselinux.so.1 from SELinux: public-domain with [GPL-2.0-only][]
parts. See libselinux.txt.
- libpcre.so.3 from PCRE: [BSD-3-Clause][]. See pcre3.txt.
- libz.so.1 from zlib: [Zlib][] license. See zlib.txt. - libz.so.1 from zlib: [Zlib][] license. See zlib.txt.
Complete source code can be obtained from the same place as Complete source code can be obtained from the same place as
pressure-vessel, or from pressure-vessel, or from <http://repo.steampowered.com/steamrt/>.
<https://packages.debian.org/source/jessie/elfutils>
and <https://packages.debian.org/source/jessie/zlib>.
[BSD-3-Clause]: https://spdx.org/licenses/BSD-3-Clause.html
[GPL-2.0-only]: https://spdx.org/licenses/GPL-2.0-only.html
[GPL-2.0-or-later]: https://spdx.org/licenses/GPL-2.0-or-later.html [GPL-2.0-or-later]: https://spdx.org/licenses/GPL-2.0-or-later.html
[LGPL-2.0-or-later]: https://spdx.org/licenses/LGPL-2.0-or-later.html
[LGPL-2.1-or-later]: https://spdx.org/licenses/LGPL-2.1-or-later.html [LGPL-2.1-or-later]: https://spdx.org/licenses/LGPL-2.1-or-later.html
[Zlib]: https://spdx.org/licenses/Zlib.html [Zlib]: https://spdx.org/licenses/Zlib.html
...@@ -27,6 +27,7 @@ import argparse ...@@ -27,6 +27,7 @@ import argparse
import glob import glob
import os import os
import re import re
import shlex
import shutil import shutil
import subprocess import subprocess
...@@ -38,20 +39,57 @@ else: ...@@ -38,20 +39,57 @@ else:
typing # silence pyflakes typing # silence pyflakes
class Architecture:
def __init__(
self,
name, # type: str
multiarch, # type: str
ld_so # type: str
):
# type: (...) -> None
self.name = name
self.multiarch = multiarch
self.ld_so = ld_so
# Debian architecture => Debian multiarch tuple # Debian architecture => Debian multiarch tuple
ARCHS = { ARCHS = [
'amd64': 'x86_64-linux-gnu', Architecture(
'i386': 'i386-linux-gnu', name='amd64',
} multiarch='x86_64-linux-gnu',
ld_so='/lib64/ld-linux-x86-64.so.2',
),
Architecture(
name='i386',
multiarch='i386-linux-gnu',
ld_so='/lib/ld-linux.so.2',
),
]
# package to install from => source package for copyright information # package to install from => source package for copyright information
DEPENDENCIES = { DEPENDENCIES = {
'libcapsule-tools-relocatable': 'libcapsule', 'libcapsule-tools-relocatable': 'libcapsule',
'libelf1': 'elfutils', 'libelf1': 'elfutils',
'zlib1g': 'zlib', 'zlib1g': 'zlib',
} }
# program to install => binary package
WRAPPED_PROGRAMS = {
'bwrap': 'bubblewrap',
}
PRIMARY_ARCH_DEPENDENCIES = {
'bubblewrap': 'bubblewrap',
'libcap2': 'libcap2',
'libselinux1': 'libselinux',
'libpcre3': 'pcre3',
}
DESTDIR = 'relocatable-install' DESTDIR = 'relocatable-install'
SCRIPTS = ('pressure-vessel-unruntime', 'pressure-vessel-wrap') SCRIPTS = [
TOOLS = ('capsule-capture-libs', 'capsule-symbols') 'pressure-vessel-unruntime',
'pressure-vessel-wrap'
]
TOOLS = [
'capsule-capture-libs',
'capsule-symbols',
]
def install(src, dst, mode=0o644): def install(src, dst, mode=0o644):
...@@ -92,9 +130,9 @@ def main(): ...@@ -92,9 +130,9 @@ def main():
os.makedirs(os.path.join(DESTDIR, 'bin'), exist_ok=True) os.makedirs(os.path.join(DESTDIR, 'bin'), exist_ok=True)
os.makedirs(os.path.join(DESTDIR, 'sources'), exist_ok=True) os.makedirs(os.path.join(DESTDIR, 'sources'), exist_ok=True)
for ma in ARCHS.values(): for arch in ARCHS:
os.makedirs( os.makedirs(
os.path.join(DESTDIR, 'lib', ma), os.path.join(DESTDIR, 'lib', arch.multiarch),
exist_ok=True, exist_ok=True,
) )
...@@ -108,12 +146,12 @@ def main(): ...@@ -108,12 +146,12 @@ def main():
) )
if args.relocatabledir is not None: if args.relocatabledir is not None:
for arch, ma in ARCHS.items(): for arch in ARCHS:
for tool in TOOLS: for tool in TOOLS:
install_exe( install_exe(
os.path.join( os.path.join(
args.relocatabledir, args.relocatabledir,
'{}-{}'.format(ma, tool), '{}-{}'.format(arch.multiarch, tool),
), ),
os.path.join(DESTDIR, 'bin'), os.path.join(DESTDIR, 'bin'),
) )
...@@ -125,19 +163,28 @@ def main(): ...@@ -125,19 +163,28 @@ def main():
else: else:
v_check_call(['make', '-f', 'Makefile.libcapsule']) v_check_call(['make', '-f', 'Makefile.libcapsule'])
for arch, ma in ARCHS.items(): for arch in ARCHS:
for tool in TOOLS: for tool in TOOLS:
install_exe( install_exe(
os.path.join('_build', arch, 'libcapsule', tool), os.path.join('_build', arch.name, 'libcapsule', tool),
os.path.join('_build', '{}-{}'.format(ma, tool)), os.path.join(
'_build',
'{}-{}'.format(arch.multiarch, tool),
),
) )
v_check_call([ v_check_call([
'chrpath', '-r', 'chrpath', '-r',
'${ORIGIN}/../lib/' + ma, '${ORIGIN}/../lib/' + arch.multiarch,
os.path.join('_build', '{}-{}'.format(ma, tool)), os.path.join(
'_build',
'{}-{}'.format(arch.multiarch, tool),
),
]) ])
install_exe( install_exe(
os.path.join('_build', '{}-{}'.format(ma, tool)), os.path.join(
'_build',
'{}-{}'.format(arch.multiarch, tool),
),
os.path.join(DESTDIR, 'bin'), os.path.join(DESTDIR, 'bin'),
) )
...@@ -152,45 +199,117 @@ def main(): ...@@ -152,45 +199,117 @@ def main():
os.path.join(DESTDIR, 'sources'), os.path.join(DESTDIR, 'sources'),
]) ])
for arch, ma in ARCHS.items(): primary_architecture = subprocess.check_output([
os.makedirs(os.path.join('_build', arch, 'lib'), exist_ok=True) 'dpkg', '--print-architecture',
]).decode('utf-8').strip()
for arch in ARCHS:
os.makedirs(os.path.join('_build', arch.name, 'lib'), exist_ok=True)
v_check_call([ v_check_call([
'{}/bin/{}-capsule-capture-libs'.format(DESTDIR, ma), '{}/bin/{}-capsule-capture-libs'.format(DESTDIR, arch.multiarch),
'--dest=_build/{}/lib'.format(arch), '--dest=_build/{}/lib'.format(arch.name),
'--no-glibc', '--no-glibc',
'soname:libelf.so.1', 'soname:libelf.so.1',
'soname:libz.so.1', 'soname:libz.so.1',
]) ])
if arch.name == primary_architecture:
v_check_call([
'{}/bin/{}-capsule-capture-libs'.format(
DESTDIR,
arch.multiarch,
),
'--dest=_build/{}/lib'.format(arch.name),
'--no-glibc',
'soname:libcap.so.2',
'soname:libpcre.so.3',
'soname:libselinux.so.1',
])
for so in glob.glob( for so in glob.glob(
os.path.join('_build', arch, 'lib', '*.so.*'), os.path.join('_build', arch.name, 'lib', '*.so.*'),
): ):
install(so, os.path.join(DESTDIR, 'lib', ma)) install(so, os.path.join(DESTDIR, 'lib', arch.multiarch))
# For bwrap (and possibly other programs in future) we don't have
# a relocatable version with a RPATH/RUNPATH, so we wrap a script
# around it instead. The script avoids setting LD_LIBRARY_PATH
# because that would leak through to the programs invoked by bwrap.
for exe, package in WRAPPED_PROGRAMS.items():
path = '/usr/bin/{}'.format(exe)
if not os.path.exists(path):
v_check_call([
'apt-get',
'download',
package,
])
v_check_call(
'dpkg-deb -x {}_*.deb _build'.format(shlex.quote(package)),
shell=True,
)
path = '_build/usr/bin/{}'.format(exe)
for arch in ARCHS:
if arch.name != primary_architecture:
continue
install_exe(
path,
os.path.join(DESTDIR, 'bin', exe + '.bin'),
)
with open(
os.path.join('_build', arch.name, exe),
'w',
) as writer:
writer.write('#!/bin/sh\n')
writer.write('set -eu\n')
writer.write('here="$(dirname "$0")"\n')
writer.write(
'exec {} --library-path "$here"/../lib/{} '
'"$here"/{}.bin "$@"\n'.format(
shlex.quote(arch.ld_so),
shlex.quote(arch.multiarch),
shlex.quote(exe),
)
)
install_exe(
os.path.join('_build', arch.name, exe),
os.path.join(DESTDIR, 'bin', exe),
)
source_to_download = set() # type: typing.Set[str] source_to_download = set() # type: typing.Set[str]
for package, source in DEPENDENCIES.items(): for package, source in (
list(DEPENDENCIES.items()) + list(PRIMARY_ARCH_DEPENDENCIES.items())
):
if args.relocatabledir is None and source == 'libcapsule': if args.relocatabledir is None and source == 'libcapsule':
continue continue
install( if os.path.exists('/usr/share/doc/{}/copyright'.format(package)):
'/usr/share/doc/{}/copyright'.format(package), install(
os.path.join(DESTDIR, 'sources', '{}.txt'.format(source)), '/usr/share/doc/{}/copyright'.format(package),
) os.path.join(DESTDIR, 'sources', '{}.txt'.format(source)),
install( )
'/usr/share/doc/{}/copyright'.format(package),
os.path.join(DESTDIR, 'sources', '{}.txt'.format(source)),
)
for expr in set( for expr in set(
v_check_output([ v_check_output([
'dpkg-query', 'dpkg-query',
'-W', '-W',
'-f', '${source:Package}=${source:Version}\n', '-f', '${source:Package}=${source:Version}\n',
package, package,
], universal_newlines=True).splitlines() ], universal_newlines=True).splitlines()
): ):
source_to_download.add(re.sub(r'[+]srt[0-9a-z.]+$', '', expr)) source_to_download.add(re.sub(r'[+]srt[0-9a-z.]+$', '', expr))
else:
install(
'_build/usr/share/doc/{}/copyright'.format(package),
os.path.join(DESTDIR, 'sources', '{}.txt'.format(source)),
)
source_to_download.add(source)
v_check_call( v_check_call(
[ [
......
...@@ -60,8 +60,8 @@ pipeline { ...@@ -60,8 +60,8 @@ pipeline {
docker.withRegistry("https://${env.CI_DOCKER_REGISTRY}", dockerRegistryCred) { docker.withRegistry("https://${env.CI_DOCKER_REGISTRY}", dockerRegistryCred) {
docker.image("${env.CI_DOCKER_REGISTRY}/steamrt/sdk:scout").inside('--mount type=tmpfs,destination=/var/cache/apt/archives') { docker.image("${env.CI_DOCKER_REGISTRY}/steamrt/sdk:scout").inside('--mount type=tmpfs,destination=/var/cache/apt/archives') {
sh ''' sh '''
set -e set -eu
make -C src make -C src PYTHON=python3.5
''' '''
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment