FS#43541 - [linux] Missing error handling in linux.install

Attached to Project: Arch Linux
Opened by Andrey Vihrov (andreyv) - Thursday, 22 January 2015, 15:17 GMT
Last edited by Tobias Powalowski (tpowa) - Sunday, 08 February 2015, 19:23 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

When installing the linux and linux-headers packages, I received this output: http://pastie.org/9851647

I noticed and fixed the problem, but the worrying part is that the installation continued even after the error occurred (see the "reinstalling linux-headers" and the pacman exit code part). If this was one of many packages being installed at the same time, the error could have gone unnoticed, and the package would have been left in a corrupt state.

It seems that this is because all commands in the linux.install file are called without checking their exit status.
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Sunday, 08 February 2015, 19:23 GMT
Reason for closing:  Not a bug
Comment by Dave Reisner (falconindy) - Friday, 23 January 2015, 17:36 GMT
You cannot abort a package installation from an install scriptlet. No amount of error checking can fix this.
Comment by Andrey Vihrov (andreyv) - Friday, 23 January 2015, 18:21 GMT
Thanks for your reply.

Is it a bug or a design feature in pacman? I understand that pacman might want to install all requested packages at once, but still it could display

error: install-time scripts failed for the following packages: xxx yyy zzz

in the end after installing everything, and exit unsuccessfully.

I tried a test install action that just does "return 1" from the script function. As you said, pacman continued installation, but at least pacman displayed

error: command failed to execute correctly

for the test package. So making the install script check errors still could be of value, as pacman would now know about the failure. Since pacman runs a separate shell for each install action, it seems that "set -e" in the .install file would be enough to implement error checking.

On the other hand, maybe pacman itself should append "-e" to the shell parameters as it executes the function? It looks like it would be easy to add it in https://projects.archlinux.org/pacman.git/tree/lib/libalpm/trans.c#n328.

I could also post a question about this on the pacman-dev mailing list if it is the correct place.

Loading...