问题描述
我想使用rpm为不同的环境(实时,测试,开发人员)但为相同文件构建子软件包,因此有一个名为name-config-live的软件包,一个名为name-config-testing的软件包和一个名为name-config-developer并在其中具有相同的路径,但每个路径都具有与它所命名的环境相对应的配置.例如
假设在所有环境中我都有一个名为/etc/name.conf的文件,在测试中我希望该文件包含"1",在开发中"2"并在活动"3"中.是否可以在同一规范中执行此操作,因为子包的生成只发生在最后,而不是按我输入的顺序进行. (希望不是%post -n)我尝试使用BuildRoot,但这似乎是全局属性
我不认为这是一种本机方法.我会像您提到的那样执行%post
.
但是,我会这样做(类似于我为工作而开发的内部专用软件包所做的事情):
- 三个独立的文件
/etc/name.conf-developer
,/etc/name.conf-live
等 - 是否所有三个软件包都提供了一个虚拟软件包,例如
name-config
- 主程序包需要
name-config
- 这将使
rpm
,yum
或需要在同一事务中至少安装一个的任何东西
- 这将使
- 三个软件包都相互冲突
- 具有每个配置包的
%post
(可能还有%verify
)符号链接/etc/name.conf
到正确的配置- 这也有助于向用户显示正在发生的事情
缺点:
- 有点黑
-
rpm --whatprovides /etc/name.conf
会说它不属于任何软件包
I would like to use a rpm to build subpackages for different environments (live,testing,developer) but for the same files, so having a package called name-config-live, one called name-config-testing and one called name-config-developer and in them to have the same paths but each with the configs corresponding to the environment it's named after.as an example
let's say on all environments I have a file called /etc/name.conf and on testing I want it to contain "1", on development "2" and on live "3". Is it possible to do this in the same spec since the subpackage generation only happens last not in the order I enter it. ( and hopefully not with %post -n )
I tried using BuildRoot but it seems that's a global attribute
I don't think there's a native way; I would do a %post
like you had noted.
However, I would do this (similar to something I do with an internal-only package I develop for work):
- Three separate files
/etc/name.conf-developer
,/etc/name.conf-live
, etc. - Have all three packages provide a virtual package, e.g.
name-config
- Have main package require
name-config
- This will make
rpm
,yum
, or whatever require at least one be installed in the same transaction
- This will make
- Have all three packages conflict with each other
- Have each config package's
%post
(and possibly%verify
) symlink/etc/name.conf
to the proper config- This also helps show the user what is happening
Cons:
- It's a little hackish
rpm --whatprovides /etc/name.conf
will say it is not owned by any package
这篇关于如何为不同的环境使用相同的路径创建RPM子包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!