Bug 206951 - create-users-groups built a script that failed, but the failure was undetected
Summary: create-users-groups built a script that failed, but the failure was undetected
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Port Management Team
Depends on:
Reported: 2016-02-05 13:43 UTC by John Hein
Modified: 2016-05-16 03:02 UTC (History)
2 users (show)

See Also:
jcfyecrayz: maintainer-feedback?


Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2016-02-05 13:43:33 UTC
Recently I had a port install fail to create a group.  The 'uchg' file attribute /etc/group file was set which caused pw(8) to fail.  But the important part for ports is that there was a failure and yet the build did not stop.  Also the corresponding user did not get added either because the group was missing.

One simple fix is to add 'set -e' at the top of the _UG_OUTPUT script (in create-users-groups in bsd.port.mk).

Another option is to add 'set -e' at the top of all PKGPREINSTALL (& PKGPOSTINSTALL?) scripts - maybe by default - maybe an option.

But that brings up the question that may affect the pkg tool: what should happen in a 'pkg install' sense if a pkg preinstall script fails part of the way into its execution?  Should the package install be aborted?  Should the installation bits that have occurred up to that point be rolled back?  Should it just ignore the error (as it seems to now), and if the user doesn't notice a subtle error message (if there is even a message) during the install just live with the [partially?] failed pre-/post-install (& deinstall for that matter)?  Maybe pkg(8) already handles this - I admit I didn't dig there yet.

'set -e' is a big hammer to throw at this issue.  Perhaps too big for a generic solution since this can have unintended consequences to install scripts in various ports (or at least unanticipated when the script was written).  It's probably fine for the create-users-groups script since that is a well controlled script built by the ports infrastructure and a possible early exit anywhere in the script is acceptable and proper if errors occur during execution.

I'll be happy to work out a patch but would like some guidance regarding a possible approach.