rpmrpmbuildrpm-spec

Can I invoke functions from an rpm.spec that were declared in dependent RPMs?


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
}

Solution

  • 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.