Skip to content
Open
16 changes: 9 additions & 7 deletions docs/sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,15 @@ Optimization

Uberenv also features options to optimize the installation

===================== ============================================== ================================================
Option Description Default
===================== ============================================== ================================================
``--mirror`` Location of a Spack mirror **None**
``--create-mirror`` Creates a Spack mirror at specified location **None**
``--upstream`` Location of a Spack upstream **None**
===================== ============================================== ================================================
====================== ============================================== ================================================
Option Description Default
====================== ============================================== ================================================
``--mirror`` Location of a Spack mirror **None**
``--create-mirror`` Creates a Spack mirror at specified location **None**
``--upstream`` Location of a Spack upstream **None**
``--mirror-autopush`` Push binaries to mirror as they are built False
``--trust-key`` Load the gpg key(s) to the Spack gpg keyring **None**
====================== ============================================== ================================================

.. note::
These options are only currently available for spack.
Expand Down
39 changes: 33 additions & 6 deletions uberenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def parse_args():
default=None,
help="spack mirror directory")

parser.add_argument("--mirror-autopush",
action="store_true",
dest="mirror_autopush",
default=False,
help="Use spack v0.22+ --autopush functionality for binary cache mirrors")

# flag to create mirror
parser.add_argument("--create-mirror",
action="store_true",
Expand Down Expand Up @@ -293,6 +299,13 @@ def parse_args():
default=None,
help="Path to Spack Environment file (e.g. spack.yaml or spack.lock)")

# option to add trusted keys to spack gpg keyring
parser.add_argument("--trust-key",
dest="key_paths",
action="append",
default=None,
help="Add the gpg keys to the spack gpg keyring")

###############
# parse args
###############
Expand Down Expand Up @@ -407,7 +420,7 @@ def setup_paths_and_dirs(self):

def set_from_args_or_json(self,setting, optional=True):
"""
When optional=False:
When optional=False:
If the setting key is not in the json file, error and raise an exception.
When optional=True:
If the setting key is not in the json file or args, return None.
Expand All @@ -425,7 +438,7 @@ def set_from_args_or_json(self,setting, optional=True):

def set_from_json(self,setting, optional=True):
"""
When optional=False:
When optional=False:
If the setting key is not in the json file, error and raise an exception.
When optional=True:
If the setting key is not in the json file or args, return None.
Expand Down Expand Up @@ -509,7 +522,7 @@ def clone_repo(self):

os.chdir(self.dest_dir)

clone_args = ("-c http.sslVerify=false "
clone_args = ("-c http.sslVerify=false "
if self.args["ignore_ssl_errors"] else "")

clone_cmd = "git {0} clone --single-branch -b {1} {2} vcpkg".format(clone_args, vcpkg_branch,vcpkg_url)
Expand Down Expand Up @@ -1057,7 +1070,7 @@ def install(self):
print("[ERROR: Failure of spack install]")
return res

# when using install or uberenv-pkg mode, create a symlink to the host config
# when using install or uberenv-pkg mode, create a symlink to the host config
if self.build_mode == "install" or \
self.build_mode == "uberenv-pkg" \
or self.use_install:
Expand Down Expand Up @@ -1157,6 +1170,7 @@ def use_mirror(self):
mirror_name = self.pkg_name
mirror_path = self.get_mirror_path()
existing_mirror_path = self.find_spack_mirror(mirror_name)
autopush = "--autopush" if self.args["mirror_autopush"] else ""

if existing_mirror_path and mirror_path != existing_mirror_path:
# Existing mirror has different URL, error out
Expand All @@ -1171,8 +1185,8 @@ def use_mirror(self):
existing_mirror_path = None
if not existing_mirror_path:
# Add if not already there
sexe("{0} mirror add --scope=defaults {1} {2}".format(
self.spack_exe(), mirror_name, mirror_path), echo=True)
sexe("{0} mirror add --scope=defaults {1} {2} {3}".format(
self.spack_exe(), autopush, mirror_name, mirror_path), echo=True)
print("[using mirror {0}]".format(mirror_path))

def find_spack_upstream(self, upstream_name):
Expand Down Expand Up @@ -1257,6 +1271,15 @@ def setup_clingo(self):
print("[ERROR: Clingo install failed with returncode {0}]".format(res))
sys.exit(-1)

def trust_gpg_keys(self):
"""
Tells spack to trust the gpg keys in key_paths.
"""
key_paths = self.args["key_paths"]
for key_path in key_paths:
key_path = pabs(key_path)
print("[adding gpg key to spack gpg keyring]")
sexe("{0} gpg trust {1}".format(self.spack_exe(use_spack_env=False), key_path), echo=True)

def find_osx_sdks():
"""
Expand Down Expand Up @@ -1334,6 +1357,10 @@ def main():
# Patch the package manager, as necessary
env.patch()

# Trust keys if the option was provided
if args["key_paths"]:
env.trust_gpg_keys()

# Clean the build
env.clean_build()

Expand Down