Skip to content

Commit

Permalink
Merge pull request #36 from greenc-FNAL/bugfix/assorted-fixes
Browse files Browse the repository at this point in the history
Assorted fixes to make_spack and build-spack-env.sh
  • Loading branch information
marcmengel authored Apr 1, 2024
2 parents ac70baa + cd6486c commit 66b0676
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
34 changes: 31 additions & 3 deletions bin/build-spack-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,28 @@ _configure_recipe_repos() {
done
path="$path-$((bnum + 1))"
fi
_cmd $DEBUG_1 git clone ${branch_etc:+-b "$branch_etc"} "$url" "$path" ||
_die "unable to clone $url to $path to configure Spack recipe repo"
if [ -d "$path" ]; then
if [ "$(_cmd $DEBUG_2 $PIPE git -C "$path" remote)" = "origin" ] &&
[ "$(_cmd $DEBUG_2 $PIPE git -C "$path" remote get-url origin)" = "$url" ]; then
if [ "$(_cmd $DEBUG_2 $PIPE git -C "$path" branch --show-current)" = "$branch_etc" ]; then
:
elif (( $(_cmd $DEBUG_2 $PIPE git -C "$path" status -s | wc -l) == 0 )) &&
[ -n "$branch_etc" ]; then
_report $INFO "Switching to branch $branch_etc in $path"
_cmd $DEBUG_1 git -C "$path" switch "$branch_etc"
fi
else
false
fi
elif ! [ -e "$path" ]; then
_cmd $DEBUG_1 git clone ${branch_etc:+-b "$branch_etc"} "$url" "$path" ||
_die "unable to clone $url to $path to configure Spack recipe repo"
else
false
fi
if (( $? )); then
_die "unable to reconcile requested repo $repo_element with existing path $path"
fi
else
path="$repo_element"
fi
Expand Down Expand Up @@ -731,7 +751,12 @@ _maybe_cache_binaries() {
# packages in order to avoid writing packages to build cache that were
# already installed from build cache. Do this in one Spack session to
# avoid unnecessary overhead.
echo 'env = spack.environment.active_environment()' > "$TMP/location_cmds.py"
cat > "$TMP/location_cmds.py" <<\EOF
import spack.cmd
import spack.environment
env = spack.environment.active_environment()
EOF
for hash in ${hashes_to_cache_tmp[*]:+"${hashes_to_cache_tmp[@]}"}; do
echo 'print("'"$hash"'", spack.cmd.disambiguate_spec("'"${hash//*\///}"'", env, False).prefix)' >> "$TMP/location_cmds.py"
done
Expand All @@ -748,6 +773,9 @@ _maybe_cache_binaries() {
done
)
)
(( $? == 0 )) ||
_die "unexpected result executing Python script $TMP/location_cmds.py:\n$(cat "$TMP/location_cmds.py")"

if (( ${#hashes_to_cache[@]} )); then
for cache in "$working_dir/copyBack/spack-$binary_mirror-cache" \
${extra_sources_write_cache[*]:+"${extra_sources_write_cache[@]}"}; do
Expand Down
9 changes: 6 additions & 3 deletions bin/make_spack
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,17 @@ bootstrap_spack() {
then
make_packages_yaml $SPACK_ROOT
else
if [ "$(spack --version)" '>' "0.20.0" ]
spack_version="$(spack --version)"
if [ "$spack_version" '>' "0.20.0" ]
then
sd="$(spack arch --platform)/"
else
sd=""
fi
echo "Installing stock packages.yaml in $SPACK_ROOT/etc/spack/${sd}${os}"
cp $spackbindir/../templates/packages.yaml.${os} $SPACK_ROOT/etc/spack/${sd}${os}/packages.yaml
mkdir -p "$SPACK_ROOT/etc/spack/${sd}${os}" &&
cp -v "$spackbindir/../templates/packages.yaml.${os}" \
"$SPACK_ROOT/etc/spack/${sd}${os}/packages.yaml"
fi
}

Expand Down Expand Up @@ -328,7 +331,7 @@ main() {
export PATH=$SPACK_ROOT/bin:$PATH
create_spack

if [ -n "$dir" ]; then
if [ -n "$dir" ] && [ -d "$dir/spack" ]; then
rm -f $dir/spack/current
ln -s $dir/spack/$spack_release $dir/spack/current
fi
Expand Down

0 comments on commit 66b0676

Please sign in to comment.