Skip to content

Commit

Permalink
Fix the %_smp_mflags macro so it works in both TW and SLE16
Browse files Browse the repository at this point in the history
Unfortunately SLE16 uses old rpm version 4.18 which does not
support %{getncpus:proc} (added in 4.19).

We need to compute the value manually. :-/
  • Loading branch information
lslezak committed Jan 24, 2025
1 parent f21c18d commit b5402e5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rust/package/agama.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

# Require at least 1.3GB RAM per each parallel job (the size is in MB)
%global _smp_tasksize_proc 1300

# Redefine the _smp_mflags macro so it takes the amount of RAM into account
#
# Unfortunately SLE16 contains older rpm v4.18 so we need to calculate that manually :-/
# TODO: use this instead when rpm in SLE16 is updated to a newer version (4.19+):
# %%define _smp_mflags "-j%%{getncpus:proc}"
%define _smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
&& RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
ram_kb="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"; \\\
ncpus_max=$(("$ram_kb"/1024/%_smp_tasksize_proc)); \\\
if [ -n "$ncpus_max" ] && [ "$ncpus_max" -gt 0 ] && [ "$RPM_BUILD_NCPUS" -gt "$ncpus_max" ]; then RPM_BUILD_NCPUS="$ncpus_max"; fi; \\\
if [ "$RPM_BUILD_NCPUS" -gt 1 ]; then echo "-j$RPM_BUILD_NCPUS"; fi)

Name: agama
# This will be set by osc services, that will run after this.
Version: 0
Expand Down

0 comments on commit b5402e5

Please sign in to comment.