Skip to content

Commit bec05e2

Browse files
authored
Merge pull request #152 from LLNL/bugfix/chapman39/builtin-destination
keep builtin destination upon removing old builtin repo
2 parents eb18535 + 7ab1bdd commit bec05e2

1 file changed

Lines changed: 48 additions & 55 deletions

File tree

uberenv.py

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -858,61 +858,6 @@ def clone_repo(self):
858858
print("[ERROR: Git failed to pull]")
859859
sys.exit(-1)
860860

861-
# Move and checkout Spack builtin package repository if not included in Spack repo
862-
if not os.path.exists(pjoin(self.dest_spack, "var", "spack", "repos", "builtin")):
863-
packages_repo = pjoin(self.dest_dir, "builtin_spack_packages_repo")
864-
865-
print(f"[info: moving spack builtin package repository to {packages_repo}]")
866-
spack_repo_set_cmd = f"{self.spack_exe(use_spack_env=False)} repo set --destination {packages_repo} builtin"
867-
res = sexe(spack_repo_set_cmd, echo=True)
868-
if res != 0:
869-
print("[ERROR: Failed to set builtin package repository destination]")
870-
sys.exit(-1)
871-
872-
# Optionally, check out Spack's builtin package repo to a specific commit/branch/tag
873-
if "spack_packages_url" in self.project_args:
874-
spack_repo_remove_cmd = f"{self.spack_exe(use_spack_env=False)} repo remove builtin"
875-
res = sexe(spack_repo_remove_cmd, echo=True)
876-
if res != 0:
877-
print("[ERROR: Failed to remove builtin package repository so it could be re-added with given URL]")
878-
sys.exit(-1)
879-
880-
# Now add it back with the correct url
881-
url = self.project_args["spack_packages_url"]
882-
spack_repo_add_cmd = f"{self.spack_exe(use_spack_env=False)} repo add --name builtin {url}"
883-
res = sexe(spack_repo_add_cmd, echo=True)
884-
if res != 0:
885-
print("[ERROR: Failed to add builtin package repository with given URL]")
886-
sys.exit(-1)
887-
888-
# Optionally, check out Spack's builtin package repo to a specific commit/branch/tag
889-
if "spack_packages_commit" in self.project_args:
890-
sha1 = self.project_args["spack_packages_commit"]
891-
892-
spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --commit {sha1} builtin"
893-
res = sexe(spack_repo_update_cmd, echo=True)
894-
if res != 0:
895-
print("[ERROR: Failed to update git commit for builtin package repository]")
896-
sys.exit(-1)
897-
elif "spack_packages_branch" in self.project_args:
898-
branch = self.project_args["spack_packages_branch"]
899-
900-
spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --branch {branch} builtin"
901-
res = sexe(spack_repo_update_cmd, echo=True)
902-
if res != 0:
903-
print("[ERROR: Failed to update git branch for builtin package repository]")
904-
sys.exit(-1)
905-
elif "spack_packages_tag" in self.project_args:
906-
tag = self.project_args["spack_packages_tag"]
907-
908-
spack_repo_update_cmd = f"{self.spack_exe(use_spack_env=False)} repo update --tag {tag} builtin"
909-
res = sexe(spack_repo_update_cmd, echo=True)
910-
if res != 0:
911-
print("[ERROR: Failed to update git tag for builtin package repository]")
912-
sys.exit(-1)
913-
else:
914-
print("[info: User did not specify any `spack_packages_*` override, Spack will pull the default ref of spack-packages]")
915-
916861

917862
def disable_spack_config_scopes(self):
918863
# disables all config scopes except "defaults", which we will
@@ -969,6 +914,54 @@ def create_spack_env(self):
969914
print("[ERROR: Failed to create Spack Environment]")
970915
sys.exit(-1)
971916

917+
# Move and checkout Spack builtin package repository if not included in Spack repo
918+
if not os.path.exists(pjoin(self.dest_spack, "var", "spack", "repos", "builtin")):
919+
packages_repo = pjoin(self.dest_dir, "builtin_spack_packages_repo")
920+
921+
# Optionally, check out Spack's builtin package repo to a specific commit/branch/tag
922+
if "spack_packages_url" in self.project_args:
923+
url = self.project_args["spack_packages_url"]
924+
spack_repo_add_cmd = f"{self.spack_exe()} repo add --name builtin {url}"
925+
res = sexe(spack_repo_add_cmd, echo=True)
926+
if res != 0:
927+
print("[ERROR: Failed to add builtin package repository with given URL]")
928+
sys.exit(-1)
929+
930+
print(f"[info: moving spack builtin package repository to {packages_repo}]")
931+
spack_repo_set_cmd = f"{self.spack_exe()} repo set --destination {packages_repo} builtin"
932+
res = sexe(spack_repo_set_cmd, echo=True)
933+
if res != 0:
934+
print("[ERROR: Failed to set builtin package repository destination]")
935+
sys.exit(-1)
936+
937+
# Optionally, check out Spack's builtin package repo to a specific commit/branch/tag
938+
if "spack_packages_commit" in self.project_args:
939+
sha1 = self.project_args["spack_packages_commit"]
940+
941+
spack_repo_update_cmd = f"{self.spack_exe()} repo update --commit {sha1} builtin"
942+
res = sexe(spack_repo_update_cmd, echo=True)
943+
if res != 0:
944+
print("[ERROR: Failed to update git commit for builtin package repository]")
945+
sys.exit(-1)
946+
elif "spack_packages_branch" in self.project_args:
947+
branch = self.project_args["spack_packages_branch"]
948+
949+
spack_repo_update_cmd = f"{self.spack_exe()} repo update --branch {branch} builtin"
950+
res = sexe(spack_repo_update_cmd, echo=True)
951+
if res != 0:
952+
print("[ERROR: Failed to update git branch for builtin package repository]")
953+
sys.exit(-1)
954+
elif "spack_packages_tag" in self.project_args:
955+
tag = self.project_args["spack_packages_tag"]
956+
957+
spack_repo_update_cmd = f"{self.spack_exe()} repo update --tag {tag} builtin"
958+
res = sexe(spack_repo_update_cmd, echo=True)
959+
if res != 0:
960+
print("[ERROR: Failed to update git tag for builtin package repository]")
961+
sys.exit(-1)
962+
else:
963+
print("[info: User did not specify any `spack_packages_*` override, Spack will pull the default ref of spack-packages]")
964+
972965
spack_pkg_keys = ("spack_packages_commit", "spack_packages_branch", "spack_packages_tag")
973966
if any(key in self.project_args for key in spack_pkg_keys):
974967
# Check if environment specifies alternate builtin packages repository

0 commit comments

Comments
 (0)