File easybuild.spec of Package easybuild

#
# spec file for package easybuild
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define pname easybuild
%define vsc_base_ver 2.8.3
%define vsc_install_ver 0.11.2
%define installdir /usr/lib/
%define eb_group easybuild

%define skip_python2 1

Name:           easybuild
Version:        4.4.0
Release:        0
Summary:        Scientific software compilation utility
License:        GPL-2.0-only
Group:          Development/Tools/Building
URL:            http://easybuilders.github.io/easybuild

Source0:        https://github.com/easybuilders/easybuild/archive/easybuild-v%{version}.tar.gz
Source1:        https://github.com/easybuilders/easybuild-easyconfigs/archive/easybuild-easyconfigs-v%{version}.tar.gz
Source2:        https://github.com/easybuilders/easybuild-framework/archive/easybuild-framework-v%{version}.tar.gz
Source3:        https://pypi.io/packages/source/v/vsc-base/vsc-base-%{vsc_base_ver}.tar.gz
Source4:        https://pypi.io/packages/source/v/vsc-install/vsc-install-%{vsc_install_ver}.tar.gz
Source5:        https://raw.githubusercontent.com/easybuilders/easybuild-framework/develop/easybuild/scripts/bootstrap_eb.py
Source7:        https://github.com/easybuilders/easybuild-easyblocks/archive/easybuild-easyblocks-v%{version}.tar.gz
Source10:       easybuild-rpmlintrc
BuildRequires:  python3
BuildRequires:  python3-setuptools
Requires:       bison
Requires:       bzip2
Requires:       easyconfigs
Requires:       openssl-devel
Requires:       python3
Requires:       rdma-core-devel
%if 0%{?suse_version} > 1500  ||  0%{?sle_version} == 150300
BuildRequires:  openmpi4-devel
Requires:       openmpi4-devel
%endif
%if 0%{?suse_version} > 1500
# we need gcc7 to build the tool chains
Requires:       gcc7-c++
%endif
Requires:       autoconf
Requires:       gcc-c++
Requires:       gmp-devel
Requires:       make
Requires:       patch
Requires:       perl
Requires:       tcsh
# needed to build minimal toolchains
Requires:       isl-devel
BuildRequires:  fdupes
BuildRequires:  lua-lmod
Requires:       lua-lmod
BuildRequires:  python
BuildArch:      noarch

%description
EasyBuild is a software build and installation framework for
managing (scientific) software on High Performance Computing (HPC)
systems.

%package easyconfigs
Summary:        Concrete configs for building software with easybuild
Group:          System/Packages
Requires:       %name
Provides:       easyconfigs

%description easyconfigs
The easyconfigs are needed by EasyBuild for building the software and contain
information for building and installing. The
easyconfigs do not include the required sources. These sources are downloaded
by EasyBuild or need to be provided in case of propriatory software.

%prep

%build

