Skip to content

Commit

Permalink
Fix the %_smp_mflags macro so it works in both TW and SLE16 (#1943)
Browse files Browse the repository at this point in the history
## Problem
- Related to #1939
- 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. :-/

## Details

- I wanted to use some `%if` and use the new option in TW. However the
macro exists in both but in SLE16 it complains about extra argument
which is not accepted. And rpm evaluates macros in both `%if`
branches... 😟
- So I basically reverted to my original implementation
  • Loading branch information
lslezak authored Jan 24, 2025
2 parents f21c18d + b5402e5 commit eeaf9bf
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 eeaf9bf

Please sign in to comment.