I have spent around 3 hrs now. How to override a macro during rpm build ? I want to override _sbindir (/usr/sbin) to /opt/sbin I have edited rpm macro files both system and local user files nothing seems to be working for me. I'm using Fedora 12.

2 Answers 2


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

%define _sbindir /foo

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.

  • I have RPM version 4.0.4 and it doesn't show the line with "wtf" (Output doesn't change at all)
    – IC_
    Oct 7, 2020 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .