Opened 8 years ago

Closed 7 years ago

#201 closed defect (fixed)

rpmbuild

Reported by: Silvan Scherrer Owned by:
Priority: minor Milestone:
Component: rpm Version:
Severity: low Keywords:
Cc:

Description

The below sequence is executed as in the macros to see how many CPU's are available. But as we don't have getconf, RPM_BUILD_NCPUS is uninitialized. This leads to warnings and errors in the log.
As we don't have getconf, I vote for initializing the value with 1

# Maximum number of CPU's to use when building, 0 for unlimited.
#%_smp_ncpus_max 0
%_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
	&& RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
        ncpus_max=%{?_smp_ncpus_max}; \\\
        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)

Change History (5)

comment:1 Changed 8 years ago by Yuri Dario

I simply set it in %HOME%\.rpmmacros

%_topdir f:/temp/build
%_smp_mflags -j4

comment:2 Changed 8 years ago by dmik

Sure, that should also work but we at least should not interfere the rpmbuild process when this is not set. This popped up because of switching to dash which is more strict about numeric comparisons than ash and barfs on things like [ "" -gt 0 ] (ash eats this and returns false in such cases).

A fix is to replace

%_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
	&& RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\

with

%_smp_mflags %([ -z "$RPM_BUILD_NCPUS" -a -x /@unixroot/usr/bin/getconf ] \\\
	&& RPM_BUILD_NCPUS="`/@unixroot/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
	[ -z "$RPM_BUILD_NCPUS" ] && RPM_BUILD_NCPUS=1; \\\

This way, it will return 1 for now and once we have getconf that supports _NPROCESSORS_ONLN, it will return the proper value.

comment:3 Changed 7 years ago by Silvan Scherrer

we should take care on that in the next rpm update, as it really annoys me :)

comment:4 Changed 7 years ago by Yuri Dario

rpm: replace $RPM_BUILD_NCPUS macro with a better version. fixes ticket#201.
Committed revision r951.

comment:5 Changed 7 years ago by Silvan Scherrer

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.