How to control the rpmbuild buildroot and install directory

若如初见. 提交于 2019-12-06 09:15:20

问题


I am confused about some directories in rpmbuild.

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.

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

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

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: How do I control the destination when we install the rpm package? For example: rpm -ivh xxx.rpm, where the files will be installed?


回答1:


You create the subdirectories yourself in %install or wherever.

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

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



来源:https://stackoverflow.com/questions/16079464/how-to-control-the-rpmbuild-buildroot-and-install-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!