how ${buildroot} is created automatically during rpmbuild?

放肆的年华 提交于 2019-12-08 03:11:46

问题


I want to create the binary rpm files from generated binary packages in centos 6.4 and noticed in one of my build system the ${buildroot} is created automatically, I want to know how it can be achieved.

The sample wget.spec looks like below. detail spec is in my gist https://gist.github.com/larrycai/1ffe134bce1860f1cf87

%install
tar xf ~/wget.tar.gz -C %{buildroot}/

%files
%defattr(-,root,root)
/usr/bin/wget

The wget.tar.gz can be created tar -zcvf ~/wget.tar.gz /usr/bin/wget

When I build it using rpmbuild -bb wget.spec, I got the

+ rpmbuild -bb wget.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.VNDZg4
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.S8koPW
+ umask 022
+ cd /home/larry/rpmbuild/BUILD
+ '[' /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 '!=' / ']'
+ rm -rf /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
++ dirname /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ mkdir -p /home/larry/rpmbuild/BUILDROOT
+ mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ tar xf /home/larry/wget.tar.gz -C /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64/
+ /usr/lib/rpm/check-buildroot
... (it is successful)

I wonder why line mkdir /home/larry/rpmbuild/BUILDROOT/wget-1.12-1.x86_64 is executed automatically.

Are there any script or rpmmacros is enabled for this ?


回答1:


The main reason is that build machines installed redhat-rpm-config package, the detail list below

This macro setting is in /usr/lib/rpm/redhat/macros

%__spec_install_pre %{___build_pre}\
    [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
    mkdir -p `dirname "$RPM_BUILD_ROOT"`\
    mkdir "$RPM_BUILD_ROOT"\
%{nil}

We can either install this package or put this macros into ~/.rpmmacros

I find it by running command rpmbuild --showrc can see that mkdir code segment is there, so I start to check whether there is special package is installed.



来源:https://stackoverflow.com/questions/24357315/how-buildroot-is-created-automatically-during-rpmbuild

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