2017-09-12 16:34:53 +02:00
|
|
|
# If argument is non-empty print with a leading underscore
|
|
|
|
%_hpc_p %([ -n "%{?1}" ]&&echo -n _%{1})
|
|
|
|
%hpc_package_name_tail() %{?hpc_ext}%{_hpc_p}%{hpc_package_name_end}
|
|
|
|
%hpc_package_name() %{pname}%{?hpc_ext}%{_hpc_p}%{hpc_package_name_end}
|
|
|
|
|
|
|
|
# Paths
|
|
|
|
%hpc_base %{_prefix}/lib/hpc/
|
|
|
|
|
|
|
|
# For (non-mpi) libraries
|
|
|
|
%hpc_install_base %{hpc_base}%{?hpc_cf_dir}%{?hpc_mpi_dir}
|
|
|
|
%hpc_install_path_base %{hpc_install_base}%{pname}%{?hpc_ext}/
|
|
|
|
%hpc_install_path %{hpc_install_path_base}%{version}
|
|
|
|
|
|
|
|
# For compilers
|
|
|
|
%hpc_cf_install_base %{hpc_base}compiler/
|
|
|
|
%hpc_cf_install_path_base %{hpc_cf_install_base}%{hpc_compiler_family}/
|
2018-01-30 11:09:11 +01:00
|
|
|
%hpc_cf_install_path %{hpc_cf_install_path_base}%{hpc_cf_dep_version}
|
2017-09-12 16:34:53 +02:00
|
|
|
|
|
|
|
# For mpi libraries
|
|
|
|
%hpc_mpi_install_base %{hpc_base}%{?hpc_cf_dir}mpi/
|
2017-09-27 09:33:00 +02:00
|
|
|
%hpc_mpi_install_path_base %{hpc_mpi_install_base}%{hpc_mpi_family}%{?hpc_ext}/
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_mpi_install_path %{hpc_mpi_install_path_base}%{version}
|
|
|
|
|
|
|
|
# Different paths - below HPC directory
|
|
|
|
%hpc_exec_prefix %{hpc_prefix}
|
|
|
|
%hpc_bindir %{hpc_prefix}/bin
|
|
|
|
%hpc_sbindir %{hpc_prefix}/sbin
|
|
|
|
%hpc_sysconfdir %{_sysconfdir}
|
|
|
|
%hpc_datadir %{hpc_prefix}/share
|
|
|
|
%hpc_includedir %{hpc_prefix}/include
|
|
|
|
%hpc_libdir %{hpc_prefix}/%{_lib}
|
|
|
|
%hpc_libexecdir %{hpc_prefix}/lib
|
|
|
|
%hpc_localstatedir %{_localstatedir}
|
|
|
|
%hpc_sharedstatedir %{_sharedstatedir}
|
|
|
|
%hpc_mandir %{hpc_prefix}/share/man
|
|
|
|
%hpc_infodir %{hpc_prefix}/share/info
|
|
|
|
%hpc_pkgconfigdir %{hpc_libdir}/pkgconfig
|
|
|
|
|
|
|
|
# pkgconfig
|
|
|
|
# %hpc_write_pkgconfig [-l <libname>][-n <pkgfile_name>]
|
|
|
|
# -l <libname>: <libname> with -l option: -l <libname>. default: none
|
|
|
|
# -n <pkgfile_name>: name of pkgconf file (without the trailing .pc)
|
|
|
|
# default: %pname
|
|
|
|
%_hpc_write_pkgconfig(l:n:) \
|
|
|
|
%{!?_hpc_init_done: %{error: "%%_hpc_write_pkgconfig: Call %%hpc_init first!"}} \
|
|
|
|
%{__mkdir_p} %{buildroot}/%{hpc_pkgconfigdir} \
|
|
|
|
echo "writing %{buildroot}%{hpc_pkgconfigdir}/%{!-n:%{pname}}%{-n:%{-n*}}.pc" \
|
|
|
|
%{__cat} << "EOF" > %{buildroot}%{hpc_pkgconfigdir}/%{!-n:%{pname}}%{-n:%{-n*}}.pc \
|
|
|
|
prefix=%{hpc_prefix} \
|
|
|
|
exec_prefix=%{hpc_exec_prefix} \
|
|
|
|
libdir=%{hpc_libdir} \
|
|
|
|
includedir=%{hpc_includedir} \
|
|
|
|
sysconfdir=%{hpc_sysconfdir} \
|
|
|
|
\
|
|
|
|
Name: %pname \
|
2018-02-09 16:37:13 +01:00
|
|
|
Description: %{summary:0} \
|
2017-09-12 16:34:53 +02:00
|
|
|
Version: %version \
|
|
|
|
Libs: -L${libdir} %{?-l:-l%{-l*}} \
|
|
|
|
Cflags: -I${includedir} \
|
|
|
|
EOF\
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%hpc_write_pkgconfig(n:l:) %{expand:%%_hpc_write_pkgconfig %{**}}
|
|
|
|
|
|
|
|
# %hpc_pkgconfig_file [-n <name_of_file>][-N]
|
|
|
|
# -n <name_of_file>: pkgconfig file name (without trailing .pc)
|
|
|
|
# -N: don't list pkgconfig directory (used when this macro is used
|
|
|
|
# more than once per file).
|
|
|
|
%hpc_pkgconfig_file(n:N) \
|
|
|
|
%{!-N:%dir %{hpc_pkgconfigdir}} \
|
|
|
|
%{hpc_pkgconfigdir}/%{!-n:%{pname}}%{-n:%{-n*}}.pc
|
|
|
|
|
|
|
|
%hpc_modulefile_add_pkgconfig_path prepend-path PKG_CONFIG_PATH %{hpc_pkgconfigdir}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Requires:
|
|
|
|
#
|
|
|
|
|
|
|
|
# Compiler
|
|
|
|
%hpc_cf_requires %{expand:%{hpc_%{hpc_compiler_family}_requires}}
|
|
|
|
# Compiler devel packages
|
|
|
|
%hpc_cf_requires_devel %{expand:%{hpc_%{hpc_compiler_family}_requires_devel}}
|
|
|
|
|
|
|
|
# MPI
|
|
|
|
%hpc_mpi_requires %{expand:%{hpc_%{hpc_mpi_family}_requires}}
|
|
|
|
# MPI devel packages
|
|
|
|
%hpc_mpi_requires_devel %{expand:%{hpc_%{hpc_mpi_family}_requires_devel}}
|
|
|
|
|
|
|
|
# Base
|
2017-11-20 21:03:10 +01:00
|
|
|
%hpc_requires Requires: lua-lmod \
|
|
|
|
%{?hpc_compiler_family:%{!?_hpc_build_compiler:%hpc_cf_requires}}\
|
|
|
|
%{?hpc_mpi_family:%{!?_hpc_build_mpi:%hpc_mpi_requires}}\
|
2017-09-12 16:34:53 +02:00
|
|
|
|
|
|
|
# Devel
|
|
|
|
%hpc_requires_devel %{?hpc_compiler_family:%{!?_hpc_build_compiler:%hpc_cf_requires_devel}}\
|
|
|
|
%{?hpc_mpi_family:%{!?_hpc_build_mpi:%hpc_mpi_requires_devel}}
|
|
|
|
|
|
|
|
#
|
|
|
|
# General settings depending in compiler and mpi family
|
|
|
|
#
|
|
|
|
|
|
|
|
# Init
|
|
|
|
#
|
|
|
|
# HCP init: Call everywhere where this framework is used.
|
|
|
|
# %hpc_init [-C|-M] -c <compiler_family> [-v <compiler_version>] -m <mpi_family> [-V <mpi_version>]
|
|
|
|
# -C: build a compiler.
|
|
|
|
# -c <arg>: set compiler family to <arg> (mandatory)
|
|
|
|
# -v <arg>: set compiler version to <arg> (optional - default: base version)
|
|
|
|
# -M: build an MPI library: -C and -M are mutually exclusive!
|
|
|
|
# -m: <arg>: set MPI family to <arg>
|
|
|
|
# -V: <arg>: set MPI version to <arg> (optional - default:)
|
|
|
|
# -e: <arg>: program name extension
|
|
|
|
%_hpc_init(Cc:Mm:v:V:e:)\
|
|
|
|
%{-m:%{!-c:%{error: Cannot est MPI family without compiler}}} \
|
|
|
|
%{-c:%{expand: %%global hpc_compiler_family %{-c*}}} \
|
|
|
|
%{-m: %{expand: %%global hpc_mpi_family %{-m*}}} \
|
|
|
|
%{!-m:%{-V:%{error: MPI version sepecified but no MPI family}}} \
|
|
|
|
%{-C:%{-M:%{error: Don't build both compiler and MPI!}}} \
|
|
|
|
%{-c:%{echo: Building for %hpc_compiler_family %{-v:version %{-v*}}}} \
|
|
|
|
%{!?pname:%{error: No package name given! Set %%pname before calling %%hpc_init }} \
|
|
|
|
%{-e:%{expand: %%global hpc_ext -%{-e*}}} \
|
|
|
|
%if %{defined hpc_compiler_family} \
|
|
|
|
%if %{defined hpc_%{expand:%{hpc_compiler_family}}_init} \
|
|
|
|
# -v passed onto here \
|
|
|
|
%{expand:%%{hpc_%{expand:%{hpc_compiler_family}}_init %{-v}}} \
|
|
|
|
%endif \
|
|
|
|
%endif \
|
|
|
|
%if %{defined hpc_mpi_family} \
|
|
|
|
%if %{defined hpc_%{expand:%{hpc_mpi_family}}_init} \
|
|
|
|
# -V passed onto here \
|
|
|
|
%{expand:%%{hpc_%{expand:%{hpc_mpi_family}}_init %{-V}}} \
|
|
|
|
%endif \
|
|
|
|
%endif \
|
|
|
|
# No further expansion needed, thus no %%{expand:..} \
|
|
|
|
%{-C:%global _hpc_build_compiler 1} \
|
|
|
|
%{-M:%global _hpc_build_mpi 1} \
|
|
|
|
# \
|
|
|
|
# Compiler \
|
|
|
|
%{?hpc_compiler_family: \
|
|
|
|
%{expand: %%global hpc_cf_full_version %%{hpc_%{hpc_compiler_family}_full_version}} \
|
|
|
|
# Version for module directories \
|
|
|
|
%{expand: %%global hpc_cf_dep_version %%{hpc_%{hpc_compiler_family}_dep_version}} \
|
|
|
|
# Version extension on binaries \
|
|
|
|
%{expand: %%global hpc_cf_bin_version %%{hpc_%{hpc_compiler_family}_bin_version}} \
|
|
|
|
# Version number on package \
|
|
|
|
%{expand: %%global hpc_cf_pack_version %%{hpc_%{hpc_compiler_family}_pack_version}} \
|
|
|
|
%{expand: %%global hpc_cf_dir %{?hpc_compiler_family:%%{hpc_%{hpc_compiler_family}_dir}/}} \
|
|
|
|
} \
|
|
|
|
# \
|
|
|
|
# MPI \
|
|
|
|
%{?hpc_mpi_family: \
|
|
|
|
%global hpc_mpi_dep_version %{?hpc_mpi_family:%%{hpc_%{hpc_mpi_family}_dep_version}} \
|
|
|
|
%global hpc_mpi_dir %{?hpc_mpi_family:%%{hpc_%{hpc_mpi_family}_dir}/} \
|
|
|
|
%global hpc_mpi_pack_version %{?hpc_mpi_family:%%{hpc_%{hpc_mpi_family}_pack_version}} \
|
|
|
|
} \
|
2017-09-14 00:51:52 +02:00
|
|
|
# Preexpanded macros \
|
2017-09-12 16:34:53 +02:00
|
|
|
%{expand: %%global hpc_prefix %{-M:%hpc_mpi_install_path}%{-C:%hpc_cf_install_path}%{!-M:%{!-C:%{hpc_install_path}}}} \
|
|
|
|
%{?_hpc_build_mpi:%global _hpc_build_xx 1} \
|
|
|
|
%{?_hpc_build_compiler:%global _hpc_build_xx 1} \
|
|
|
|
%{!?hpc_compiler_family:%global _hpc_build_xx 1} \
|
|
|
|
%define _hpc_package_name_compiler %{?hpc_compiler_family:-%{hpc_compiler_family}%{?hpc_cf_pack_version}} \
|
|
|
|
%define _hpc_package_name_mpi %{?hpc_mpi_family:%{!?_hpc_build_mpi:-%{hpc_mpi_family}%{?hpc_mpi_pack_version}}} \
|
|
|
|
%global hpc_package_name_end %{_hpc_package_name_compiler}%{_hpc_package_name_mpi}-hpc \
|
2017-09-14 00:51:52 +02:00
|
|
|
# Dependency Generator \
|
|
|
|
%global tmp %__elf_exclude_path \
|
|
|
|
%global __elf_exclude_path (%tmp)|(^%hpc_base) \
|
|
|
|
%undefine tmp \
|
|
|
|
%global tmp %__elflib_exclude_path \
|
|
|
|
%global __elflib_exclude_path (%tmp)|(^%hpc_base) \
|
|
|
|
%undefine tmp \
|
2018-03-04 12:15:02 +01:00
|
|
|
%{expand:%([ 0%{?sle_version} -ge 150000 ] && echo %%global _hpc_python3 1)} \
|
2017-09-12 16:34:53 +02:00
|
|
|
%global _hpc_init_done 1
|
|
|
|
|
|
|
|
%hpc_init(Cc:Mm:v:V:e:) %{expand:%%_hpc_init %{**}}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Environment Modules
|
|
|
|
#
|
|
|
|
%hpc_mpi_family_path %{?hpc_mpi_family:-%{hpc_mpi_family}%([ -n "%{hpc_mpi_dep_version}" ] &&
|
|
|
|
echo -n "-%{hpc_mpi_dep_version}")}
|
|
|
|
|
|
|
|
%hpc_compiler_family_path %{?hpc_compiler_family:%{hpc_compiler_family}-%{hpc_cf_dep_version}}
|
|
|
|
|
|
|
|
# Used for MPI library build to create the module install directory for MPI dependent libs.
|
|
|
|
%hpc_module_dep_install %{lua_lmod_moduledeps}/%{hpc_compiler_family_path}%{?hpc_mpi_family_path}
|
|
|
|
|
|
|
|
# Install path base for the module file of the current package
|
2018-03-04 12:15:02 +01:00
|
|
|
%_hpc_module_base %{!?compiler_family:%{lua_lmod_modulesdir}}%{?compiler_family:%{?_hpc_build_compiler:%{lua_lmod_modulesdir}}%{!?_hpc_build_compiler:%{lua_lmod_moduledeps}}/}
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_module_dep_path %{_hpc_module_base}%{hpc_compiler_family_path}%{!?_hpc_build_mpi:%{?hpc_mpi_family_path}}
|
|
|
|
|
|
|
|
# install the module file here. If the default path (according to
|
|
|
|
# hpc_cf_family and hpc_mpi_family should not be used, pass trailing path
|
|
|
|
# element as argument. Do not use for compiler!
|
|
|
|
%hpc_module_dep_base %{hpc_module_dep_path}/%{hpc_module_pname}%{?hpc_ext}/
|
|
|
|
|
|
|
|
# This can be overridden in the spec file.
|
|
|
|
%hpc_module_pname %pname
|
|
|
|
|
|
|
|
%hpc_setup_compiler \
|
|
|
|
%{!?_hpc_init_done: %{error: "%%hpc_setup_compiler: Call %%hpc_init first!"}} \
|
|
|
|
module purge \
|
|
|
|
%{?hpc_compiler_family:%{expand:%{hpc_setup_%{hpc_compiler_family}}}}
|
|
|
|
|
|
|
|
%hpc_setup_mpi \
|
|
|
|
%{?hpc_mpi_family:%{expand:%{hpc_setup_%{hpc_mpi_family}}}}
|
|
|
|
|
|
|
|
%hpc_setup \
|
|
|
|
%hpc_setup_compiler \
|
|
|
|
%{!?_hpc_build_mpi:%hpc_setup_mpi}
|
|
|
|
|
|
|
|
# delete default in %postun
|
|
|
|
%hpc_module_delete_if_default \
|
|
|
|
_tmp=$(readlink -e %{hpc_module_dep_base}/version) && \
|
|
|
|
test "$_tmp" = "$(readlink -f %{hpc_module_dep_base}/.version.%{version})" && \
|
|
|
|
rm -f %{hpc_module_dep_base}/version || exit 0
|
|
|
|
|
|
|
|
#
|
|
|
|
%hpc_write_modules_version_file \
|
|
|
|
echo "Writing %{buildroot}%{hpc_module_dep_base}.version.%{version}" \
|
|
|
|
%{__cat} << EOF > %{buildroot}%{hpc_module_dep_base}.version.%{version} \
|
|
|
|
#%%Module1.0#####################################################################\
|
|
|
|
##\
|
|
|
|
## version file for %{pname}-%{version}\
|
|
|
|
##\
|
|
|
|
set ModulesVersion "%{version}"\
|
|
|
|
EOF\
|
|
|
|
%nil
|
|
|
|
|
|
|
|
#
|
|
|
|
%hpc_make_modules_dir mkdir -p %{buildroot}%{hpc_module_dep_base}
|
|
|
|
|
|
|
|
#
|
|
|
|
%hpc_write_modules_files \
|
|
|
|
%{?_hpc_build_mpi:mkdir -p %{buildroot}%{hpc_install_base}} \
|
|
|
|
%hpc_make_modules_dir \
|
|
|
|
%{?_hpc_build_xx:mkdir -p %{buildroot}%{hpc_module_dep_install}} \
|
|
|
|
%hpc_write_modules_version_file \
|
|
|
|
echo "Writing %{buildroot}%{hpc_module_dep_base}%{version}" \
|
|
|
|
cat << EOF > %{buildroot}%{hpc_module_dep_base}%{version}
|
|
|
|
|
|
|
|
%hpc_modulepath %{?_hpc_build_xx:%{hpc_module_dep_install}}%{!?_hpc_build_xx:%{hpc_module_dep_path}}
|
|
|
|
|
|
|
|
# For files section:
|
|
|
|
## Modules Files
|
|
|
|
%hpc_modules_files \
|
|
|
|
%{?_hpc_build_xx:%{hpc_module_dep_install}} \
|
|
|
|
%dir %{hpc_module_dep_base} \
|
|
|
|
%{hpc_module_dep_base}/.version.%{version} \
|
|
|
|
%{hpc_module_dep_base}/%{version}
|
|
|
|
|
|
|
|
# Compilers - use in library package when building compilers
|
|
|
|
%hpc_cf_dirs \
|
|
|
|
%dir %hpc_cf_install_base \
|
|
|
|
%dir %hpc_cf_install_path_base \
|
|
|
|
%dir %hpc_cf_install_path
|
|
|
|
|
|
|
|
# mpi libraries - use in library package when building mpi libraries
|
|
|
|
%hpc_mpi_dirs \
|
|
|
|
%dir %{hpc_install_base} \
|
|
|
|
%dir %hpc_mpi_install_base \
|
|
|
|
%dir %hpc_mpi_install_path_base \
|
|
|
|
%dir %hpc_mpi_install_path
|
|
|
|
|
|
|
|
# serial and parallel libraries - use in library package
|
|
|
|
%hpc_dirs \
|
|
|
|
%{!?hpc_compiler_family:%dir %{hpc_install_base}} \
|
|
|
|
%dir %{hpc_install_path_base} \
|
|
|
|
%dir %{hpc_install_path} \
|
|
|
|
%dir %{hpc_libdir}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Autotools
|
|
|
|
#
|
|
|
|
|
|
|
|
%hpc_configure \
|
|
|
|
%{!?_hpc_init_done: %{error: "%%hpc_configure: Call %%hpc_init first!"}} \
|
|
|
|
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
|
|
|
|
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
|
|
|
|
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
|
|
|
|
%{_configure} --host=%{_host} --build=%{_build} \\\
|
|
|
|
%{?_program_prefix:--program-prefix=%{_program_prefix}} \\\
|
|
|
|
--disable-dependency-tracking \\\
|
|
|
|
--prefix=%{hpc_prefix} \\\
|
|
|
|
--exec-prefix=%{hpc_exec_prefix} \\\
|
|
|
|
--bindir=%{hpc_bindir} \\\
|
|
|
|
--sbindir=%{hpc_sbindir} \\\
|
|
|
|
--sysconfdir=%{_sysconfdir} \\\
|
|
|
|
--datadir=%{hpc_datadir} \\\
|
|
|
|
--includedir=%{hpc_includedir} \\\
|
|
|
|
--libdir=%{hpc_libdir} \\\
|
|
|
|
--libexecdir=%{hpc_libexecdir} \\\
|
|
|
|
--localstatedir=%{hpc_localstatedir} \\\
|
|
|
|
--sharedstatedir=%{hpc_sharedstatedir} \\\
|
|
|
|
--mandir=%{hpc_mandir} \\\
|
|
|
|
--infodir=%{hpc_infodir}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Debugging
|
|
|
|
#
|
|
|
|
|
|
|
|
# %hpc_debug [-x]
|
|
|
|
# -x: exit with a non-zero exit code. This will stop the build and keep the
|
|
|
|
# generated script file around.
|
|
|
|
#
|
|
|
|
%hpc_debug(x) \
|
|
|
|
echo "Package name %{name} for %{pname} %{?hpc_ext: ext: %{hpc_ext}}" \
|
|
|
|
%{?_hpc_build_compiler: echo "Building Compiler"} \
|
|
|
|
%{?_hpc_build_mpi: echo "Building MPI lib"} \
|
|
|
|
echo %nil \
|
|
|
|
%if %{defined hpc_compiler_family} \
|
|
|
|
echo Building for compiler family: %{hpc_compiler_family} \
|
|
|
|
echo cf_full_version: %{hpc_cf_full_version} \
|
|
|
|
echo cf_dep_version: %{hpc_cf_dep_version} \
|
|
|
|
echo cf_bin_version: %{hpc_cf_bin_version} \
|
|
|
|
echo cf_pack_version: %{hpc_cf_pack_version} \
|
|
|
|
echo cf_dir: %{hpc_cf_dir} \
|
|
|
|
echo cf_install_path: %{hpc_cf_install_path} \
|
|
|
|
echo cf_install_path_base: %{hpc_cf_install_path_base} \
|
|
|
|
echo %nil \
|
|
|
|
%endif \
|
|
|
|
%if %{defined hpc_mpi_family} \
|
|
|
|
echo "Building with MPI family support for %{hpc_mpi_family}" \
|
|
|
|
echo hpc_mpi_dep_version: %hpc_mpi_dep_version \
|
|
|
|
%{?hpc_mpi_pack_version: echo hpc_mpi_pack_version: %hpc_mpi_pack_version} \
|
|
|
|
echo hpc_mpi_family_path: %hpc_mpi_family_path \
|
|
|
|
echo hpc_mpi_dir: %{hpc_mpi_dir} \
|
|
|
|
echo %nil \
|
|
|
|
%endif \
|
|
|
|
echo hpc_prefix: %{hpc_prefix} \
|
|
|
|
echo hpc_module_dep_path: %{hpc_module_dep_path} \
|
|
|
|
echo %nil \
|
|
|
|
%{-x:exit 1}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create 'master' package: packages which have the built package as
|
|
|
|
# dependency. This way, the latest version of a library can be installed
|
|
|
|
# without knowing its version number.
|
|
|
|
# The dependent library package will be kept around when an update to
|
|
|
|
# this package pulls in a new version of the dependent library, because
|
|
|
|
# these libraries also carry the version number of their names and
|
|
|
|
# don't conflict with an earlier version.
|
2017-10-19 19:40:53 +02:00
|
|
|
# %hpc_master_package [-n <full_package_name>][-g <group>][-s# <.so-version>][-l][-L][-N <pname>][-q] <package_ext>
|
2017-09-12 16:34:53 +02:00
|
|
|
# -n <full_package_name>: specify the full package name. This may not be used in conjunction with
|
|
|
|
# the package name extension <package_ext>.
|
|
|
|
# -g <group>: Specify the group to use.
|
|
|
|
# -s <.so-version>: If this is a dependency for a library package, specify the
|
|
|
|
# .so version. This will cause the package name to be prepended with
|
|
|
|
# `lib`. This should not be used together with -l.
|
|
|
|
# -l: mark a library package, prepend the package name with a `lib` (like -s
|
|
|
|
# but without an explicite so version. Do not use -l and -s together.
|
|
|
|
# -L: Create a link from the .version.<version_no> file to the .version file
|
|
|
|
# to mark the default version.
|
|
|
|
# -a: Use native arch even if no library package.
|
2017-10-19 19:40:53 +02:00
|
|
|
# -N <pname>: Specify if a sub-package has different basename (pname)
|
2017-09-12 16:34:53 +02:00
|
|
|
# -q: For internal use only!
|
2018-06-16 21:49:12 +02:00
|
|
|
# -M: use specified name in place of %%name
|
2017-09-12 16:34:53 +02:00
|
|
|
#
|
2018-06-16 21:49:12 +02:00
|
|
|
%hpc_master_package(n:g:s:lLaqN:M:) \
|
2017-09-12 16:34:53 +02:00
|
|
|
%define _mylib %{-s:lib}%{!-s:%{-l:lib}} \
|
|
|
|
%define _p_ext %(test -n "%{*}" && echo -%{*}) \
|
2018-06-16 21:49:12 +02:00
|
|
|
%{-M: \ %define name %{-M*}} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%{!-N:\
|
|
|
|
%define _pname %{pname} \
|
|
|
|
%define _name %{name} \
|
|
|
|
} \
|
|
|
|
%{-N:\
|
|
|
|
%define _pname %{-N*} \
|
|
|
|
%define _name %(echo %{name} | sed -e "s/%{pname}/%{_pname}/") \
|
|
|
|
} \
|
|
|
|
%{-n:%define _lname %{-n*}} \
|
2017-09-12 16:34:53 +02:00
|
|
|
%{!-n:\
|
2017-10-19 19:40:53 +02:00
|
|
|
%define _lname_cf %{?compiler_family:-%{compiler_family}%{?hpc_cf_pack_version}} \
|
|
|
|
%define _lname_mpi %{!?_hpc_build_mpi:%{?hpc_mpi_family:-%{hpc_mpi_family}%{?hpc_mpi_pack_version}}} \
|
|
|
|
%define _lname_build_mpi_name %{?_hpc_build_mpi:%{hpc_mpi_family}%{?hpc_ext}%{?hpc_mpi_pack_version}} \
|
|
|
|
%define _lname_name %{!?_hpc_build_mpi:%{_pname}%{?hpc_ext}%{-s*}} \
|
|
|
|
%define _lname_header %{_mylib}%{_lname_build_mpi_name}%{_lname_name} \
|
|
|
|
%define _lname %{_lname_header}%{_lname_cf}%{_lname_mpi}-hpc%{_p_ext} \
|
2017-09-12 16:34:53 +02:00
|
|
|
}\
|
2017-10-19 19:40:53 +02:00
|
|
|
%{-q:%(echo -n %{_lname}; true %{_mylib} %{_p_ext})} \
|
2017-09-12 16:34:53 +02:00
|
|
|
%{!-q:\
|
|
|
|
%{-g:%define _group %{-g*}} \
|
|
|
|
%{!-g: \
|
2017-10-19 19:40:53 +02:00
|
|
|
%define _group %(lname=%_lname; \
|
|
|
|
case $lname in \
|
2017-09-12 16:34:53 +02:00
|
|
|
(*-devel|*-devel-static) \
|
|
|
|
echo -n "Development/Libraries/%{?hpc_mpi_family:Parallel}%{!?hpc_mpi_family:C and C++}" ;; \
|
|
|
|
(*) \
|
|
|
|
if [ -n "%_mylib" ] \
|
|
|
|
then \
|
|
|
|
echo -n System/Libraries \
|
|
|
|
else \
|
|
|
|
echo -n Productivity/Scientific/Other \
|
|
|
|
fi ;; esac)\
|
|
|
|
} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%{!-s:%define n_name %_name} \
|
|
|
|
%{-s:%define n_name %(a=%{_name};echo -n ${a/%{_pname}/%{_pname}%{-s*}})} \
|
2018-06-16 21:49:12 +02:00
|
|
|
%{!-s:%define s_name %{_mylib}%{n_name}%{_p_ext}} \
|
|
|
|
%{-s:%define s_name %(echo -n %{_mylib}%{_name}%{_p_ext} | sed -e "s/\\(.*%{_pname}\\)\\(.*\\)/\\\\1%{-s*}\\\\2/")} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%package -n %_lname \
|
2018-06-16 21:49:12 +02:00
|
|
|
Summary: Dependency package for %{s_name} \
|
2017-09-12 16:34:53 +02:00
|
|
|
Group: %_group \
|
2017-10-19 19:40:53 +02:00
|
|
|
Obsoletes: %_lname < %version \
|
2018-06-16 21:49:12 +02:00
|
|
|
Requires: %{s_name} = %version \
|
2017-09-12 16:34:53 +02:00
|
|
|
%{!-l:%{!-s:%{!-a:BuildArch: noarch}}} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%description -n %_lname \
|
2018-06-16 21:49:12 +02:00
|
|
|
The package %{l_name} provides the dependency to get the latest binary package version of %{_pname} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%{-L:%post -n %_lname \
|
2017-09-12 16:34:53 +02:00
|
|
|
ln -sf %{hpc_module_dep_base}.version.%{version} %{hpc_module_dep_base}.version} \
|
2017-10-19 19:40:53 +02:00
|
|
|
%files -n %{_lname} \
|
2017-09-12 16:34:53 +02:00
|
|
|
%defattr(-,root,root)\
|
2018-06-16 21:49:12 +02:00
|
|
|
%define _msg '%{summary:0}: Provide the dependency to get the latest binary package version of %{_pname}' \
|
2017-10-19 19:40:53 +02:00
|
|
|
%define _readme README.%{_mylib}%{_name}%{_p_ext} \
|
2017-09-12 16:34:53 +02:00
|
|
|
%define _tmpexec %(tmp=$(mktemp /tmp/scr-XXXXXX); \
|
|
|
|
readme=%{_readme} \
|
|
|
|
echo "#!/bin/bash" > $tmp; \
|
|
|
|
echo "echo %_msg \> $readme && rm -f $tmp || true" >> $tmp; \
|
|
|
|
chmod u+x $tmp; echo -n $tmp) \
|
|
|
|
%doc $(%_tmpexec)./%{_readme} \
|
|
|
|
} \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
##
|
|
|
|
# Functions
|
|
|
|
##
|
|
|
|
%hpc_upcase() %(echo %{**} | tr [a-z] [A-Z])
|
2017-11-20 21:03:10 +01:00
|
|
|
%hpc_PNAME() %(echo %{**} | tr [a-z-] [A-Z_])
|
2017-09-12 16:34:53 +02:00
|
|
|
|
|
|
|
##
|
|
|
|
# Macros specific for python packages
|
|
|
|
##
|
|
|
|
%_hpc_python_sysconfig_path() %(%1 -c "import sysconfig as s; \\\
|
|
|
|
print(s.get_paths(%{?3:vars={'platbase':\\"%3\\", 'base' : \\"%3\\"}}).get('%2'));")
|
|
|
|
|
2017-10-04 13:09:55 +02:00
|
|
|
# get the python version specific directory for arch specific files in the HPC
|
2018-03-04 12:15:02 +01:00
|
|
|
# directory structure (singlepsec).
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_python_sitearch %{_hpc_python_sysconfig_path %python_flavor platlib %{?hpc_prefix}}
|
|
|
|
|
2018-03-04 12:15:02 +01:00
|
|
|
# same for non-singlespec (using internal %%_hpc_python3)
|
|
|
|
%hpc_python_sitearch_no_singlespec %{_hpc_python_sysconfig_path %{?_hpc_python3:/usr/bin/python3}%{!?_hpc_python3:%python_flavor} platlib %{?hpc_prefix}}
|
|
|
|
|
2017-09-12 16:34:53 +02:00
|
|
|
%_hpc_python_ver() %(%1 -c "import sys as s;print(s.version[:3]);")
|
|
|
|
|
2018-03-04 12:15:02 +01:00
|
|
|
# get the (abbreviated) python version used for package and directory names (singlespec).
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_python_version %{_hpc_python_ver %python_flavor}
|
|
|
|
|
2017-10-04 13:09:55 +02:00
|
|
|
# %{hpc_python_master_package [-n <package_name>] [-g <group>] [-l][-L][-a]}
|
2018-03-04 12:15:02 +01:00
|
|
|
# (singlespec)
|
2017-10-04 13:09:55 +02:00
|
|
|
# -n: specify a package name
|
|
|
|
# -g: specify a group name
|
|
|
|
# -l: mark the package as library package
|
|
|
|
# -L: (for environment modules) create a link from the
|
|
|
|
# `.version.<version_no>` file to the `.version`-file to
|
|
|
|
# mark the default version.
|
|
|
|
# -a: mark package as architecture dependent
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_python_master_package(n:g:lLa) \
|
|
|
|
%{?_python_macro_init} \
|
|
|
|
%{lua: \
|
|
|
|
if _hpc_python_master_package_inited ~= true then \
|
|
|
|
_hpc_python_package_list = {} \
|
|
|
|
_hpc_python_master_package_inited = true \
|
|
|
|
end \
|
|
|
|
local arg_list = "" \
|
|
|
|
local function add_args (a, opt) \
|
|
|
|
if a ~= "" then \
|
|
|
|
if arg_list ~= "" then arg_list = arg_list .. " " end \
|
|
|
|
if opt ~= nil then arg_list = arg_list .. opt .. " " end \
|
|
|
|
arg_list = arg_list .. a \
|
|
|
|
end \
|
|
|
|
end \
|
|
|
|
local n_arg = rpm.expand("%{-n*}") \
|
|
|
|
local g_arg = rpm.expand("%{-g*}") \
|
|
|
|
local l_arg = rpm.expand("%{?-l:-l}") \
|
|
|
|
local L_arg = rpm.expand("%{?-L:-L}") \
|
|
|
|
local a_arg = rpm.expand("%{?-a:-a}") \
|
|
|
|
local other_arg = rpm.expand("%{*}") \
|
|
|
|
local pname = rpm.expand("%pname") \
|
2017-11-20 21:03:10 +01:00
|
|
|
local name = rpm.expand("%name") \
|
2017-09-12 16:34:53 +02:00
|
|
|
local python_flavor = rpm.expand("%python_flavor") \
|
|
|
|
-- io.stderr:write("n_arg "..n_arg.."\\n") \
|
|
|
|
if n_arg ~= "" then \
|
|
|
|
n_arg=n_arg:gsub("^(%w+)python%-(.*)","%1"..python_flavor.."-%2") \
|
|
|
|
-- io.stderr:write("n_arg modfied "..n_arg .."\\n") \
|
|
|
|
end \
|
|
|
|
local n_pname = pname:gsub("^python", python_flavor,1) \
|
2017-11-20 21:03:10 +01:00
|
|
|
local n_name = name:gsub("^python", python_flavor,1) \
|
2017-09-12 16:34:53 +02:00
|
|
|
rpm.define("pname "..n_pname) \
|
2017-11-20 21:03:10 +01:00
|
|
|
rpm.define("name "..n_name) \
|
2017-09-12 16:34:53 +02:00
|
|
|
add_args (g_arg, "-g") \
|
|
|
|
add_args (n_arg, "-n") \
|
|
|
|
add_args (l_arg) \
|
|
|
|
add_args (L_arg) \
|
|
|
|
add_args (a_arg) \
|
|
|
|
add_args (other_arg) \
|
|
|
|
-- io.stderr:write("pname "..rpm.expand("%pname").."\\n") \
|
|
|
|
-- io.stderr:write(rpm.expand("%{hpc_master_package " .. arg_list .."}").."\\n") \
|
|
|
|
-- io.stderr:write(rpm.expand("%{hpc_master_package " .. arg_list .." -q}"):gsub("%s","").."\\n") \
|
|
|
|
local package = rpm.expand("%{hpc_master_package " .. arg_list .." -q}"):gsub("%s","") \
|
|
|
|
if package ~= "" then \
|
|
|
|
-- check if we have seen this package before. Since we will not have an empty files section \
|
|
|
|
-- skip it entirely! \
|
|
|
|
if _hpc_python_package_list[package] == true then \
|
|
|
|
rpm.define("pname " .. pname) \
|
2017-11-20 21:03:10 +01:00
|
|
|
rpm.define("name " .. name) \
|
2017-09-12 16:34:53 +02:00
|
|
|
return \
|
|
|
|
else \
|
|
|
|
_hpc_python_package_list[package] = true \
|
|
|
|
end \
|
|
|
|
end \
|
|
|
|
-- io.stderr:write(">>> "..package.."\\n") \
|
|
|
|
io.stderr:write("pname "..rpm.expand("%pname").."\\n") \
|
|
|
|
io.stderr:write("%{hpc_master_package " .. arg_list .. "}\\n\\n") \
|
|
|
|
print(rpm.expand("%{hpc_master_package " .. arg_list .. "}") .."\\n") \
|
|
|
|
rpm.define("pname " .. pname) \
|
2017-11-20 21:03:10 +01:00
|
|
|
rpm.define("name " .. name) \
|
2017-09-12 16:34:53 +02:00
|
|
|
-- io.stderr:write("pname "..rpm.expand("%pname").."\\n\\n") \
|
|
|
|
}
|
|
|
|
|
2018-03-04 12:15:02 +01:00
|
|
|
# %hpc_shebang_sanitize_scripts <dir>
|
|
|
|
#
|
|
|
|
# find all scripts in and below <dir> and sanitize any #!/usr/bin/env ..
|
|
|
|
%hpc_shebang_sanitize_scripts() \
|
|
|
|
for file in $(find %{1} -type f); do \
|
|
|
|
line=$(head -1 $file) \
|
|
|
|
if [[ $line =~ \\#\\!.*bin/env ]]; then \
|
|
|
|
newline="" \
|
|
|
|
case $line in \
|
|
|
|
*python3) newline='#! /usr/bin/python3' ;; \
|
|
|
|
%{!?_hpc_python3: \
|
|
|
|
*python2) newline='#! /usr/bin/python2' ;; \
|
|
|
|
*python1*) %{hpc_verify_python3 $file} && \
|
|
|
|
newline='#! /usr/bin/python3' || : ;; \
|
|
|
|
*python) newline='#! /usr/bin/python' ;; } \
|
|
|
|
%{?_hpc_python3: \
|
|
|
|
*python2|*python1*|*python) \
|
|
|
|
%{hpc_verify_python3 $file} && \
|
|
|
|
newline='#! /usr/bin/python3' || : ;; }\
|
|
|
|
*perl) newline='#! /usr/bin/perl' ;; \
|
|
|
|
*bash) newline='#! /bin/bash' ;; \
|
|
|
|
*tcsh) newline='#! /usr/bin/bash' ;; \
|
|
|
|
*csh) newline='#! /usr/bin/csh' ;; \
|
|
|
|
*ksh) newline='#! /usr/bin/ksh' ;; \
|
|
|
|
*) echo "hpc_cleanup_scripts: \"$line\" found - leaving untouched" >&2 ;;\
|
|
|
|
esac; \
|
|
|
|
[ -n "$newline" ] && sed -i "1s,^.*,${newline}\\n," $file \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
# %hpc_shebang_remove <file>
|
|
|
|
#
|
|
|
|
# remove any leading shebang (#!..) lines from <file>
|
|
|
|
%hpc_shebang_remove() \
|
|
|
|
while true; do \
|
|
|
|
line=$(head -1 %{1}) \
|
|
|
|
if [[ $line =~ \\#\\!.* ]]; then \
|
|
|
|
sed -i "1d" %{1}; \
|
|
|
|
else \
|
|
|
|
break \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
# %hpc_shebang_prepend_list [ -n <ext> ] <filelist>
|
|
|
|
#
|
|
|
|
# prenpend a matching shebang, unless explicitely specified
|
|
|
|
# using the -n <ext> option, it is determined by the file
|
|
|
|
# 'extend'. Known types are: sh, csh, pl, py, awl, lua
|
|
|
|
# the execute bit are also set.
|
|
|
|
%hpc_shebang_prepend_list(n:) \
|
|
|
|
unset _hpc_engine \
|
|
|
|
%{-n:_hpc_shebang=%{-n*}} \
|
|
|
|
_hpc_files="%{*}" \
|
|
|
|
for file in $_hpc_files; do \
|
|
|
|
[ -n "$_hpc_engine" ] || _hpc_engine=${file##*.} \
|
|
|
|
if [ -n "$_hpc_engine" ]; then \
|
|
|
|
unset _hpc_newline \
|
|
|
|
case "$_hpc_engine" in \
|
|
|
|
sh) _hpc_newline='#! /bin/bash';; \
|
|
|
|
csh) _hpc_newline='#! /usr/bin/csh';; \
|
|
|
|
pl) _hpc_newline='#! /usr/bin/perl' ;; \
|
|
|
|
py) _hpc_newline='#! /usr/bin/python%{?_hpc_python3:3}' ;; \
|
|
|
|
awk) _hpc_newline='#! /usr/bin/awk -f' ;; \
|
|
|
|
lua) _hpc_newline='#! /usr/bin/lua' ;; \
|
|
|
|
*) echo "Unknown file type $_hpc_engine" ;; \
|
|
|
|
esac \
|
|
|
|
if [ -n "$_hpc_newline" ]; then \
|
|
|
|
line=$(head -1 $file) \
|
|
|
|
if [[ $line =~ \\#\\!.* ]]; then \
|
|
|
|
true \
|
|
|
|
else \
|
2018-03-12 20:23:13 +01:00
|
|
|
sed -i -e "1s;^;$_hpc_newline\\n;" $file; \
|
2018-03-04 12:15:02 +01:00
|
|
|
fi \
|
|
|
|
chmod a+x $file \
|
|
|
|
fi \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
# %hpc_python_mv_to_sitearch <file>
|
|
|
|
#
|
|
|
|
# move <file> to python sitearch, remove shebang lines and
|
|
|
|
# remove any excecute permissions.
|
|
|
|
# This should be done on any python files that do not contain
|
|
|
|
# any executable code.
|
|
|
|
%hpc_python_mv_to_sitearch() \
|
|
|
|
_hpc_pydir=%hpc_python_sitearch_no_singlespec \
|
|
|
|
_hpc_base=$(basename %{1}) \
|
|
|
|
[ -d %{buildroot}/$_hpc_pydir ] || mkdir -p %{buildroot}/$_hpc_pydir \
|
|
|
|
mv %{buildroot}%{1} %{buildroot}/$_hpc_pydir \
|
|
|
|
chmod a-x %{buildroot}/$_hpc_pydir/$_hpc_base \
|
|
|
|
%{hpc_shebang_remove %{buildroot}/$_hpc_pydir/$_hpc_base}
|
|
|
|
|
|
|
|
# %hpc_verify_python3 <file>
|
|
|
|
#
|
|
|
|
# verify that code in <file> is valid python 3
|
|
|
|
%hpc_verify_python3() \
|
|
|
|
/usr/bin/python3 -c "import sys, ast\
|
|
|
|
file=sys.argv[1]\
|
|
|
|
try:\
|
|
|
|
ast.parse(open(file).read()) or sys.exit(1)\
|
|
|
|
except SyntaxError:\
|
|
|
|
sys.exit(1) \
|
|
|
|
sys.exit(0)" %{1}
|
|
|
|
|
2017-09-12 16:34:53 +02:00
|
|
|
#
|
|
|
|
# man pages
|
|
|
|
#
|
2017-10-04 13:09:55 +02:00
|
|
|
# %{hpc_compress_man <num>} compress man page in %hpc_mandir/man<num>
|
2017-09-12 16:34:53 +02:00
|
|
|
%hpc_compress_man() \
|
|
|
|
[ -n "%{*}" ] || { echo "no man page list!" >&2 ; exit 1; } \
|
|
|
|
for j in %{*}; do \
|
|
|
|
for i in $(ls %{buildroot}%hpc_mandir/man${j}/*.${j}* | grep -v ".*\.gz$"); \
|
|
|
|
do \
|
|
|
|
test -L $i && continue \
|
|
|
|
gzip $i \
|
|
|
|
done; \
|
|
|
|
done
|
|
|
|
|