$ RPM_BUILD_ROOT实际上是什么? [英] What actually is $RPM_BUILD_ROOT?

查看:144
本文介绍了$ RPM_BUILD_ROOT实际上是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建RPM软件包的过程中,我必须指定BuildRoot,以后将在%install中使用它来侵害$ RPM_BUILD_ROOT.我一直认为$ RPM_BUILD_ROOT是RPM执行打包的假安装.然后,在使用RPM软件包进行安装时,它将安装到实际位置.例如:

$RPM_BUILD_ROOT/usr/bin

我认为$ RPM_BUILD_ROOT仅用于打包过程,并且在某些方面,当用户执行"rpm -ivh package.rpm"时,RPM可以区分$ RPM_BUILD_ROOT和实际安装位​​置为/usr/bin. /p>

但是最近阅读一些文档时,建议将$ RPM_BUILD_ROOT是将要安装的实际位置,并且$ RPM_BUILD_ROOT由用户通过设置环境变量$ RPM_BUILD_ROOT来指定,以便让用户安装软件包在他们想要的位置.否则,$ RPM_BUILD_ROOT将为空,并将安装到默认位置.在上述情况下,它是/usr/bin.因此,$ RPM_BUILD_ROOT不仅用于打包或假安装"过程,而且是用户定义安装位置的一种方式,类似于在Windows中选择文件夹位置.

我不知道我的想法是正确的还是错误的.有人可以验证吗?预先感谢.

解决方案

$RPM_BUILD_ROOT(或等效的%{buildroot} SPEC文件宏)始终保留RPM将在其中查找任何文件的目录包装. RPM脚本(例如,压缩手册页的脚本)也将使用该值来知道从何处查找刚刚安装的文件.通常,该值是非空的,并且包含一个远离系统目录的位置-通常在/tmp/var/tmp下.

SPEC文件的作者应确保make install(或有问题的软件正在使用的任何安装程序)将任何文件放置在$RPM_BUILD_ROOT下,并具有与该软件相同的层次结构.终于安装好了.例如.要在/bin/ls中将RPM安装ls%install SPEC文件部分应确保将ls放置在$RPM_BUILD_ROOT/bin/ls中.

SPEC文件的作者也应使用BuildRoot:标记指定正确的位置.或者,构建系统可以具有带有正确条目的rpmrc RPM配置文件.在任何情况下都应设置构建根目录,以便:

  • 普通用户将能够构建源程序包.

  • 如果超级用户曾经构建过源软件包,则除非超级用户安装了生成的二进制软件包,否则构建过程不会破坏任何系统文件.是的,也许有充分的理由将 some 软件包构建为root-例如,运行完整的glibc测试套件需要某些测试具有root特权.

也就是说,RPM可以并且将使用一个空的构建根变量来构建一个软件包.在这种情况下,构建安装位置和最终目标位置都将重合.可能会致电给例如make install将使用默认位置,从而破坏系统文件,例如/usr/lib(如果具有足够的特权运行).此外,在%files部分中包含/usr/bin/*会很高兴将构建主机/usr/bin/目录的全部内容拉入您的二进制包中.

底线:

  • 切勿使用空的构建根.

  • 除非绝对没有其他方法,否则请勿将软件包构建为root.

In the process of building an RPM package, I have to specify the BuildRoot and later will be used in %install which invovles $RPM_BUILD_ROOT. I always think that $RPM_BUILD_ROOT is the fake installation for RPM to perform packaging. Then, at install time using the RPM package, it will install into actual location. For example:

$RPM_BUILD_ROOT/usr/bin

I thought that $RPM_BUILD_ROOT is for the packaging process only, and in some ways RPM can distinguish the $RPM_BUILD_ROOT and the actual install location when the user performs "rpm -ivh package.rpm" will be /usr/bin.

But recently upon reading some documents, it is suggested that $RPM_BUILD_ROOT is the actual location which will be installed, and the $RPM_BUILD_ROOT is specified by user with the setting of environment variable $RPM_BUILD_ROOT in order to let the users install the package in their desire locations. Otherwise, $RPM_BUILD_ROOT will be null and it will install into the default location. In the above case, it is /usr/bin . Thus, $RPM_BUILD_ROOT is not just for packaging or "fake installation" process, but is a way for user to define install location, similar to select folder location in Windows.

I don't know my thinking is correct or not. Can someone please verify? Thanks in advance.

解决方案

$RPM_BUILD_ROOT (or the equivalent %{buildroot} SPEC file macro) always holds the directory under which RPM will look for any files to package. The RPM scripts (e.g. the script that compresses the manual pages) will also use that value to know where to look for the files that were just installed. Normally, this value will be non-empty and contain a location away from the system directories - usually somewhere under /tmp or /var/tmp.

The author of the SPEC file is expected to make sure that make install (or whatever installer the software in question is using) will place any files under $RPM_BUILD_ROOT, with the same hierarchy that should be used when the software is finally installed. E.g. to have RPM install ls in /bin/ls, the %install SPEC file section should make sure that ls is placed in $RPM_BUILD_ROOT/bin/ls.

The author of the SPEC file is also expected to use the BuildRoot: tag to specify a proper location. Alternatively, the build system could have an rpmrc RPM configuration file with a proper entry. In any case the build root should be set, so that:

  • Normal users will be able to build the source package.

  • Should the superuser ever build the source package, the build process will not clobber any system files, unless the superuser installs the resulting binary package. And yes, there may be a good reason to build some packages as root - for example, running the full glibc testsuite requires root privileges for some tests.

That said, RPM can and will build a package with an empty build root variable. In that case both the build install and the final destination locations will coincide. A potential call to e.g. make install will use the default locations, thus clobbering the system files under e.g. /usr/lib if run with sufficient privileges. Additionally, having /usr/bin/* in your %files section will happily pull the whole contents of the build host /usr/bin/ directory into your binary package.

Bottom line:

  • Never use an empty build root.

  • Do not build packages as root unless there is absolutely no other way.

这篇关于$ RPM_BUILD_ROOT实际上是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