Skip to content
Snippets Groups Projects
Commit fe0d2dd2 authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

update prepare env to include checks to update the branch

parent 7acc797e
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!1Resolve "First draft for user interface for top level install command"
...@@ -66,49 +66,47 @@ def setup_log_cmd(shared_var, msg=None): ...@@ -66,49 +66,47 @@ def setup_log_cmd(shared_var, msg=None):
f"Spack environments branch: {shared_var['spe_branch']} (commit hash: {shared_var['spe_commit_hash']})\n" f"Spack environments branch: {shared_var['spe_branch']} (commit hash: {shared_var['spe_commit_hash']})\n"
) )
def prepare_environment(mpsd_release, toolchain_base_dir): def prepare_environment(mpsd_release, script_dir):
if not os.path.exists(toolchain_base_dir): release_base_dir = os.path.join(script_dir, mpsd_release)
os.makedirs(toolchain_base_dir) if not os.path.exists(release_base_dir):
os.makedirs(release_base_dir)
else: else:
if not skip_dir_check: # Warn that the target directory already exists.
raise ValueError( print(">Target directory already exists. Continuing...")
f"Error: Target directory {toolchain_base_dir} already exists. \n\ with os_chdir(release_base_dir):
Please remove it and try again." # Clone the spack-environments repo if it doesn't exist
) if not os.path.exists("spack-environments"):
with os_chdir(toolchain_base_dir):
subprocess.run(
[
"git",
"clone",
config_vars['spack_environments_repo'],
]
)
with os_chdir("spack-environments"):
subprocess.run( subprocess.run(
[ [
"git", "git",
"checkout", "clone",
mpsd_release, config_vars['spack_environments_repo'],
] ]
) )
with os_chdir("spack-environments"):
# Git fetch and checkout the release branch and git pull to be sure that the resulting repo is up to date
subprocess.run(["git", "fetch", "--all"])
subprocess.run(["git", "checkout", mpsd_release])
subprocess.run(["git", "pull"])
# Get the branch and commit hash of the spack-environments repo and store them in shared_var # Get the branch and commit hash of the spack-environments repo and store them in shared_var
shared_var['spe_commit_hash'] = ( spe_commit_hash = (
subprocess.run( subprocess.run(
["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE ["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE
) )
.stdout.decode() .stdout.decode()
.strip() .strip()
) )
shared_var['spe_branch'] = ( spe_branch = (
subprocess.run( subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE ["git", "rev-parse", "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE
) )
.stdout.decode() .stdout.decode()
.strip() .strip()
) )
shared_var['available_toolchains'] = os.listdir("toolchains") available_toolchains = os.listdir("toolchains")
setup_log_cmd(shared_var) setup_log_cmd(shared_var)
return shared_var return shared_var
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment