pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk Continue with install script cleanup -- we now crea...
details: https://anonhg.NetBSD.org/pkgsrc/rev/3e836308564d
branches: trunk
changeset: 488331:3e836308564d
user: jlam <jlam%pkgsrc.org@localhost>
date: Fri Jan 28 07:37:55 2005 +0000
description:
Continue with install script cleanup -- we now create a +USERGROUP
script that is unpacked by the +INSTALL script at PRE-INSTALL time
before any other actions take place, and invoke +USERGROUP to create
any necessary users and groups. Remove the now-unused code for
PKG_USERS and PKG_GROUPS from the install and deinstall templates.
We also reference count the users and groups and store the reference
counts in ${PKG_DBDIR}/.refcount/{users,groups}. This allows multiple
packages to register that they use same users and groups, and allows
+USERGROUP to be invoked at any time to repair an installed package.
Also fix the install and deinstall templates to invoke the CHECK-*
actions with ${PKG_METADATA_DIR} so that the correct PKGNAME can be
derived. This fixes the weird messages asking the user to create
directories for ".pkgdb" during a "make install".
diffstat:
mk/bsd.pkg.install.mk | 41 +++++-
mk/install/deinstall | 53 +------
mk/install/header | 7 +-
mk/install/install | 112 +-------------
mk/install/usergroup | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 419 insertions(+), 153 deletions(-)
diffs (truncated from 674 to 300 lines):
diff -r 1d3652432ea9 -r 3e836308564d mk/bsd.pkg.install.mk
--- a/mk/bsd.pkg.install.mk Fri Jan 28 06:30:58 2005 +0000
+++ b/mk/bsd.pkg.install.mk Fri Jan 28 07:37:55 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.install.mk,v 1.73 2005/01/28 06:30:58 jlam Exp $
+# $NetBSD: bsd.pkg.install.mk,v 1.74 2005/01/28 07:37:55 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk to use the common
# INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply:
@@ -104,14 +104,12 @@
#
# Only the group is required; the groupid is optional.
#
+PKG_GROUPS?= # empty
PKG_USERS?= # empty
_PKG_USER_HOME?= /nonexistent
_PKG_USER_SHELL?= ${NOLOGIN}
-PKG_GROUPS?= # empty
-FILES_SUBST+= PKG_USERS=${PKG_USERS:Q}
FILES_SUBST+= PKG_USER_HOME=${_PKG_USER_HOME}
FILES_SUBST+= PKG_USER_SHELL=${_PKG_USER_SHELL}
-FILES_SUBST+= PKG_GROUPS=${PKG_GROUPS:Q}
# Interix is very Special in that users are groups cannot have the
# same name. Interix.mk tries to work around this by overriding
@@ -131,6 +129,41 @@
DEPENDS+= ${_USER_DEPENDS}
.endif
+INSTALL_USERGROUP_FILE= ${WRKDIR}/.install-usergroup
+INSTALL_UNPACK_TMPL+= ${INSTALL_USERGROUP_FILE}
+
+${INSTALL_USERGROUP_FILE}: ../../mk/install/usergroup
+ ${_PKG_SILENT}${_PKG_DEBUG}{ \
+ ${ECHO} "# start of install-usergroup"; \
+ ${ECHO} "#"; \
+ ${ECHO} "# Generate a +USERGROUP script that reference counts users"; \
+ ${ECHO} "# and groups that are required for the proper functioning"; \
+ ${ECHO} "# of the package."; \
+ ${ECHO} "#"; \
+ ${ECHO} "case \$${STAGE} in"; \
+ ${ECHO} "PRE-INSTALL)"; \
+ ${ECHO} " \$${CAT} > ./+USERGROUP << 'EOF_USERGROUP'"; \
+ ${SED} ${FILES_SUBST_SED} ../../mk/install/usergroup; \
+ ${ECHO} ""; \
+ eval set -- ${PKG_GROUPS} ; \
+ while ${TEST} $$# -gt 0; do \
+ i="$$1"; shift; \
+ ${ECHO} "# GROUP: $$i"; \
+ done; \
+ eval set -- ${PKG_USERS} ; \
+ while ${TEST} $$# -gt 0; do \
+ i="$$1"; shift; \
+ ${ECHO} "# USER: $$i"; \
+ done; \
+ ${ECHO} "EOF_USERGROUP"; \
+ ${ECHO} " \$${CHMOD} +x ./+USERGROUP"; \
+ ${ECHO} " ;;"; \
+ ${ECHO} "esac"; \
+ ${ECHO} ""; \
+ ${ECHO} "# end of install-usergroup"; \
+ } > ${.TARGET}.tmp; \
+ ${MV} -f ${.TARGET}.tmp ${.TARGET}
+
# SPECIAL_PERMS are lists that look like:
# file user group mode
# At post-install time, file (it may be a directory) is changed to be
diff -r 1d3652432ea9 -r 3e836308564d mk/install/deinstall
--- a/mk/install/deinstall Fri Jan 28 06:30:58 2005 +0000
+++ b/mk/install/deinstall Fri Jan 28 07:37:55 2005 +0000
@@ -1,25 +1,6 @@
# start of deinstall
#
-# $NetBSD: deinstall,v 1.30 2005/01/28 06:30:59 jlam Exp $
-
-eval set -- ${PKG_USERS}
-for userset; do
- user=`
- IFS=":"
- set -- ${userset}
- ${ECHO} "$1"
- `
- ALL_USERS="${ALL_USERS} \"${user}\""
-done
-eval set -- ${PKG_GROUPS}
-for groupset; do
- group=`
- IFS=":"
- set -- ${groupset}
- ${ECHO} "$1"
- `
- ALL_GROUPS="${ALL_GROUPS} \"${group}\""
-done
+# $NetBSD: deinstall,v 1.31 2005/01/28 07:37:55 jlam Exp $
eval set -- ${CONF_FILES} ${SUPPORT_FILES}
while [ $# -gt 0 ]; do
@@ -115,35 +96,15 @@
case ${_PKG_CONFIG} in
YES) ${TEST} -x ./+DIRS && ./+DIRS REMOVE ${PKG_METADATA_DIR} ;;
esac
+ case ${_PKG_CREATE_USERGROUP} in
+ YES) ${TEST} -x ./+USERGROUP && ./+USERGROUP REMOVE ${PKG_METADATA_DIR} ;;
+ esac
- if [ -n "${ALL_USERS}" -o -n "${ALL_GROUPS}" -o \
- -n "${modified_files}" -o -n "${existing_dirs}" ]; then
+ if [ -n "${modified_files}" ]; then
${CAT} << EOF
===========================================================================
If you won't be using ${PKGNAME} any longer, you may want to remove
EOF
- if [ -n "${ALL_USERS}" ]; then
- ${ECHO} ""
- allusersmsg=" * the following users"
- sep=": "
- eval set -- ${ALL_USERS}
- for user; do
- allusersmsg="${allusersmsg}${sep}${user}"
- sep=", "
- done
- ${ECHO} "${allusersmsg}"
- fi
- if [ -n "${ALL_GROUPS}" ]; then
- ${ECHO} ""
- allgroupsmsg=" * the following groups"
- sep=": "
- eval set -- ${ALL_GROUPS}
- for group; do
- allgroupsmsg="${allgroupsmsg}${sep}${group}"
- sep=", "
- done
- ${ECHO} "${allgroupsmsg}"
- fi
if [ -n "${modified_files}" ]; then
${CAT} << EOF
@@ -166,7 +127,9 @@
===========================================================================
EOF
fi
- ${TEST} -x ./+DIRS && ./+DIRS CHECK-REMOVE
+
+ ${TEST} -x ./+USERGROUP && ./+USERGROUP CHECK-REMOVE ${PKG_METADATA_DIR}
+ ${TEST} -x ./+DIRS && ./+DIRS CHECK-REMOVE ${PKG_METADATA_DIR}
;;
esac
diff -r 1d3652432ea9 -r 3e836308564d mk/install/header
--- a/mk/install/header Fri Jan 28 06:30:58 2005 +0000
+++ b/mk/install/header Fri Jan 28 07:37:55 2005 +0000
@@ -2,7 +2,7 @@
#
# start of header
#
-# $NetBSD: header,v 1.28 2005/01/28 06:30:59 jlam Exp $
+# $NetBSD: header,v 1.29 2005/01/28 07:37:55 jlam Exp $
PKGNAME=$1
STAGE=$2
@@ -62,9 +62,6 @@
*) VIEW="" ;;
esac
-PKG_USERS="@PKG_USERS@"
-PKG_GROUPS="@PKG_GROUPS@"
-
SPECIAL_PERMS="@SPECIAL_PERMS@"
CONF_FILES="@CONF_FILES@"
@@ -90,8 +87,6 @@
PKG_REGISTER_SHELLS="@PKG_REGISTER_SHELLS@"
PKG_SHELL="@PKG_SHELL@"
-ALL_USERS=
-ALL_GROUPS=
ALL_FILES=
VIEW_FILES=
diff -r 1d3652432ea9 -r 3e836308564d mk/install/install
--- a/mk/install/install Fri Jan 28 06:30:58 2005 +0000
+++ b/mk/install/install Fri Jan 28 07:37:55 2005 +0000
@@ -1,106 +1,22 @@
# start of install
#
-# $NetBSD: install,v 1.34 2005/01/28 06:30:59 jlam Exp $
+# $NetBSD: install,v 1.35 2005/01/28 07:37:55 jlam Exp $
case ${STAGE} in
PRE-INSTALL)
- msginit
- _pkg_exit=0
- if [ -n "${PKG_GROUPS}" ]; then
- _print_group_header=1
- eval set -- ${PKG_GROUPS}
- for groupset; do
- save_IFS="${IFS}"; IFS=":"
- set -- ${groupset}
- group="$1"; groupid="$2"
- IFS="${save_IFS}"
-
- # We need to check that ${PKG_GROUP} exists before
- # adding the user. Do it with chgrp to be able to
- # use NIS.
- #
- ${TOUCH} /tmp/grouptest.$$
- if ${CHGRP} ${group} /tmp/grouptest.$$ >/dev/null 2>&1; then
- ${ECHO} "Group '${group}' already exists."
- elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
- if [ ${_print_group_header} -gt 0 ]; then
- _print_group_header=0
- msgadd ""
- msgadd "The following groups need to be created for ${PKGNAME}:"
- msgadd ""
- fi
- if [ -z "${groupid}" ]; then
- groupid_str=
- else
- groupid_str=" (${groupid})"
- fi
- msgadd "#${group}${groupid_str}"
- _pkg_exit=1
- else
- groupid_option=
- if [ -n "${groupid}" ]; then
- groupid_option="-g"
- fi
- ${ECHO} "Creating group: ${group}"
- ${GROUPADD} ${groupid_option} ${groupid} "${group}"
- fi
- ${RM} -f /tmp/grouptest.$$
- done
+ #
+ # Require that necessary users and groups exist or else fail the
+ # installation of the package.
+ #
+ case ${_PKG_CREATE_USERGROUP} in
+ YES) ${TEST} -x ./+USERGROUP && ./+USERGROUP ADD ${PKG_METADATA_DIR} ;;
+ esac
+ if ${TEST} -x ./+USERGROUP && ./+USERGROUP CHECK-ADD ${PKG_METADATA_DIR}; then
+ :
+ else
+ exit 1
fi
- if [ -n "${PKG_USERS}" ]; then
- _print_user_header=1
- eval set -- ${PKG_USERS}
- for userset; do
- save_IFS="${IFS}"; IFS=":"
- set -- ${userset}
- user="$1"; group="$2"; userid="$3"
- descr="${4:-${PKGBASE} ${user} user}"
- home="${5:-@PKG_USER_HOME@}"
- shell="${6:-@PKG_USER_SHELL@}"
- IFS="${save_IFS}"
-
- # Use `id' to be able to use NIS.
- if ${ID} "${user}" >/dev/null 2>&1; then
- ${ECHO} "User '${user}' already exists."
- elif [ "${_PKG_CREATE_USERGROUP}" = "NO" ]; then
- if [ ${_print_user_header} -gt 0 ]; then
- _print_user_header=0
- msgadd ""
- msgadd "The following users need to be created for ${PKGNAME}:"
- msgadd ""
- fi
- if [ -z "${userid}" ]; then
- userid_str=
- else
- userid_str=" (${userid})"
- fi
- msgadd "#${user}${userid_str}: ${group}, ${home}, ${shell}"
- _pkg_exit=1
- else
- userid_option=
- if [ -n "${userid}" ]; then
- userid_option="-u"
- fi
- ${ECHO} "Creating user: ${user}"
- ${USERADD} -c "${descr}" \
- ${userid_option} ${userid} \
- -g "${group}" \
- -d "${home}" \
- -s "${shell}" \
- "${user}"
- fi
- done
- fi
- if ! msgempty; then
- ${ECHO} "==========================================================================="
- msgprint
- ${ECHO} ""
- ${ECHO} "==========================================================================="
- fi
- if [ ${_pkg_exit} -gt 0 ]; then
- exit ${_pkg_exit}
- fi
-
+ #
# Create package directories at pre-install time.
Home |
Main Index |
Thread Index |
Old Index