Reputation: 1839
Why does %files
needed and why it cannot be created automatically by listing $RPM_BUILD_ROOT
directory contents?
For example, in that spec file i have to use some modifications in it in script, that build an RPM package for me. I have to cd
into ~/RPM/SOURCES
, then find .
in it and echo
each line into .spec
file to setup %files
section. It can be done automatically by the tool using the same techniuque i do in the background but from $RPM_BUILD_ROOT
directory instead?
%install
mkdir -p $RPM_BUILD_ROOT/opt/MyCompany/MyProduct/
cp -rf -- ~/RPM/SOURCES/* $RPM_BUILD_ROOT/opt/MyCompany/MyProduct/
%files
/opt/MyCompany/MyProduct/file_1
/opt/MyCompany/MyProduct/file_2
/opt/MyCompany/MyProduct/file_3
... - a lot of lines here
/opt/MyCompany/MyProduct/file_100000
UPD:
Yes it is possible to use all copied files automatically (Doc http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html)
In my case %files
can be rewritten as that
%files
/opt/MyCompany/MyProduct/*
It will take files from $RPM_BUILD_ROOT/opt/MyCompany/MyProduct
, so to use star we need to omit build root which is $RPM_BUILD_ROOT
or %{buildroot}
(Which is default path where rpm searches for files IIUC)
Upvotes: 0
Views: 2381
Reputation: 56
Why does %files needed and why it cannot be created automatically by listing $RPM_BUILD_ROOT directory contents?
It is common that one spec file build creates multiple (sub)packages - then also multiple %files sections are needed.
Even though there exist some automatic %files section generators, nb there's the %files -f option, in general it isn't possible to split the files automatically.
Worth saying that most of the package maintainers don't maintain the software
source code, but just package the "upstream" releases. If the %files sections
are rather manually maintained (in contrast with the wildcard patterns), the
package maintainer has everything a bit more under control because he is
notified about the changes in the software installation layout (e.g. when a new
file appears in /usr/bin
with a new release, rpmbuild starts complaining that
there's a new "unpackaged" file, see below).
It can be done automatically by the tool using the same techniuque i do in the background but from $RPM_BUILD_ROOT directory instead?
You don't even have to run find
manually. As long as %install creates the
files in $RPM_BUILD_ROOT, if you don't mention them in %files - you get reports
like those:
$ rpmbuild -bb *.spec
...
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/user/rpmbuild/BUILDROOT/test-1-1.x86_64
error: Installed (but unpackaged) file(s) found:
/usr/bin/not-packaged
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/bin/not-packaged
Upvotes: 2