From owner-svn-ports-all@FreeBSD.ORG Wed Oct 30 17:47:49 2013 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 59564E63; Wed, 30 Oct 2013 17:47:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 451D92591; Wed, 30 Oct 2013 17:47:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9UHlniL078336; Wed, 30 Oct 2013 17:47:49 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9UHlmrb078334; Wed, 30 Oct 2013 17:47:48 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201310301747.r9UHlmrb078334@svn.freebsd.org> From: Baptiste Daroussin Date: Wed, 30 Oct 2013 17:47:48 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r332158 - head/Mk X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Oct 2013 17:47:49 -0000 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}