Search code examples
linuxrpmrpmbuildrpm-spec

What does "%{__install}" mean in terms of rpm spec?


Maybe it's very stupid question but I can't find out the answer. I've neverr tried to write a spec file for rpm package until today. I found an example of spec and I see a lot of %{__install} thinks in the %install section. As far as I understand by the syntax it's a king of makros. But there is no defenition for it in the spec files. In my example it looks like this:

%install
%{__install} -pD -m 644 $RPM_BUILD_DIR/my-project-%{version}/deploy/my-project.service $RPM_BUILD_ROOT/usr/lib/systemd/system/my_project-emperor.service

I also seen a lot of examples with this macros in other spec-s I've found. Like this or that. They have the same syntax:

%{__install} -s %{name} %{buildroot}%{_sbindir}/
%{__install} -c -m 644 examples/acl-content-sw.cfg %{buildroot}%{_sysconfdir}/%{name}/%{name}-acl-content-sw.cfg.example
%{__install} -c -m 644 examples/auth.cfg %{buildroot}%{_sysconfdir}/%{name}/%{name}-auth.cfg.example

But what %{__install} actually is? Some kind of built-in macros for rpm builder? It's hard to google it or find it in the official docs, but it looks like it's a some kind of common thing.


Solution

  • Unfortunately there is no magical answer. Rpm macros can be redefined differently on different OS and can even be redefined afterwards by other packages.

    Default definitions can be found in /usr/lib/rpm/macros, but other packages can install more macros in /usr/lib/rpm/macros.d/.

    in my /usr/lib/rpm/macros if found this definition:

    %__install              /usr/bin/install
    

    so in this case the macro %__install doesn't really add anything.

    But I find the %make_install macro rather handy; which is defined as:

    %make_install %{__make} install DESTDIR=%{?buildroot} INSTALL="%{__install} -p"
    

    so instead of putting

    make install DESTDIR=%{?buildroot}
    

    I can just put

    %make_install
    

    in my spec file... (and while explaining this; I just got to know the -p option of install :) )