Reputation: 1856
Let's say I have an rpm.spec
script that builds a MyRPM.rpm
package:
-- rpm.spec for MyRPM.rpm
%define logdir %{my_dir}/logs/%{name}
Summary: bla bla bla
Name: MyRPM
Version: @@@version@@@
Release: @@@revision@@@
License: bla
Group: Applications/System
Requires: That-Other-RPM
%description
This is my RPM
%prep
%build
%install
doSomething //invoking a function
The Requires
parameter there should trigger the install process of That-Other-RPM
. Assuming that the doSomething
function was declared in That-Other-RPM
, can I invoke it from MyRPM's rpm.spec
since it triggers the other one?
-- rpm.spec for That-Other-RPM.rpm
%define logdir %{my_dir}/logs/%{name}
Summary: bla bla bla
Name: That-Other-RPM
Version: @@@version@@@
Release: @@@revision@@@
License: bla
Group: Applications/System
%description
This is that other RPM
%prep
%build
%install
function doSomething {
//doing something here
}
Upvotes: 2
Views: 1181
Reputation: 4325
It's not exactly a solution for the question, but it solves the problem how a function can be used from multiple %post
or %postun
scriptlets within the same spec file:
The trick is to define the function as a macro (yes, it's ugly!):
%define FOO \
foo()\
{\
echo blabla\
echo soso\
}
#...
%post
%FOO
foo
# ...
%postun
%FOO
foo
# ...
So %FOO
defines the function, and foo
calls it.
Upvotes: 0
Reputation: 80921
No, you can't.
functions in spec files sections like that are only available in the scriptlet in which they are defined.
There is no shared shell session between your RPM and the other RPM.
Upvotes: 4