diff options
author | Patrick Gartung <gartung@fnal.gov> | 2020-07-08 15:05:58 -0500 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-08-13 00:33:31 -0700 |
commit | 4d25481473120303ceab42c3f7a675d0b90afcd0 (patch) | |
tree | f0d40664536fd8878ddd3a8cdc5598c128f7379e | |
parent | ecbfa5e44853fbd07028bd5f98e3b0f2d783f0ed (diff) | |
download | spack-4d25481473120303ceab42c3f7a675d0b90afcd0.tar.gz spack-4d25481473120303ceab42c3f7a675d0b90afcd0.tar.bz2 spack-4d25481473120303ceab42c3f7a675d0b90afcd0.tar.xz spack-4d25481473120303ceab42c3f7a675d0b90afcd0.zip |
Buildcache: bindist test without invoking spack compiler wrappers. (#15687)
* Buildcache:
* Try mocking an install of quux, corge and garply using prebuilt binaries
* Put patchelf install after ccache restore
* Add script to install patchelf from source so it can be used on Ubuntu:Trusty which does not have a patchelf pat package. The script will skip building on macOS
* Remove mirror at end of bindist test
* Add patchelf to Ubuntu build env
* Revert mock patchelf package to allow other tests to run.
* Remove depends_on('patchelf', type='build') relying instead on
* Test fixture to ensure patchelf is available.
* Call g++ command to build libraries directly during test build
* Flake8
* Install patchelf in before_install stage using apt unless on Trusty where a build is done.
* Add some symbolic links between packages
* Flake8
* Flake8:
* Update mock packages to write their own source files
* Create the stage because spec search does not create it any longer
* updates after change of list command arguments
* cleanup after merge
* flake8
-rw-r--r-- | .travis.yml | 8 | ||||
-rw-r--r-- | lib/spack/spack/binary_distribution.py | 1 | ||||
-rw-r--r-- | lib/spack/spack/test/bindist.py | 471 | ||||
-rwxr-xr-x | share/spack/qa/install_patchelf.sh | 22 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/corge/package.py | 155 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/garply/package.py | 112 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/patchelf/package.py | 19 | ||||
-rw-r--r-- | var/spack/repos/builtin.mock/packages/quux/package.py | 132 |
8 files changed, 911 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml index e4e6383dbd..808e79bbff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,14 @@ addons: - zsh - fish +before_install: + - if [[ "$TRAVIS_DIST" == "trusty" ]]; then + share/spack/qa/install_patchelf.sh; + else + sudo apt-get update; + sudo apt-get -y install patchelf; + fi + # Install various dependencies install: - pip install --upgrade pip diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index 31d60f84e1..220686f831 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -497,6 +497,7 @@ def download_tarball(spec): # stage the tarball into standard place stage = Stage(url, name="build_cache", keep=True) + stage.create() try: stage.fetch() return stage.save_filename diff --git a/lib/spack/spack/test/bindist.py b/lib/spack/spack/test/bindist.py new file mode 100644 index 0000000000..f561077edd --- /dev/null +++ b/lib/spack/spack/test/bindist.py @@ -0,0 +1,471 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +""" +This test checks creating and install buildcaches +""" +import os +import py +import pytest +import argparse +import platform +import spack.repo +import spack.store +import spack.binary_distribution as bindist +import spack.cmd.buildcache as buildcache +import spack.cmd.install as install +import spack.cmd.uninstall as uninstall +import spack.cmd.mirror as mirror +from spack.spec import Spec +from spack.directory_layout import YamlDirectoryLayout + + +def_install_path_scheme = '${ARCHITECTURE}/${COMPILERNAME}-${COMPILERVER}/${PACKAGE}-${VERSION}-${HASH}' # noqa: E501 +ndef_install_path_scheme = '${PACKAGE}/${VERSION}/${ARCHITECTURE}-${COMPILERNAME}-${COMPILERVER}-${HASH}' # noqa: E501 + +mirror_path_def = None +mirror_path_rel = None + + +@pytest.fixture(scope='function') +def cache_directory(tmpdir): + old_cache_path = spack.caches.fetch_cache + tmpdir.ensure('fetch_cache', dir=True) + fsc = spack.fetch_strategy.FsCache(str(tmpdir.join('fetch_cache'))) + spack.config.caches = fsc + yield spack.config.caches + tmpdir.join('fetch_cache').remove() + spack.config.caches = old_cache_path + + +@pytest.fixture(scope='session') +def session_mirror_def(tmpdir_factory): + dir = tmpdir_factory.mktemp('mirror') + global mirror_path_rel + mirror_path_rel = dir + dir.ensure('build_cache', dir=True) + yield dir + dir.join('build_cache').remove() + + +@pytest.fixture(scope='function') +def mirror_directory_def(session_mirror_def): + yield str(session_mirror_def) + + +@pytest.fixture(scope='session') +def session_mirror_rel(tmpdir_factory): + dir = tmpdir_factory.mktemp('mirror') + global mirror_path_rel + mirror_path_rel = dir + dir.ensure('build_cache', dir=True) + yield dir + dir.join('build_cache').remove() + + +@pytest.fixture(scope='function') +def mirror_directory_rel(session_mirror_rel): + yield(session_mirror_rel) + + +@pytest.fixture(scope='session') +def config_directory(tmpdir_factory): + tmpdir = tmpdir_factory.mktemp('test_configs') + # restore some sane defaults for packages and config + config_path = py.path.local(spack.paths.etc_path) + modules_yaml = config_path.join('spack', 'defaults', 'modules.yaml') + os_modules_yaml = config_path.join('spack', 'defaults', '%s' % + platform.system().lower(), + 'modules.yaml') + packages_yaml = config_path.join('spack', 'defaults', 'packages.yaml') + config_yaml = config_path.join('spack', 'defaults', 'config.yaml') + repos_yaml = config_path.join('spack', 'defaults', 'repos.yaml') + tmpdir.ensure('site', dir=True) + tmpdir.ensure('user', dir=True) + tmpdir.ensure('site/%s' % platform.system().lower(), dir=True) + modules_yaml.copy(tmpdir.join('site', 'modules.yaml')) + os_modules_yaml.copy(tmpdir.join('site/%s' % platform.system().lower(), + 'modules.yaml')) + packages_yaml.copy(tmpdir.join('site', 'packages.yaml')) + config_yaml.copy(tmpdir.join('site', 'config.yaml')) + repos_yaml.copy(tmpdir.join('site', 'repos.yaml')) + yield tmpdir + tmpdir.remove() + + +@pytest.fixture(scope='function') +def default_config(tmpdir_factory, config_directory, monkeypatch): + + mutable_dir = tmpdir_factory.mktemp('mutable_config').join('tmp') + config_directory.copy(mutable_dir) + + cfg = spack.config.Configuration( + *[spack.config.ConfigScope(name, str(mutable_dir)) + for name in ['site/%s' % platform.system().lower(), + 'site', 'user']]) + + monkeypatch.setattr(spack.config, 'config', cfg) + + # This is essential, otherwise the cache will create weird side effects + # that will compromise subsequent tests if compilers.yaml is modified + monkeypatch.setattr(spack.compilers, '_cache_config_file', []) + njobs = spack.config.get('config:build_jobs') + if not njobs: + spack.config.set('config:build_jobs', 4, scope='user') + extensions = spack.config.get('config:template_dirs') + if not extensions: + spack.config.set('config:template_dirs', + [os.path.join(spack.paths.share_path, 'templates')], + scope='user') + + mutable_dir.ensure('build_stage', dir=True) + build_stage = spack.config.get('config:build_stage') + if not build_stage: + spack.config.set('config:build_stage', + [str(mutable_dir.join('build_stage'))], scope='user') + timeout = spack.config.get('config:connect_timeout') + if not timeout: + spack.config.set('config:connect_timeout', 10, scope='user') + yield spack.config.config + mutable_dir.remove() + + +@pytest.fixture(scope='function') +def install_dir_default_layout(tmpdir): + """Hooks a fake install directory with a default layout""" + real_store = spack.store.store + real_layout = spack.store.layout + spack.store.store = spack.store.Store(str(tmpdir.join('opt'))) + spack.store.layout = YamlDirectoryLayout(str(tmpdir.join('opt')), + path_scheme=def_install_path_scheme) # noqa: E501 + yield spack.store + spack.store.store = real_store + spack.store.layout = real_layout + + +@pytest.fixture(scope='function') +def install_dir_non_default_layout(tmpdir): + """Hooks a fake install directory with a non-default layout""" + real_store = spack.store.store + real_layout = spack.store.layout + spack.store.store = spack.store.Store(str(tmpdir.join('opt'))) + spack.store.layout = YamlDirectoryLayout(str(tmpdir.join('opt')), + path_scheme=ndef_install_path_scheme) # noqa: E501 + yield spack.store + spack.store.store = real_store + spack.store.layout = real_layout + + +@pytest.mark.requires_executables( + '/usr/bin/gcc', 'patchelf', 'strings', 'file') +@pytest.mark.disable_clean_stage_check +@pytest.mark.maybeslow +@pytest.mark.usefixtures('default_config', 'cache_directory', + 'install_dir_default_layout') +def test_default_rpaths_create_install_default_layout(tmpdir, + mirror_directory_def, + install_mockery): + """ + Test the creation and installation of buildcaches with default rpaths + into the default directory layout scheme. + """ + + gspec = Spec('garply') + gspec.concretize() + cspec = Spec('corge') + cspec.concretize() + + # Install patchelf needed for relocate in linux test environment + iparser = argparse.ArgumentParser() + install.setup_parser(iparser) + # Install some packages with dependent packages + iargs = iparser.parse_args(['--no-cache', cspec.name]) + install.install(iparser, iargs) + + global mirror_path_def + mirror_path_def = mirror_directory_def + mparser = argparse.ArgumentParser() + mirror.setup_parser(mparser) + margs = mparser.parse_args( + ['add', '--scope', 'site', 'test-mirror-def', 'file://%s' % mirror_path_def]) + mirror.mirror(mparser, margs) + margs = mparser.parse_args(['list']) + mirror.mirror(mparser, margs) + + # setup argument parser + parser = argparse.ArgumentParser() + buildcache.setup_parser(parser) + + # Set default buildcache args + create_args = ['create', '-a', '-u', '-d', str(mirror_path_def), + cspec.name] + install_args = ['install', '-a', '-u', cspec.name] + + # Create a buildache + args = parser.parse_args(create_args) + buildcache.buildcache(parser, args) + # Test force overwrite create buildcache + create_args.insert(create_args.index('-a'), '-f') + args = parser.parse_args(create_args) + buildcache.buildcache(parser, args) + # create mirror index + args = parser.parse_args(['update-index', '-d', 'file://%s' % str(mirror_path_def)]) + buildcache.buildcache(parser, args) + # list the buildcaches in the mirror + args = parser.parse_args(['list', '-a', '-l', '-v']) + buildcache.buildcache(parser, args) + + # Uninstall the package and deps + uparser = argparse.ArgumentParser() + uninstall.setup_parser(uparser) + uargs = uparser.parse_args(['-y', '--dependents', gspec.name]) + uninstall.uninstall(uparser, uargs) + + # test install + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + # This gives warning that spec is already installed + buildcache.buildcache(parser, args) + + # test overwrite install + install_args.insert(install_args.index('-a'), '-f') + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + args = parser.parse_args(['keys', '-f']) + buildcache.buildcache(parser, args) + + args = parser.parse_args(['list']) + buildcache.buildcache(parser, args) + + args = parser.parse_args(['list', '-a']) + buildcache.buildcache(parser, args) + + args = parser.parse_args(['list', '-l', '-v']) + buildcache.buildcache(parser, args) + bindist._cached_specs = set() + spack.stage.purge() + margs = mparser.parse_args( + ['rm', '--scope', 'site', 'test-mirror-def']) + mirror.mirror(mparser, margs) + + +@pytest.mark.requires_executables( + '/usr/bin/gcc', 'patchelf', 'strings', 'file') +@pytest.mark.disable_clean_stage_check +@pytest.mark.maybeslow +@pytest.mark.nomockstage +@pytest.mark.usefixtures('default_config', 'cache_directory', + 'install_dir_non_default_layout') +def test_default_rpaths_install_nondefault_layout(tmpdir, + install_mockery): + """ + Test the creation and installation of buildcaches with default rpaths + into the non-default directory layout scheme. + """ + + gspec = Spec('garply') + gspec.concretize() + cspec = Spec('corge') + cspec.concretize() + + global mirror_path_def + mparser = argparse.ArgumentParser() + mirror.setup_parser(mparser) + margs = mparser.parse_args( + ['add', '--scope', 'site', 'test-mirror-def', 'file://%s' % mirror_path_def]) + mirror.mirror(mparser, margs) + + # setup argument parser + parser = argparse.ArgumentParser() + buildcache.setup_parser(parser) + + # Set default buildcache args + install_args = ['install', '-a', '-u', '%s' % cspec.name] + + # Install some packages with dependent packages + # test install in non-default install path scheme + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + # test force install in non-default install path scheme + install_args.insert(install_args.index('-a'), '-f') + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + bindist._cached_specs = set() + spack.stage.purge() + margs = mparser.parse_args( + ['rm', '--scope', 'site', 'test-mirror-def']) + mirror.mirror(mparser, margs) + + +@pytest.mark.requires_executables( + '/usr/bin/gcc', 'patchelf', 'strings', 'file') +@pytest.mark.disable_clean_stage_check +@pytest.mark.maybeslow +@pytest.mark.nomockstage +@pytest.mark.usefixtures('default_config', 'cache_directory', + 'install_dir_default_layout') +def test_relative_rpaths_create_default_layout(tmpdir, + mirror_directory_rel, + install_mockery): + """ + Test the creation and installation of buildcaches with relative + rpaths into the default directory layout scheme. + """ + + gspec = Spec('garply') + gspec.concretize() + cspec = Spec('corge') + cspec.concretize() + + global mirror_path_rel + mirror_path_rel = mirror_directory_rel + # Install patchelf needed for relocate in linux test environment + iparser = argparse.ArgumentParser() + install.setup_parser(iparser) + # Install some packages with dependent packages + iargs = iparser.parse_args(['--no-cache', cspec.name]) + install.install(iparser, iargs) + + # setup argument parser + parser = argparse.ArgumentParser() + buildcache.setup_parser(parser) + + # set default buildcache args + create_args = ['create', '-a', '-u', '-r', '-d', + str(mirror_path_rel), + cspec.name] + + # create build cache with relatived rpaths + args = parser.parse_args(create_args) + buildcache.buildcache(parser, args) + # create mirror index + args = parser.parse_args(['update-index', '-d', 'file://%s' % str(mirror_path_rel)]) + buildcache.buildcache(parser, args) + # Uninstall the package and deps + uparser = argparse.ArgumentParser() + uninstall.setup_parser(uparser) + uargs = uparser.parse_args(['-y', '--dependents', gspec.name]) + uninstall.uninstall(uparser, uargs) + + bindist._cached_specs = set() + spack.stage.purge() + + +@pytest.mark.requires_executables( + '/usr/bin/gcc', 'patchelf', 'strings', 'file') +@pytest.mark.disable_clean_stage_check +@pytest.mark.maybeslow +@pytest.mark.nomockstage +@pytest.mark.usefixtures('default_config', 'cache_directory', + 'install_dir_default_layout') +def test_relative_rpaths_install_default_layout(tmpdir, + install_mockery): + """ + Test the creation and installation of buildcaches with relative + rpaths into the default directory layout scheme. + """ + + gspec = Spec('garply') + gspec.concretize() + cspec = Spec('corge') + cspec.concretize() + + global mirror_path_rel + mparser = argparse.ArgumentParser() + mirror.setup_parser(mparser) + margs = mparser.parse_args( + ['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel]) + mirror.mirror(mparser, margs) + + # Install patchelf needed for relocate in linux test environment + iparser = argparse.ArgumentParser() + install.setup_parser(iparser) + + # setup argument parser + parser = argparse.ArgumentParser() + buildcache.setup_parser(parser) + + # set default buildcache args + install_args = ['install', '-a', '-u', + cspec.name] + + # install buildcache created with relativized rpaths + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + # This gives warning that spec is already installed + buildcache.buildcache(parser, args) + + # Uninstall the package and deps + uparser = argparse.ArgumentParser() + uninstall.setup_parser(uparser) + uargs = uparser.parse_args(['-y', '--dependents', gspec.name]) + uninstall.uninstall(uparser, uargs) + + # install build cache + buildcache.buildcache(parser, args) + + # test overwrite install + install_args.insert(install_args.index('-a'), '-f') + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + bindist._cached_specs = set() + spack.stage.purge() + margs = mparser.parse_args( + ['rm', '--scope', 'site', 'test-mirror-rel']) + mirror.mirror(mparser, margs) + + +@pytest.mark.requires_executables( + '/usr/bin/gcc', 'patchelf', 'strings', 'file') +@pytest.mark.disable_clean_stage_check +@pytest.mark.maybeslow +@pytest.mark.nomockstage +@pytest.mark.usefixtures('default_config', 'cache_directory', + 'install_dir_non_default_layout') +def test_relative_rpaths_install_nondefault(tmpdir, + install_mockery): + """ + Test the installation of buildcaches with relativized rpaths + into the non-default directory layout scheme. + """ + + gspec = Spec('garply') + gspec.concretize() + cspec = Spec('corge') + cspec.concretize() + + global mirror_path_rel + + mparser = argparse.ArgumentParser() + mirror.setup_parser(mparser) + margs = mparser.parse_args( + ['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel]) + mirror.mirror(mparser, margs) + + # Install patchelf needed for relocate in linux test environment + iparser = argparse.ArgumentParser() + install.setup_parser(iparser) + + # setup argument parser + parser = argparse.ArgumentParser() + buildcache.setup_parser(parser) + + # Set default buildcache args + install_args = ['install', '-a', '-u', '%s' % cspec.name] + + # test install in non-default install path scheme and relative path + args = parser.parse_args(install_args) + buildcache.buildcache(parser, args) + + bindist._cached_specs = set() + spack.stage.purge() + margs = mparser.parse_args( + ['rm', '--scope', 'site', 'test-mirror-rel']) + mirror.mirror(mparser, margs) diff --git a/share/spack/qa/install_patchelf.sh b/share/spack/qa/install_patchelf.sh new file mode 100755 index 0000000000..7660ba8eef --- /dev/null +++ b/share/spack/qa/install_patchelf.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +# +# Description: +# Install patchelf for use in buildcache unit tests +# +# Usage: +# install-patchelf.sh +# +set -ex +if [ "$TRAVIS_OS_NAME" = "linux" ]; then + olddir=$PWD + cd /tmp + wget https://github.com/NixOS/patchelf/archive/0.10.tar.gz + tar -xvf 0.10.tar.gz + cd patchelf-0.10 && ./bootstrap.sh && ./configure --prefix=/usr && make && sudo make install && cd $olddir +fi diff --git a/var/spack/repos/builtin.mock/packages/corge/package.py b/var/spack/repos/builtin.mock/packages/corge/package.py new file mode 100644 index 0000000000..48f9ac8e6e --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/corge/package.py @@ -0,0 +1,155 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack import * +import os + + +class Corge(Package): + """A toy package to test dependencies""" + + homepage = "https://www.example.com" + url = "https://github.com/gartung/corge/archive/v3.0.0.tar.gz" + + version('3.0.0', + sha256='5058861c3b887511387c725971984cec665a8307d660158915a04d7786fed6bc') + + depends_on('quux') + + def install(self, spec, prefix): + corge_cc = '''#include <iostream> +#include <stdexcept> +#include "corge.h" +#include "corge_version.h" +#include "quux/quux.h" + +const int Corge::version_major = corge_version_major; +const int Corge::version_minor = corge_version_minor; + +Corge::Corge() +{ +} + +int +Corge::get_version() const +{ + return 10 * version_major + version_minor; +} + +int +Corge::corgegate() const +{ + int corge_version = get_version(); + std::cout << "Corge::corgegate version " << corge_version + << " invoked" << std::endl; + std::cout << "Corge config directory = %s" <<std::endl; + Quux quux; + int quux_version = quux.quuxify(); + + if(quux_version != corge_version) { + throw std::runtime_error( + "Corge found an incompatible version of Garply."); + } + + return corge_version; +} +''' + corge_h = '''#ifndef CORGE_H_ + +class Corge +{ +private: + static const int version_major; + static const int version_minor; + +public: + Corge(); + int get_version() const; + int corgegate() const; +}; + +#endif // CORGE_H_ +''' + corge_version_h = ''' +const int corge_version_major = %s; +const int corge_version_minor = %s; +''' + corgegator_cc = ''' +#include <iostream> +#include "corge.h" + +int +main(int argc, char* argv[]) +{ + std::cout << "corgerator called with "; + if (argc == 0) { + std::cout << "no command-line arguments" << std::endl; + } else { + std::cout << "command-line arguments:"; + for (int i = 0; i < argc; ++i) { + std::cout << " \"" << argv[i] << "\""; + } + std::cout << std::endl; + } + std::cout << "corgegating.."<<std::endl; + Corge corge; + corge.corgegate(); + std::cout << "done."<<std::endl; + return 0; +} +''' + mkdirp(prefix.lib64) + mkdirp('%s/corge' % prefix.include) + mkdirp('%s/corge' % self.stage.source_path) + with open('%s/corge_version.h' % self.stage.source_path, 'w') as f: + f.write(corge_version_h % (self.version[0], self.version[1:])) + with open('%s/corge/corge.cc' % self.stage.source_path, 'w') as f: + f.write(corge_cc % prefix.config) + with open('%s/corge/corge.h' % self.stage.source_path, 'w') as f: + f.write(corge_h) + with open('%s/corge/corgegator.cc' % self.stage.source_path, 'w') as f: + f.write(corgegator_cc) + gpp = which('/usr/bin/g++') + gpp('-Dcorge_EXPORTS', + '-I%s' % self.stage.source_path, + '-I%s' % spec['quux'].prefix.include, + '-I%s' % spec['garply'].prefix.include, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'corge.cc.o', + '-c', 'corge/corge.cc') + gpp('-Dcorge_EXPORTS', + '-I%s' % self.stage.source_path, + '-I%s' % spec['quux'].prefix.include, + '-I%s' % spec['garply'].prefix.include, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'corgegator.cc.o', + '-c', 'corge/corgegator.cc') + gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', + '-Wl,-soname,libcorge.so', '-o', 'libcorge.so', 'corge.cc.o', + '-Wl,-rpath,%s:%s::::' % + (spec['quux'].prefix.lib64, spec['garply'].prefix.lib64), + '%s/libquux.so' % spec['quux'].prefix.lib64, + '%s/libgarply.so' % spec['garply'].prefix.lib64) + gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', + 'corgegator.cc.o', '-o', 'corgegator', + '-Wl,-rpath,%s:%s:%s:::' % (prefix.lib64, + spec['quux'].prefix.lib64, + spec['garply'].prefix.lib64), + 'libcorge.so', + '%s/libquux.so' % spec['quux'].prefix.lib64, + '%s/libgarply.so' % spec['garply'].prefix.lib64) + copy('corgegator', '%s/corgegator' % prefix.lib64) + copy('libcorge.so', '%s/libcorge.so' % prefix.lib64) + copy('%s/corge/corge.h' % self.stage.source_path, + '%s/corge/corge.h' % prefix.include) + mkdirp(prefix.bin) + copy('corge_version.h', '%s/corge_version.h' % prefix.bin) + os.symlink('%s/corgegator' % prefix.lib64, + '%s/corgegator' % prefix.bin) + os.symlink('%s/quuxifier' % spec['quux'].prefix.lib64, + '%s/quuxifier' % prefix.bin) + os.symlink('%s/garplinator' % spec['garply'].prefix.lib64, + '%s/garplinator' % prefix.bin) diff --git a/var/spack/repos/builtin.mock/packages/garply/package.py b/var/spack/repos/builtin.mock/packages/garply/package.py new file mode 100644 index 0000000000..8fa0778287 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/garply/package.py @@ -0,0 +1,112 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack import * +import os + + +class Garply(Package): + """Toy package for testing dependencies""" + + homepage = "https://www.example.com" + url = "https://github.com/gartung/garply/archive/v3.0.0.tar.gz" + + version('3.0.0', + sha256='534ac8ba7a6fed7e8bbb543bd43ca04999e65337445a531bd296939f5ac2f33d') + + def install(self, spec, prefix): + garply_h = '''#ifndef GARPLY_H_ + +class Garply +{ +private: + static const int version_major; + static const int version_minor; + +public: + Garply(); + int get_version() const; + int garplinate() const; +}; + +#endif // GARPLY_H_ +''' + garply_cc = '''#include "garply.h" +#include "garply_version.h" +#include <iostream> + +const int Garply::version_major = garply_version_major; +const int Garply::version_minor = garply_version_minor; + +Garply::Garply() {} + +int +Garply::get_version() const +{ + return 10 * version_major + version_minor; +} + +int +Garply::garplinate() const +{ + std::cout << "Garply::garplinate version " << get_version() + << " invoked" << std::endl; + std::cout << "Garply config dir = %s" << std::endl; + return get_version(); +} +''' + garplinator_cc = '''#include "garply.h" +#include <iostream> + +int +main() +{ + Garply garply; + garply.garplinate(); + + return 0; +} +''' + garply_version_h = '''const int garply_version_major = %s; +const int garply_version_minor = %s; +''' + mkdirp(prefix.lib64) + mkdirp('%s/garply' % prefix.include) + mkdirp('%s/garply' % self.stage.source_path) + with open('%s/garply_version.h' % self.stage.source_path, 'w') as f: + f.write(garply_version_h % (self.version[0], self.version[1:])) + with open('%s/garply/garply.h' % self.stage.source_path, 'w') as f: + f.write(garply_h) + with open('%s/garply/garply.cc' % self.stage.source_path, 'w') as f: + f.write(garply_cc % prefix.config) + with open('%s/garply/garplinator.cc' % + self.stage.source_path, 'w') as f: + f.write(garplinator_cc) + gpp = which('/usr/bin/g++') + gpp('-Dgarply_EXPORTS', + '-I%s' % self.stage.source_path, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'garply.cc.o', + '-c', '%s/garply/garply.cc' % self.stage.source_path) + gpp('-Dgarply_EXPORTS', + '-I%s' % self.stage.source_path, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'garplinator.cc.o', + '-c', '%s/garply/garplinator.cc' % self.stage.source_path) + gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', + '-Wl,-soname,libgarply.so', '-o', 'libgarply.so', 'garply.cc.o') + gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', + 'garplinator.cc.o', '-o', 'garplinator', + '-Wl,-rpath,%s' % prefix.lib64, + 'libgarply.so') + copy('libgarply.so', '%s/libgarply.so' % prefix.lib64) + copy('garplinator', '%s/garplinator' % prefix.lib64) + copy('%s/garply/garply.h' % self.stage.source_path, + '%s/garply/garply.h' % prefix.include) + mkdirp(prefix.bin) + copy('garply_version.h', '%s/garply_version.h' % prefix.bin) + os.symlink('%s/garplinator' % prefix.lib64, + '%s/garplinator' % prefix.bin) diff --git a/var/spack/repos/builtin.mock/packages/patchelf/package.py b/var/spack/repos/builtin.mock/packages/patchelf/package.py index 0f72271921..80221e10e8 100644 --- a/var/spack/repos/builtin.mock/packages/patchelf/package.py +++ b/var/spack/repos/builtin.mock/packages/patchelf/package.py @@ -7,16 +7,17 @@ from spack import * class Patchelf(AutotoolsPackage): - """ - PatchELF is a small utility to modify the - dynamic linker and RPATH of ELF executables. - """ + """PatchELF is a small utility to modify the dynamic linker and RPATH of + ELF executables.""" homepage = "https://nixos.org/patchelf.html" - url = "http://nixos.org/releases/patchelf/patchelf-0.8/patchelf-0.8.tar.gz" - - list_url = "http://nixos.org/releases/patchelf/" + url = "https://nixos.org/releases/patchelf/patchelf-0.10/patchelf-0.10.tar.gz" + list_url = "https://nixos.org/releases/patchelf/" list_depth = 1 - version('0.9', '3c265508526760f233620f35d79c79fc') - version('0.8', '407b229e6a681ffb0e2cdd5915cb2d01') + version('0.10', sha256='b2deabce05c34ce98558c0efb965f209de592197b2c88e930298d740ead09019') + version('0.9', sha256='f2aa40a6148cb3b0ca807a1bf836b081793e55ec9e5540a5356d800132be7e0a') + version('0.8', sha256='14af06a2da688d577d64ff8dac065bb8903bbffbe01d30c62df7af9bf4ce72fe') + + def install(self, spec, prefix): + install_tree(self.stage.source_path, prefix) diff --git a/var/spack/repos/builtin.mock/packages/quux/package.py b/var/spack/repos/builtin.mock/packages/quux/package.py new file mode 100644 index 0000000000..6db243f154 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/quux/package.py @@ -0,0 +1,132 @@ +# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack import * +import os + + +class Quux(Package): + """Toy package for testing dependencies""" + + homepage = "https://www.example.com" + url = "https://github.com/gartung/quux/archive/v3.0.0.tar.gz" + + version('3.0.0', + sha256='b91bc96fb746495786bddac2c527039177499f2f76d3fa9dcf0b393859e68484') + + depends_on('garply') + + def install(self, spec, prefix): + quux_cc = '''#include "quux.h" +#include "garply/garply.h" +#include "quux_version.h" +#include <iostream> +#include <stdexcept> + +const int Quux::version_major = quux_version_major; +const int Quux::version_minor = quux_version_minor; + +Quux::Quux() {} + +int +Quux::get_version() const +{ + return 10 * version_major + version_minor; +} + +int +Quux::quuxify() const +{ + int quux_version = get_version(); + std::cout << "Quux::quuxify version " << quux_version + << " invoked" <<std::endl; + std::cout << "Quux config directory is %s" <<std::endl; + Garply garply; + int garply_version = garply.garplinate(); + + if (garply_version != quux_version) { + throw std::runtime_error( + "Quux found an incompatible version of Garply."); + } + + return quux_version; +} +''' + quux_h = '''#ifndef QUUX_H_ + +class Quux +{ +private: + static const int version_major; + static const int version_minor; + +public: + Quux(); + int get_version() const; + int quuxify() const; +}; + +#endif // QUUX_H_ +''' + quuxifier_cc = ''' +#include "quux.h" +#include <iostream> + +int +main() +{ + Quux quux; + quux.quuxify(); + + return 0; +} +''' + quux_version_h = '''const int quux_version_major = %s; +const int quux_version_minor = %s; +''' + mkdirp(prefix.lib64) + mkdirp('%s/quux' % prefix.include) + with open('%s/quux_version.h' % self.stage.source_path, 'w') as f: + f.write(quux_version_h % (self.version[0], self.version[1:])) + with open('%s/quux/quux.cc' % self.stage.source_path, 'w') as f: + f.write(quux_cc % (prefix.config)) + with open('%s/quux/quux.h' % self.stage.source_path, 'w') as f: + f.write(quux_h) + with open('%s/quux/quuxifier.cc' % self.stage.source_path, 'w') as f: + f.write(quuxifier_cc) + gpp = which('/usr/bin/g++') + gpp('-Dquux_EXPORTS', + '-I%s' % self.stage.source_path, + '-I%s' % spec['garply'].prefix.include, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'quux.cc.o', + '-c', 'quux/quux.cc') + gpp('-Dquux_EXPORTS', + '-I%s' % self.stage.source_path, + '-I%s' % spec['garply'].prefix.include, + '-O2', '-g', '-DNDEBUG', '-fPIC', + '-o', 'quuxifier.cc.o', + '-c', 'quux/quuxifier.cc') + gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', + '-Wl,-soname,libquux.so', '-o', 'libquux.so', 'quux.cc.o', + '-Wl,-rpath,%s:%s::::' % (prefix.lib64, + spec['garply'].prefix.lib64), + '%s/libgarply.so' % spec['garply'].prefix.lib64) + gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', + 'quuxifier.cc.o', '-o', 'quuxifier', + '-Wl,-rpath,%s:%s::::' % (prefix.lib64, + spec['garply'].prefix.lib64), + 'libquux.so', + '%s/libgarply.so' % spec['garply'].prefix.lib64) + copy('libquux.so', '%s/libquux.so' % prefix.lib64) + copy('quuxifier', '%s/quuxifier' % prefix.lib64) + copy('%s/quux/quux.h' % self.stage.source_path, + '%s/quux/quux.h' % prefix.include) + mkdirp(prefix.bin) + copy('quux_version.h', '%s/quux_version.h' % prefix.bin) + os.symlink('%s/quuxifier' % prefix.lib64, '%s/quuxifier' % prefix.bin) + os.symlink('%s/garplinator' % spec['garply'].prefix.lib64, + '%s/garplinator' % prefix.bin) |