From 8c4117367803fac989582550fc546323e3586862 Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Wed, 8 Jul 2020 15:05:58 -0500 Subject: 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 --- .../repos/builtin.mock/packages/corge/package.py | 155 +++++++++++++++++++++ .../repos/builtin.mock/packages/garply/package.py | 112 +++++++++++++++ .../builtin.mock/packages/patchelf/package.py | 19 +-- .../repos/builtin.mock/packages/quux/package.py | 132 ++++++++++++++++++ 4 files changed, 409 insertions(+), 9 deletions(-) create mode 100644 var/spack/repos/builtin.mock/packages/corge/package.py create mode 100644 var/spack/repos/builtin.mock/packages/garply/package.py create mode 100644 var/spack/repos/builtin.mock/packages/quux/package.py (limited to 'var') 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 +#include +#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" < +#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.."< + +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 + +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 +#include + +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" < + +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) -- cgit v1.2.3-70-g09d2