4

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?

guido
  • 18,864
  • 6
  • 70
  • 95
boardrider
  • 5,882
  • 7
  • 49
  • 86
  • 1
    You are asking too fast. See my answer in you previous question http://stackoverflow.com/a/34634718/3489429 – msuchy Jan 06 '16 at 13:49

2 Answers2

5

%post is an install-time script section, so it will execute only when trying to install 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.

alteredinstance
  • 587
  • 3
  • 17
guido
  • 18,864
  • 6
  • 70
  • 95
2

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

Further reading:

D Hydar
  • 502
  • 2
  • 8
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105