Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Oct 2013 17:47:48 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r332158 - head/Mk
Message-ID:  <201310301747.r9UHlmrb078334@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Oct 30 17:47:48 2013
New Revision: 332158
URL: http://svnweb.freebsd.org/changeset/ports/332158

Log:
  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

Modified:
  head/Mk/bsd.pkgng.mk
  head/Mk/bsd.port.mk

Modified: head/Mk/bsd.pkgng.mk
==============================================================================
--- head/Mk/bsd.pkgng.mk	Wed Oct 30 17:46:53 2013	(r332157)
+++ head/Mk/bsd.pkgng.mk	Wed Oct 30 17:47:48 2013	(r332158)
@@ -81,11 +81,24 @@ create-manifest:
 .endfor
 .undef opt
 	@${ECHO_CMD} "}" >> ${MANIFESTF}
-	@[ -f ${PKGINSTALL} ] && ${CP} ${PKGINSTALL} ${METADIR}/+INSTALL; \
-	[ -f ${PKGPREINSTALL} ] && ${CP} ${PKGPREINSTALL} ${METADIR}/+PRE_INSTALL; \
-	[ -f ${PKGPOSTINSTALL} ] && ${CP} ${PKGPOSTINSTALL} ${METADIR}/+POST_INSTALL; \
+	@[ -f ${PKGINSTALL} ] && ${CAT} ${PKGINSTALL} ${METADIR}/+INSTALL; \
+	${RM} -f ${METADIR}/+PRE_INSTALL ; \
+	for a in ${PKGPREINSTALL}; do \
+		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_INSTALL ; \
+	done ; \
+	${RM} -f ${METADIR}/+POST_INSTALL ; \
+	for a in ${PKGPOSTINSTALL}; do \
+		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_INSTALL ; \
+	done ; \
 	[ -f ${PKGDEINSTALL} ] && ${CP} ${PKGDEINSTALL} ${METADIR}/+DEINSTALL; \
-	[ -f ${PKGPREDEINSTALL} ] && ${CP} ${PKGPREDEINSTALL} ${METADIR}/+PRE_DEINSTALL; \
+	${RM} -f ${METADIR}/+PRE_DEINSTALL ; \
+	for a in ${PKGPREDEINSTALL}; do \
+		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_DEINSTALL ; \
+	done ; \
+	${RM} -f ${METADIR}/+POST_DEINSTALL ; \
+	for a in ${PKGPOSRDEINSTALL}; do \
+		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_DEINSTALL ; \
+	done ; \
 	[ -f ${PKGPOSTDEINSTALL} ] && ${CP} ${PKGPOSTDEINSTALL} ${METADIR}/+POST_DEINSTALL; \
 	[ -f ${PKGUPGRADE} ] && ${CP} ${PKGUPGRADE} ${METADIR}/+UPGRADE; \
 	[ -f ${PKGPREUPGRADE} ] && ${CP} ${PKGPREUPGRADE} ${METADIR}/+PRE_UPGRADE; \

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Wed Oct 30 17:46:53 2013	(r332157)
+++ head/Mk/bsd.port.mk	Wed Oct 30 17:47:48 2013	(r332158)
@@ -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}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310301747.r9UHlmrb078334>