Let %post scriptlet always exits with the zero exit status

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2247940

Currently, CoreOS image fails to be built. This is because since commit
00c37d8c ("spec: Drop special handling for IA64 machines"), the last
command is now servicelog_notify and it fails to run in such
invocation environment. Thus the %post scriptlet returns a non-zero
exit code which breaks package installation,

    Running scriptlet: kexec-tools-2.0.27-4.fc40.ppc64le
    /proc/ is not mounted. This is not a supported mode of operation. Please fix your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway. Your mileage may vary.
    servicelog_notify: is not supported on the Unknown platform
    warning: %post(kexec-tools-2.0.27-4.fc40.ppc64le) scriptlet failed, exit status 1
    Error in POSTIN scriptlet in rpm package kexec-tools

Quoting [1],
> Non-zero exit codes from scriptlets can break installs/upgrades/erases
> such that no further actions will be taken for that package in a
> transaction (see Ordering), which may for example prevent an old version
> of a package from being erased on upgrades, ...
>
> All scriptlets MUST exit with the zero exit status. Because RPM in its
> default configuration does not execute shell scriptlets with the -e
> argument to the shell, excluding explicit exit calls (frowned upon with
> a non-zero argument!), the exit status of the last command in a
> scriptlet determines its exit status...
>
> Usually the most important bit is to apply this to the last command
> executed in a scriptlet, or to add a separate command such as plain “:”
> or “exit 0” as the last one in a scriptlet.

Following the above suggestion, add a separate command ":" as the last
one to the %post scriptlet.

[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/

Reported-by: Colin Walters <walters@redhat.com>
Cc: Dusty Mabe <dustymabe@redhat.com>
Cc: Philipp Rudo <prudo@redhat.com>
Fixes: 00c37d8c ("spec: Drop special handling for IA64 machines")
Signed-off-by: Coiby Xu <coxu@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Coiby Xu 2023-11-16 10:19:19 +08:00
parent 0177e24832
commit bc31f6dd0f

View File

@ -271,6 +271,7 @@ touch /etc/kdump.conf
servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh 2>/dev/null
servicelog_notify --add --command=/usr/lib/kdump/kdump-migrate-action.sh --match='refcode="#MIGRATE" and serviceable=0' --type=EVENT --method=pairs_stdin >/dev/null
%endif
:
%postun