This issue was originally raised against the Nebula plugin for Gradle, but I closed it there because they are merely a wrapper around Redline which I'm pretty sure is the source of the problem, though I'm not sure what it is.
According to the Fedora guide for building RPMs, scriptlets such as %post, %preun are passed an argument (retrievable by $1) that indicates
the number of packages of this name which will be left on the system when the action completes
These arguments are intended as tests for whether the scriptlet should proceed or not, to protect against bad things happening in the case of erroroneous installs. I want to wrap some my %post, %preun, %postun functionality in tests that depend on these parameters
In particular on an uninstall, the expected value of $1 for the %preun and %postun scripts is supposed to be 0. However, I find that after a successful install of an rpm built with Redline, on installing this rpm, the $1 argument value is 1, and therefore the functionality in %preun that is guarded against execution when an instance of the rpm will remain installed is wrongly not executed when it should be, because we are in fact about to uninstall the last instance.
To make this clearer, here is the scriptlet:
echo "PRE-UNINSTALL PROCESS HAS BEEN INITIATED"
echo The number of packages that will be installed after the uninstall completes is ${1}
if [ ${1} != 0 ]
then
echo "SINCE THERE IS CURRENTLY MORE THAN ONE PACKAGE INSTALLED THE PRE-UNINSTALL SCRIPT WILL NOT BE RUN"
exit 0
fi
echo Running any pre uninstall scripts found in the tar file!
if [ -s /usr/local/vtone/apps/%{name}/rpm/%{release}/preremove ]
then
sh /usr/local/vtone/apps/%{name}/rpm/%{release}/preremove
fi
echo "PRE-UNINSTALL PROCESS HAS BEEN COMPLETED"
Expected output is:
The number of packages that will be installed after the uninstall completes is 0
...
PRE-UNINSTALL PROCESS HAS BEEN COMPLETED
but instead, I see
The number of packages that will be installed after the uninstall completes is 1
SINCE THERE IS CURRENTLY MORE THAN ONE PACKAGE INSTALLED THE PRE-UNINSTALL SCRIPT WILL NOT BE RUN
There is another version of this rpm that is built with rpmbuild and it does not have this problem, so I presume that there's something wrong with what Redline is doing, or at least with how I have configured it.
Here is one bit of information that might be relevant to the problem:
With the version of the rpm built with rpmbuild, the following query shows the what the rpm requires:
# rpm -qR gvp008
rpmlib(VersionedDependencies) <= 3.0.3-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
whereas, when the version of the rpm that was built with rpmbuild is installed, the results are guite different:
I should also mention the environment this is running under (and the rpm is being built and installed on the same machine):
# uname -a
Linux servername 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
# rpm --version
RPM version 4.8.0