Search code examples
makefileredhatfedorarpm

%config(noreplace) errors out if there are no files in destination


I was compiling Fedora's kernel 6.4.9 and it errored out at this line:
%config(noreplace) /etc/modprobe.d/*-blacklist.conf\ saying "File not found."
When I remove this line the compilation proceeds fine. The compilation was fine also when there were files in that folder in the BUILDROOT.
Is there a way to handle this exception?


Solution

  • That line from the %files section of the RPM spec assumes that following the completion of the %install script, there there will indeed be at least one one file matching the glob formed by RPM macro expansion of %{buildroot}/etc/modprobe.d/*-blacklist.conf. If there isn't, rpm building will fail (though the actual kernel build will have already succeeded for that point even to be reached). It's unclear to me why that expectation is not being satisfied, but I presume that it has something to do with whatever changes you made to the spec.

    Is there a way to handle this exception?

    Handle, no. Avoid, yes.

    If you are trying to build a kernel RPM that will not include any modprobe blacklists then remove the glob in question, or comment it out. In this case, do note that the trailing \ on that line in the question is probably a line-continuation character, so you're making a bigger change than you think if you remove the whole line.

    If you are trying to build a kernel RPM that will include modprobe blacklists, then figure out why they are not being produced, and fix that.

    You should not need to guess which of those situations applies -- at least not from one attempt to the next to build the same rpm -- because rpm builds are reproducible. For greatest reproducibility, however, consider installing the "mock" utility and using it to perform your builds (and do not confuse this "mock" with any of the several API-mocking frameworks aimed at unit testing).

    If you want to go deeper then the RPM spec language contains conditional directives and limited support (rpmbuild) command-line options, and beyond that, fully-programmable macros. But I don't think you need to get into any of that.