Date: Mon, 28 Nov 2011 16:55:33 -0800 From: Jason Helfman <jhelfman@experts-exchange.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: crees@FreeBSD.org Subject: ports/162934: databases/postgresql90-server: fix broken non-default PG_USER installations Message-ID: <1322528133.115266.48193.nullmailer@experts-exchange.com> Resent-Message-ID: <201111290100.pAT10Oei093389@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 162934 >Category: ports >Synopsis: databases/postgresql90-server: fix broken non-default PG_USER installations >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Nov 29 01:00:23 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Jason Helfman >Release: FreeBSD 8.2-RELEASE amd64 >Organization: Experts Exchange, LLC. >Environment: System: FreeBSD dormouse.experts-exchange.com 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: When building/installing postgresql with a non-default user, it will fail with the following error: ===> Checking if databases/postgresql90-server already installed ** /work/a/ports/databases/postgresql90-server/work/pggid doesn't exist. Exiting. *** Error code 1 >How-To-Repeat: add PG_USER=postgres to /etc/make.conf and make install the port >Fix: This fix brings in the old functionality, as there are compatibility issues with USERS/GROUPS infrastruture for customized users/groups. This change only affects a non-default user, so it overrides the target for creation, does it's own creation, and fixes the plist, as well. The old functionatlity worked in shell, but it was in a separate script file. I have moved it into the Makefile. Here is a link the old functionality (http://www.freebsd.org/cgi/cvsweb.cgi/ports/databases/postgresql90-server/files/Attic/pkg-install-server.in.diff?hideattic=0&r1=text&tr1=1.3&r2=text&tr2=1.4) This patch can more than likely be applied to all postgresql??-server ports. Index: Makefile =================================================================== RCS file: /home/jhelfman/ncvs/ports/databases/postgresql90-server/Makefile,v retrieving revision 1.230 diff -u -r1.230 Makefile --- Makefile 20 Oct 2011 21:07:28 -0000 1.230 +++ Makefile 29 Nov 2011 00:35:50 -0000 @@ -7,7 +7,7 @@ PORTNAME?= postgresql DISTVERSION?= 9.0.5 -PORTREVISION?= 1 +PORTREVISION?= 2 CATEGORIES?= databases MASTER_SITES= ${MASTER_SITE_PGSQL} MASTER_SITE_SUBDIR= source/v${DISTVERSION} @@ -349,9 +349,37 @@ . endif . if defined(SERVER_ONLY) && (${PG_USER} != "pgsql") +create-users-groups: + @${DO_NADA} + pre-install: @${SED} -n s,pgsql,${PG_USER},gp ${PORTSDIR}/UIDs > ${WRKDIR}/pguid @${SED} -n s,pgsql,${PG_GROUP},gp ${PORTSDIR}/GIDs > ${WRKDIR}/pggid + + @if pw group show "${PG_GROUP}" 2>/dev/null; then \ + echo "You already have a group \"${PG_GROUP}\", so I will use it."; \ + else \ + if pw groupadd ${PG_GROUP} -g ${PG_UID}; then \ + echo "Added group ${PG_GROUP}."; \ + else \ + echo "Adding group ${PG_GROUP} failed." ;\ + exit 1 ;\ + fi ;\ + fi; + + @if pw user show "${PG_USER}" 2>/dev/null; then \ + echo "You already have a user \"${PG_USER}\", so I will use it."; \ + else \ + if pw useradd ${PG_USER} -u ${PG_UID} -g ${PG_GROUP} -h - \ + -d `cut -d : -f 9 ${WRKDIR}/pguid` -c "PostgreSQL Daemon" ;\ + then \ + echo "Added user \"${PG_USER}\"." ;\ + else \ + echo "Adding user \"${PG_USER}\" failed..." ;\ + exit 1 ;\ + fi ;\ + fi; + . endif do-install: @@ -388,4 +416,18 @@ fi .endif +. if defined(SERVER_ONLY) && (${PG_USER} != "pgsql") +post-install-script: + @${ECHO_CMD} "@exec echo \"===> Creating users and/or groups.\"" >> ${TMPPLIST} + @${ECHO_CMD} "@exec if ! ${PW} groupshow ${PG_GROUP} >/dev/null 2>&1; then \ + echo \"Creating group '${PG_GROUP}' with gid '${PG_UID}'.\"; \ + @${PW} groupadd ${PG_GROUP} -g ${PG_UID}; else echo \"Using existing group '${PG_GROUP}'.\"; fi" >> ${TMPPLIST} + @${ECHO_CMD} "@exec if ! ${PW} usershow ${PG_USER} >/dev/null 2>&1; then \ + echo \"Creating user '${PG_USER}' with uid '${PG_UID}'.\"; \ + @${PW} useradd ${PG_USER} -u ${PG_UID} -g ${PG_UID} -d `cut -d : -f 9 ${WRKDIR}/pguid` -s /bin/sh; \ + else echo \"Using existing user '${PG_USER}'.\"; fi" >> ${TMPPLIST} +. endif + + + .include <bsd.port.post.mk> >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1322528133.115266.48193.nullmailer>