RPM 构建过程无需安装

发布于 2024-12-04 21:13:30 字数 223 浏览 1 评论 0原文

我正在尝试构建自己的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放赐 2024-12-11 21:13:30

如果您在实时文件系统上构建 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:

  • you do not try and package more files than intended
  • you do not miss any files when packaging

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.

羞稚 2024-12-11 21:13:30

让你的系统知道你想在哪里构建你的包 - 请参阅 $HOME/.rpmmacros 文件中的 '_topdir' 值:

rpm --eval %{_topdir} # get your current value

其次你想更改它的构建根值:

rpmbuild --buildroot=[path] ..

(--buildroot 键仅获得非 root 用户的能力构建自己的 rpm 包)

如果我说的有问题请纠正我。

Let your system know where u want to build your package - see $HOME/.rpmmacros file for the '_topdir' value:

rpm --eval %{_topdir} # get your current value

Second u want to change its your build root value:

rpmbuild --buildroot=[path] ..

(--buildroot key only get capability non-root user to build own rpm packages)

correct me, if something wrong that i say.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文