diff options
author | jlam <jlam@pkgsrc.org> | 2005-07-29 18:32:17 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2005-07-29 18:32:17 +0000 |
commit | 7f9ad8c688694b59ce8fe49f44c895097f6d57bb (patch) | |
tree | d95985cff341d15fd04e23c8993836a50f19ab9a /mk/install | |
parent | 778ada342d9f6ddb60be87e7a1abf218e057d47b (diff) | |
download | pkgsrc-7f9ad8c688694b59ce8fe49f44c895097f6d57bb.tar.gz |
* Separate out the shell registration into a separately unpacked script
+SHELL.
* Turn PKG_REGISTER_SHELLS into a variable that can be set in the shell
environment so that admins can make a choice when installing from
binary packages.
* PKG_SHELL is now a list of paths, and if the path is relative, then it
is taken to be relative to ${PREFIX}. Convert packages that set
PKG_SHELL to take advantage of this new feature by changing the full
paths to the shells into relative paths.
Diffstat (limited to 'mk/install')
-rw-r--r-- | mk/install/bsd.pkginstall.mk | 52 | ||||
-rw-r--r-- | mk/install/deinstall | 17 | ||||
-rw-r--r-- | mk/install/header | 14 | ||||
-rw-r--r-- | mk/install/install | 18 | ||||
-rw-r--r-- | mk/install/shell | 188 |
5 files changed, 259 insertions, 30 deletions
diff --git a/mk/install/bsd.pkginstall.mk b/mk/install/bsd.pkginstall.mk index 6c811bf8d37..561462eeaa3 100644 --- a/mk/install/bsd.pkginstall.mk +++ b/mk/install/bsd.pkginstall.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkginstall.mk,v 1.3 2005/07/27 04:55:43 jlam Exp $ +# $NetBSD: bsd.pkginstall.mk,v 1.4 2005/07/29 18:32:18 jlam Exp $ # # This Makefile fragment is included by bsd.pkg.mk to use the common # INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply: @@ -399,6 +399,42 @@ ${INSTALL_DIRS_FILE}: ../../mk/install/dirs ) > ${.TARGET}.tmp; \ ${MV} -f ${.TARGET}.tmp ${.TARGET} +# PKG_SHELL contains the pathname of the shell that should be added or +# removed from the shell database, /etc/shells. If the pathname +# is relative, then it is taken to be relative to ${PREFIX}. +# +PKG_SHELL?= # empty + +INSTALL_SHELL_FILE= ${WRKDIR}/.install-shell +INSTALL_UNPACK_TMPL+= ${INSTALL_SHELL_FILE} + +${INSTALL_SHELL_FILE}: ../../mk/install/shell + ${_PKG_SILENT}${_PKG_DEBUG}( \ + eval set -- ${PKG_SHELL} ; \ + ${TEST} $$# -gt 0 || exit 0; \ + ${ECHO} "# start of install-shell"; \ + ${ECHO} "#"; \ + ${ECHO} "# Generate a +SHELL script that handles shell registration."; \ + ${ECHO} "#"; \ + ${ECHO} "case \$${STAGE} in"; \ + ${ECHO} "PRE-INSTALL|UNPACK)"; \ + ${ECHO} " \$${CAT} > ./+SHELL << 'EOF_SHELL'"; \ + ${SED} ${FILES_SUBST_SED} ../../mk/install/shell; \ + ${ECHO} ""; \ + eval set -- ${PKG_SHELL} ; \ + while ${TEST} $$# -gt 0; do \ + i="$$1"; shift; \ + ${ECHO} "# SHELL: $$i"; \ + done; \ + ${ECHO} "EOF_SHELL"; \ + ${ECHO} " \$${CHMOD} +x ./+SHELL"; \ + ${ECHO} " ;;"; \ + ${ECHO} "esac"; \ + ${ECHO} ""; \ + ${ECHO} "# end of install-shell"; \ + ) > ${.TARGET}.tmp; \ + ${MV} -f ${.TARGET}.tmp ${.TARGET} + # PKG_CREATE_USERGROUP indicates whether the INSTALL script should # automatically add any needed users/groups to the system using # useradd/groupadd. It is either YES or NO and defaults to YES. @@ -413,26 +449,20 @@ ${INSTALL_DIRS_FILE}: ../../mk/install/dirs # to ${RCD_SCRIPTS_DIR}. It is either YES or NO and defaults to # NO. This variable only takes effect if ${PKG_CONFIG} == "YES". # +# PKG_REGISTER_SHELLS indicates whether to automatically register shells +# in /etc/shells. It is either YES or NO and defaults to YES. +# # These values merely set the defaults for INSTALL/DEINSTALL scripts, but # they may be overridden by resetting them in the environment. # PKG_CREATE_USERGROUP?= YES PKG_CONFIG?= YES PKG_RCD_SCRIPTS?= NO +PKG_REGISTER_SHELLS?= YES FILES_SUBST+= PKG_CREATE_USERGROUP=${PKG_CREATE_USERGROUP} FILES_SUBST+= PKG_CONFIG=${PKG_CONFIG} FILES_SUBST+= PKG_RCD_SCRIPTS=${PKG_RCD_SCRIPTS} - -# PKG_REGISTER_SHELLS indicates whether to automatically register shells -# in /etc/shells. It is either YES or NO and defaults to YES. -# -# PKG_SHELL contains the full pathname of the shell being installed. -# - -PKG_REGISTER_SHELLS?= YES -PKG_SHELL?= # empty FILES_SUBST+= PKG_REGISTER_SHELLS=${PKG_REGISTER_SHELLS} -FILES_SUBST+= PKG_SHELL=${PKG_SHELL:Q} # Substitute for various programs used in the DEINSTALL/INSTALL scripts and # in the rc.d scripts. diff --git a/mk/install/deinstall b/mk/install/deinstall index 26f51d0b18a..aa492660a65 100644 --- a/mk/install/deinstall +++ b/mk/install/deinstall @@ -1,7 +1,7 @@ # -*- sh -*- # start of deinstall # -# $NetBSD: deinstall,v 1.34 2005/07/27 16:18:54 jlam Exp $ +# $NetBSD: deinstall,v 1.35 2005/07/29 18:32:18 jlam Exp $ case ${STAGE} in VIEW-DEINSTALL) @@ -20,12 +20,15 @@ VIEW-DEINSTALL) esac ;; esac - if [ -n "${PKG_SHELL}" -a "${PKG_REGISTER_SHELLS}" = "YES" ]; then - ${ECHO} "===> Updating /etc/shells" - ${CP} /etc/shells /etc/shells.pkgsrc."$$" - (${GREP} -v "^${PKG_SHELL}" /etc/shells.pkgsrc."$$" || ${TRUE}) > /etc/shells - ${RM} /etc/shells.pkgsrc."$$" - fi + # + # Remove shells from /etc/shells. + # + case ${_PKG_REGISTER_SHELLS} in + YES) ${TEST} ! -x ./+SHELL || + ./+SHELL REMOVE ${PKG_METADATA_DIR} ;; + esac + ${TEST} ! -x ./+SHELL || + ./+SHELL CHECK-REMOVE ${PKG_METADATA_DIR} ;; DEINSTALL) diff --git a/mk/install/header b/mk/install/header index 12cf1600253..fbe8d9ac935 100644 --- a/mk/install/header +++ b/mk/install/header @@ -2,7 +2,7 @@ # # start of header # -# $NetBSD: header,v 1.32 2005/02/02 10:33:01 jlam Exp $ +# $NetBSD: header,v 1.33 2005/07/29 18:32:18 jlam Exp $ PKGNAME=$1 STAGE=$2 @@ -71,9 +71,6 @@ case ${VIEW} in *) PKG_SYSCONFVIEWBASE="${PKG_SYSCONFBASE}/${VIEW}" ;; esac -PKG_REGISTER_SHELLS="@PKG_REGISTER_SHELLS@" -PKG_SHELL="@PKG_SHELL@" - CONF_IGNORE_FILES="*[~#] *.OLD *.orig *,v .pkgsrc */.pkgsrc" PKG_INSTALLATION_TYPE="@PKG_INSTALLATION_TYPE@" @@ -105,4 +102,13 @@ case "${PKG_RCD_SCRIPTS:-@PKG_RCD_SCRIPTS@}" in ;; esac +case "${PKG_REGISTER_SHELLS:-@PKG_REGISTER_SHELLS@}" in +[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + _PKG_REGISTER_SHELLS=YES + ;; +[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + _PKG_REGISTER_SHELLS=NO + ;; +esac + # end of header diff --git a/mk/install/install b/mk/install/install index 6f9a51a5f48..3e37342a9bf 100644 --- a/mk/install/install +++ b/mk/install/install @@ -1,7 +1,7 @@ # -*- sh -*- # start of install # -# $NetBSD: install,v 1.39 2005/07/27 16:18:54 jlam Exp $ +# $NetBSD: install,v 1.40 2005/07/29 18:32:18 jlam Exp $ case ${STAGE} in PRE-INSTALL) @@ -71,14 +71,16 @@ POST-INSTALL) ;; VIEW-INSTALL) - if [ -n "${PKG_SHELL}" -a "${PKG_REGISTER_SHELLS}" = "YES" ]; then - ${ECHO} "===> Updating /etc/shells" - ${TOUCH} /etc/shells - ${CP} /etc/shells /etc/shells.pkgsrc."$$" - (${GREP} -v "^${PKG_SHELL}" /etc/shells.pkgsrc."$$" || ${TRUE}; ${ECHO} ${PKG_SHELL}) > /etc/shells - ${RM} /etc/shells.pkgsrc."$$" - fi # + # Register shells in /etc/shells. + # + case ${_PKG_REGISTER_SHELLS} in + YES) ${TEST} ! -x ./+SHELL || + ./+SHELL ADD ${PKG_METADATA_DIR} ;; + esac + ${TEST} ! -x ./+SHELL || + ./+SHELL CHECK-ADD ${PKG_METADATA_DIR} + # If ${PKG_SYSCONFBASE} points outside of ${PREFIX}, then add the # package config files to the proper view. # diff --git a/mk/install/shell b/mk/install/shell new file mode 100644 index 00000000000..6991cc2e900 --- /dev/null +++ b/mk/install/shell @@ -0,0 +1,188 @@ +#!@SH@ +# +# $NetBSD: shell,v 1.1 2005/07/29 18:32:18 jlam Exp $ +# +# +SHELL - shell registration script +# +# Usage: ./+SHELL ADD|REMOVE [metadatadir] +# ./+SHELL CHECK-ADD|CHECK-REMOVE [metadatadir] +# +# This script supports two actions, ADD and REMOVE, that will add or +# remove shell paths from the shell database in /etc/shells. The +# CHECK-ADD action will check whether shell paths provided by the +# package are missing from the shell database, and print an informative +# message noting those shell paths. The CHECK-REMOVE action will check +# whether shell paths provided by the package are still present in the +# shell database, and print an informative message noting those shell +# paths. The CHECK-ADD and CHECK-REMOVE actions return non-zero if +# they detect either missing or existing paths, respectively. +# +# Lines starting with "# SHELL: " are data read by this script that +# name the shell paths that should be added or removed from the shell +# database. If the path is relative, then it is taken to be relative +# to ${PKG_PREFIX}. +# +# # SHELL: bin/pdksh +# +CAT="@CAT@" +CP="@CP@" +ECHO="@ECHO@" +GREP="@GREP@" +PWD_CMD="@PWD_CMD@" +RM="@RM@" +SED="@SED@" +SORT="@SORT@" +TEST="@TEST@" +TOUCH="@TOUCH@" + +SELF=$0 +ACTION=$1 + +PKG_METADATA_DIR="${2-`${PWD_CMD}`}" +: ${PKG_PREFIX=@PREFIX@} +: ${PKGNAME=${PKG_METADATA_DIR##*/}} + +exitcode=0 +case $ACTION in +ADD) + ${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u | + { while read shell; do + case $shell in + /*) continue ;; + *) shell="${PKG_PREFIX}/$shell" ;; + esac + ${TEST} -f "$shell" || continue + + shelldb="/etc/shells" + if ${TEST} -f "$shelldb" && \ + ${GREP} "^$shell" $shelldb >/dev/null; then + : + else + case "$printed_header" in + yes) ;; + *) printed_header=yes + ${ECHO} "===========================================================================" + ${ECHO} "Adding shells from ${PKGNAME} to $shelldb:" + ${ECHO} "" + ;; + esac + ${ECHO} " $shell" + ${TOUCH} $shelldb + ${CP} $shelldb $shelldb.pkgsrc."$$" + { ${CAT} $shelldb.pkgsrc."$$"; ${ECHO} "$shell"; } > $shelldb + ${RM} $shelldb.pkgsrc."$$" + fi + done + case "$printed_header" in + yes) ${ECHO} "" + ${ECHO} "===========================================================================" + ;; + esac; } + ;; + +REMOVE) + ${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u | + { while read shell; do + case $shell in + /*) continue ;; + *) shell="${PKG_PREFIX}/$shell" ;; + esac + ${TEST} -f "$shell" || continue + + shelldb="/etc/shells" + if ${TEST} -f "$shelldb" && \ + ${GREP} "^$shell" $shelldb >/dev/null; then + case "$printed_header" in + yes) ;; + *) printed_header=yes + ${ECHO} "===========================================================================" + ${ECHO} "Removing shells from ${PKGNAME} to $shelldb:" + ${ECHO} "" + ;; + esac + ${ECHO} " $shell" + ${TOUCH} $shelldb + ${CP} $shelldb $shelldb.pkgsrc."$$" + { ${GREP} -v "^$shell" $shelldb.pkgsrc."$$" || ${TRUE}; } > $shelldb + ${RM} $shelldb.pkgsrc."$$" + fi + done + case "$printed_header" in + yes) ${ECHO} "" + ${ECHO} "===========================================================================" + ;; + esac; } + ;; + +CHECK-ADD) + ${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u | + { while read shell; do + case $shell in + /*) continue ;; + *) shell="${PKG_PREFIX}/$shell" ;; + esac + ${TEST} -f "$shell" || continue + + shelldb="/etc/shells" + if ${TEST} -f "$shelldb" && \ + ${GREP} "^$shell" $shelldb >/dev/null; then + : + else + case "$printed_header" in + yes) ;; + *) printed_header=yes + ${ECHO} "===========================================================================" + ${ECHO} "The following lines can be added to $shelldb:" + ${ECHO} "" + ;; + esac + ${ECHO} " $shell" + fi + done + case "$printed_header" in + yes) ${ECHO} "" + ${ECHO} "===========================================================================" + exit 1 + ;; + esac; } + ${TEST} $? -eq 0 || exitcode=1 + ;; + +CHECK-REMOVE) + ${SED} -n "/^\# SHELL: /{s/^\# SHELL: //;p;}" ${SELF} | ${SORT} -u | + { while read shell; do + case $shell in + /*) continue ;; + *) shell="${PKG_PREFIX}/$shell" ;; + esac + ${TEST} -f "$shell" || continue + + shelldb="/etc/shells" + if ${TEST} -f "$shelldb" && \ + ${GREP} "^$shell" $shelldb >/dev/null; then + case "$printed_header" in + yes) ;; + *) printed_header=yes + ${ECHO} "===========================================================================" + ${ECHO} "The following lines can be removed from $shelldb:" + ${ECHO} "" + ;; + esac + ${ECHO} " $shell" + fi + done + case "$printed_header" in + yes) ${ECHO} "" + ${ECHO} "===========================================================================" + exit 1 + ;; + esac; } + ${TEST} $? -eq 0 || exitcode=1 + ;; + +*) + ${ECHO} "Usage: ./+SHELL ADD|REMOVE [metadatadir]" + ${ECHO} " ./+SHELL CHECK-ADD|CHECK-REMOVE [metadatadir]" + ;; +esac +exit $exitcode |