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

2

5

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.

Spontoon answered 15/3, 2019 at 10:10 Comment(0)
L
6

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 :) )

Leslie answered 15/3, 2019 at 10:43 Comment(0)
T
5

%__install is a macro.

If you want to get value of a macro, then use 'rpm --eval':

$ rpm --eval '%__install'
/usr/bin/install
$ rpm --eval '%{__install} -s %{name} %{buildroot}%{_sbindir}/'
/usr/bin/install -s %{name} /home/msuchy/rpmbuild/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr/sbin/

In the second example, you can see that %{name} was not expanded, because that is not a system macro, but it is defined in the spec file by the Name tag.

Additionally, rpm --showrc shows you a list of system macros defined on your system. It shows the definition - not expanded macros.

Theme answered 15/3, 2019 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.