pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/pkginstall Print an understandable error message if...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/85a542668342
branches:  trunk
changeset: 536226:85a542668342
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Dec 06 22:03:22 2007 +0000

description:
Print an understandable error message if the number of arguments for
CONF_FILES, CONF_FILES_PERMS, REQD_FILES, REQD_FILES_PERMS is wrong.

NB: The code doesn't read like "shift 5 || error_out" since NetBSD's
shell exits if a shift fails in this case, instead of just reporting an
error.

Fixes PR 37489.

I didn't fix the code in pkglint (which was suggested in the PR) since
it seems too complicated to me. There is no support for a
"MultipleShellWords" data type by now, and pkglint would have to know
that SETUID_ROOT_PERMS is of type "ThreeShellWords: Username, Groupname,
Filemode". That's too much work and doesn't look nicely.

diffstat:

 mk/pkginstall/bsd.pkginstall.mk |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (43 lines):

diff -r 1afd623b4889 -r 85a542668342 mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk   Thu Dec 06 22:03:10 2007 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk   Thu Dec 06 22:03:22 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.36 2007/11/23 11:50:19 rillig Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.37 2007/12/06 22:03:22 rillig Exp $
 #
 # This Makefile fragment is included by bsd.pkg.mk and implements the
 # common INSTALL/DEINSTALL scripts framework.  To use the pkginstall
@@ -418,6 +418,7 @@
        ${RUN} p="${DESTDIR}${PREFIX}";                                 \
        ${_FUNC_STRIP_PREFIX};                                          \
        canon() { f=`strip_prefix "$$1"`; case $$f in [!/]*) f="$$p/$$f"; esac; echo "$$f"; }; \
+       needargs() { [ $$3 -ge $$2 ] || ${FAIL_MSG} "[bsd.pkginstall.mk] $$1 must have a multiple of $$2 words. Rest: $$4"; }; \
        set args ${RCD_SCRIPTS}; shift;                                 \
        while [ $$# -gt 0 ]; do                                         \
                egfile=`canon "${RCD_SCRIPTS_EXAMPLEDIR}/$$1"`; shift;  \
@@ -425,21 +426,25 @@
        done;                                                           \
        set args ${CONF_FILES}; shift;                                  \
        while [ $$# -gt 0 ]; do                                         \
+               needargs CONF_FILES 2 $$# "$$*";                        \
                egfile=`canon "$$1"`; shift 2;                          \
                [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILE $$egfile does not exist."; \
        done;                                                           \
        set args ${REQD_FILES}; shift;                                  \
        while [ $$# -gt 0 ]; do                                         \
+               needargs REDQ_FILES 2 $$# "$$*";                        \
                egfile=`canon "$$1"`; shift 2;                          \
                [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILE $$egfile does not exist."; \
        done;                                                           \
        set args ${CONF_FILES_PERMS}; shift;                            \
        while [ $$# -gt 0 ]; do                                         \
+               needargs CONF_FILES_PERMS 5 $$# "$$*";                  \
                egfile=`canon "$$1"`; shift 5;                          \
                [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "CONF_FILES_PERMS $$egfile does not exist."; \
        done;                                                           \
        set args ${REQD_FILES_PERMS}; shift;                            \
        while [ $$# -gt 0 ]; do                                         \
+               needargs REQD_FILES_PERMS 5 $$# "$$*";                  \
                egfile=`canon "$$1"`; shift 5;                          \
                [ -f "$$egfile" ] || [ -c "$$egfile" ] || ${FAIL_MSG} "REQD_FILES_PERMS $$egfile does not exist."; \
        done



Home | Main Index | Thread Index | Old Index