如何设置 rpmbuild 每次调用的构建区域
我正在修改自动构建,并希望告诉 rpmbuild 在调用它时使用特定的构建区域。
这类似于现有问题,但更具体。
我不想以 root 用户身份运行任何构建命令;目的只是为了获得 RPM,而不是在系统中安装任何东西。
我不想要求用户更改他们的点文件(例如
$HOME/.rpmrc
);构建应该是独立的,不会影响用户的现有设置。我不想将位置硬编码到
foo.spec
文件中;如果用户想要在不同的位置进行构建,该文件应该可以按原样使用。--buildroot
选项 不是我需要的;为构建过程的make
部分设置伪根文件系统,但我需要为整个 RPM 构建过程指定“构建区域”。
我正在寻找的是一个假设的--build-area FOODIR
选项,它可以提供给rpmbuild
命令,或等效的环境多变的。因此,它应该只影响该命令的单次调用,并使其为其构建区域使用指定的用户可写位置。
我已经看到对 _topdir
宏的引用,这似乎就是我正在谈论的内容,但它似乎无法在每次调用时进行配置。
如果 rpmbuild 可以在需要时在该位置设置自己的环境,那将是理想的,但我不介意为每个构建设置目录,因为这可以作为自动化的一部分构建。目标是让用户可写位置仅在构建运行期间存在,然后在生成 RPM 文件后通过删除整个位置来进行清理。
I'm modifying an automated build, and want to tell rpmbuild
to use a specific build area when invoking it.
This is similar to an existing question, but more specific.
I don't want to run any of the build commands as the root user; the aim is only to have an RPM, not to install anything into the system.
I don't want to require the user to change their dotfiles (e.g.
$HOME/.rpmrc
); the build should be self-contained and not affect the user's existing settings.I don't want to hard-code the location into the
foo.spec
file; that file should be useable as-is if the user wants to build in a different location.The
--buildroot
option is not what I need; that sets a pseudo-root filesystem for themake
part of the build process, but I need to specify the “build area” for the entire RPM build process.
What I'm looking for is a hypothetical --build-area FOODIR
option that can be given to the rpmbuild
command, or an equivalent environment variable. It should thus affect just that single invocation of the command and cause it to use a specified user-writable location for its build area.
I've seen references to a _topdir
macro that seems to be what I'm talking about, but it doesn't appear to be configurable per invocation.
It would be ideal if rpmbuild
could set up its own environment in that location when it needs it, but I don't mind setting up the directories for that per build, since that can be automated as part of the build. The goal is to have that user-writable location exist only for the duration of the build run, and then clean up by deleting that entire location once the RPM file is generated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然没有记录,但
_topdir
宏决定了构建区域。因此,您可以使用 rpmbuild --define "_topdir ${PWD}/foobar" ... 设置此每次调用,将目录设置为您想要的任何目录。
--define
是为任何宏设置值的关键,而不仅仅是 _topdir。It's not documented, but the
_topdir
macro determines the build area.So you can set this per-invocation with
rpmbuild --define "_topdir ${PWD}/foobar" ...
to set the directory to whatever you want.--define
is the key to setting values for any macro, not just _topdir.--buildroot 选项不是您正在寻找的。这个名称有点误导,因为它没有更改构建根目录,而是为构建的安装阶段设置根目录。 RPM 基本上是在构建过程中执行“make install”,然后打包结果。 buildroot 选项允许您将此安装到例如 /tmp/myinstallroot 中。
我最近不得不将 rpm 包构建集成到自动构建中,并且遇到了同样的问题。我所做的是生成一个自定义的 .rpmmacros 文件,并适当设置 %topdir 。然后,我只是暂时将 HOME 更改为该自定义 .rpmmacros 文件的位置。
The --buildroot option is not what you are looking for. The name is a bit misleading as it is not changing the buildroot but instead is setting the root for the install phase of the build. RPM is basically doing a "make install" as part of the build and is then packing the results of this. The buildroot option allows you to do this install into for example /tmp/myinstallroot.
I recently had to integrate rpm package building into an automated build and had the same problem. What i did was to generate a custom .rpmmacros file with %topdir set appropriately. I then just temporarily changes HOME to the location of that custom .rpmmacros file.