pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk mk/pkgtasks: Failures in POST- stages of the script...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2ee7ccdf501e
branches:  trunk
changeset: 366291:2ee7ccdf501e
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Thu Aug 10 05:41:52 2017 +0000

description:
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:

 mk/pkgformat/pkg/templates/deinstall |  16 +++++++++++++---
 mk/pkgformat/pkg/templates/header    |   3 ++-
 mk/pkgformat/pkg/templates/install   |  17 +++++++++++++++--
 mk/pkgtasks/bsd.pkgtasks.mk          |  11 ++++++++++-
 4 files changed, 40 insertions(+), 7 deletions(-)

diffs (144 lines):

diff -r 3e327ec50085 -r 2ee7ccdf501e mk/pkgformat/pkg/templates/deinstall
--- a/mk/pkgformat/pkg/templates/deinstall      Thu Aug 10 05:41:23 2017 +0000
+++ b/mk/pkgformat/pkg/templates/deinstall      Thu Aug 10 05:41:52 2017 +0000
@@ -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 @@
        # 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 -r 3e327ec50085 -r 2ee7ccdf501e mk/pkgformat/pkg/templates/header
--- a/mk/pkgformat/pkg/templates/header Thu Aug 10 05:41:23 2017 +0000
+++ b/mk/pkgformat/pkg/templates/header Thu Aug 10 05:41:52 2017 +0000
@@ -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 @@
 : ${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 -r 3e327ec50085 -r 2ee7ccdf501e mk/pkgformat/pkg/templates/install
--- a/mk/pkgformat/pkg/templates/install        Thu Aug 10 05:41:23 2017 +0000
+++ b/mk/pkgformat/pkg/templates/install        Thu Aug 10 05:41:52 2017 +0000
@@ -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 @@
        # 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 -r 3e327ec50085 -r 2ee7ccdf501e mk/pkgtasks/bsd.pkgtasks.mk
--- a/mk/pkgtasks/bsd.pkgtasks.mk       Thu Aug 10 05:41:23 2017 +0000
+++ b/mk/pkgtasks/bsd.pkgtasks.mk       Thu Aug 10 05:41:52 2017 +0000
@@ -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 @@
 #      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 @@
 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}



Home | Main Index | Thread Index | Old Index