I've put some common utility scripts into common.sh
, which I want to use in my RPM specfile during %pre
. common.sh
is located in the root of the RPM package.
What I was planning to do is simply call something like source common.sh
, but how can I access common.sh
from the RPM during %pre
?
I was able to solve this using RPM macros, the following way:
Before doing
rpmbuild
I have putcommon.spec
into theSPECS
folder.common.spec
I've added
%include SPECS/common.spec
as the first line of my actual spec file.Usage example
Multi-line macros
Pretty fragile syntactically imo, but you can put line breaks into your macros using
\
. That will tell the RPM builder that it should continue parsing the macro. Given the previous macro as an example:This way the code will be still parsed back into a single line, hence the
;
on the first and second line.