RPM 构建过程无需安装
我正在尝试构建自己的 rpm 包,但有一些疑问。
首先,在几个地方我已经强调不要以 root 身份构建 rpm。这是为什么?在构建过程中,rpmbuild 必须经历安装阶段,将文件安装到系统中。
据我了解,如果我不是 root,我就无法做到这一点。 rpmbuild 进程结束时出现错误。那么,问题是是否真的可以在不向系统安装东西的情况下构建 rpm?或者最终我必须成为 root 才能完成构建过程?
I'm trying to build my own rpm package and have a couple of doubts.
First of all, in several places I've red that one shouldn't build rpms as root. Why is that? During the building process, rpmbuild has to go through the install stage where it installs files to the system.
As far as I understand I can't do that if I'm not root. rpmbuild process finishes with error. So, the question is if it is really possible to build an rpm without installing stuff into the system? Or eventually I do have to become root to complete the build process?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在实时文件系统上构建 RPM,您将会覆盖已有的内容。这是构建过程中意外的副作用,应不惜一切代价避免。
构建 RPM 的正确方法是将所有文件安装到暂存目录中(通常在
/var/tmp
中)。这可以避免与实时系统发生任何冲突,并可以帮助您确保:这些都不需要 root 权限。如果您的 RPM 构建脚本需要 root 才能运行,那么您就错了。
由于它不需要 root 权限,因此您不应以 root 身份运行它。 尽可能避免以 root 身份运行。
If you build RPMs on the live filesystem, you WILL overwrite what's already there. This is an unintended side effect of the build process and should be avoided at all costs.
The correct way of building RPMs is to have all files installed into a staging directory (usually in
/var/tmp
). This avoids any conflicts with the live system and can help you ensure that:None of this requires root privileges. If your RPM build script needs root to run, you're Doing It Wrong.
Since it does not require root privileges, you should not run it as root. Avoid running as root whenever possible.
让你的系统知道你想在哪里构建你的包 - 请参阅 $HOME/.rpmmacros 文件中的 '_topdir' 值:
其次你想更改它的构建根值:
(--buildroot 键仅获得非 root 用户的能力构建自己的 rpm 包)
如果我说的有问题请纠正我。
Let your system know where u want to build your package - see $HOME/.rpmmacros file for the '_topdir' value:
Second u want to change its your build root value:
(--buildroot key only get capability non-root user to build own rpm packages)
correct me, if something wrong that i say.