From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Nov 29 01:00:26 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 320731065680 for ; Tue, 29 Nov 2011 01:00:26 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 8E32D8FC13 for ; Tue, 29 Nov 2011 01:00:24 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pAT10O7w093402 for ; Tue, 29 Nov 2011 01:00:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pAT10Oei093389; Tue, 29 Nov 2011 01:00:24 GMT (envelope-from gnats) Resent-Date: Tue, 29 Nov 2011 01:00:24 GMT Resent-Message-Id: <201111290100.pAT10Oei093389@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jason Helfman Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00E85106564A; Tue, 29 Nov 2011 00:55:58 +0000 (UTC) (envelope-from jhelfman@experts-exchange.com) Received: from mail.experts-exchange.com (mail.experts-exchange.com [72.29.183.251]) by mx1.freebsd.org (Postfix) with ESMTP id D69518FC16; Tue, 29 Nov 2011 00:55:57 +0000 (UTC) Received: from mail.experts-exchange.com (localhost [127.0.0.1]) by mail.experts-exchange.com (Postfix) with ESMTP id 6DF396F423C; Mon, 28 Nov 2011 16:55:57 -0800 (PST) Received: from mail.experts-exchange.com ([127.0.0.1]) by mail.experts-exchange.com (mail.experts-exchange.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Uie68j5B34f3; Mon, 28 Nov 2011 16:55:57 -0800 (PST) Received: from experts-exchange.com (unknown [192.168.103.120]) by mail.experts-exchange.com (Postfix) with SMTP id 467876F423B; Mon, 28 Nov 2011 16:55:57 -0800 (PST) Received: (nullmailer pid 48194 invoked by uid 1001); Tue, 29 Nov 2011 00:55:33 -0000 Message-Id: <1322528133.115266.48193.nullmailer@experts-exchange.com> Date: Mon, 28 Nov 2011 16:55:33 -0800 From: Jason Helfman To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: crees@FreeBSD.org Subject: ports/162934: databases/postgresql90-server: fix broken non-default PG_USER installations X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jason Helfman List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2011 01:00:26 -0000 >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 >Release-Note: >Audit-Trail: >Unformatted: