From 0e8f00c1e957ec3ce99fba7b359b9eefb83a8b94 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 7 May 2019 09:01:05 -0400 Subject: [PATCH] import rpm-mpi-hooks-5-4.el8 --- .gitignore | 0 .rpm-mpi-hooks.metadata | 0 SOURCES/LICENSE | 19 ++++++ SOURCES/mpi.attr | 6 ++ SOURCES/mpi.prov | 97 +++++++++++++++++++++++++++++++ SOURCES/mpi.req | 115 +++++++++++++++++++++++++++++++++++++ SOURCES/mpilibsymlink.attr | 6 ++ SPECS/rpm-mpi-hooks.spec | 105 +++++++++++++++++++++++++++++++++ 8 files changed, 348 insertions(+) create mode 100644 .gitignore create mode 100644 .rpm-mpi-hooks.metadata create mode 100644 SOURCES/LICENSE create mode 100644 SOURCES/mpi.attr create mode 100755 SOURCES/mpi.prov create mode 100755 SOURCES/mpi.req create mode 100644 SOURCES/mpilibsymlink.attr create mode 100644 SPECS/rpm-mpi-hooks.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.rpm-mpi-hooks.metadata b/.rpm-mpi-hooks.metadata new file mode 100644 index 0000000..e69de29 diff --git a/SOURCES/LICENSE b/SOURCES/LICENSE new file mode 100644 index 0000000..7eef87b --- /dev/null +++ b/SOURCES/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 Sandro Mani + +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. diff --git a/SOURCES/mpi.attr b/SOURCES/mpi.attr new file mode 100644 index 0000000..03ea6af --- /dev/null +++ b/SOURCES/mpi.attr @@ -0,0 +1,6 @@ +%__mpi_provides %{_rpmconfigdir}/mpi.prov %{?__filter_GLIBC_PRIVATE:--filter-private} +%__mpi_requires %{_rpmconfigdir}/mpi.req %{?__filter_GLIBC_PRIVATE:--filter-private} +%__mpi_path ^%{_prefix}/lib(64)?/.*$ +%__mpi_magic ^(setuid )?(setgid )?(sticky )?ELF (32|64)-bit.*$ +%__mpi_flags exeonly,magic_and_path +%__elf_exclude_path ^%{_prefix}/lib(64)?/.*$ diff --git a/SOURCES/mpi.prov b/SOURCES/mpi.prov new file mode 100755 index 0000000..cf489f2 --- /dev/null +++ b/SOURCES/mpi.prov @@ -0,0 +1,97 @@ +#!/bin/bash + +# Copyright (c) 2015-2016 Sandro Mani +# +# 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 + + +buildroot="$RPM_BUILD_ROOT" +if [ ! -d "$buildroot" ]; then + >&2 echo "Invalid buildroot" + exit 1 +fi + +# Remaining arguments are passed to elfdeps +shift +elfdepsargs="$@" + +# Search for all MPI implementations: +# - Search all modules which start with mpi +# - For each module, store $MPI_DIR -> $MPI_COMPILER in assoc. array +declare -A mpi_compiler_for_dir +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 + if [ -z "${MPI_COMPILER}" ]; then + >&2 echo "Invalid module file, no MPI_COMPILER defined" + exit 1 + fi + if [ -z "${MPI_HOME}" ]; then + >&2 echo "Invalid module file, no MPI_HOME defined" + exit 1 + fi + mpi_compiler_for_dir[${MPI_HOME}]=${MPI_COMPILER} + if [ ! -z "${MPI_FORTRAN_MOD_DIR}" ]; then + mpi_compiler_for_dir[${MPI_FORTRAN_MOD_DIR}]=${MPI_COMPILER} + fi + if [ ! -z "${MPI_PYTHON2_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON2_SITEARCH}]=${MPI_COMPILER} + fi + if [ ! -z "${MPI_PYTHON3_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON3_SITEARCH}]=${MPI_COMPILER} + fi + 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 + prov=$(echo $file | /usr/lib/rpm/elfdeps --provides $elfdepsargs) + if [ -z "$prov" ]; then + continue + fi + + # If the path to the scanned binary starts with a known mpi binary directory, + # append the corresponding ($MPI_COMPILER) to the provides string + for mpi_dir in "${!mpi_compiler_for_dir[@]}"; do + if [[ "$file" == "$buildroot$mpi_dir"* ]]; then + prov="${prov}(${mpi_compiler_for_dir[$mpi_dir]})" + break + fi + done + + echo "$prov" + done +fi diff --git a/SOURCES/mpi.req b/SOURCES/mpi.req new file mode 100755 index 0000000..4eb4080 --- /dev/null +++ b/SOURCES/mpi.req @@ -0,0 +1,115 @@ +#!/bin/bash + +# Copyright (c) 2015-2016 Sandro Mani +# +# 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 + + +buildroot="$RPM_BUILD_ROOT" +if [ ! -d "$buildroot" ]; then + >&2 echo "Invalid buildroot" + exit 1 +fi + +# Remaining arguments are passed to elfdeps +shift +elfdepsargs="$@" + +# Search for all MPI implementations: +# - Search all modules which start with mpi +# - For each module, store $MPI_DIR -> $MPI_COMPILER and +# $MPI_COMPILER -> $MPI_LIB in assoc. array +declare -A mpi_compiler_for_dir +declare -A mpi_lib_for_compiler +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 + if [ -z "${MPI_COMPILER}" ]; then + >&2 echo "Invalid module file, no MPI_COMPILER defined" + exit 1 + fi + if [ -z "${MPI_HOME}" ]; then + >&2 echo "Invalid module file, no MPI_HOME defined" + exit 1 + fi + if [ -z "${MPI_LIB}" ]; then + >&2 echo "Invalid module file, no MPI_LIB defined" + exit 1 + fi + mpi_compiler_for_dir[${MPI_HOME}]=${MPI_COMPILER} + mpi_lib_for_compiler[${MPI_COMPILER}]=${MPI_LIB} + if [ ! -z "${MPI_FORTRAN_MOD_DIR}" ]; then + mpi_compiler_for_dir[${MPI_FORTRAN_MOD_DIR}]=${MPI_COMPILER} + fi + if [ ! -z "${MPI_PYTHON2_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON2_SITEARCH}]=${MPI_COMPILER} + fi + if [ ! -z "${MPI_PYTHON3_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON3_SITEARCH}]=${MPI_COMPILER} + fi + module unload $module + done +fi + +# Read file list from stdin +filelist=`sed "s/[]['\"*?{}]/\\\\\&/g"` + +# List requires: +if [ -x /usr/lib/rpm/elfdeps -a -n "$filelist" ]; then + for file in $(echo $filelist | tr '[:blank:]' \\n); do + + # Get the default requres string from elfdeps + reqs=$(echo $file | /usr/lib/rpm/elfdeps --requires $elfdepsargs) + + # Check whether the scanned binary is inside a know mpi binary dir + mpi_comp= + for mpi_dir in "${!mpi_compiler_for_dir[@]}"; do + if [[ "$file" == "$buildroot$mpi_dir"* ]]; then + mpi_comp="${mpi_compiler_for_dir[$mpi_dir]}" + break + fi + done + + # If the scanned binary is inside an mpi dir, for each dependency, check + # whether the library exists in $MPI_LIB, and if yes, append + # ($MPI_COMPILER) to each requires string + if [ ! -z "$mpi_comp" ]; then + mpi_lib=${mpi_lib_for_compiler[$mpi_comp]} + for req in $reqs; do + lib=$(echo $req | grep -Eo '^.*\.so[^(]*') + if [ ! -z "$lib" ] && ( [ -e "$mpi_lib/$lib" ] || [ -e "$buildroot$mpi_lib/$lib" ] ); then + req="${req}($mpi_comp)" + fi + echo "$req" + done + else + echo "$reqs" + fi + done +fi diff --git a/SOURCES/mpilibsymlink.attr b/SOURCES/mpilibsymlink.attr new file mode 100644 index 0000000..b286559 --- /dev/null +++ b/SOURCES/mpilibsymlink.attr @@ -0,0 +1,6 @@ +# Make libfoo.so symlinks require the soname-provide of the target library +%__mpilibsymlink_requires %{_rpmconfigdir}/mpi.prov %{buildroot} --soname-only +%__mpilibsymlink_magic ^symbolic link to .*lib.*\.so\..*$ +%__mpilibsymlink_path ^%{_prefix}/lib(64)?/.*\.so$ +%__mpilibsymlink_flags magic_and_path +%__libsymlink_exclude_path ^%{_prefix}/lib(64)?/.*$ diff --git a/SPECS/rpm-mpi-hooks.spec b/SPECS/rpm-mpi-hooks.spec new file mode 100644 index 0000000..efaaea0 --- /dev/null +++ b/SPECS/rpm-mpi-hooks.spec @@ -0,0 +1,105 @@ +Name: rpm-mpi-hooks +Version: 5 +Release: 4%{?dist} +Summary: RPM dependency generator hooks for MPI packages + +License: MIT +BuildArch: noarch + +Source0: mpi.attr +Source1: mpilibsymlink.attr +Source2: mpi.prov +Source3: mpi.req +Source4: LICENSE + +Requires: filesystem +# Instead of adding a BuildRequires to every MPI implementation spec +Requires: environment(modules) + +%description +RPM dependency generator hooks for MPI packages. This package should be added +as a BuildRequires to all mpi implementations (i.e. openmpi, mpich) as well as +a Requires to the their -devel packages. + + +%prep +cp -a %SOURCE4 . + + +%build +# Nothing to build + + +%install +install -Dpm 0644 %{SOURCE0} %{buildroot}%{_rpmconfigdir}/fileattrs/mpi.attr +install -Dpm 0644 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/fileattrs/mpilibsymlink.attr +install -Dpm 0755 %{SOURCE2} %{buildroot}%{_rpmconfigdir}/mpi.prov +install -Dpm 0755 %{SOURCE3} %{buildroot}%{_rpmconfigdir}/mpi.req + + +%files +%license LICENSE +%{_rpmconfigdir}/fileattrs/mpi.attr +%{_rpmconfigdir}/fileattrs/mpilibsymlink.attr +%{_rpmconfigdir}/mpi.req +%{_rpmconfigdir}/mpi.prov + + +%changelog +* Thu Sep 13 2018 Jarod Wilson - 5-4 +- Make hooks more resilient to missing info +- Error out with a useful message when necessary info isn't there +- Resolves: rhbz#1627122 + +* Fri Feb 09 2018 Fedora Release Engineering - 5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon Apr 17 2017 Orion Poplawski - 5-1 +- Exclude build-id files from symlink requires path (bug #1435690) + +* Sat Feb 11 2017 Fedora Release Engineering - 4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu May 12 2016 Sandro Mani 4-1 +- Use RPM_BUILD_ROOT directly instead of passing it as an argument +- Use MPI_PYTHON3_SITEARCH + +* Thu Feb 04 2016 Fedora Release Engineering - 3-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Fri Jan 08 2016 Sandro Mani 3-5 +- Add quotes around strings which may contain spaces + +* Tue Dec 22 2015 Orion Poplawski - 3-4 +- Require environment(modules) + +* Mon Nov 2 2015 Orion Poplawski - 3-3 +- Drop requires rpm-build, fileattrs now owned by rpm + +* Mon Aug 17 2015 Zbigniew Jędrzejewski-Szmek - 3-2 +- Also handle modules for Python 3 + +* Mon Aug 10 2015 Sandro Mani 3-1 +- Also handle binaries in $MPI_FORTRAN_MOD_DIR and $MPI_PYTHON_SITEARCH + +* Sun Jul 26 2015 Sandro Mani 2-1 +- Add %%__mpi_magic, %%__mpi_flags to mpi.attrs +- Add mpilibsymlink.attr + +* Thu Jul 09 2015 Sandro Mani 1.0-4 +- mpi.prov, mpi.req: Use "module -t avail" instead of "module avail" +- mpi.prov, mpi.req: Also look in moduledirs in %%buildroot +- mpi.attrs: add %%__libsymlink_exclude_path + +* Thu Jul 09 2015 Sandro Mani 1.0-3 +- Add LICENSE + +* Thu Jul 09 2015 Sandro Mani 1.0-2 +- BuildRequires: rpm -> rpm-build +- Change license to MIT + +* Thu Jul 09 2015 Sandro Mani 1.0-1 +- Initial package