diff options
author | jlam <jlam@pkgsrc.org> | 2017-08-10 05:41:52 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2017-08-10 05:41:52 +0000 |
commit | 4b9ae519d0e5a460e90578b24cf7cb44887d50d0 (patch) | |
tree | a82c35322eec92f84bc12d5b3fd9b2cad6e3ae6e /mk | |
parent | dabd7bdc340729b07f1a50d8bef756335f2af14c (diff) | |
download | pkgsrc-4b9ae519d0e5a460e90578b24cf7cb44887d50d0.tar.gz |
mk/pkgtasks: Failures in POST- stages of the scripts are non-fatal.
The return values of the postinstall and postremove meta-tasks are
ignored unless the user-settable variable ${PKG_FATAL_ERRORS} is
"yes". ${PKG_FATAL_ERRORS} defaults to "no" to preserve the
existing behavior of install scripts by mk/pkginstall.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/pkgformat/pkg/templates/deinstall | 16 | ||||
-rw-r--r-- | mk/pkgformat/pkg/templates/header | 3 | ||||
-rw-r--r-- | mk/pkgformat/pkg/templates/install | 17 | ||||
-rw-r--r-- | mk/pkgtasks/bsd.pkgtasks.mk | 11 |
4 files changed, 40 insertions, 7 deletions
diff --git a/mk/pkgformat/pkg/templates/deinstall b/mk/pkgformat/pkg/templates/deinstall index 7fd115c3560..727501c29b9 100644 --- a/mk/pkgformat/pkg/templates/deinstall +++ b/mk/pkgformat/pkg/templates/deinstall @@ -27,7 +27,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $NetBSD: deinstall,v 1.1 2017/06/01 02:09:43 jlam Exp $ +# $NetBSD: deinstall,v 1.2 2017/08/10 05:41:52 jlam Exp $ case ${STAGE} in DEINSTALL) @@ -36,19 +36,29 @@ DEINSTALL) # Use the data in the shell comments appended at the end of # the script. # + # Failures during the "DEINSTALL" stage are fatal since the + # package files likely can't be removed properly if that + # happens. + # task_preremove "${SELF}" || exit $? ;; POST-DEINSTALL) task_load postremove + task_load truthy # Use the data in the shell comments appended at the end of # the script. # # Failures during the POST-DEINSTALL stage are non-fatal, so - # ignore the return value of the "postremove" task. + # ignore the return value of the "postremove" task unless + # ${PKG_FATAL_ERRORS} is truthy. # - task_postremove "${SELF}" + if task_is_truthy "${PKG_FATAL_ERRORS}"; then + task_postremove "${SELF}" || exit $? + else + task_postremove "${SELF}" + fi ;; esac diff --git a/mk/pkgformat/pkg/templates/header b/mk/pkgformat/pkg/templates/header index 6fd517ea8a7..099b0043934 100644 --- a/mk/pkgformat/pkg/templates/header +++ b/mk/pkgformat/pkg/templates/header @@ -29,7 +29,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $NetBSD: header,v 1.5 2017/08/10 05:41:07 jlam Exp $ +# $NetBSD: header,v 1.6 2017/08/10 05:41:52 jlam Exp $ # Package task loader. : ${TASK_MODULE_DIR:=@LOCALBASE@/share/pkgtasks-1} @@ -163,5 +163,6 @@ CURDIR=$( ${PWD_CMD} ) : ${PKG_INIT_SCRIPTS:=@PKG_INIT_SCRIPTS@} : ${PKG_REGISTER_SHELLS:=@PKG_REGISTER_SHELLS@} : ${PKG_UPDATE_FONTS_DB:=@PKG_UPDATE_FONTS_DB@} +: ${PKG_FATAL_ERRORS:=@PKG_FATAL_ERRORS@} ### END: pkgsrc/mk/pkgformat/pkg/templates/header diff --git a/mk/pkgformat/pkg/templates/install b/mk/pkgformat/pkg/templates/install index c7fea9f903b..7021a1558bf 100644 --- a/mk/pkgformat/pkg/templates/install +++ b/mk/pkgformat/pkg/templates/install @@ -27,7 +27,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $NetBSD: install,v 1.1 2017/06/01 02:09:43 jlam Exp $ +# $NetBSD: install,v 1.2 2017/08/10 05:41:52 jlam Exp $ case ${STAGE} in PRE-INSTALL) @@ -36,16 +36,29 @@ PRE-INSTALL) # Use the data in the shell comments appended at the end of # the script. # + # Failures during the "PRE-INSTALL" stage are fatal since the + # package files likely can't be installed properly if that + # happens. + # task_preinstall "${SELF}" || exit $? ;; POST-INSTALL) task_load postinstall + task_load truthy # Use the data in the shell comments appended at the end of # the script. # - task_postinstall "${SELF}" || exit $? + # Failures during the POST-INSTALL stage are non-fatal, so + # ignore the return value of the "postinstall" task unless + # ${PKG_FATAL_ERRORS} is truthy. + # + if task_is_truthy "${PKG_FATAL_ERRORS}"; then + task_postinstall "${SELF}" || exit $? + else + task_postinstall "${SELF}" + fi ;; esac diff --git a/mk/pkgtasks/bsd.pkgtasks.mk b/mk/pkgtasks/bsd.pkgtasks.mk index e577bef8f31..1ef98d720a5 100644 --- a/mk/pkgtasks/bsd.pkgtasks.mk +++ b/mk/pkgtasks/bsd.pkgtasks.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkgtasks.mk,v 1.5 2017/08/10 05:41:07 jlam Exp $ +# $NetBSD: bsd.pkgtasks.mk,v 1.6 2017/08/10 05:41:53 jlam Exp $ # # Copyright (c) 2017 The NetBSD Foundation, Inc. # All rights reserved. @@ -52,6 +52,13 @@ _VARGROUPS+= pkgtasks # Possible: yes, no (case-insensitive) # Default: yes # +# PKG_FATAL_ERRORS +# User-settable variable for whether the return value of the +# {pre,post}{install,remove} meta-tasks is used or not. +# +# Possible: yes, no (case-insensitive) +# Default: no +# # PKG_INIT_SCRIPTS # User-settable variable for whether to copy init scripts into # the appropriate places for the init system to locate them, @@ -81,12 +88,14 @@ _USER_VARS.pkgtasks+= PKG_CONFIG PKG_CONFIG_PERMS PKG_INIT_SCRIPTS PKG_CONFIG?= yes PKG_CONFIG_PERMS?= no PKG_CREATE_USERGROUP?= yes +PKG_FATAL_ERRORS?= no PKG_INIT_SCRIPTS?= ${PKG_RCD_SCRIPTS:Uno} # deprecated PKG_REGISTER_SHELLS?= yes PKG_UPDATE_FONTS_DB?= yes FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG:tl:Q} FILES_SUBST+= PKG_CONFIG_PERMS=${PKG_CONFIG_PERMS:tl:Q} FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP:tl:Q} +FILES_SUBST+= PKG_FATAL_ERRORS=${PKG_FATAL_ERRORS:tl:Q} FILES_SUBST+= PKG_INIT_SCRIPTS=${PKG_INIT_SCRIPTS:tl:Q} FILES_SUBST+= PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS:tl:Q} FILES_SUBST+= PKG_UPDATE_FONTS_DB=${PKG_UPDATE_FONTS_DB:tl:Q} |