File openmpi-gnu-ohpc.spec of Package openmpi-gnu-ohpc

#
# spec file for package ohpc
#
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%{!?compiler_family: %global compiler_family gnu}
%{!?mpi_family: %global mpi_family openmpi}

Summary:   OpenHPC %compiler_family and %mpi_family environments
Name:      openmpi-gnu-ohpc
Version:   1.2
Release:   1
License:   BSD-3-Clause and MIT

Group:     Development/Libraries/Parallel
URL:       https://github.com/openhpc/ohpc
Source0:	template.spec.in
Source1:	   LICENSE
Source2:	   rpmlintrc
Source3:	spec_fix.pl
Source4:	replacements
BuildRequires: %{compiler_family}-compilers-ohpc
BuildRequires: lua-lmod
Requires:  lua-lmod
Requires:  %{compiler_family}-compilers-ohpc
Requires:  %{mpi_family}

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define mpiversion %{version}

%description
Provides configuration for the %{compiler_family} compiler
toolchain and %{mpi_family} MPI environment.
# Not 'noarch': modules files contain arch dependent library paths.

%define meta README.meta

%package default
Summary:   OpenHPC default login environment for %compiler_family and %mpi_family
Requires: lua-lmod
Provides:  ohpc-default
BuildArch: noarch

%description default
Provides default login configuration using the %{compiler_family} compiler
toolchain and %{mpi_family} MPI environment.

%package devel
Summary:   Devel package for OpenHPC %compiler_family and %mpi_family environments
Requires:  %{compiler_family}-compilers-ohpc-devel
Requires:  %{mpi_family}-devel
Requires:  %{name}
BuildArch: noarch
Group:     Development/ohpc

%description devel
Provides package dependencies for the %{compiler_family} compiler
toolchain and %{mpi_family} MPI environment.

%prep

%build

%{__cp} %{S:1} .
%{__cat} <<EOF > %{meta}
%{name}-devel is a meta package to ensure installation of the 
%{mpi_family} MPI environment.
EOF

%install

# OpenHPC also adds a modules file for prun and autotools.
# Since we use the system-wide autotools we won't need this.
# If needed we could add a 
#        module tryadd prun
#        module tryadd autotools
# to the load function and
#        module del prun
#        module del autotools
# to the remove function.
%{__mkdir_p} %{buildroot}%{lua_lmod_modulesdir}
%{__cat} <<EOF > %{buildroot}%{lua_lmod_modulesdir}/ohpc
#%%Module1.0#####################################################################
# Default OpenHPC environment
#############################################################################

proc ModulesHelp { } {
puts stderr "Setup default login environment"
}

#
# Load Desired Modules
#

prepend-path     PATH   %{OHPC_PUB}/bin

if { [ expr [module-info mode load] || [module-info mode display] ] } {
        module try-add %{compiler_family}
        module try-add %{mpi_family}
}

if [ module-info mode remove ] {
        module del %{mpi_family}
        module del %{compiler_family}
}
EOF

%define install_path %{_libdir}/mpi/gcc/%{mpi_family}
%{__mkdir_p} %{buildroot}/%{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}
%{__cat} <<EOF > %{buildroot}/%{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}/%{version}
#%%Module1.0#####################################################################

proc ModulesHelp { } {

puts stderr " "
puts stderr "This module loads the %{mpi_family} library built with the %{compiler_family} toolchain."
puts stderr "\nVersion %{mpiversion}\n"

}
module-whatis "Name: %{pname} built with %{compiler_family} toolchain"
module-whatis "Version: %{mpiversion}"
module-whatis "Category: runtime library"
module-whatis "Description: %{summary}"
module-whatis "URL: %{url}"

set     version                     %{mpiversion}

prepend-path    PATH                %{install_path}/bin
prepend-path    MANPATH             %{install_path}/man
prepend-path    LD_LIBRARY_PATH     %{install_path}/%{_lib}
prepend-path    MODULEPATH          %{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}
prepend-path    INCLUDE             %{install_path}/include
prepend-path    MPI_DIR             %{install_path}
prepend-path    PKG_CONFIG_PATH     %{install_path}/%{_lib}/pkgconfig

family "MPI"
EOF

export mpiversion=%mpiversion
export mpi_family=%mpi_family
%{__cat} << EOF > %{buildroot}/%{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}/.version.%{version}
#%%Module1.0#####################################################################
##
## version file for ${mpi_family}-${mpiversion}
##
set     ModulesVersion      "%{mpiversion}"

EOF

%files
%defattr(-,root,root,-)
%dir %{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}
%{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}/%{mpiversion}
%{lua_lmod_modulesdir}/%{compiler_family}/%{mpi_family}/.version.%{mpiversion}

%files default
%defattr(-,root,root,-)
%doc LICENSE
%{lua_lmod_modulesdir}/ohpc

%files devel
%defattr(-,root,root,-)
%doc %{meta}

%changelog
openSUSE Build Service is sponsored by