gpt4 book ai didi

rpmbuild - 如果 SPEC 文件的 %Files 部分中的条件

转载 作者:行者123 更新时间:2023-12-04 18:09:22 25 4
gpt4 key购买 nike

我是编写规范文件和构建 RPM 的新手。目前我有一个 RPM,它应该在 2 个可能的目录之一中部署一些文件,这些目录将随操作系统而变化。

我如何在 %files 部分验证它们?我不能使用变量......我无法验证两个路径,因为一个肯定会失败......我试图在 %install 部分之前定义一个宏,但它只会被定义一次,不会被重新定义在每个 RPM 安装...

我能在这里做什么?

谢谢

最佳答案

我遇到过类似的情况,即在除 RELEASE 构建中的所有文件之外进行调试构建的情况下,RPM 中还包含其他文件。

诀窍是将文件列表传递给 %files 以及它下面的常规文件列表:

%install
# Create a temporary file containing the list of files
EXTRA_FILES=$RPM_BUILD_ROOT/ExtraFiles.list
touch %{EXTRA_FILES}

# If building in DEBUG mode, then include additional test binaries in the package
%if %{build_mode} == "DEBUG"
# %{build_mode} is a variable that is passed to the spec file when invoked by the build script
# Like: rpmbuild --define "build_mode DEBUG"
echo path/to/file1 > %{EXTRA_FILES}
echo path/to/file2 >> %{EXTRA_FILES}
%endif

%files -f %{EXTRA_FILES}
path/to/release/file1
path/to/release/file2

在您的情况下,您可以利用 %install 部分中的 %if 条件,将操作系统用作传递给 rpmbuild 的规范变量。 (或在 RPM 规范本身中检测它)然后将包含列表的文件传递给 %files

关于rpmbuild - 如果 SPEC 文件的 %Files 部分中的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18701771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com