Add macros.build-constraints

Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
i10ce
Michel Alexandre Salim 4 years ago
parent 05b5b0ae2c
commit f44829e9fc

@ -1,6 +1,6 @@
Name: epel-rpm-macros
Version: 8
Release: 22
Release: 23
Summary: Extra Packages for Enterprise Linux RPM macros
Group: System Environment/Base
@ -15,6 +15,8 @@ Source1: macros.zzz-epel-override
Source2: gpgverify
Source3: pythondist.attr
Source9: GPL
# misc macros
Source150: macros.build-constraints
BuildArch: noarch
Requires: redhat-release >= %{version}
@ -55,6 +57,10 @@ install -Dpm 755 %{SOURCE2} \
install -Dpm 644 %{SOURCE3} \
%{buildroot}%{_fileattrsdir}/pythondist.attr
# misc macros
install -Dpm 644 %{SOURCE150} \
%{buildroot}/usr/lib/rpm/macros.d/macros.build-constraints
%files
%license GPL
@ -62,9 +68,14 @@ install -Dpm 644 %{SOURCE3} \
/etc/rpm/macros.zzz-epel-override
%{_rpmconfigdir}/gpgverify
%{_fileattrsdir}/pythondist.attr
# misc macros
/usr/lib/rpm/macros.d/macros.build-constraints
%changelog
* Sat Jul 24 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 8-23
- Add macros.build-constraints
* Wed Jul 14 2021 Miro Hrončok <mhroncok@redhat.com> - 8-22
- Introduce %%py3_check_import

@ -0,0 +1,10 @@
# Macros to constrain resource use during the build process
# m: memory limit in MBs per core; default is 1024
%limit_build(m:) \
_mem_per_process="%{-m:%{-m*}}%{!-m:1024}" \
_max_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) \
_max_jobs="$(($_max_mem / ($_mem_per_process * 1024)))" \
_cur_max_jobs="%{_smp_build_ncpus}" \
test "${_cur_max_jobs}" -gt "${_max_jobs}" && _cur_max_jobs="${_max_jobs}" && echo "Warning: Reducing build parallelism to -j${_max_jobs} because of memory limits" \
%global _smp_build_ncpus "${_cur_max_jobs}"
Loading…
Cancel
Save