在安装/升级 RPM 软件包之前,我必须对目标系统执行多次复杂的“健全性”检查。我想将该过程与其他附件文件(例如 SQL 脚本)一起包含在脚本(bash/python/php 或其他)中,这些文件不会与其他文件一起安装,但仅在 pre(安装|升级)。
我应该将 rpmbuild 的这些文件放在哪里,以及如何在 %pre 部分和主脚本内调用/引用它们(路径等)?如何引用随后要安装的数据文件(即 SQL 脚本)?
感谢您的任何帮助。
I have to perform multiple elaborate "sanity" checks on target system before an RPM package installs/upgrades. I want to contain the procedure in a script (bash/python/php or otherwise) alongside other accessory files (such as SQL scripts) which wouldn't be installed with other files but only used during pre(install|upgrade).
Where do I put these files for rpmbuild and how do I call/reference them (paths, etc.) inside %pre section and inside main script? How do I reference then-to-be-installed data files (said SQL scripts)?
Thanks for any help.
发布评论
评论(2)
RPM 没有这个功能。在我看来,您有两个选择:
打包文件,将它们编码为文本格式(例如 uuencode),然后在 %pre 中解码和解压它们。丑陋,但可能。
有一个单独的 RPM(例如 sql-dependencies)来提供这些文件。然后在现有的 RPM 中添加以下内容:
需要(pre):sql-dependency。
RPM doesn't have this functionality. As I see it, you have two options:
Tar up the files, encode them to a text format (e.g. uuencode) and decode and untar them in the %pre. Ugly, but possible.
Have a separate RPM, say sql-dependencies, that provides these files. Then in your existing RPM add the following:
Requires(pre) : sql-dependencies.
如果您将脚本放入自解压存档中,并将其设为 rpm 脚本,则可以实现这一点。这可以通过 Makeself (直接下载链接)。
使用 footest 作为示例名称,运行以下命令:
/path/to/footest
是包含要运行的脚本的目录,./run.sh< /code> 是 footest 目录中的脚本,在提取时运行。
在您的
.spec
文件中,添加footest.sh
作为源,并将其作为脚本:当您查询 rpm 中的脚本时,它将显示以下内容
footest.sh
,这是一个 makeself,后跟要运行的测试套件的 base64 编码。注意:为了使其工作,您必须应用补丁来使自己使用base64编码(当前版本没有此功能),并且rpm不喜欢其二进制数据脚本:
makeself-2.1.5-base64.patch:
This is possible if you put the scripts in a self-extracting archive, and make it the rpm script. This is possible with Makeself (direct link to download).
Using footest as an example name, run this:
The
/path/to/footest
is a directory with your scripts to run, and./run.sh
is the script inside the footest directory, which is ran upon extraction.In your
.spec
file, addfootest.sh
as a source, and put this as the script:When you query your rpm for scripts, it'll show the contents of
footest.sh
, which is a makeself followed by the base64 encoding of your test suite to run.NOTE: in order for this to work, you have to apply a patch to makeself to use the base64 encoding (the current release does not have this feature), and rpm doesn't like binary data in its scripts:
makeself-2.1.5-base64.patch: