FS#77982 - [mkinitcpio] does not halt/fail when errors occur, and proceeds to generate bad boot images

Attached to Project: Arch Linux
Opened by Erik Johnson (EkriirkE) - Friday, 24 March 2023, 10:42 GMT
Last edited by Jelle van der Waa (jelly) - Monday, 18 September 2023, 17:44 GMT
Task Type Bug Report
Category Arch Projects
Status Closed
Assigned To Giancarlo Razzolini (grazzolini)
Morten Linderud (Foxboron)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
I did an update to my system (bog standard pacman -Suy) that broke the cp and install commands. Another package was also updated that triggered mkinitcpio.
mkinitcpio tries to use cp and install commands to build the base image, but each step fails. An image is built with no files, and thus making the system unbootable.

mkinitcpio should detect errors when copying files and refuse to continue/generate an image.

Additional info:
mkinitcpio-35.1-1.1
File attach button doesn't work, but logs can be found on this post https://archlinuxarm.org/forum/viewtopic.php?f=15&t=16432

Steps to reproduce:
Have a system with malfunctioning cp and/or install commands. Or bad initcpio fileset
# mkinitcpio
This task depends upon

Closed by  Jelle van der Waa (jelly)
Monday, 18 September 2023, 17:44 GMT
Reason for closing:  Moved
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/m kinitcpio/mkinitcpio/issues/209
Comment by Morten Linderud (Foxboron) - Friday, 24 March 2023, 11:19 GMT
Sorry, but this generally seems like a broken coreutils package where failing commands doesn't return a failing exit codes. I don't understand what you expect mkinitcpio to do in this case?
Comment by Erik Johnson (EkriirkE) - Friday, 24 March 2023, 11:29 GMT
Yes the issue originated from coreutils, which I m not reporting here.
---

# cp A B;echo $?
cp: failed to clone 'B' from 'A': Inappropriate ioctl for device
1

It *does* return a failure code. I would like to see the mkinitcpio script check failure codes and not proceed blindly.
Even later on as you see in the logs, it tries to manipulate libraries with depmod which fails because the libs are corrupt(empty). Those commands are working property but, returning error codes caused by the above original issue
Comment by Morten Linderud (Foxboron) - Friday, 24 March 2023, 11:36 GMT
mkinitcpio does still print the warning at the end of the run? Right?

==> WARNING: errors were encountered during the build. The image may not be complete.

Comment by Erik Johnson (EkriirkE) - Friday, 24 March 2023, 12:19 GMT
It does... I see what you were trying to get at;
If one is manually running it yes its easy to catch and avoid. But when triggered *forcefully* by another process like pacman, that is pretty useless to an average user.

Maybe I should bring this to pacman? Build in temp and not destroy the boot image otherwise
Comment by Morten Linderud (Foxboron) - Friday, 24 March 2023, 12:27 GMT
I'm a little bit torn what a better option would be. We could maybe not overwrite the image if there are errors in the build process. I'll try and think a little bit what a better option would be.

Currently however mkinitcpio is probably not going to default with `set -e` so any scripts running `add_file` will need to check the error code manually and I think that is fine.

Loading...