Hi,
On CentOS 6, when we try to install any rpm it fails with scriplet failed with exit status 1 but return status of rpm is also 1 which is correct. Example: But On CentOS 7, we are not getting return status of rpm as 1 it is coming 0, which is installing the RPM.
rpm -Uvh /home/seldridg/rpmbuild/RPMS/noarch/test-1.0-1.el6.noarch.rpm; echo $? Preparing... ########################################### [100%] 1:test ########################################### [100%] Test Script called failure seen while executing test-script error: %post(test-1.0-1.el6.noarch) scriptlet failed, exit status 1 1 <-- verified this works as expected
I checked the source code of rpm package for CentOS6/7 and found that one patch is applicable in CentOS6 rpm package and because of this any failure is coming during scriplet failure it treats warning as an error and giving rpm status as a 1 and not installing that RPM in your system.
rpm -Uvh /home/seldridg/rpmbuild/RPMS/noarch/test-1.0-1.el7.noarch.rpm; echo $? Preparing... ########################################### [100%] 1:test ########################################### [100%] Test Script called failure seen while executing test-script error: %post(test-1.0-1.el7.noarch) scriptlet failed, exit status 1 0 <-- verified this works as expected
Below is the patch: +++ b/rpm-4.8.x-strict-script-errors.patch @@ -0,0 +1,25 @@ +diff -up rpm-4.8.0/lib/psm.c.strict-script rpm-4.8.0/lib/psm.c +--- rpm-4.8.0/lib/psm.c.strict-script 2013-08-05 11:09:40.290136043 +0300 ++++ rpm-4.8.0/lib/psm.c 2013-08-05 11:12:18.465137945 +0300 +@@ -517,7 +517,9 @@ static rpmRC runLuaScript(rpmpsm psm, He + if (rc != RPMRC_OK) { + if ((stag != RPMTAG_PREIN && stag != RPMTAG_PREUN && + stag != RPMTAG_VERIFYSCRIPT && stag != RPMTAG_PRETRANS)) { +- warn_only = 1; ++ if (!rpmExpandNumeric("%{?_strict_script_errors}")) { ++ warn_only = 1; ++ } + } + } + umask(oldmask); +@@ -774,7 +776,9 @@ static rpmRC runScript(rpmpsm psm, Heade + } else { + /* filter out "regular" error exits from non-pre scriptlets */ + if ((stag != RPMTAG_PREIN && stag != RPMTAG_PREUN && stag != RPMTAG_VERIFYSCRIPT && stag != RPMTAG_PRETRANS)) { +- warn_only = 1; ++ if (!rpmExpandNumeric("%{?_strict_script_errors}")) { ++ warn_only = 1; ++ } + } + rpmlog(warn_only ? RPMLOG_WARNING : RPMLOG_ERR, + _("%s scriptlet failed, exit status %d\n"),
I tried to modify the code according to this but not getting success. Please help me on this. I want the same behavior of CentOS 6 on CentOS 7.
Regards, Shagun
On 10/07/2019 05:52, Maheshwari, Shagun wrote:
Hi,
On CentOS 6, when we try to install any rpm it fails with scriplet failed with exit status 1 but return status of rpm is also 1 which is correct.
Example:
But On CentOS 7, we are not getting return status of rpm as 1 it is coming 0, which is installing the RPM.
Since CentOS is a rebuild of the sources used to create RHEL, you will need to report this on bugzilla.redhat.com to stand a chance of getting it changed. If Redhat accept the change and publish the fix then it will be picked up and rebuilt for CentOS once it is released.
Trevor
Hi Trevor,
Thank you!! for your response.
I will raise this issue on Bugzilla but I want to know why RPM is allow to install in your system when scriptlet failing error is coming? Is this a right behavior?
Regards, Shagun
From: Trevor Hemsley trevor.hemsley@ntlworld.com Sent: Wednesday, July 10, 2019 2:31 PM To: The CentOS developers mailing list. centos-devel@centos.org; Maheshwari, Shagun Shagun.Maheshwari@Harman.com Subject: [EXTERNAL] Re: [CentOS-devel] Rpm post scriplet failed with exit status 1 but return status of rpm is 0
On 10/07/2019 05:52, Maheshwari, Shagun wrote: Hi,
On CentOS 6, when we try to install any rpm it fails with scriplet failed with exit status 1 but return status of rpm is also 1 which is correct. Example: But On CentOS 7, we are not getting return status of rpm as 1 it is coming 0, which is installing the RPM.
Since CentOS is a rebuild of the sources used to create RHEL, you will need to report this on bugzilla.redhat.com to stand a chance of getting it changed. If Redhat accept the change and publish the fix then it will be picked up and rebuilt for CentOS once it is released.
Trevor
On Wed, Jul 10, 2019 at 09:49:50AM +0000, Maheshwari, Shagun wrote:
Hi Trevor,
Thank you!! for your response.
I will raise this issue on Bugzilla but I want to know why RPM is allow to install in your system when scriptlet failing error is coming? Is this a right behavior?
In my experience, a failure in %post doesn't prevent the RPM from being installed, as that scriptlet is fired after the installation completes.
Similarly, if there's an error in %postun, the RPM's payload is removed, but the RPM is seen as still installed by the RPM database.
Regards, Shagun
On Wed, Jul 10, 2019 at 4:20 PM Brian Reichert reichert@numachi.com wrote:
On Wed, Jul 10, 2019 at 09:49:50AM +0000, Maheshwari, Shagun wrote:
Hi Trevor,
Thank you!! for your response.
I will raise this issue on Bugzilla but I want to know why RPM is allow to install in your system when scriptlet failing error is coming? Is this a right behavior?
In my experience, a failure in %post doesn't prevent the RPM from being installed, as that scriptlet is fired after the installation completes.
Similarly, if there's an error in %postun, the RPM's payload is removed, but the RPM is seen as still installed by the RPM database.
Exactly.
Also managed to find:
https://access.redhat.com/errata/RHBA-2013:1665
which says:
With this update, Red Hat Enterprise Linux 5 backwards-compatibility option, "%_strict_script_errors macro", has been added. The default behavior of Red Hat Enterprise Linux 6 does not change with this update and users that do not demand this option specifically are not advised to use it. (BZ#963724)
And also:
https://github.com/rpm-software-management/rpm/commit/5455f02523a9b8583d5a94...
which I guess will not be backported to EL7, but perhaps is already part of EL8 (didn't check).
As a side note, which is also one reason why I am interested in this, in otopi (oVirt's setup-programs framework) we decided to fail on any error, see also if interested:
https://bugzilla.redhat.com/show_bug.cgi?id=1493160
https://bugzilla.redhat.com/show_bug.cgi?id=1528290
Best regards,