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

Build relocatable installation from installed files in a temp directory

parent 4236e11b
No related branches found
No related tags found
No related merge requests found
...@@ -38,32 +38,28 @@ build:scout: ...@@ -38,32 +38,28 @@ build:scout:
apt-get -y --no-install-recommends install \ apt-get -y --no-install-recommends install \
bubblewrap \ bubblewrap \
libcapsule0 \ libcapsule0 \
libcapsule-tools-relocatable \ libcapsule-tools-relocatable:amd64 \
libcapsule-tools-relocatable:i386 \
libglib2.0-dev \ libglib2.0-dev \
libxau-dev \ libxau-dev \
meson \ meson \
${NULL+} ${NULL+}
meson \ meson --prefix="$(pwd)/_build/prefix" -Dpython=python3.5 _build
--prefix="$(pwd)/_build/relocatable-install" \
-Dpython=python3.5 \
_build
ninja -C _build ninja -C _build
ninja -C _build install
meson test --verbose -C _build meson test --verbose -C _build
ninja -C _build install
rm -fr _build/relocatable-install
./build-relocatable-install.py \ ./build-relocatable-install.py \
--srcdir . \ --srcdir . \
--builddir _build \ --builddir _build \
--libcapsuledir /usr/lib/libcapsule/relocatable \ --libcapsuledir /usr/lib/libcapsule/relocatable \
--prefix="$(pwd)/_build/relocatable-install" \ --output _build/relocatable-install \
--archive "$(pwd)/_build" \ --archive "$(pwd)/_build" \
--set-version "$(cat .tarball-version)" \ --set-version "$(cat .tarball-version)" \
${NULL+} ${NULL+}
prove -v ./tests/relocatable-install.py :: \ prove -v ./tests/relocatable-install.py :: \
--srcdir . \ "$(pwd)/_build/relocatable-install"
--builddir _build \
--prefix="$(pwd)/_build/relocatable-install" \
${NULL+}
# Artifacts are currently disabled because uploading them to the # Artifacts are currently disabled because uploading them to the
# coordinator results in HTTP 413 Request Entity Too Large. # coordinator results in HTTP 413 Request Entity Too Large.
......
...@@ -143,25 +143,24 @@ Building a relocatable install for deployment ...@@ -143,25 +143,24 @@ Building a relocatable install for deployment
To make the built version compatible with older systems, you will need To make the built version compatible with older systems, you will need
a SteamRT 1 'scout' environment. a SteamRT 1 'scout' environment.
The most straightforward method is to have prebuilt versions of For this, you need prebuilt versions of libcapsule-tools-relocatable:amd64
libcapsule-tools-relocatable:amd64, libcapsule-tools-relocatable:i386 and libcapsule-tools-relocatable:i386 either in your build environment
and bubblewrap in your build environment. For example, you could do the or available via apt-get. For example, you could do the build in a
build in a SteamRT 1 'scout' SDK Docker image that has those packages SteamRT 1 'scout' SDK Docker image that has those packages already.
already. Then you can do: Then you can do:
meson --prefix=$(pwd)/_build/relocatable-install _build meson --prefix="$(pwd)/_build/prefix" _build
ninja -C _build ninja -C _build
rm -fr $(pwd)/_build/relocatable-install
meson test -v -C _build # optional meson test -v -C _build # optional
ninja -C _build install ninja -C _build install
rm -fr _build/relocatable-install
./build-relocatable-install.py \ ./build-relocatable-install.py \
--srcdir . \ --srcdir . \
--builddir _build \ --builddir _build \
--libcapsuledir /usr/lib/libcapsule/relocatable \ --libcapsuledir /usr/lib/libcapsule/relocatable \
--output _build/relocatable-install \
--archive . --archive .
./tests/relocatable-install.py \ ./tests/relocatable-install.py _build/relocatable-install # optional
--srcdir . \
--builddir _build # optional
For more convenient use on a development system, if you have a For more convenient use on a development system, if you have a
SteamRT 1 'scout' SDK tarball or an unpacked sysroot, you can place a SteamRT 1 'scout' SDK tarball or an unpacked sysroot, you can place a
...@@ -170,16 +169,15 @@ tarball at `_build/sysroot.tar.gz` or unpack a sysroot into ...@@ -170,16 +169,15 @@ tarball at `_build/sysroot.tar.gz` or unpack a sysroot into
`./sysroot/run-in-sysroot.py`: `./sysroot/run-in-sysroot.py`:
./sysroot/run-in-sysroot.py apt-get update ./sysroot/run-in-sysroot.py apt-get update
./sysroot/run-in-sysroot.py meson ... ./sysroot/run-in-sysroot.py meson --prefix="$(pwd)/_build/prefix" _build
rm -fr $(pwd)/_build/relocatable-install ./sysroot/run-in-sysroot.py ninja -C _build
./sysroot/run-in-sysroot.py ninja ... (etc.)
./sysroot/run-in-sysroot.py ./build-relocatable-install.py ...
(Or put them in different locations and pass the `--sysroot` and (Or put them in different locations and pass the `--sysroot` and
`--tarball` options to `./sysroot/run-in-sysroot.py`.) `--tarball` options to `./sysroot/run-in-sysroot.py`.)
The relocatable install goes into`_build/relocatable-install` (or The relocatable install goes into `relocatable-install` (or
whatever you used as the `--prefix`), and a compressed version ends whatever you used as the `--output`), and a compressed version ends
up in the directory passed as an argument to `--archive`. up in the directory passed as an argument to `--archive`.
Instructions for testing Instructions for testing
......
...@@ -30,6 +30,7 @@ import os ...@@ -30,6 +30,7 @@ import os
import re import re
import shutil import shutil
import subprocess import subprocess
import tempfile
try: try:
import typing import typing
...@@ -141,6 +142,7 @@ def main(): ...@@ -141,6 +142,7 @@ def main():
parser.add_argument( parser.add_argument(
'--builddir', default=os.getenv('MESON_BUILD_ROOT', '_build')) '--builddir', default=os.getenv('MESON_BUILD_ROOT', '_build'))
parser.add_argument('--prefix', default=None) parser.add_argument('--prefix', default=None)
parser.add_argument('--output', '-o', default=None)
parser.add_argument('--archive', default=None) parser.add_argument('--archive', default=None)
parser.add_argument('--libcapsuledir', default='') parser.add_argument('--libcapsuledir', default='')
parser.add_argument('--set-version', dest='version', default='unknown') parser.add_argument('--set-version', dest='version', default='unknown')
...@@ -171,389 +173,423 @@ def main(): ...@@ -171,389 +173,423 @@ def main():
'please specify --prefix' 'please specify --prefix'
) )
os.chdir(args.builddir) with tempfile.TemporaryDirectory(prefix='pressure-vessel-') as tmpdir:
if args.output is None:
destdir_prefix = args.destdir + args.prefix installation = os.path.join(tmpdir, 'installation')
else:
installation = args.output
os.makedirs(os.path.join(destdir_prefix, 'bin'), exist_ok=True) if os.path.exists(installation):
os.makedirs(os.path.join(destdir_prefix, 'metadata'), exist_ok=True) raise RuntimeError('--output directory must not already exist')
for arch in ARCHS: destdir_prefix = args.destdir + args.prefix
os.makedirs(
os.path.join(destdir_prefix, 'lib', arch.multiarch),
exist_ok=True,
)
for script in SCRIPTS: os.makedirs(os.path.join(installation, 'bin'), exist_ok=True)
install_exe( os.makedirs(os.path.join(installation, 'metadata'), exist_ok=True)
os.path.join(args.srcdir, script),
os.path.join(destdir_prefix, 'bin'),
)
for exe in EXECUTABLES: for arch in ARCHS:
install_exe( os.makedirs(
os.path.join(args.builddir, exe), os.path.join(installation, 'lib', arch.multiarch),
os.path.join(destdir_prefix, 'bin'), exist_ok=True,
) )
install( for script in SCRIPTS:
os.path.join(args.srcdir, 'THIRD-PARTY.md'), install_exe(
os.path.join(destdir_prefix, 'metadata', 'README.txt'), os.path.join(destdir_prefix, 'bin', script),
0o644, os.path.join(installation, 'bin'),
) )
if args.libcapsuledir: for exe in EXECUTABLES:
for arch in ARCHS: install_exe(
for tool in TOOLS: os.path.join(destdir_prefix, 'bin', exe),
install_exe( os.path.join(installation, 'bin'),
os.path.join( )
args.libcapsuledir,
'{}-{}'.format(arch.multiarch, tool),
),
os.path.join(destdir_prefix, 'bin'),
)
install( install(
'/usr/share/doc/libcapsule-tools-relocatable/copyright', os.path.join(args.srcdir, 'THIRD-PARTY.md'),
os.path.join(destdir_prefix, 'metadata', 'libcapsule.txt'), os.path.join(installation, 'metadata', 'README.txt'),
0o644,
) )
else:
for arch in ARCHS: if args.libcapsuledir:
for tool in TOOLS: for arch in ARCHS:
install_exe( for tool in TOOLS:
os.path.join( install_exe(
'build-relocatable', os.path.join(
arch.name, args.libcapsuledir,
'libcapsule', '{}-{}'.format(arch.multiarch, tool),
tool, ),
), os.path.join(installation, 'bin'),
os.path.join( )
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
)
v_check_call([
'chrpath', '-r',
'${ORIGIN}/../lib/' + arch.multiarch,
os.path.join(
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
])
install_exe(
os.path.join(
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
os.path.join(destdir_prefix, 'bin'),
)
install( install(
os.path.join( '/usr/share/doc/libcapsule-tools-relocatable/copyright',
args.builddir, os.path.join(installation, 'metadata', 'libcapsule.txt'),
'libcapsule',
'debian',
'copyright',
),
os.path.join(destdir_prefix, 'metadata', 'libcapsule.txt'),
) )
else:
for arch in ARCHS:
for tool in TOOLS:
install_exe(
os.path.join(
args.builddir,
'build-relocatable',
arch.name,
'libcapsule',
tool,
),
os.path.join(
tmpdir,
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
)
v_check_call([
'chrpath', '-r',
'${ORIGIN}/../lib/' + arch.multiarch,
os.path.join(
tmpdir,
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
])
install_exe(
os.path.join(
tmpdir,
'build-relocatable',
'{}-{}'.format(arch.multiarch, tool),
),
os.path.join(installation, 'bin'),
)
primary_architecture = subprocess.check_output([ install(
'dpkg', '--print-architecture', os.path.join(
]).decode('utf-8').strip() args.builddir,
'libcapsule',
'debian',
'copyright',
),
os.path.join(installation, 'metadata', 'libcapsule.txt'),
)
for arch in ARCHS: primary_architecture = subprocess.check_output([
os.makedirs( 'dpkg', '--print-architecture',
os.path.join('build-relocatable', arch.name, 'lib'), ]).decode('utf-8').strip()
exist_ok=True,
)
v_check_call([ for arch in ARCHS:
'{}/bin/{}-capsule-capture-libs'.format( os.makedirs(
destdir_prefix, os.path.join(tmpdir, 'build-relocatable', arch.name, 'lib'),
arch.multiarch, exist_ok=True,
), )
'--dest=build-relocatable/{}/lib'.format(arch.name),
'--no-glibc',
'soname:libelf.so.1',
'soname:libz.so.1',
])
if arch.name == primary_architecture:
v_check_call([ v_check_call([
'{}/bin/{}-capsule-capture-libs'.format( '{}/bin/{}-capsule-capture-libs'.format(
destdir_prefix, installation,
arch.multiarch, arch.multiarch,
), ),
'--dest=build-relocatable/{}/lib'.format(arch.name), '--dest={}/build-relocatable/{}/lib'.format(
tmpdir,
arch.name,
),
'--no-glibc', '--no-glibc',
'soname:libXau.so.6', 'soname:libelf.so.1',
'soname:libcap.so.2', 'soname:libz.so.1',
'soname:libgio-2.0.so.0',
'soname:libpcre.so.3',
'soname:libselinux.so.1',
]) ])
for so in glob.glob( if arch.name == primary_architecture:
os.path.join('build-relocatable', arch.name, 'lib', '*.so.*'), v_check_call([
): '{}/bin/{}-capsule-capture-libs'.format(
install(so, os.path.join(destdir_prefix, 'lib', arch.multiarch)) installation,
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 '--dest={}/build-relocatable/{}/lib'.format(
# around it instead. The script avoids setting LD_LIBRARY_PATH tmpdir,
# because that would leak through to the programs invoked by bwrap. arch.name,
for exe, package in WRAPPED_PROGRAMS.items(): ),
path = '/usr/bin/{}'.format(exe) '--no-glibc',
'soname:libXau.so.6',
'soname:libcap.so.2',
'soname:libgio-2.0.so.0',
'soname:libpcre.so.3',
'soname:libselinux.so.1',
])
if not os.path.exists(path): for so in glob.glob(
v_check_call([ os.path.join(
'apt-get', tmpdir,
'download', 'build-relocatable',
package, arch.name,
]) 'lib',
v_check_call( '*.so.*',
'dpkg-deb -x {}_*.deb build-relocatable'.format(
quote(package),
), ),
shell=True, ):
) install(so, os.path.join(installation, 'lib', arch.multiarch))
path = 'build-relocatable/usr/bin/{}'.format(exe)
for arch in ARCHS: # For bwrap (and possibly other programs in future) we don't have
if arch.name != primary_architecture: # a relocatable version with a RPATH/RUNPATH, so we wrap a script
continue # 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)
install_exe( if not os.path.exists(path):
path, v_check_call([
os.path.join(destdir_prefix, 'bin', exe + '.bin'), 'apt-get',
) 'download',
package,
], cwd=tmpdir)
v_check_call(
'dpkg-deb -x {}_*.deb build-relocatable'.format(
quote(package),
),
cwd=tmpdir,
shell=True,
)
path = '{}/build-relocatable/usr/bin/{}'.format(tmpdir, exe)
for arch in ARCHS:
if arch.name != primary_architecture:
continue
install_exe(
path,
os.path.join(installation, 'bin', exe + '.bin'),
)
with open( with open(
os.path.join('build-relocatable', arch.name, exe), os.path.join(tmpdir, 'build-relocatable', arch.name, exe),
'w', 'w',
) as writer: ) as writer:
writer.write('#!/bin/sh\n') writer.write('#!/bin/sh\n')
writer.write('set -eu\n') writer.write('set -eu\n')
writer.write('here="$(dirname "$0")"\n') writer.write('here="$(dirname "$0")"\n')
writer.write( writer.write(
'exec ${{RELOCATABLE_INSTALL_WRAPPER-}} {} ' 'exec ${{RELOCATABLE_INSTALL_WRAPPER-}} {} '
'--library-path "$here"/../lib/{} ' '--library-path "$here"/../lib/{} '
'"$here"/{}.bin "$@"\n'.format( '"$here"/{}.bin "$@"\n'.format(
quote(arch.ld_so), quote(arch.ld_so),
quote(arch.multiarch), quote(arch.multiarch),
quote(exe), quote(exe),
)
) )
install_exe(
os.path.join(tmpdir, 'build-relocatable', arch.name, exe),
os.path.join(installation, 'bin', exe),
) )
install_exe( source_to_download = set() # type: typing.Set[str]
os.path.join('build-relocatable', arch.name, exe), installed_binaries = set() # type: typing.Set[str]
os.path.join(destdir_prefix, 'bin', exe),
)
source_to_download = set() # type: typing.Set[str] for package, source in (
installed_binaries = set() # type: typing.Set[str] list(DEPENDENCIES.items()) + list(PRIMARY_ARCH_DEPENDENCIES.items())
):
if not args.libcapsuledir and source == 'libcapsule':
continue
for package, source in ( if os.path.exists('/usr/share/doc/{}/copyright'.format(package)):
list(DEPENDENCIES.items()) + list(PRIMARY_ARCH_DEPENDENCIES.items()) installed_binaries.add(package)
):
if not args.libcapsuledir and source == 'libcapsule':
continue
if os.path.exists('/usr/share/doc/{}/copyright'.format(package)): install(
installed_binaries.add(package) '/usr/share/doc/{}/copyright'.format(package),
os.path.join(
installation,
'metadata',
'{}.txt'.format(source),
),
)
install( for expr in set(
'/usr/share/doc/{}/copyright'.format(package), v_check_output([
os.path.join( 'dpkg-query',
destdir_prefix, '-W',
'metadata', '-f', '${source:Package}=${source:Version}\n',
'{}.txt'.format(source), package,
), ], universal_newlines=True).splitlines()
):
source_to_download.add(re.sub(r'[+]srt[0-9a-z.]+$', '', expr))
else:
install(
'{}/build-relocatable/usr/share/doc/{}/copyright'.format(
tmpdir,
package,
),
os.path.join(
installation,
'metadata',
'{}.txt'.format(source),
),
)
source_to_download.add(source)
with open(
os.path.join(installation, 'metadata', 'packages.txt'), 'w'
) as writer:
writer.write(
'#Package[:Architecture]\t#Version\t#Source\t#Installed-Size\n'
) )
v_check_call([
'dpkg-query',
'-W',
'-f',
r'${binary:Package}\t${Version}\t${Source}\t${Installed-Size}\n',
] + sorted(installed_binaries), stdout=writer)
with open(
os.path.join(installation, 'metadata', 'VERSION.txt'),
'w',
) as writer:
writer.write('{}\n'.format(args.version))
shutil.copytree(
os.path.join(installation, 'metadata'),
os.path.join(installation, 'sources'),
)
for expr in set( if not args.libcapsuledir:
v_check_output([ for dsc in glob.glob(
'dpkg-query', os.path.join(args.srcdir, 'libcapsule*.dsc')
'-W',
'-f', '${source:Package}=${source:Version}\n',
package,
], universal_newlines=True).splitlines()
): ):
source_to_download.add(re.sub(r'[+]srt[0-9a-z.]+$', '', expr)) v_check_call([
else: 'dcmd', 'install', '-m644', dsc,
install( os.path.join(installation, 'sources'),
'build-relocatable/usr/share/doc/{}/copyright'.format(package), ])
os.path.join(
destdir_prefix,
'metadata',
'{}.txt'.format(source),
),
)
source_to_download.add(source)
with open( v_check_call(
os.path.join(destdir_prefix, 'metadata', 'packages.txt'), 'w' [
) as writer: 'apt-get',
writer.write( '--download-only',
'#Package[:Architecture]\t#Version\t#Source\t#Installed-Size\n' '--only-source',
'source',
] + list(source_to_download),
cwd=os.path.join(installation, 'sources'),
) )
v_check_call([
'dpkg-query',
'-W',
'-f',
r'${binary:Package}\t${Version}\t${Source}\t${Installed-Size}\n',
] + sorted(installed_binaries), stdout=writer)
with open(
os.path.join(destdir_prefix, 'metadata', 'VERSION.txt'),
'w',
) as writer:
writer.write('{}\n'.format(args.version))
shutil.copytree(
os.path.join(destdir_prefix, 'metadata'),
os.path.join(destdir_prefix, 'sources'),
)
if not args.libcapsuledir:
for dsc in glob.glob(
os.path.join(args.srcdir, 'libcapsule*.dsc')
):
v_check_call([
'dcmd', 'install', '-m644', dsc,
os.path.join(destdir_prefix, 'sources'),
])
v_check_call( os.makedirs(
[ os.path.join(installation, 'sources', 'pressure-vessel'),
'apt-get', exist_ok=True,
'--download-only', )
'--only-source',
'source',
] + list(source_to_download),
cwd=os.path.join(destdir_prefix, 'sources'),
)
os.makedirs(
os.path.join(destdir_prefix, 'sources', 'pressure-vessel'),
exist_ok=True,
)
for src_tar in (
os.path.join(
args.srcdir,
'pressure-vessel-{}.tar.gz'.format(args.version),
),
os.path.join(
args.srcdir,
'pressure-vessel-{}.tar.xz'.format(args.version),
),
):
if os.path.exists(src_tar):
subprocess.check_call([
'tar',
'-C', os.path.join(
destdir_prefix,
'sources',
'pressure-vessel',
),
'--strip-components=1',
'-xvf', src_tar,
])
break
else:
if os.path.exists('/usr/bin/git'):
git_archive = subprocess.Popen([
'git', 'archive', '--format=tar', 'HEAD',
], cwd=args.srcdir, stdout=subprocess.PIPE)
subprocess.check_call([
'tar',
'-C', os.path.join(
destdir_prefix,
'sources',
'pressure-vessel',
),
'-xvf-',
], stdin=git_archive.stdout)
if git_archive.wait() != 0: for src_tar in (
raise subprocess.CalledProcessError( os.path.join(
returncode=git_archive.returncode, args.srcdir,
cmd=git_archive.args, '..',
) 'pressure-vessel_{}.orig.tar.xz'.format(args.version),
else: ),
tar = subprocess.Popen([ os.path.join(
'tar', args.builddir,
'-C', args.srcdir, 'meson-dist/pressure-vessel-{}.tar.gz'.format(
'--exclude=./.git', args.version,
'--exclude=./_build',
'--exclude=./relocatable-install',
'--exclude=./.mypy_cache',
'--exclude=.*.swp',
'-cf-',
'.',
], stdout=subprocess.PIPE)
subprocess.check_call([
'tar',
'-C', os.path.join(
destdir_prefix,
'sources',
'pressure-vessel',
), ),
'-xvf-', ),
], stdin=tar.stdout) os.path.join(
args.srcdir,
'pressure-vessel-{}.tar.xz'.format(args.version),
),
):
if os.path.exists(src_tar):
subprocess.check_call([
'tar',
'-C', os.path.join(
installation,
'sources',
'pressure-vessel',
),
'--strip-components=1',
'-xvf', src_tar,
])
break
else:
if os.path.exists('/usr/bin/git'):
git_archive = subprocess.Popen([
'git', 'archive', '--format=tar', 'HEAD',
], cwd=args.srcdir, stdout=subprocess.PIPE)
subprocess.check_call([
'tar',
'-C', os.path.join(
installation,
'sources',
'pressure-vessel',
),
'-xvf-',
], stdin=git_archive.stdout)
if tar.wait() != 0: if git_archive.wait() != 0:
raise subprocess.CalledProcessError( raise subprocess.CalledProcessError(
returncode=git_archive.returncode, returncode=git_archive.returncode,
cmd=git_archive.args, cmd=git_archive.args,
) )
else:
tar = subprocess.Popen([
'tar',
'-C', args.srcdir,
'--exclude=./.git',
'--exclude=./_build',
'--exclude=./relocatable-install',
'--exclude=./.mypy_cache',
'--exclude=.*.swp',
'-cf-',
'.',
], stdout=subprocess.PIPE)
subprocess.check_call([
'tar',
'-C', os.path.join(
installation,
'sources',
'pressure-vessel',
),
'-xvf-',
], stdin=tar.stdout)
if tar.wait() != 0:
raise subprocess.CalledProcessError(
returncode=git_archive.returncode,
cmd=git_archive.args,
)
with open( with open(
os.path.join( os.path.join(
destdir_prefix, installation,
'sources', 'sources',
'pressure-vessel', 'pressure-vessel',
'.tarball-version', '.tarball-version',
), ),
'w', 'w',
) as writer: ) as writer:
writer.write('{}\n'.format(args.version)) writer.write('{}\n'.format(args.version))
bin_tar = os.path.join( bin_tar = os.path.join(
args.archive, args.archive,
'pressure-vessel-{}-bin.tar.gz'.format(args.version), 'pressure-vessel-{}-bin.tar.gz'.format(args.version),
) )
src_tar = os.path.join( src_tar = os.path.join(
args.archive, args.archive,
'pressure-vessel-{}-bin+src.tar.gz'.format(args.version), 'pressure-vessel-{}-bin+src.tar.gz'.format(args.version),
) )
subprocess.check_call([ subprocess.check_call([
'tar', 'tar',
r'--transform=s,^\(\.\(/\|$\)\)\?,pressure-vessel-{}/,'.format( r'--transform=s,^\(\.\(/\|$\)\)\?,pressure-vessel-{}/,'.format(
args.version, args.version,
), ),
'--exclude=metadata', # this is all duplicated in sources/ '--exclude=metadata', # this is all duplicated in sources/
'-zcvf', src_tar + '.tmp', '-zcvf', src_tar + '.tmp',
'-C', destdir_prefix, '-C', installation,
'.', '.',
]) ])
subprocess.check_call([ subprocess.check_call([
'tar', 'tar',
r'--transform=s,^\(\.\(/\|$\)\)\?,pressure-vessel-{}/,'.format( r'--transform=s,^\(\.\(/\|$\)\)\?,pressure-vessel-{}/,'.format(
args.version, args.version,
), ),
'--exclude=sources', '--exclude=sources',
'-zcvf', bin_tar + '.tmp', '-zcvf', bin_tar + '.tmp',
'-C', destdir_prefix, '-C', installation,
'.', '.',
]) ])
os.rename(bin_tar + '.tmp', bin_tar) os.rename(bin_tar + '.tmp', bin_tar)
os.rename(src_tar + '.tmp', src_tar) os.rename(src_tar + '.tmp', src_tar)
print('Generated {}'.format(os.path.abspath(bin_tar))) print('Generated {}'.format(os.path.abspath(bin_tar)))
print('Generated {}'.format(os.path.abspath(src_tar))) print('Generated {}'.format(os.path.abspath(src_tar)))
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -109,23 +109,21 @@ pipeline { ...@@ -109,23 +109,21 @@ pipeline {
sh ''' sh '''
set -eu set -eu
cd src cd src
meson --prefix="${WORKSPACE}/src/_build/relocatable-install" -Dpython=python3.5 _build meson --prefix="$(pwd)/_build/prefix" -Dpython=python3.5 _build
ninja -C _build ninja -C _build
ninja -C _build install
meson test --verbose -C _build meson test --verbose -C _build
ninja -C _build install
rm -fr ../relocatable-install
./build-relocatable-install.py \ ./build-relocatable-install.py \
--srcdir . \ --srcdir . \
--builddir _build \ --builddir _build \
--libcapsuledir /usr/lib/libcapsule/relocatable \ --libcapsuledir /usr/lib/libcapsule/relocatable \
--prefix="${WORKSPACE}/src/_build/relocatable-install" \ --output "${WORKSPACE}/relocatable-install" \
--archive "${WORKSPACE}" \ --archive "${WORKSPACE}" \
--set-version "$(cat .tarball-version)" \ --set-version "$(cat .tarball-version)" \
${NULL+} ${NULL+}
prove -v ./tests/relocatable-install.py :: \ prove -v ./tests/relocatable-install.py :: \
--srcdir . \ "${WORKSPACE}/relocatable-install"
--builddir _build \
--prefix="${WORKSPACE}/src/_build/relocatable-install" \
${NULL+}
''' '''
} }
} }
......
...@@ -176,40 +176,10 @@ def main(): ...@@ -176,40 +176,10 @@ def main():
# type: () -> None # type: () -> None
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--destdir', default=os.getenv('DESTDIR', '')) parser.add_argument('path')
parser.add_argument('--srcdir', default=G_TEST_SRCDIR)
parser.add_argument('--builddir', default=G_TEST_BUILDDIR)
parser.add_argument('--prefix', default=None)
args = parser.parse_args() args = parser.parse_args()
if args.destdir: relocatable_install = os.path.abspath(args.path)
args.destdir = os.path.abspath(args.destdir)
args.srcdir = os.path.abspath(args.srcdir)
args.builddir = os.path.abspath(args.builddir)
if args.prefix is None:
blob = subprocess.check_output([
'meson', 'introspect', args.builddir, '--buildoptions',
], universal_newlines=True)
for opt in json.loads(blob):
if opt['name'] == 'prefix':
args.prefix = opt['value']
break
else:
raise RuntimeError(
'Unable to determine installation prefix from Meson, '
'please specify --prefix'
)
relocatable_install = args.destdir + args.prefix
if relocatable_install is None:
relocatable_install = os.path.join(args.builddir, 'relocatable-install')
if not os.path.exists(relocatable_install):
print('1..0 # SKIP relocatable-install not in expected location')
sys.exit(0)
test = TapTest() test = TapTest()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment