diff options
author | jmmv <jmmv@pkgsrc.org> | 2010-05-07 12:00:36 +0000 |
---|---|---|
committer | jmmv <jmmv@pkgsrc.org> | 2010-05-07 12:00:36 +0000 |
commit | 1b8b180443237e0ab8be4b9bcb4c3d7879c86500 (patch) | |
tree | 6629f9367aca3f2bd71667ebd7c48ef852af0d2e /mk/pkginstall | |
parent | 421614da97e766e47baece3d310d7ee3dd92dc9b (diff) | |
download | pkgsrc-1b8b180443237e0ab8be4b9bcb4c3d7879c86500.tar.gz |
Use shells(8) from sysutils/etcutils to update /etc/shells instead of
hardcoding the logic into the pkginstall scripts. As discussed in
tech-pkg@.
Note: The current pkginstall/shell code is overly complicated. It looks
like it can be simplified but, at the moment, given that I do not understand
the need for such complexity, I'm just doing this tiny change.
Note 2: The ability to update /etc/services, which was also discussed, will
come later once this change proves to be stable.
Diffstat (limited to 'mk/pkginstall')
-rw-r--r-- | mk/pkginstall/bsd.pkginstall.mk | 7 | ||||
-rw-r--r-- | mk/pkginstall/shell | 30 |
2 files changed, 15 insertions, 22 deletions
diff --git a/mk/pkginstall/bsd.pkginstall.mk b/mk/pkginstall/bsd.pkginstall.mk index f0b9a98183c..7fd31a52c72 100644 --- a/mk/pkginstall/bsd.pkginstall.mk +++ b/mk/pkginstall/bsd.pkginstall.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkginstall.mk,v 1.47 2010/03/10 15:01:42 rillig Exp $ +# $NetBSD: bsd.pkginstall.mk,v 1.48 2010/05/07 12:00:36 jmmv Exp $ # # This Makefile fragment is included by bsd.pkg.mk and implements the # common INSTALL/DEINSTALL scripts framework. To use the pkginstall @@ -762,6 +762,10 @@ install-script-data-info-files: # PKG_SHELL?= # empty +.if !empty(PKG_SHELL) +DEPENDS+= etcutils>=0.1:../../sysutils/etcutils +FILES_SUBST+= SHELLS=${PREFIX:Q}/sbin/shells + _INSTALL_SHELL_FILE= ${_PKGINSTALL_DIR}/shell _INSTALL_SHELL_DATAFILE= ${_PKGINSTALL_DIR}/shell-data _INSTALL_UNPACK_TMPL+= ${_INSTALL_SHELL_FILE} @@ -788,6 +792,7 @@ ${_INSTALL_SHELL_FILE}: ../../mk/pkginstall/shell ${RM} -f ${.TARGET}; \ ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \ fi +.endif # SHLIB_TYPE # The type of shared library supported by the platform. diff --git a/mk/pkginstall/shell b/mk/pkginstall/shell index b46b07ffdb1..ba9fd79dd2b 100644 --- a/mk/pkginstall/shell +++ b/mk/pkginstall/shell @@ -1,4 +1,4 @@ -# $NetBSD: shell,v 1.4 2007/07/12 19:41:46 jlam Exp $ +# $NetBSD: shell,v 1.5 2010/05/07 12:00:36 jmmv Exp $ # # Generate a +SHELL script that handles shell registration for the package. # @@ -29,17 +29,12 @@ UNPACK,|UNPACK,+SHELL) # # # SHELL: bin/pdksh # -CAT="@CAT@" -CP="@CP@" ECHO="@ECHO@" -GREP="@GREP@" PWD_CMD="@PWD_CMD@" -RM="@RM@" SED="@SED@" +SHELLS="@SHELLS@" SORT="@SORT@" TEST="@TEST@" -TRUE="@TRUE@" -TOUCH="@TOUCH@" SELF=$0 ACTION=$1 @@ -77,16 +72,12 @@ ADD) ${TEST} -f "$shell" || continue shelldb="/etc/shells" - ${TEST} -f "$shelldb" || continue - if ${TEST} -f "$shelldb" && \ - ${GREP} "^$shell" $shelldb >/dev/null; then + if ${TEST} -f ${shelldb} && \ + ${SHELLS} -K ${shelldb} check ${shell}; then : else ${ECHO} "${PKGNAME}: adding $shell to $shelldb" - ${TOUCH} $shelldb - ${CP} $shelldb $shelldb.pkgsrc."$$" - { ${CAT} $shelldb.pkgsrc."$$"; ${ECHO} "$shell"; } > $shelldb - ${RM} $shelldb.pkgsrc."$$" + ${SHELLS} -K ${shelldb} add ${shell} fi done ;; @@ -109,12 +100,9 @@ REMOVE) shelldb="/etc/shells" if ${TEST} -f "$shelldb" && \ - ${GREP} "^$shell" $shelldb >/dev/null; then + ${SHELLS} -K ${shelldb} check ${shell}; then ${ECHO} "${PKGNAME}: removing $shell from $shelldb" - ${TOUCH} $shelldb - ${CP} $shelldb $shelldb.pkgsrc."$$" - { ${GREP} -v "^$shell" $shelldb.pkgsrc."$$" || ${TRUE}; } > $shelldb - ${RM} $shelldb.pkgsrc."$$" + ${SHELLS} -K ${shelldb} remove ${shell} fi done ;; @@ -134,7 +122,7 @@ CHECK-ADD) shelldb="/etc/shells" if ${TEST} -f "$shelldb" && \ - ${GREP} "^$shell" $shelldb >/dev/null; then + ${SHELLS} -K ${shelldb} check ${shell}; then : else case "$printed_header" in @@ -172,7 +160,7 @@ CHECK-REMOVE) shelldb="/etc/shells" if ${TEST} -f "$shelldb" && \ - ${GREP} "^$shell" $shelldb >/dev/null; then + ${SHELLS} -K ${shelldb} check ${shell}; then case "$printed_header" in yes) ;; *) printed_header=yes |