Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use %exclude macro properly in rpmbuild SPEC files?

Consider the following in a SPEC file:

%files
%defattr(-,bubba,users,-)
...
%attr(-,root,users) %{_localstatedir}/foo/
%config %attr(-,root,root) %{_localstatedir}/foo/blah.crap

I want to include all files under foo but also specifically mark blah.crap as a config file (and its permissions may not match foo's). Doing this causes rpmbuild to complain that the file is listed twice.

I tried to add the following between the last two lines above:

%exclude %{_localstatedir}/foo/blah.crap

However, this seems to permanently override any other inclusion, because, despite the fact that the next %config line ought to include the file (now as a config file), blah.crap does not get installed when I install the RPM.

So what's the right way to do this? Just ignoring the warning from rpmbuild is a BS answer, as is "just make a list of all files in foo instead of listing the whole directory".

like image 832
Display Name Avatar asked Nov 17 '25 23:11

Display Name


1 Answers

The best solution is to create a file manifest using find(1) in %install and used sed(1) to add %config or otherwise filter the manifest to taste.

like image 95
Jeff Johnson Avatar answered Nov 19 '25 12:11

Jeff Johnson