aboutsummaryrefslogtreecommitdiff
path: root/Mk/bsd.port.mk
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2013-10-30 17:47:48 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2013-10-30 17:47:48 +0000
commitff058e31764c43fe88a9ae1f35378cca35194c64 (patch)
treefa46115894f3d83f8346b1f1f9a6eda7015459e5 /Mk/bsd.port.mk
parent7effb2dc8d409dedd79ecda8510c629e7266d139 (diff)
downloadports-ff058e31764c43fe88a9ae1f35378cca35194c64.tar.gz
ports-ff058e31764c43fe88a9ae1f35378cca35194c64.zip
Staging showed that user/groups creation from plist are done in
post-install process instead of pre-install. in case pkgng is in use. Replace it by a new mecanism that allows to append scripts into what will become pre-install, post-install, pre-deinstall or post-deinstall Change the user-group creation to use that mecanism in case the ports tree is using pkgng. Reported by: mandree Reviewed by: bdrewery
Notes
Notes: svn path=/head/; revision=332158
Diffstat (limited to 'Mk/bsd.port.mk')
-rw-r--r--Mk/bsd.port.mk54
1 files changed, 43 insertions, 11 deletions
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 302cf0f4e2f0..8d2337fdbc13 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -4151,6 +4151,12 @@ install-ldconfig-file:
.endif
.if !target(create-users-groups)
+.if defined(GROUPS) || defined(USERS)
+.if defined(WITH_PKGNG)
+_UG_OUTPUT= ${WRKDIR}/users-groups.sh
+PKGPREINSTALL+= ${_UG_OUTPUT}
+.endif
+.endif
create-users-groups:
.if defined(GROUPS) || defined(USERS)
.if defined(GROUPS)
@@ -4159,8 +4165,15 @@ create-users-groups:
@${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1
.endif
.endfor
+.if defined(WITH_PKGNG)
+ @${RM} -f ${_UG_OUTPUT} || ${TRUE}
+.endif
@${ECHO_MSG} "===> Creating users and/or groups."
+.if defined(WITH_PKGNG)
+ @${ECHO_CMD} "echo \"===> Creating users and/or groups.\"" >> ${_UG_OUTPUT}
+.else
@${ECHO_CMD} "@exec echo \"===> Creating users and/or groups.\"" >> ${TMPPLIST}
+.endif
.for _group in ${GROUPS}
# _bgpd:*:130:
@if ! ${GREP} -h ^${_group}: ${GID_FILES} >/dev/null 2>&1; then \
@@ -4177,9 +4190,15 @@ create-users-groups:
${ECHO_MSG} "Using existing group \`$$group'."; \
fi; \
fi ; \
- ${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then \
- echo \"Creating group '$$group' with gid '$$gid'.\"; \
- ${PW} groupadd $$group -g $$gid; else echo \"Using existing group '$$group'.\"; fi" >> ${TMPPLIST}; \
+ if [ -z "${WITH_PKGNG}" ]; then \
+ ${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then \
+ echo \"Creating group '$$group' with gid '$$gid'.\"; \
+ ${PW} groupadd $$group -g $$gid; else echo \"Using existing group '$$group'.\"; fi" >> ${TMPPLIST}; \
+ else \
+ ${ECHO_CMD} -e "if ! ${PW} groupshow $$group >/dev/null 2>&1; then \n \
+ echo \"Creating group '$$group' with gid '$$gid'.\" \n \
+ ${PW} groupadd $$group -g $$gid; else echo \"Using existing group '$$group'.\"\nfi" >> ${_UG_OUTPUT}; \
+ fi ; \
done
.endfor
.endif
@@ -4209,10 +4228,17 @@ create-users-groups:
${ECHO_MSG} "Using existing user \`$$login'."; \
fi; \
fi; \
- ${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then \
- echo \"Creating user '$$login' with uid '$$uid'.\"; \
- ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; \
- else echo \"Using existing user '$$login'.\"; fi" >> ${TMPPLIST}; \
+ if [ -z "${WITH_PKGNG}" ]; then \
+ ${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then \
+ echo \"Creating user '$$login' with uid '$$uid'.\"; \
+ ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; \
+ else echo \"Using existing user '$$login'.\"; fi" >> ${TMPPLIST}; \
+ else \
+ ${ECHO_CMD} -e "if ! ${PW} usershow $$login >/dev/null 2>&1; then \n \
+ echo \"Creating user '$$login' with uid '$$uid'.\" \n \
+ ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell \n \
+ else \necho \"Using existing user '$$login'.\" \nfi" >> ${_UG_OUTPUT}; \
+ fi ; \
case $$homedir in /nonexistent|/var/empty) ;; *) ${ECHO_CMD} "@exec ${INSTALL} -d -g $$gid -o $$uid $$homedir" >> ${TMPPLIST};; esac; \
done
.endfor
@@ -4228,9 +4254,15 @@ create-users-groups:
${ECHO_MSG} "Adding user \`$${_login}' to group \`${_group}'."; \
${PW} groupmod ${_group} -m $${_login}; \
fi; \
- ${ECHO_CMD} "@exec if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
- echo \"Adding user '$${_login}' to group '${_group}'.\"; \
- ${PW} groupmod ${_group} -m $${_login}; fi" >> ${TMPPLIST}; \
+ if [ -z "${WITH_PKGNG}" ]; then \
+ ${ECHO_CMD} "@exec if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
+ echo \"Adding user '$${_login}' to group '${_group}'.\"; \
+ ${PW} groupmod ${_group} -m $${_login}; fi" >> ${TMPPLIST}; \
+ else \
+ ${ECHO_CMD} "if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \n \
+ echo \"Adding user '$${_login}' to group '${_group}'.\" \n \
+ ${PW} groupmod ${_group} -m $${_login} \nfi" >> ${_UG_OUTPUT}; \
+ fi ; \
fi; \
done; \
done; \
@@ -4256,7 +4288,7 @@ create-users-groups:
# and user(s) are the first in pkg-plist
.if !target(fix-plist-sequence)
fix-plist-sequence: ${TMPPLIST}
-.if defined(GROUPS) || defined(USERS)
+.if !defined(WITH_PKGNG) && (defined(GROUPS) || defined(USERS))
@${ECHO_CMD} "===> Correct pkg-plist sequence to create group(s) and user(s)"
@${EGREP} -e '^@exec echo.*Creating users and' -e '^@exec.*${PW}' -e '^@exec ${INSTALL} -d -g' ${TMPPLIST} > ${TMPGUCMD}
@${EGREP} -v -e '^@exec echo.*Creating users and' -e '^@exec.*${PW}' -e '^@exec ${INSTALL} -d -g' ${TMPPLIST} >> ${TMPGUCMD}