如何控制rpmbuild buildroot和安装目录 [英] How to control the rpmbuild buildroot and install directory

查看:1790
本文介绍了如何控制rpmbuild buildroot和安装目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对rpmbuild中的某些目录感到困惑.

I am confused about some directories in rpmbuild.

1:buildroot:当最终用户安装二进制软件包时,应使用它来存储应该安装的文件.

1: buildroot: which should be used to store the files that are supposed to be installed when the binary package is installed by an end-user.

问题:如何控制此目录? BuildRoot是什么意思?

Questions: how to control this directory? What does BuildRoot mean?

 $ cat 3.spec
 ..
 BuildRoot: /opt/abc
 ..
 %prep
 echo %{buildroot}
 echo  $RPM_BUILD_ROOT   

无论我将BuildRoot设置为什么,我都会得到在/usr/lib/rpm/macros中定义的结果.如果在~/.rpmmacros中定义%buildroot,我将从中得到结果.

whatever I set the BuildRoot to, I get the result which was defined in /usr/lib/rpm/macros. If I define %buildroot in ~/.rpmmacros, I will get the result from it.

2:安装rpm软件包时,如何控制目标位置?例如:rpm -ivh xxx.rpm,文件将安装在哪里?

2: How do I control the destination when we install the rpm package? For example: rpm -ivh xxx.rpm, where the files will be installed?

推荐答案

您可以在%install或任意位置创建子目录.

You create the subdirectories yourself in %install or wherever.

示例:您希望将所有文件安装在/opt/mypkg/中,但还需要配置文件/etc/mypkg.conf.因此,在%install部分中,您:

Example: You want to install all your files in /opt/mypkg/ but also want a config file /etc/mypkg.conf. So in the %install section you:

mkdir -p %{buildroot}/opt/mypkg
mkdir -p %{buildroot}/etc

因此,您正在重新创建要安装的树,所有这些都将%{buildroot}等同于目标的/.

So you are re-creating the tree that you want installed, all with %{buildroot} as the equivalent of the target's /.

这篇关于如何控制rpmbuild buildroot和安装目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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