From f8c5bbc9a2f5aa604e4699ca65d5ae33ba90d65e Mon Sep 17 00:00:00 2001 From: James Antill Date: Thu, 26 May 2022 14:11:07 -0400 Subject: [PATCH] Auto sync2gitlab import of rpm-mpi-hooks-8-2.el8.src.rpm --- .gitignore | 0 EMPTY | 1 - LICENSE | 19 ++++++++ mpi.attr | 6 +++ mpi.prov | 88 +++++++++++++++++++++++++++++++++++ mpi.req | 102 ++++++++++++++++++++++++++++++++++++++++ mpilibsymlink.attr | 6 +++ rpm-mpi-hooks.spec | 113 +++++++++++++++++++++++++++++++++++++++++++++ sources | 0 9 files changed, 334 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 EMPTY create mode 100644 LICENSE create mode 100644 mpi.attr create mode 100755 mpi.prov create mode 100755 mpi.req create mode 100644 mpilibsymlink.attr create mode 100644 rpm-mpi-hooks.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/EMPTY b/EMPTY deleted file mode 100644 index 0519ecb..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7eef87b --- /dev/null +++ b/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/mpi.attr b/mpi.attr new file mode 100644 index 0000000..03ea6af --- /dev/null +++ b/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/mpi.prov b/mpi.prov new file mode 100755 index 0000000..a37dbce --- /dev/null +++ b/mpi.prov @@ -0,0 +1,88 @@ +#!/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 + +# Arguments are passed to elfdeps +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/." | sed "s/(default)$//"); do + module load $module + mpi_compiler_for_dir[${MPI_HOME}]=${MPI_COMPILER} + mpi_compiler_for_dir[${MPI_FORTRAN_MOD_DIR}]=${MPI_COMPILER} + if [ -n "${MPI_PYTHON2_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON2_SITEARCH}]=${MPI_COMPILER} + elif [ -n "${MPI_PYTHON_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON_SITEARCH}]=${MPI_COMPILER} + fi + if [ -n "${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/mpi.req b/mpi.req new file mode 100755 index 0000000..6055aa5 --- /dev/null +++ b/mpi.req @@ -0,0 +1,102 @@ +#!/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 + +# Arguments are passed to elfdeps +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/." | sed "s/(default)$//"); do + module load $module + mpi_compiler_for_dir[${MPI_HOME}]=${MPI_COMPILER} + mpi_compiler_for_dir[${MPI_FORTRAN_MOD_DIR}]=${MPI_COMPILER} + if [ -n "${MPI_PYTHON2_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON2_SITEARCH}]=${MPI_COMPILER} + elif [ -n "${MPI_PYTHON_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON_SITEARCH}]=${MPI_COMPILER} + fi + if [ -n "${MPI_PYTHON3_SITEARCH}" ]; then + mpi_compiler_for_dir[${MPI_PYTHON3_SITEARCH}]=${MPI_COMPILER} + fi + mpi_lib_for_compiler[${MPI_COMPILER}]=${MPI_LIB} + 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/mpilibsymlink.attr b/mpilibsymlink.attr new file mode 100644 index 0000000..b286559 --- /dev/null +++ b/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/rpm-mpi-hooks.spec b/rpm-mpi-hooks.spec new file mode 100644 index 0000000..ff30ad2 --- /dev/null +++ b/rpm-mpi-hooks.spec @@ -0,0 +1,113 @@ +Name: rpm-mpi-hooks +Version: 8 +Release: 2%{?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 +* Tue May 18 2021 Honggang Li - 8-2 +- Rebuilt after building tool chain update +- Resolves: rhbz#1924665 + +* Wed Apr 07 2021 Honggang Li - 8-1 +- Sync with latest Fedora repo +- Resolves: rhbz#1924665 + +* 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 diff --git a/sources b/sources new file mode 100644 index 0000000..e69de29