In the Getting started Section we already mentioned that
Spack can bootstrap some of its dependencies, including
clingo. In fact, there
is an entire command dedicated to the management of every aspect of bootstrapping:
$ spack bootstrap --help usage: spack bootstrap [-h] SUBCOMMAND ... manage bootstrap configuration positional arguments: SUBCOMMAND status get the status of Spack enable enable bootstrapping disable disable bootstrapping reset reset bootstrapping configuration to Spack defaults root get/set the root bootstrap directory list list all the sources of software to bootstrap Spack trust trust a bootstrapping source untrust untrust a bootstrapping source add add a new source for bootstrapping remove remove a bootstrapping source mirror create a local mirror to bootstrap Spack optional arguments: -h, --help show this help message and exit
The first thing to know to understand bootstrapping in Spack is that each of Spack’s dependencies is bootstrapped lazily; i.e. the first time it is needed and can’t be found. You can readily check if any prerequisite for using Spack is missing by running:
% spack bootstrap status Spack v0.17.1 - email@example.com [FAIL] Core Functionalities [B] MISSING "clingo": required to concretize specs [FAIL] Binary packages [B] MISSING "gpg2": required to sign/verify buildcaches Spack will take care of bootstrapping any missing dependency marked as [B]. Dependencies marked as [-] are instead required to be found on the system.
In the case of the output shown above Spack detected that both
are missing and it’s giving detailed information on why they are needed and whether
they can be bootstrapped. Running a command that concretize a spec, like:
% spack solve zlib ==> Bootstrapping clingo from pre-built binaries ==> Fetching https://mirror.spack.io/bootstrap/github-actions/v0.1/build_cache/darwin-catalina-x86_64/apple-clang-12.0.0/clingo-bootstrap-spack/darwin-catalina-x86_64-apple-clang-12.0.0-clingo-bootstrap-spack-p5on7i4hejl775ezndzfdkhvwra3hatn.spack ==> Installing "clingo-bootstrap@firstname.lastname@example.org~docs~ipo+python build_type=Release arch=darwin-catalina-x86_64" from a buildcache [ ... ]
triggers the bootstrapping of clingo from pre-built binaries as expected.
The Bootstrapping store¶
The software installed for bootstrapping purposes is deployed in a separate store. Its location can be checked with the following command:
% spack bootstrap root
It can also be changed with the same command by just specifying the newly desired path:
% spack bootstrap root /opt/spack/bootstrap
You can check what is installed in the bootstrapping store at any time using:
% spack find -b ==> Showing internal bootstrap store at "/Users/spack/.spack/bootstrap/store" ==> 11 installed packages -- darwin-catalina-x86_64 / email@example.com ------------------ clingo-bootstrap@spack firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com
In case it is needed you can remove all the software in the current bootstrapping store with:
% spack clean -b ==> Removing bootstrapped software and configuration in "/Users/spack/.spack/bootstrap" % spack find -b ==> Showing internal bootstrap store at "/Users/spack/.spack/bootstrap/store" ==> 0 installed packages
Enabling and disabling bootstrapping methods¶
Bootstrapping is always performed by trying the methods listed by:
$ spack bootstrap list Name: github-actions-v0.2 TRUSTED Type: buildcache Info: url: https://mirror.spack.io/bootstrap/github-actions/v0.2 homepage: https://github.com/spack/spack-bootstrap-mirrors releases: https://github.com/spack/spack-bootstrap-mirrors/releases Description: Buildcache generated from a public workflow using Github Actions. The sha256 checksum of binaries is checked before installation. Name: github-actions-v0.1 UNKNOWN Type: buildcache Info: url: https://mirror.spack.io/bootstrap/github-actions/v0.1 homepage: https://github.com/spack/spack-bootstrap-mirrors releases: https://github.com/spack/spack-bootstrap-mirrors/releases Description: Buildcache generated from a public workflow using Github Actions. The sha256 checksum of binaries is checked before installation. Name: spack-install TRUSTED Type: install Info: url: https://mirror.spack.io Description: Specs built from sources downloaded from the Spack public mirror.
in the order they appear, from top to bottom. By default Spack is configured to try first bootstrapping from pre-built binaries and to fall-back to bootstrapping from sources if that failed.
If need be, you can disable bootstrapping altogether by running:
% spack bootstrap disable
in which case it’s your responsibility to ensure Spack runs in an environment where all its prerequisites are installed. You can also configure Spack to skip certain bootstrapping methods by untrusting them. For instance:
% spack bootstrap untrust github-actions ==> "github-actions" is now untrusted and will not be used for bootstrapping
tells Spack to skip trying to bootstrap from binaries. To add the “github-actions” method back you can:
% spack bootstrap trust github-actions
There is also an option to reset the bootstrapping configuration to Spack’s defaults:
% spack bootstrap reset ==> Bootstrapping configuration is being reset to Spack's defaults. Current configuration will be lost. Do you want to continue? [Y/n] %
Creating a mirror for air-gapped systems¶
Spack’s default configuration for bootstrapping relies on the user having access to the internet, either to fetch pre-compiled binaries or source tarballs. Sometimes though Spack is deployed on air-gapped systems where such access is denied.
To help with similar situations Spack has a command that recreates, in a local folder of choice, a mirror containing the source tarballs and/or binary packages needed for bootstrapping.
% spack bootstrap mirror --binary-packages /opt/bootstrap ==> Adding "clingo-bootstrap@spack+python %apple-clang target=x86_64" and dependencies to the mirror at /opt/bootstrap/local-mirror ==> Adding "firstname.lastname@example.org: %apple-clang target=x86_64" and dependencies to the mirror at /opt/bootstrap/local-mirror ==> Adding "email@example.com:0.13.99 %apple-clang target=x86_64" and dependencies to the mirror at /opt/bootstrap/local-mirror ==> Adding binary packages from "https://github.com/alalazo/spack-bootstrap-mirrors/releases/download/v0.1-rc.2/bootstrap-buildcache.tar.gz" to the mirror at /opt/bootstrap/local-mirror To register the mirror on the platform where it's supposed to be used run the following command(s): % spack bootstrap add --trust local-sources /opt/bootstrap/metadata/sources % spack bootstrap add --trust local-binaries /opt/bootstrap/metadata/binaries
This command needs to be run on a machine with internet access and the resulting folder has to be moved over to the air-gapped system. Once the local sources are added using the commands suggested at the prompt, they can be used to bootstrap Spack.