2015-07-21 09:24:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-01-08 14:41:21 +00:00
|
|
|
# Copyright (c) 2015-2016 Sandro Mani <manisandro@gmail.com>
|
2015-07-21 09:24:20 +00:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
# THE SOFTWARE
|
|
|
|
|
|
|
|
|
2016-05-12 11:16:33 +00:00
|
|
|
buildroot="$RPM_BUILD_ROOT"
|
2015-07-21 09:24:20 +00:00
|
|
|
if [ ! -d "$buildroot" ]; then
|
|
|
|
>&2 echo "Invalid buildroot"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-07-26 19:56:53 +00:00
|
|
|
# Remaining arguments are passed to elfdeps
|
|
|
|
shift
|
|
|
|
elfdepsargs="$@"
|
2015-07-21 09:24:20 +00:00
|
|
|
|
|
|
|
# Search for all MPI implementations:
|
|
|
|
# - Search all modules which start with mpi
|
2015-08-10 17:18:57 +00:00
|
|
|
# - For each module, store $MPI_DIR -> $MPI_COMPILER in assoc. array
|
2015-08-17 23:02:49 +00:00
|
|
|
declare -A mpi_compiler_for_dir
|
2015-07-21 09:24:20 +00:00
|
|
|
if [ -e /etc/profile.d/modules.sh ]; then
|
|
|
|
. /etc/profile.d/modules.sh;
|
|
|
|
|
|
|
|
# Add moduledirs in buildroot also for cases where an MPI implementation
|
|
|
|
# package is being built, meaning that its module files are not yet installed
|
|
|
|
IFS=':' read -ra _MODULEPATH <<< "$MODULEPATH"
|
|
|
|
for i in "${!_MODULEPATH[@]}"; do
|
|
|
|
_MODULEPATH[$i]=$buildroot${_MODULEPATH[$i]}
|
|
|
|
done
|
|
|
|
export MODULEPATH="$MODULEPATH:$(IFS=:; echo "${_MODULEPATH[*]}")"
|
|
|
|
|
|
|
|
for module in $(module -t avail 2>&1 | grep "^mpi/"); do
|
|
|
|
module load $module
|
2015-08-17 23:02:49 +00:00
|
|
|
mpi_compiler_for_dir[${MPI_HOME}]=${MPI_COMPILER}
|
|
|
|
mpi_compiler_for_dir[${MPI_FORTRAN_MOD_DIR}]=${MPI_COMPILER}
|
2016-05-12 11:16:10 +00:00
|
|
|
mpi_compiler_for_dir[${MPI_PYTHON2_SITEARCH}]=${MPI_COMPILER}
|
|
|
|
mpi_compiler_for_dir[${MPI_PYTHON3_SITEARCH}]=${MPI_COMPILER}
|
2015-07-21 09:24:20 +00:00
|
|
|
module unload $module
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Read file list from stdin
|
|
|
|
filelist=$(sed "s/['\"]/\\\&/g")
|
|
|
|
|
|
|
|
# List provides:
|
|
|
|
if [ -x /usr/lib/rpm/elfdeps -a -n "$filelist" ]; then
|
|
|
|
for file in $(echo $filelist | tr '[:blank:]' \\n); do
|
|
|
|
|
|
|
|
# Get the default provides string from elfdeps
|
2015-07-26 19:56:53 +00:00
|
|
|
prov=$(echo $file | /usr/lib/rpm/elfdeps --provides $elfdepsargs)
|
2016-01-08 14:41:21 +00:00
|
|
|
if [ -z "$prov" ]; then
|
2015-07-21 09:24:20 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2015-08-10 17:18:57 +00:00
|
|
|
# If the path to the scanned binary starts with a known mpi binary directory,
|
|
|
|
# append the corresponding ($MPI_COMPILER) to the provides string
|
2015-08-17 23:02:49 +00:00
|
|
|
for mpi_dir in "${!mpi_compiler_for_dir[@]}"; do
|
2015-08-10 17:18:57 +00:00
|
|
|
if [[ "$file" == "$buildroot$mpi_dir"* ]]; then
|
2015-08-17 23:02:49 +00:00
|
|
|
prov="${prov}(${mpi_compiler_for_dir[$mpi_dir]})"
|
2015-07-21 09:24:20 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "$prov"
|
|
|
|
done
|
|
|
|
fi
|