pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/pkginstall Use shells(8) from sysutils/etcutils to ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/afd3c05556f0
branches: trunk
changeset: 575268:afd3c05556f0
user: jmmv <jmmv%pkgsrc.org@localhost>
date: Fri May 07 12:00:36 2010 +0000
description:
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:
mk/pkginstall/bsd.pkginstall.mk | 7 ++++++-
mk/pkginstall/shell | 30 +++++++++---------------------
2 files changed, 15 insertions(+), 22 deletions(-)
diffs (109 lines):
diff -r a11c1fe416d4 -r afd3c05556f0 mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk Fri May 07 11:35:45 2010 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk Fri May 07 12:00:36 2010 +0000
@@ -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 @@
#
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 @@
${RM} -f ${.TARGET}; \
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
+.endif
# SHLIB_TYPE
# The type of shared library supported by the platform.
diff -r a11c1fe416d4 -r afd3c05556f0 mk/pkginstall/shell
--- a/mk/pkginstall/shell Fri May 07 11:35:45 2010 +0000
+++ b/mk/pkginstall/shell Fri May 07 12:00:36 2010 +0000
@@ -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 @@
#
# # 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 @@
${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 @@
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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index