forked from pool/suse-hpc
Egbert Eich
7ec2537086
- Fix master package macro to handle sub-packages with a different basename correctly. OBS-URL: https://build.opensuse.org/request/show/535288 OBS-URL: https://build.opensuse.org/package/show/science:HPC/suse-hpc?expand=0&rev=11
517 lines
20 KiB
Plaintext
517 lines
20 KiB
Plaintext
# 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}/
|
|
%hpc_cf_install_path %{hpc_cf_install_path_base}%{hpc_cf_full_version}
|
|
|
|
# For mpi libraries
|
|
%hpc_mpi_install_base %{hpc_base}%{?hpc_cf_dir}mpi/
|
|
%hpc_mpi_install_path_base %{hpc_mpi_install_base}%{hpc_mpi_family}%{?hpc_ext}/
|
|
%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 \
|
|
Description: %summary \
|
|
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
|
|
%hpc_requires %{?hpc_compiler_family:%{!?_hpc_build_compiler:%hpc_cf_requires}}\
|
|
%{?hpc_mpi_family:%{!?_hpc_build_mpi:%hpc_mpi_requires}}
|
|
|
|
# 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}} \
|
|
} \
|
|
# Preexpanded macros \
|
|
%{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 \
|
|
# 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 \
|
|
%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
|
|
%_hpc_module_base %{?!compiler_family:%{lua_lmod_modulesdir}}%{?compiler_family:%{?_hpc_build_compiler:%{lua_lmod_modulesdir}}%{!?_hpc_build_compiler:%{lua_lmod_moduledeps}}/}
|
|
%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.
|
|
# %hpc_master_package [-n <full_package_name>][-g <group>][-s# <.so-version>][-l][-L][-N <pname>][-q] <package_ext>
|
|
# -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.
|
|
# -N <pname>: Specify if a sub-package has different basename (pname)
|
|
# -q: For internal use only!
|
|
#
|
|
%hpc_master_package(n:g:s:lLaqN:) \
|
|
%define _mylib %{-s:lib}%{!-s:%{-l:lib}} \
|
|
%define _p_ext %(test -n "%{*}" && echo -%{*}) \
|
|
%{!-N:\
|
|
%define _pname %{pname} \
|
|
%define _name %{name} \
|
|
} \
|
|
%{-N:\
|
|
%define _pname %{-N*} \
|
|
%define _name %(echo %{name} | sed -e "s/%{pname}/%{_pname}/") \
|
|
} \
|
|
%{-n:%define _lname %{-n*}} \
|
|
%{!-n:\
|
|
%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} \
|
|
}\
|
|
%{-q:%(echo -n %{_lname}; true %{_mylib} %{_p_ext})} \
|
|
%{!-q:\
|
|
%{-g:%define _group %{-g*}} \
|
|
%{!-g: \
|
|
%define _group %(lname=%_lname; \
|
|
case $lname in \
|
|
(*-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)\
|
|
} \
|
|
%{!-s:%define n_name %_name} \
|
|
%{-s:%define n_name %(a=%{_name};echo -n ${a/%{_pname}/%{_pname}%{-s*}})} \
|
|
%package -n %_lname \
|
|
Summary: Dependency package for %{n_name}%{_p_ext} \
|
|
Group: %_group \
|
|
Obsoletes: %_lname < %version \
|
|
%{!-s:Requires: %{_mylib}%{_name}%{_p_ext} = %version} \
|
|
%{-s:Requires: %(echo -n %{_mylib}%{_name}%{_p_ext} | sed -e "s/\\(.*%{_pname}\\)\\(.*\\)/\\\\1%{-s*}\\\\2/") = %version} \
|
|
%{!-l:%{!-s:%{!-a:BuildArch: noarch}}} \
|
|
%description -n %_lname \
|
|
The package %{n_name}%{_p_ext} provides the dependency to get the latest version of %_pname \
|
|
%{-L:%post -n %_lname \
|
|
ln -sf %{hpc_module_dep_base}.version.%{version} %{hpc_module_dep_base}.version} \
|
|
%files -n %{_lname} \
|
|
%defattr(-,root,root)\
|
|
%define _msg '%summary: Provide the dependency to get the latest version of %_pname' \
|
|
%define _readme README.%{_mylib}%{_name}%{_p_ext} \
|
|
%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])
|
|
|
|
##
|
|
# 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'));")
|
|
|
|
# get the python version specific directory for arch specific files in the HPC
|
|
# directory structure.
|
|
%hpc_python_sitearch %{_hpc_python_sysconfig_path %python_flavor platlib %{?hpc_prefix}}
|
|
|
|
%_hpc_python_ver() %(%1 -c "import sys as s;print(s.version[:3]);")
|
|
|
|
# get the (abbreviated_) pythin version used for package and directory names.
|
|
%hpc_python_version %{_hpc_python_ver %python_flavor}
|
|
|
|
# %{hpc_python_master_package [-n <package_name>] [-g <group>] [-l][-L][-a]}
|
|
# -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
|
|
%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") \
|
|
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) \
|
|
rpm.define("pname "..n_pname) \
|
|
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) \
|
|
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) \
|
|
-- io.stderr:write("pname "..rpm.expand("%pname").."\\n\\n") \
|
|
}
|
|
|
|
#
|
|
# man pages
|
|
#
|
|
# %{hpc_compress_man <num>} compress man page in %hpc_mandir/man<num>
|
|
%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
|
|
|