diff options
author | jlam <jlam> | 2001-11-26 20:37:38 +0000 |
---|---|---|
committer | jlam <jlam> | 2001-11-26 20:37:38 +0000 |
commit | 53bbe8c3452be12f505c193455702365bbd556f9 (patch) | |
tree | 14c0d9f381d74ca492c950829a9e8cced859770c /mk/install | |
parent | 3b047c08a8e5b12fc71c6d96f63447b0e0f1ffbb (diff) | |
download | pkgsrc-53bbe8c3452be12f505c193455702365bbd556f9.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/install')
-rw-r--r-- | mk/install/deinstall | 67 | ||||
-rw-r--r-- | mk/install/header | 12 | ||||
-rw-r--r-- | mk/install/install | 147 |
3 files changed, 146 insertions, 80 deletions
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 |