You are not logged in.

#1 2008-04-10 18:46:50

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Error-handling in PKGBUILDs is far from perfect

Hi, PKGBUILDs should die on failure, rather than just continue regardless of errors. Here's a little rant:

Why is it acceptable for ./configure to fail? Or make install to fail? Or the installation of just about any file? They could fail for lots of reasons, such as expecting a non-existent directory to exist, just being badly-written, or disk corruption, or running out of disk space. I see this lack of error-handling both in official packages and in the AUR.

Failing on an error is a fundamental part of programming, and BASH makes a mockery of it. And then Linux developers seem to get brainwashed by BASH into believing that mixing important and non-important errors together, then just ignoring all the errors, is an acceptable programming practice. It's not - it's a comedy of errors (excuse the pun).

SourceMage handles this problem by having one huge command constructed with && at the end of each line, so at least will fail on error.

Gentoo is using its custom die command more often these days (|| die), but my proposal is in limbo, presumably because "SpanKY" overrules every other dev (little bit of Gentoo politics there smile ).

The current practice of make || return 1 is correct, but || return 1 should be used far more often - example  (notice the looped use of install, and the annoyance of having to check $? after the loop). "More often" includes make install even if it's on the final line, both for consistency, and so it is not forgotten to be added when further lines are added to the end (e.g. to install the license/documentation files).


I'll place this on flyspray after a bit of feedback.

Edit: I'll distro-hop instead.

Last edited by brebs (2008-04-21 13:55:33)

Offline

#2 2008-04-10 20:51:18

kumico
Member
Registered: 2007-09-28
Posts: 224
Website

Re: Error-handling in PKGBUILDs is far from perfect

this has already been discussed, iirc i made those recomendations already.
in either case, i think you'll get more input if you post it on the mailing lists

Offline

#3 2008-04-10 22:02:40

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: Error-handling in PKGBUILDs is far from perfect

I agree with both of you.

Offline

#4 2008-04-11 01:39:23

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,400
Website

Re: Error-handling in PKGBUILDs is far from perfect

I'm as guilty as anyone in this.  However, I always use it on the initial "configure" and "make install" lines where there is a lot of output.  I tend to miss it when installing individual files at the end (e.g. Licences, icons...) because I can see if they failed from the output.

Offline

Board footer

Powered by FluxBB