Tomáš Chvátal 2018-04-06 12:33:52 +00:00 committed by Git OBS Bridge
parent 7de55a45c4
commit 48dda7c9ae
2 changed files with 4 additions and 3 deletions

View File

@ -5,10 +5,10 @@
# rather than just giving you OOM # rather than just giving you OOM
# #
# m: memory limit in Bs per core; default is 1000000 # m: memory limit in MBs per core; default is 1000
%limit_build(m:) \ %limit_build(m:) \
_threads="`/usr/bin/getconf _NPROCESSORS_ONLN`" \ _threads="`/usr/bin/getconf _NPROCESSORS_ONLN`" \
_core_memory="%{-m:%{-m*}}%{!-m:1000000}" \ _core_memory="%{-m:%{-m*}}%{!-m:1000}" \
echo "Available memory:" \ echo "Available memory:" \
cat /proc/meminfo \ cat /proc/meminfo \
echo "System limits:" \ echo "System limits:" \
@ -17,7 +17,7 @@
if test "$_threads" -gt 1 ; then \ if test "$_threads" -gt 1 ; then \
mem_per_process="$_core_memory" \ mem_per_process="$_core_memory" \
max_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) \ max_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) \
max_jobs="$(($max_mem / $mem_per_process))" \ max_jobs="$(($max_mem / ($mem_per_process * 1000)))" \
test "$_threads" -gt "$max_jobs" && $_threads="$max_jobs" && echo "Warning: Reducing number of jobs to $max_jobs because of memory limits" \ test "$_threads" -gt "$max_jobs" && $_threads="$max_jobs" && echo "Warning: Reducing number of jobs to $max_jobs because of memory limits" \
test "$_threads" -le 0 && $_threads=1 && echo "Warning: Do not use the parallel build at all becuse of memory limits" \ test "$_threads" -le 0 && $_threads=1 && echo "Warning: Do not use the parallel build at all becuse of memory limits" \
fi \ fi \

View File

@ -26,6 +26,7 @@ URL: https://www.opensuse.org/
Source0: %{name}.macros Source0: %{name}.macros
BuildRequires: rpm BuildRequires: rpm
Requires: awk Requires: awk
Requires: coreutils
BuildArch: noarch BuildArch: noarch
%description %description