summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2001-11-26 20:37:38 +0000
committerjlam <jlam@pkgsrc.org>2001-11-26 20:37:38 +0000
commit22d02d6b3ee441bb598f813d6f7a5421dca6335f (patch)
tree14c0d9f381d74ca492c950829a9e8cced859770c /mk
parent4353c85a3caedb327da560d18f335992fe6b6591 (diff)
downloadpkgsrc-22d02d6b3ee441bb598f813d6f7a5421dca6335f.tar.gz
Replace PKG_{USER,GROUP} with PKG_USERS and PKG_GROUPS:
PKG_USERS represents the users to create for the package. It is a space-separated list of elements of the form user:group[:[userid][:[descr][:[home][:shell]]]] Only the user and group are required; everything else is optional, but the colons must be in the right places when specifying optional bits. Note that if the description contains spaces, then spaces should be double backslash-escaped, e.g. foo:foogrp::The\\ Foomister PKG_GROUPS represents the groups to create for the package. It is a space-separated list of elements of the form group[:groupid] Only the group is required; the groupid is optional. This solves the problem of what to do when there is more than one user or group needed for a package, e.g. qmail. Also add a bit more error-checking to the INSTALL/DEINSTALL scripts.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.install.mk64
-rw-r--r--mk/install/deinstall67
-rw-r--r--mk/install/header12
-rw-r--r--mk/install/install147
4 files changed, 177 insertions, 113 deletions
diff --git a/mk/bsd.pkg.install.mk b/mk/bsd.pkg.install.mk
index a8a3e877439..cc0f1a2fe6d 100644
--- a/mk/bsd.pkg.install.mk
+++ b/mk/bsd.pkg.install.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.install.mk,v 1.6 2001/11/25 18:59:50 jlam Exp $
+# $NetBSD: bsd.pkg.install.mk,v 1.7 2001/11/26 20:37:38 jlam Exp $
#
# This Makefile fragment is included by package Makefiles to use the common
# INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply:
@@ -51,42 +51,40 @@ FILES_SUBST+= PREFIX=${PREFIX}
FILES_SUBST+= LOCALBASE=${LOCALBASE}
FILES_SUBST+= X11BASE=${X11BASE}
FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
+FILES_SUBST+= PKGBASE=${PKGBASE}
-# PKG_USER and PKG_GROUP are the user and group that need to be created
-# before this package is installed.
-#
-# PKG_USERID and PKG_GROUPID are the numeric IDs used in creating the user
-# and group. If they're blank, then the default values chosen by the
-# system is used.
-#
-# PKG_USER_DESCR is the description of the user to add to the system. It
-# defaults to "foo user" for package "foo".
-#
-# PKG_USER_HOME is the home directory of the user to add to the system. It
-# defaults to "/".
-#
-# PKG_USER_SHELL is the login shell for the user. For system security
-# purposes, it defaults to "${NOLOGIN}".
-#
-PKG_USER?= # empty
-PKG_USERID?= # empty
-PKG_USER_DESCR?= ${PKGBASE} user
-PKG_USER_HOME?= /
-PKG_USER_SHELL?= ${NOLOGIN}
-PKG_GROUP?= # empty
-PKG_GROUPID?= # empty
-FILES_SUBST+= PKG_USER=${PKG_USER}
-FILES_SUBST+= PKG_USERID=${PKG_USERID}
-FILES_SUBST+= PKG_USER_DESCR=${PKG_USER_DESCR:Q}
-FILES_SUBST+= PKG_USER_HOME=${PKG_USER_HOME}
-FILES_SUBST+= PKG_USER_SHELL=${PKG_USER_SHELL}
-FILES_SUBST+= PKG_GROUP=${PKG_GROUP}
-FILES_SUBST+= PKG_GROUPID=${PKG_GROUPID}
+# PKG_USERS represents the users to create for the package. It is a
+# space-separated list of elements of the form
+#
+# user:group[:[userid][:[descr][:[home][:shell]]]]
+#
+# Only the user and group are required; everything else is optional,
+# but the colons must be in the right places when specifying optional
+# bits. Note that if the description contains spaces, then spaces
+# should be double backslash-escaped, e.g.
+#
+# foo:foogrp::The\\ Foomister
+#
+# PKG_GROUPS represents the groups to create for the package. It is a
+# space-separated list of elements of the form
+#
+# group[:groupid]
+#
+# Only the group is required; the groupid is optional.
+#
+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}
-.if !empty(PKG_USER)
+.if !empty(PKG_USERS)
USE_USERADD= YES
.endif
-.if !empty(PKG_GROUP)
+.if !empty(PKG_GROUPS)
USE_USERGROUP= YES
.endif
diff --git a/mk/install/deinstall b/mk/install/deinstall
index 2a67aa13128..d022f432a51 100644
--- a/mk/install/deinstall
+++ b/mk/install/deinstall
@@ -1,6 +1,27 @@
# start of deinstall
#
-# $NetBSD: deinstall,v 1.7 2001/11/26 14:48:53 jlam Exp $
+# $NetBSD: deinstall,v 1.8 2001/11/26 20:37:39 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
eval set -- ${CONF_FILES} ${SUPPORT_FILES}
for file
@@ -48,11 +69,11 @@ do
ALL_DIRS="${ALL_DIRS} \"${dir}\""
done
ALL_DIRS=`
- ( eval set -- ${ALL_DIRS}
- for dir
- do
- ${ECHO} "\"${dir}\""
- done
+ ( eval set -- ${ALL_DIRS}
+ for dir
+ do
+ ${ECHO} "\"${dir}\""
+ done
) | ${SORT} -r
`
@@ -117,26 +138,38 @@ POST-DEINSTALL)
fi
done
- if [ -n "${PKG_USER}" -o -n "${PKG_GROUP}" -o \
+ if [ -n "${ALL_USERS}" -o -n "${ALL_GROUPS}" -o \
-n "${modified_files}" -o -n "${existing_dirs}" ]
then
${CAT} << EOF
===========================================================================
If you won't be using ${PKGNAME} any longer, you may want to remove
EOF
- if [ -n "${PKG_USER}" ]
+ if [ -n "${ALL_USERS}" ]
then
- ${CAT} << EOF
-
- * the \`${PKG_USER}' user
-EOF
+ ${ECHO} ""
+ ${ECHO} -n " * the following users"
+ sep=": "
+ eval set -- ${ALL_USERS}
+ for user
+ do
+ ${ECHO} -n "${sep}${user}"
+ sep=", "
+ done
+ ${ECHO} ""
fi
- if [ -n "${PKG_GROUP}" ]
+ if [ -n "${ALL_GROUPS}" ]
then
- ${CAT} << EOF
-
- * the \`${PKG_GROUP}' group
-EOF
+ ${ECHO} ""
+ ${ECHO} -n " * the following groups"
+ sep=": "
+ eval set -- ${ALL_GROUPS}
+ for group
+ do
+ ${ECHO} -n "${sep}${group}"
+ sep=", "
+ done
+ ${ECHO} ""
fi
if [ -n "${modified_files}" ]
then
diff --git a/mk/install/header b/mk/install/header
index 7fd862b4823..f9f99143db7 100644
--- a/mk/install/header
+++ b/mk/install/header
@@ -2,7 +2,7 @@
#
# start of header
#
-# $NetBSD: header,v 1.5 2001/11/25 21:16:30 jlam Exp $
+# $NetBSD: header,v 1.6 2001/11/26 20:37:39 jlam Exp $
PKGNAME=$1
STAGE=$2
@@ -33,10 +33,10 @@ TR="@TR@"
TRUE="@TRUE@"
USERADD="@USERADD@"
-PKG_USER="@PKG_USER@"
-PKG_USERID="@PKG_USERID@"
-PKG_GROUP="@PKG_GROUP@"
-PKG_GROUPID="@PKG_GROUPID@"
+PKGBASE="@PKGBASE@"
+
+PKG_USERS="@PKG_USERS@"
+PKG_GROUPS="@PKG_GROUPS@"
CONF_FILES="@CONF_FILES@"
CONF_FILES_PERMS="@CONF_FILES_PERMS@"
@@ -50,6 +50,8 @@ MAKE_DIRS_PERMS="@MAKE_DIRS_PERMS@"
OWN_DIRS="@OWN_DIRS@"
OWN_DIRS_PERMS="@OWN_DIRS_PERMS@"
+ALL_USERS=
+ALL_GROUPS=
ALL_FILES=
ALL_MAKE_DIRS=
ALL_DIRS=
diff --git a/mk/install/install b/mk/install/install
index b285c04ec16..dc9f68f954e 100644
--- a/mk/install/install
+++ b/mk/install/install
@@ -1,54 +1,72 @@
# start of install
#
-# $NetBSD: install,v 1.4 2001/11/26 14:48:53 jlam Exp $
+# $NetBSD: install,v 1.5 2001/11/26 20:37:39 jlam Exp $
case ${STAGE} in
PRE-INSTALL)
- if [ -n "${PKG_GROUP}" ]
+ if [ -n "${PKG_GROUPS}" ]
then
- # 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.$$
- ${CHGRP} ${PKG_GROUP} /tmp/grouptest.$$ >/dev/null 2>&1
- if [ $? -eq 0 ]
- then
- ${ECHO} "Group '${PKG_GROUP}' already exists."
- else
- groupid_option=
- if [ -n "${PKG_GROUPID}" ]
- then
- groupid_option="-g ${PKG_GROUPID}"
- fi
- ${ECHO} "Creating '${PKG_GROUP}' group..."
- ${GROUPADD} ${groupid_option} "${PKG_GROUP}"
- ${ECHO} "Done."
- fi
- ${RM} -f /tmp/grouptest.$$
+ eval set -- ${PKG_GROUPS}
+ for groupset
+ do
+ ( IFS=":"
+ set -- ${groupset}
+ group="$1"; groupid="$2"
+
+ # 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."
+ else
+ groupid_option=
+ if [ -n "${groupid}" ]
+ then
+ groupid_option="-g ${groupid}"
+ fi
+ ${ECHO} "Creating group: ${group}"
+ ${GROUPADD} ${groupid_option} "${group}"
+ fi
+ ${RM} -f /tmp/grouptest.$$
+ )
+ done
fi
- if [ -n "${PKG_USER}" -a -n "${PKG_GROUP}" ]
+ if [ -n "${PKG_USERS}" ]
then
- # Use `id' to be able to use NIS.
- ${ID} ${PKG_USER} >/dev/null 2>&1
- if [ $? -eq 0 ]
- then
- ${ECHO} "User '${PKG_USER}' already exists."
- else
- userid_option=
- if [ -n "${PKG_USERID}" ]
- then
- userid_option="-u ${PKG_USERID}"
- fi
- ${ECHO} "Creating '${PKG_USER}' user..."
- ${USERADD} -c "@PKG_USER_DESCR@" \
- ${userid_option} \
- -g "${PKG_GROUP}" \
- -d "@PKG_USER_HOME@" \
- -s "@PKG_USER_SHELL@" \
- "${PKG_USER}"
- ${ECHO} "Done."
- fi
+ eval set -- ${PKG_USERS}
+ for userset
+ do
+ ( IFS=":"
+ set -- ${userset}
+ user="$1"; group="$2"; userid="$3"
+ descr="${4:-${PKGBASE} ${user} user}"
+ home="${5:-@PKG_USER_HOME@}"
+ shell="${6:-@PKG_USER_SHELL@}"
+
+ # Use `id' to be able to use NIS.
+ if ${ID} "${user}" >/dev/null 2>&1
+ then
+ ${ECHO} "User '${user}' already exists."
+ else
+ userid_option=
+ if [ -n "${userid}" ]
+ then
+ userid_option="-u ${userid}"
+ fi
+ ${ECHO} "Creating user: ${user}"
+ ${USERADD} -c "${descr}" \
+ ${userid_option} \
+ -g "${group}" \
+ -d "${home}" \
+ -s "${shell}" \
+ "${user}"
+ fi
+ )
+ done
fi
;;
@@ -70,8 +88,9 @@ POST-INSTALL)
${CHMOD} "${mode}" "${dir}"
done
- if [ -n "${CONF_FILES}" -o -n "${CONF_FILES_PERMS}" -o \
- -n "${SUPPORT_FILES}" -o -n "${SUPPORT_FILES_PERMS}" ]
+ if [ -n "${CONF_FILES}" -o -n "${CONF_FILES_PERMS}" -o \
+ -n "${SUPPORT_FILES}" -o -n "${SUPPORT_FILES_PERMS}" -o \
+ -n "${RCD_SCRIPTS}" ]
then
${ECHO} "Installing configuration files:"
fi
@@ -85,9 +104,12 @@ POST-INSTALL)
then
${ECHO} " ${file} already exists"
else
- ${ECHO} " ${file}"
- ${CP} "${samplefile}" "${file}"
- ${CHMOD} @CONF_FILES_MODE@ "${file}"
+ if [ -e "${samplefile}" ]
+ then
+ ${ECHO} " ${file}"
+ ${CP} "${samplefile}" "${file}"
+ ${CHMOD} @CONF_FILES_MODE@ "${file}"
+ fi
fi
done
eval set -- ${SUPPORT_FILES}
@@ -100,9 +122,12 @@ POST-INSTALL)
then
${ECHO} " ${file} already exists"
else
- ${ECHO} " ${file}"
- ${CP} "${samplefile}" "${file}"
- ${CHMOD} @SUPPORT_FILES_MODE@ "${file}"
+ if [ -e "${samplefile}" ]
+ then
+ ${ECHO} " ${file}"
+ ${CP} "${samplefile}" "${file}"
+ ${CHMOD} @SUPPORT_FILES_MODE@ "${file}"
+ fi
fi
done
eval set -- ${CONF_FILES_PERMS} ${SUPPORT_FILES_PERMS}
@@ -115,11 +140,14 @@ POST-INSTALL)
then
${ECHO} " ${file} already exists"
else
- ${ECHO} " ${file}"
- ${CP} "${samplefile}" "${file}"
- ${CHOWN} "${owner}" "${file}"
- ${CHGRP} "${group}" "${file}"
- ${CHMOD} ${mode} "${file}"
+ if [ -e "${samplefile}" ]
+ then
+ ${ECHO} " ${file}"
+ ${CP} "${samplefile}" "${file}"
+ ${CHOWN} "${owner}" "${file}"
+ ${CHGRP} "${group}" "${file}"
+ ${CHMOD} ${mode} "${file}"
+ fi
fi
done
eval set -- ${RCD_SCRIPTS}
@@ -132,9 +160,12 @@ POST-INSTALL)
then
${ECHO} " ${file} already exists"
else
- ${ECHO} " ${file}"
- ${CP} "${samplefile}" "${file}"
- ${CHMOD} @RCD_SCRIPTS_MODE@ "${file}"
+ if [ -e "${samplefile}" ]
+ then
+ ${ECHO} " ${file}"
+ ${CP} "${samplefile}" "${file}"
+ ${CHMOD} @RCD_SCRIPTS_MODE@ "${file}"
+ fi
fi
done