RPM spec %post doesn't execute in rpmbuild

邮差的信 提交于 2019-12-10 19:35:47

问题


Given the minimal RPM spec file, that should only execute a %post stanza:

$ cat ~/RPMBUILD/SPECS/test.spec
Name:           None
Version:        1.0
Release:        1
Summary:        Bla
License:        Proprietary

%description
Bla

%prep

%build

%install

%clean

%post
echo ">>> Inside post <<<"

%files

However, the echo from the %post is not executed:

$ rpmbuild -v -bb  ~/RPMBUILD/SPECS/test.spec
Executing(%prep): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.IvhCZs
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%build): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.yCLpOK
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.uEbSD2
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ '[' /home/ronbarak/RPMBUILD/BUILDROOT/None-1.0-1.x86_64 '!=' / ']'
+ rm -rf /home/ronbarak/RPMBUILD/BUILDROOT/None-1.0-1.x86_64
++ dirname /home/ronbarak/RPMBUILD/BUILDROOT/None-1.0-1.x86_64
+ mkdir -p /home/ronbarak/RPMBUILD/BUILDROOT
+ mkdir /home/ronbarak/RPMBUILD/BUILDROOT/None-1.0-1.x86_64
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: None-1.0-1.x86_64
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/ronbarak/RPMBUILD/BUILDROOT/None-1.0-1.x86_64
Wrote: /home/ronbarak/RPMBUILD/RPMS/x86_64/None-1.0-1.x86_64.rpm
Executing(%clean): /bin/sh -e /home/ronbarak/RPMBUILD/tmp/rpm-tmp.wLCv3C
+ umask 022
+ cd /home/ronbarak/RPMBUILD/BUILD
+ exit 0

What should I change so that the %post will execute?


回答1:


%post is an install/uninstall time script section, so it will execute only when trying to install or uninstall the generated rpm.

From the documentation:

The %post script executes after the package has been installed. One of the most popular reasons a %post script is needed is to run ldconfig to update the list of available shared libraries after a new one has been installed. Of course, other functions can be performed in a %post script. For example, packages that install shells use the %post script to add the shell name to /etc/shells.

If you want to execute additional stuff at build time, you need to rely on the %build or %install sections.




回答2:


The %post section runs when you install an RPM, not during rpmbuild.

Further reading:

  • Scripts: RPM's Workhorse
  • How to create an RPM package


来源:https://stackoverflow.com/questions/34633287/rpm-spec-post-doesnt-execute-in-rpmbuild

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