Bug 40582 - install check ignores non-zero exit status of %post scriptlets
Summary: install check ignores non-zero exit status of %post scriptlets
Status: CLOSED FIXED
Alias: None
Product: Infrastructure
Classification: Infrastructure
Component: girar (show other bugs)
Version: unspecified
Hardware: x86_64 Linux
: P5 normal
Assignee: placeholder@altlinux.org
QA Contact: Andrey Cherepanov
URL: https://lists.altlinux.org/pipermail/...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-26 21:36 MSK by Ivan Zakharyaschev
Modified: 2021-08-04 13:17 MSK (History)
3 users (show)

See Also:


Attachments
create_chroot(): pin %%_rpmscript_werror (as expected in Girar install checks) (2.45 KB, patch)
2021-07-26 21:40 MSK, Ivan Zakharyaschev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Zakharyaschev 2021-07-26 21:36:33 MSK
For non-zero exit codes of the %%post scriplets to be treated as fatal
errors (in install checks in Girar), %%_rpmscript_werror flag was recently
added to rpm, and an attempt was made to turn this behavior on in
Girar in commit 6c5d2738e0ad04d00c31c980a6e8f71ff5bb24ab:

Author: Dmitry V. Levin <ldv@altlinux.org>
Date:   Thu Dec 19 00:44:59 2019 +0000

    gb-remote-plant: add %_rpmscript_werror to .rpmmacros

    Enable traditional rpm behaviour of treating all scriptlet failures
    as fatal.

However, adding it to ~/.rpmmacros didn't have the desired effect,
because, in hasher, firstly, rpmmacros from the host system are
primarily used to fill in builder's rpmmacros (and affect only
building packages), and secondly, even there they are not copied
verbatim, but rather some needed values are evaluated and
inserted. (See "# Create RPM build directory tree." in hsh-initroot.)
Also, aptbox sees ~/.rpmmacros from the host system (or re-creates its
own $aptbox_home/.rpmmacros), but they don't seem to affect the
behavior of rpm w.r.t. the exit status of the scriptlets of the
packages being installed.

This is demonstrated by the trivial test packages from
http://git.altlinux.org/people/imz/packages/rpmscript_warn_only-checkinstall.git

The test for %pre "passes": https://lists.altlinux.org/pipermail/sisyphus-incominger/2021-July/624894.html
The test for %post doesn't: https://lists.altlinux.org/pipermail/sisyphus-incominger/2021-July/624896.html

Reported-by: Alexey Appolonov <alexey@altlinux.org>

As a workaround we can simply hardcode the %_rpmscript_werror in hasher (branch rpmscript_werror in my Git repo):

commit 8c3acab99cdd866f9fc978bc6cf685d198d4d6cd
Author: Ivan Zakharyaschev <imz@altlinux.org>
Date:   Mon Jul 26 17:00:27 2021 +0300

    create_chroot(): pin %%_rpmscript_werror (as expected in Girar install checks)
    
    (I don't like hardcoding this; a more flexible solution allowing to
    choose the behavior for each invocation of hsh --ini or hsh-install
    would be better: it could be an option to pass the corresponding
    option along with rpmi.)
    
    (For this change to take effect, one should rm -rf ~/hasher/cache/chroot/ )
    
    For non-zero exit codes of the %%post scriplets to be treated as fatal
    errors (in install checks in Girar), %%_rpmscript_werror flag was recently
    added to rpm, and an attempt was made to turn this behavior on in
    Girar in commit 6c5d2738e0ad04d00c31c980a6e8f71ff5bb24ab:

    ...
Comment 1 Ivan Zakharyaschev 2021-07-26 21:40:24 MSK
Created attachment 9537 [details]
create_chroot(): pin %%_rpmscript_werror (as expected in Girar install checks)

a patch to hardcode the desired behavior in hasher
Comment 2 Ivan Zakharyaschev 2021-07-28 15:13:39 MSK
hasher-1.4.7-alt1 with this fix has been committed to Sisyphus, and the new good behavior can already be observed in Girar on x86_64 and i586, but not yet on armh, aarch64, ppc64le -- https://lists.altlinux.org/pipermail/sisyphus-incominger/2021-July/625568.html :

2021-Jul-28 11:45:27 :: [aarch64] #300 rpmscript_warn_only-post-checkinstall: install check OK
2021-Jul-28 11:45:28 :: [ppc64le] #300 rpmscript_warn_only-post-checkinstall: install check OK
	i586: rpmscript_warn_only-post-checkinstall=1-alt1 install failed:
 <13>Jul 28 11:45:28 rpmi: rpmscript_warn_only-post-checkinstall-1-alt1 sisyphus+280840.300.5.1 1627472606 installed
 error: %post(rpmscript_warn_only-post-checkinstall-1-alt1.noarch) scriptlet failed, exit status 1
 error: rpmscript_warn_only-post-checkinstall-1-alt1.noarch: install failed
 hsh-install: Packages installation failed.
2021-Jul-28 11:45:28 :: [i586] #300 rpmscript_warn_only-post-checkinstall: install check FAILED
2021-Jul-28 11:45:28 :: [i586] requesting cancellation of task processing
2021-Jul-28 11:45:34 :: [armh] #300 rpmscript_warn_only-post-checkinstall: install check OK
	x86_64: rpmscript_warn_only-post-checkinstall=1-alt1 install failed:
 <13>Jul 28 11:45:35 rpmi: rpmscript_warn_only-post-checkinstall-1-alt1 sisyphus+280840.300.5.1 1627472606 installed
 error: %post(rpmscript_warn_only-post-checkinstall-1-alt1.noarch) scriptlet failed, exit status 1
 error: rpmscript_warn_only-post-checkinstall-1-alt1.noarch: install failed
 hsh-install: Packages installation failed.
2021-Jul-28 11:45:35 :: [x86_64] #300 rpmscript_warn_only-post-checkinstall: install check FAILED
Comment 3 Dmitry V. Levin 2021-07-28 18:09:54 MSK
(In reply to Ivan Zakharyaschev from comment #2)
> hasher-1.4.7-alt1 with this fix has been committed to Sisyphus, and the new
> good behavior can already be observed in Girar on x86_64 and i586, but not
> yet on armh, aarch64, ppc64le --

It will take a bit more time to reboot those hosts.