diff --git a/README.md b/README.md index 043c19dbdb1820efe7c05f63d05e2eced0a619d1..87ae78d92c3c8640107bb0e6f2d3a9d45cd17242 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,17 @@ already. Then you can do: meson --prefix=$(pwd)/_build/relocatable-install -Drelocatable=true _build ninja -C _build - meson test -v -C _build # optional rm -fr $(pwd)/_build/relocatable-install + meson test -v -C _build # optional ninja -C _build install + ./build-relocatable-install.py \ + --srcdir . \ + --builddir _build \ + --libcapsuledir /usr/lib/libcapsule/relocatable \ + --archive . + ./tests/relocatable-install.py \ + --srcdir . \ + --builddir _build # optional 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 @@ -163,11 +171,16 @@ tarball at `_build/sysroot.tar.gz` or unpack a sysroot into ./sysroot/run-in-sysroot.py apt-get update ./sysroot/run-in-sysroot.py meson ... + rm -fr $(pwd)/_build/relocatable-install + ./sysroot/run-in-sysroot.py ninja ... + ./sysroot/run-in-sysroot.py ./build-relocatable-install.py ... (Or put them in different locations and pass the `--sysroot` and `--tarball` options to `./sysroot/run-in-sysroot.py`.) -The relocatable install ends up in `_build/relocatable-install`. +The relocatable install goes into`_build/relocatable-install` (or +whatever you used as the `--prefix`), and a compressed version ends +up in the directory passed as an argument to `--archive`. Instructions for testing ------------------------ diff --git a/build-relocatable-install.py b/build-relocatable-install.py index f39b5dfd0af0c0435952a11ad0a6f2b583085c2e..992ada4249f1d398d75bb82c129d044e277f216a 100755 --- a/build-relocatable-install.py +++ b/build-relocatable-install.py @@ -25,6 +25,7 @@ import argparse import glob +import json import os import re import shutil @@ -139,25 +140,40 @@ def main(): '--srcdir', default=os.getenv('MESON_SOURCE_ROOT', '.')) parser.add_argument( '--builddir', default=os.getenv('MESON_BUILD_ROOT', '_build')) - parser.add_argument( - '--prefix', - default=os.getenv( - 'MESON_INSTALL_PREFIX', - os.path.abspath(os.path.join('_build', 'relocatable-install')), - ), - ) - parser.add_argument( - '--archive', default=os.getenv('MESON_BUILD_ROOT', '.')) - parser.add_argument('--relocatabledir', default='') + parser.add_argument('--prefix', default=None) + parser.add_argument('--archive', default=None) + parser.add_argument('--libcapsuledir', default='') parser.add_argument('--set-version', dest='version', default='unknown') args = parser.parse_args() + if args.destdir: + args.destdir = os.path.abspath(args.destdir) + + args.srcdir = os.path.abspath(args.srcdir) + args.builddir = os.path.abspath(args.builddir) + + if args.archive is None: + args.archive = args.builddir + else: + args.archive = os.path.abspath(args.archive) + + 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' + ) + os.chdir(args.builddir) - destdir_prefix = os.getenv( - 'MESON_INSTALL_DESTDIR_PREFIX', - args.destdir + args.prefix, - ) + destdir_prefix = args.destdir + args.prefix os.makedirs(os.path.join(destdir_prefix, 'bin'), exist_ok=True) os.makedirs(os.path.join(destdir_prefix, 'metadata'), exist_ok=True) @@ -186,12 +202,12 @@ def main(): 0o644, ) - if args.relocatabledir: + if args.libcapsuledir: for arch in ARCHS: for tool in TOOLS: install_exe( os.path.join( - args.relocatabledir, + args.libcapsuledir, '{}-{}'.format(arch.multiarch, tool), ), os.path.join(destdir_prefix, 'bin'), @@ -341,7 +357,7 @@ def main(): for package, source in ( list(DEPENDENCIES.items()) + list(PRIMARY_ARCH_DEPENDENCIES.items()) ): - if not args.relocatabledir and source == 'libcapsule': + if not args.libcapsuledir and source == 'libcapsule': continue if os.path.exists('/usr/share/doc/{}/copyright'.format(package)): @@ -400,7 +416,7 @@ def main(): os.path.join(destdir_prefix, 'sources'), ) - if not args.relocatabledir: + if not args.libcapsuledir: for dsc in glob.glob( os.path.join(args.srcdir, 'libcapsule*.dsc') ): diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 07196d10516dd81ccd1cbae392210bbf07583a2c..118390c20b62750ce5be14e8006048f5c5373a22 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -109,19 +109,30 @@ pipeline { sh ''' set -eu cd src - meson --prefix="${WORKSPACE}/src/_build/relocatable-install" -Dpython=python3.5 -Drelocatable=true _build + meson --prefix="${WORKSPACE}/src/_build/relocatable-install" -Dpython=python3.5 _build ninja -C _build ninja -C _build install meson test --verbose -C _build + ./build-relocatable-install.py \ + --srcdir . \ + --builddir _build \ + --libcapsuledir /usr/lib/libcapsule/relocatable \ + --prefix="${WORKSPACE}/src/_build/relocatable-install" \ + --archive "${WORKSPACE}" \ + --set-version "$(cat .tarball-version)" \ + ${NULL+} + prove -v ./tests/relocatable-install.py :: \ + --srcdir . \ + --builddir _build \ + --prefix="${WORKSPACE}/src/_build/relocatable-install" \ + ${NULL+} ''' } } } - dir('src/_build') { - archiveArtifacts 'pressure-vessel-*-bin.tar.gz' - archiveArtifacts 'pressure-vessel-*-bin+src.tar.gz' - } + archiveArtifacts 'pressure-vessel-*-bin.tar.gz' + archiveArtifacts 'pressure-vessel-*-bin+src.tar.gz' } } } diff --git a/meson.build b/meson.build index 43946cdc57ce860a64af7dbdc5922b6de2d1ebb3..e64ec6454ee85ac1e2be6aca6c3ac151a8f76100 100644 --- a/meson.build +++ b/meson.build @@ -117,7 +117,6 @@ tests = [ 'mypy.sh', 'pycodestyle.sh', 'pyflakes.sh', - 'relocatable-install.py', 'shellcheck.sh', ] @@ -188,17 +187,4 @@ executable( kwargs : rpath_kwargs, ) -if get_option('relocatable') - meson.add_install_script( - python.path(), - join_paths(meson.current_source_dir(), 'build-relocatable-install.py'), - '--srcdir', meson.current_source_dir(), - '--builddir', meson.current_build_dir(), - '--relocatabledir', '/usr/lib/libcapsule/relocatable', - '--prefix', get_option('prefix'), - '--archive', meson.current_build_dir(), - '--set-version', version, - ) -endif - # vim:set sw=2 sts=2 et: diff --git a/tests/relocatable-install.py b/tests/relocatable-install.py index 3f122c31cfc1d2fcf2db941ca91fb34ec1caabff..28e202a42ae69e9ef0e718cd723aba0acc8fe3eb 100755 --- a/tests/relocatable-install.py +++ b/tests/relocatable-install.py @@ -22,6 +22,8 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +import argparse +import json import os import subprocess import sys @@ -172,11 +174,42 @@ def check_dependencies(test, relocatable_install, path, is_wrapper=False): def main(): # type: () -> None - relocatable_install = os.path.join(G_TEST_BUILDDIR, 'relocatable-install') - if not os.path.exists(relocatable_install): - print('1..0 # SKIP relocatable-install not in expected location') - sys.exit(0) + parser = argparse.ArgumentParser() + parser.add_argument('--destdir', default=os.getenv('DESTDIR', '')) + 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() + + if args.destdir: + 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()