How do you make _topdir relative to the location of the .spec file when building an RPM?

荒凉一梦 提交于 2019-12-08 14:42:06

问题


I have a .spec file that relies on a variable called _topdir.

Right now when you checkout the SRPM source from git, you have to go and change where _topdir is pointing to to get the rpmbuild to function correctly.

# We need the following line so that RPM can find the BUILD and SOURCES and RPMS dirs.
%define _topdir /root/projects/my-project/my-project-srpm/

How do you specify that _topdir should be relative to the location of the .spec file so that _topdir isn't hard coded?


回答1:


specify your topdir on the command line like so ...

rpmbuild --define "_topdir \`pwd\`" ...



回答2:


You can define the _topdir variable in your spec file (e.g., at the top)

%define _topdir %(echo $PWD)/



回答3:


In your ~/.rpmmacros file, do this:

%_topdir      %(echo $PWD)/subdir

I'm unsure if you can do this inside the spec file itself, I don't see why not, but I'm unsure how to notate it.



来源:https://stackoverflow.com/questions/6285792/how-do-you-make-topdir-relative-to-the-location-of-the-spec-file-when-building

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