Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add utility for listing pkg versions for spack-stack wiki #1443

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions util/get_version_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Gets list of versions from active or specified environment and prints a
# wiki-formatted table to be inserted into the spack-stack wiki.
# Only reports packages directly used by *-env metapackages.
# Uses SPACK_ENV by default to derive list of installed packages.
# The entire output can be copied and pasted into the wiki page at
# https://github.com/JCSDA/spack-stack/wiki/Package-versions
# noting that <SITE> should be replaced by the appropriate site name.

# Usage:
# $ . setup.sh
# $ ./util/get_version_list.sh envs/unified-dev

# Alex Richert, Jan 2025

set -e

if [ -z $SPACK_ENV ]; then
export SPACK_ENV=$1
fi

export SPACK_STACK_DIR=${SPACK_STACK_DIR:-$(realpath ${SPACK_ENV}/../..)}
spackstackver=$(echo $SPACK_STACK_DIR | grep -oP "/\Kspack-stack-[^/]+")
echo "# $spackstackver"
# Determine which packages to report versions of by looking at -env packages
envmetapkgs=$(grep -Po '(-) \K[^\s]+-env' ${SPACK_STACK_DIR}/configs/templates/unified-dev/spack.yaml | grep '-env$' | sort | uniq)
secondarymetapkgs=$(for p in $envmetapkgs ; do spack dependencies $p ; done | grep '-env$' | sort | uniq)
metapkgs=$(echo -e "${envmetapkgs}\n${secondarymetapkgs}")
deplist=$(for p in $metapkgs ; do spack dependencies $p ; done | grep -v '-env$' | sort | uniq)
installedlist=$(spack find --format '{name}')
pkgstoreport=$(echo "$installedlist" | grep -xf <(echo "$deplist"))
listfortable=$(spack find --format '| {name} | {version} |' $pkgstoreport)
echo -e "| Package_name | Version |\n| --- | --- |\n$listfortable" | column -t | sed 's:Package_name:Package name:'
echo
echo "_Versions taken from <SITE>:${SPACK_ENV}_"
Loading