1
votes

I would like to get some help regarding spec file and specifically the %pre section.

What I would like to do is, in the %pre section I want to be able to refer and use to a .sh file.

I got this idea from the following link rpmbuild: using script files contained in the package in %pre script

In the link above keep the focus on the fact that in the preamble section of the spec file, a source .sh file is declared.

Source0:xyz.sh .... ....

The %pre section then uses the xyz.sh file

%pre -f xyz.sh

I tried the above approach but I am not able to get this to work.

So the question

where to place the script, in this example xyz.sh

and how does it become available to the %pre section since the %pre is called even before any files that are a part of the rpm is copied to the target machine.

1
Can't you just put your script directly in the %pre? Why do you need it as seperated sh file? - Eran Ben-Natan

1 Answers

2
votes

You should probably just put the contents directly in the proper spec file section, but you can also:

Install it onto the system, then call it in the post-install script, or

Reference it from within the spec file, like:

Source1: xyz.sh

...

%{SOURCE01}

or

%{_sourcedir}/xyz.sh