%install
#for file in $(find %{buildroot}/%{installdir} -type f -name \*sh); do sed -i 's@#!/usr/bin/env bash@#!/usr/bin/bash@' $file; done
#for file in $(find %{buildroot}/%{installdir} -type f -name \*py); do sed -i 's@#!/usr/bin/env python@#!/usr/bin/python3@' $file; done
cd %{buildroot}
cp %{_sourcedir}/*py .

export EASYBUILD_BOOTSTRAP_SOURCEPATH=%{_sourcedir}
export EASYBUILD_INSTALLPATH=%{buildroot}/%{installdir}
export EASYBUILD_MODULE_SYNTAX=Tcl
export PATH=${LMOD_DIR}:${PATH}

python3 ./bootstrap_eb.py $EASYBUILD_INSTALLPATH
# remove cache file as there are inconsistent times
rm %{buildroot}%{installdir}/software/EasyBuild/%{version}/lib/python%{python_version}/site-packages/easybuild/easyblocks/generic/__pycache__/pythonpackage.cpython-%{python_version_nodots}.pyc

rm bootstrap_eb.py
# just keep on copy
pushd %{buildroot}/%{installdir}/modules/tools/EasyBuild/
rm %version
ln -s ../../all/EasyBuild/%version .
mkdir -p %{buildroot}/%{_datadir}/lmod/modulefiles/%{name}/
cp ../../all/EasyBuild/%version %{buildroot}/%{_datadir}/lmod/modulefiles/%{name}/
popd
%fdupes -s %{buildroot}/%{installdir}
find %{buildroot}/%{installdir} -name \*.eb -perm 755 -type f -exec chmod 644 {} +
# remove spurious buildroot
for file in $(find %buildroot -name %version -type f); do sed -i 's@%buildroot@@' $file ; done
cd %{buildroot}/%{installdir}/software/EasyBuild/%{version}/easybuild/
rm *test_report.md *log *easybuild-devel
cd -
rm -rf $(find %buildroot -type d -name __archive__)
mkdir -pv %{buildroot}/%{_datadir}/lmod/modulefiles/%{name}

# Create /etc/profile.d/easybuild.sh
# This file properly sets MODULEPATH so lua-lmod can find the modules created by spack
mkdir -p %{buildroot}/%{_sysconfdir}/profile.d
cat > %{buildroot}/%{_sysconfdir}/profile.d/easybuild.sh <<EOFOUTER

# copy local configuration, if its not there
# test if user is in easybuild group by touching the location
if ! touch %{installdir}/software &> /dev/null ; then
  export MODULEPATH=~/.local/easybuild/modules/all:\${MODULEPATH}
else
  test -d \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild || mkdir -p \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild
  test -e \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg || cat > \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg <<EOF
[main]
installpath=%{installdir}/software/EasyBuild/%{version}/software
EOF
fi
MODULEPATH=%{installdir}/software/EasyBuild/%version/software/modules/all:\${MODULEPATH}
EOFOUTER
# Same for csh
cat > %{buildroot}/%{_sysconfdir}/profile.d/easybuild.csh <<EOFOUTER
touch %{installdir}/software >& /dev/null
if ( \$? == 1  ) then
  set MODULEPATH="~/.local/easybuild/modules/all:\${MODULEPATH}"
else
  test -d \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild || mkdir -p \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild
  test -e \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg || cat > \${XDG_CONFIG_HOME:-\$HOME/.local}/easybuild/location.cfg <<EOF
[main]
installpath=%{installdir}/software/EasyBuild/%{version}/software
EOF
endif
EOFOUTER

# create a config, so that not too much stuff is build
mkdir -p %{buildroot}/%{_sysconfdir}/xdg/easybuild.d/
cat > %{buildroot}/%{_sysconfdir}/xdg/easybuild.d/suse.cfg <<EOF
[override]
%if 0%{?suse_version} > 1500
minimal-build-env=CC:gcc-7,CXX:g++-7
%endif
filter-deps=binutils,Bison,M4,flex,Perl,Autoconf,Automake,Autotools
EOF
mkdir -p %{buildroot}/%{installdir}/software/EasyBuild/%version/modules

%pre
getent group %eb_group >/dev/null || groupadd -r %eb_group

%post
# create the system toolchain modules, but only if mpicc can be found
test -e /usr/lib64/mpi/gcc/openmpi4/bin || exit 0
source /etc/profile.d/lmod.sh
USER=root PATH=/usr/lib64/mpi/gcc/openmpi4/bin:$PATH \
PYTHONPATH=%{installdir}/software/EasyBuild/%{version}/lib/python%{python_version}/site-packages:$PYTHONPATH \
%{installdir}/software/EasyBuild/%{version}/bin/eb \
--installpath %{installdir}/software/EasyBuild/%{version}/software/ gompi-system-2.29.eb -r --allow-use-as-root-and-accept-consequences \
--filter-deps=binutils,Bison,M4,flex,Perl,Autoconf,Automake,Autotools


%files
#%%doc ChangeLog README COPYING
%dir %{installdir}software
%{installdir}/software
#%%exclude %{installdir}/%{_datadir}
%exclude %{installdir}/software/EasyBuild/%version/easybuild/easyconfigs
%dir %{_datadir}/lmod/modulefiles/%{name}
%{_datadir}/lmod/modulefiles/%{name}/%{version}
%{installdir}/modules
%dir %{_sysconfdir}/xdg/easybuild.d
%config %{_sysconfdir}/xdg/easybuild.d/suse.cfg
%config %{_sysconfdir}/profile.d/easybuild.*sh
%attr(0775, root, %eb_group) %{installdir}/software/EasyBuild/%version/modules

%files easyconfigs
%{installdir}/software/EasyBuild/%version/easybuild/easyconfigs

%changelog
openSUSE Build Service is sponsored by