我可以从依赖 RPM 中声明的 rpm.spec 调用函数吗?

问题描述 投票:0回答:2

假设我有一个

rpm.spec
脚本,可以构建
MyRPM.rpm
包:

-- MyRPM.rpm 的 rpm.spec

%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

那里的

Requires
参数应该会触发
That-Other-RPM
的安装过程。假设
doSomething
函数在
That-Other-RPM
中声明,我可以从 MyRPM 的
rpm.spec
调用它吗,因为它会触发另一个函数?

-- That-Other-RPM.rpm 的 rpm.spec

%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
}
rpm rpmbuild rpm-spec
2个回答
4
投票

不,你不能。

规范文件部分中的函数仅在定义它们的脚本中可用。

您的 RPM 和其他 RPM 之间没有共享 shell 会话。


0
投票

这并不完全是问题的解决方案,但它解决了如何在多个

%post
%postun
scriptlet 在同一规范文件中使用函数的问题: 诀窍是将函数定义为宏(是的,它很丑!):

%define FOO \ foo()\ {\ echo blabla\ echo soso\ } #... %post %FOO foo # ... %postun %FOO foo # ...
因此 

%FOO

 定义了该函数,并且 
foo
 调用它。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.