how to override rpm macro

Solution 1:

Don't try and override _foo macros. But if you really must, add this to the top of your specfile.

%define _sbindir /foo

Solution 2:

Have you tried defining it from the rpmbuild command-line? The --showrc switch shows you the "level" at which various macros are defined. There is a hierarchy in case something is defined in more than one place, where -8 (command-line) wins out over -14 (disk, i.e. ~/.rpmmacros file).

$ rpmbuild --showrc | grep ' _sbindir'

-14: _sbindir       %{_exec_prefix}/sbin
%global _sbindir    %{_exec_prefix}/sbin

$ rpmbuild --define "_sbindir /tmp/wtf" --showrc | grep ' _sbindir'

-8: _sbindir        wtf
%global _sbindir    %{_exec_prefix}/sbin

FWIW, on my CentOS-6 host, the %global is defined in the /etc/rpm/macros.scl file.