Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Sep 2001 03:15:37 +0900
From:      "Akinori MUSHA" <knu@iDaemons.org>
To:        sam@inf.enst.fr
Cc:        ports@FreeBSD.org
Subject:   devel/perforce update
Message-ID:  <86u1ymu69i.wl@archon.local.idaemons.org>

next in thread | raw e-mail | index | archive | help
Hello,

I've made a patch against your devel/perforce port as attached, which
includes the following improvements:

- Update to version 01.1
- Support the alpha platform (although it is still at version 99.1)
- Install p4ftpd
- Create a non-privileged user and run p4d as the user
- Dig directories and make the port plug-and-play
- Change the configuration file's name to perforce.conf
- Do not unconditionally remove perforce.conf on deinstall
- Make almost everything (including directory layouts and user/group
  names) configurable via make variables

What do you think?  Could I commit this?

-- 
                     /
                    /__  __            Akinori.org / MUSHA.org
                   / )  )  ) )  /     FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ /  ( (__(  @ iDaemons.org / and.or.jp

"Freeze this moment a little bit longer, make each impression
  a little bit stronger..  Experience slips away -- Time stand still"

M Makefile
M distinfo
A pkg-install
M pkg-plist
R files/perforce
A files/perforce.conf.in
M files/perforce.sh.in

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/devel/perforce/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- Makefile	9 Jan 2001 12:29:22 -0000	1.3
+++ Makefile	1 Sep 2001 18:05:17 -0000
@@ -6,15 +6,15 @@
 #
 
 PORTNAME=	perforce
-PORTVERSION=	00.2
+PORTVERSION=	${VERSION}
 PORTEPOCH=	1
 CATEGORIES=	devel
-MASTER_SITES=	ftp://ftp.perforce.com/pub/perforce/r${PORTVERSION}/bin.freebsd/ \
-		http://www.dsmit.com/p4/ \
+MASTER_SITES=	ftp://ftp.perforce.com/pub/perforce/r${PORTVERSION}/bin.${PLATFORM}/ \
 		ftp://ftp.perforce.com/pub/perforce/r${PORTVERSION}/doc/man/
 EXTRACT_SUFX=
-DISTFILES=	p4 p4d p4web p4.1 p4d.1
-DIST_SUBDIR=	perforce
+DISTFILES=	${BIN_FILES} ${SBIN_FILES} ${MAN1}
+EXTRACT_ONLY=	# none
+DIST_SUBDIR=	perforce/${VERSION}/${ARCH}
 
 MAINTAINER=	sam@inf.enst.fr
 
@@ -22,23 +22,83 @@
 NO_CDROM=	Restricted distribution
 MAN1=		p4.1 p4d.1
 
-do-extract:
-	@${MKDIR} ${WRKSRC}
+NO_WRKSUBDIR=	yes
+
+.include <bsd.port.pre.mk>
+
+# These variables are all configurable.
+PERFORCE_USER?=		p4admin
+PERFORCE_UID?=		94
+PERFORCE_GROUP?=	p4admin
+PERFORCE_GID?=		94
+PERFORCE_HOME?=		${LOCALBASE}/perforce
+PERFORCE_ROOT?=		${PERFORCE_HOME}/root
+PERFORCE_LOGS?=		${PERFORCE_HOME}/logs
+PERFORCE_PORT?=		1666
+
+.if ${ARCH} == i386
+VERSION=	01.1
+PLATFORM=	freebsd
+BIN_FILES=	p4 p4web
+SBIN_FILES=	p4d p4ftpd
+.elif ${ARCH} == alpha
+VERSION=	99.1
+PLATFORM=	freebsdaxp
+BIN_FILES=	p4
+SBIN_FILES=	p4d
+.else
+.error "Unsupported platform, sorry."
+.endif
 
 do-build:
+	${SED} -e "s,@PERFORCE_ROOT@,${PERFORCE_ROOT},g" \
+	       -e "s,@PERFORCE_LOGS@,${PERFORCE_LOGS},g" \
+	       -e "s,@PERFORCE_USER@,${PERFORCE_USER},g" \
+	       -e "s,@PERFORCE_PORT@,${PERFORCE_PORT},g" \
+		< ${FILESDIR}/perforce.conf.in > ${WRKSRC}/perforce.conf
 	${SED} -e "s,@PREFIX@,${PREFIX},g" \
 		< ${FILESDIR}/perforce.sh.in > ${WRKSRC}/perforce.sh
 
+pre-install:
+	${SETENV} PKG_PREFIX=${PREFIX} \
+		PERFORCE_USER=${PERFORCE_USER} \
+		PERFORCE_UID=${PERFORCE_UID} \
+		PERFORCE_GROUP=${PERFORCE_GROUP} \
+		PERFORCE_GID=${PERFORCE_GID} \
+		PERFORCE_HOME=${PERFORCE_HOME} \
+		PERFORCE_ROOT=${PERFORCE_ROOT} \
+		PERFORCE_LOGS=${PERFORCE_LOGS} \
+		${SH} ${PKGDIR}/pkg-install ${PORTNAME} PRE-INSTALL
+
 do-install:
-	${INSTALL_PROGRAM} ${DISTDIR}/${DIST_SUBDIR}/p4 ${PREFIX}/bin/
-	${INSTALL_PROGRAM} ${DISTDIR}/${DIST_SUBDIR}/p4web ${PREFIX}/bin/
-	${INSTALL_PROGRAM} ${DISTDIR}/${DIST_SUBDIR}/p4d ${PREFIX}/sbin/
-	if [ ! -f ${PREFIX}/etc/perforce ]; then \
-	  ${INSTALL_DATA} ${FILESDIR}/perforce ${PREFIX}/etc/; \
+.for f in ${BIN_FILES}
+	${INSTALL_PROGRAM} ${_DISTDIR}/${f} ${PREFIX}/bin/
+.endfor
+.for f in ${SBIN_FILES}
+	${INSTALL_PROGRAM} ${_DISTDIR}/${f} ${PREFIX}/sbin/
+.endfor
+	${INSTALL_DATA} ${WRKSRC}/perforce.conf ${PREFIX}/etc/perforce.conf.default; \
+	if [ ! -f ${PREFIX}/etc/perforce.conf ]; then \
+		${CP} -p ${PREFIX}/etc/perforce.conf.default ${PREFIX}/etc/perforce.conf; \
 	fi
 	${INSTALL_SCRIPT} ${WRKSRC}/perforce.sh ${PREFIX}/etc/rc.d/
-.for PERFMAN in p4 p4d
-	${INSTALL_MAN} ${DISTDIR}/${DIST_SUBDIR}/${PERFMAN}.1 ${PREFIX}/man/man1
+.for f in ${MAN1}
+	${INSTALL_MAN} ${_DISTDIR}/${f} ${PREFIX}/man/man1/
+.endfor
+.for f in ${BIN_FILES}
+	${INSTALL_PROGRAM} ${_DISTDIR}/${f} ${PREFIX}/bin/
+.endfor
+.for f in ${SBIN_FILES}
+	${INSTALL_PROGRAM} ${_DISTDIR}/${f} ${PREFIX}/sbin/
+.endfor
+
+post-install:
+.for f in ${BIN_FILES}
+	${ECHO} bin/${f} >> ${TMPPLIST}
+.endfor
+.for f in ${SBIN_FILES}
+	${ECHO} sbin/${f} >> ${TMPPLIST}
 .endfor
+	${ECHO} "@unexec /bin/rmdir ${PERFORCE_ROOT} ${PERFORCE_LOGS} ${PERFORCE_HOME} 2>/dev/null || true" >> ${TMPPLIST}
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
Index: distinfo
===================================================================
RCS file: /home/ncvs/ports/devel/perforce/distinfo,v
retrieving revision 1.4
diff -u -r1.4 distinfo
--- distinfo	9 Jan 2001 12:29:22 -0000	1.4
+++ distinfo	1 Sep 2001 16:19:44 -0000
@@ -1,5 +1,10 @@
-MD5 (perforce/p4) = cd395c485cd7e0a2f80d6b972374dca6
-MD5 (perforce/p4d) = 8556db22a77aa1b67542ab4712292731
-MD5 (perforce/p4web) = 1a64aaa96d9088f4375cdc4a1ec2a2bb
-MD5 (perforce/p4.1) = 4019bba1166429d5a7111319afa09e48
-MD5 (perforce/p4d.1) = 29b1bd9838acb517f00becf1b8273592
+MD5 (perforce/01.1/i386/p4) = 128d067c5feec61d7e6df74d871e3ed0
+MD5 (perforce/01.1/i386/p4d) = bfbb3ed930fc66f7ce7b1da4cbfe6b61
+MD5 (perforce/01.1/i386/p4ftpd) = 2d02f69be2f636c52dbdae9e1dbfe9b8
+MD5 (perforce/01.1/i386/p4web) = ee5843ee0539700e8eb0e65eff5f4d74
+MD5 (perforce/01.1/i386/p4.1) = 7eed553dc7b484ec3fd7a81173e531b7
+MD5 (perforce/01.1/i386/p4d.1) = 50b3a5705319fa8389a8f83123f80e8f
+MD5 (perforce/99.1/alpha/p4) = 7c1300a82ab03b7ede46cf8a02c48fd9
+MD5 (perforce/99.1/alpha/p4d) = 8f34c41c18185011ed848aaf450cffa5
+MD5 (perforce/99.1/alpha/p4.1) = 4a9d035eb5ef96342c2f701a02da40f9
+MD5 (perforce/99.1/alpha/p4d.1) = a08eb04e9668ba4d0abf47f3b12c56f7
Index: pkg-install
===================================================================
RCS file: pkg-install
diff -N pkg-install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pkg-install	1 Sep 2001 17:57:14 -0000
@@ -0,0 +1,52 @@
+#! /bin/sh
+#
+# $FreeBSD$
+
+PATH=/bin:/usr/sbin
+
+PERFORCE_USER=${PERFORCE_USER:-p4admin}
+PERFORCE_UID=${PERFORCE_UID:-94}
+PERFORCE_GROUP=${PERFORCE_GROUP:-p4admin}
+PERFORCE_GID=${PERFORCE_GID:-94}
+PERFORCE_HOME=${PERFORCE_HOME:-$PKG_PREFIX/perforce}
+PERFORCE_LOGDIR=${PERFORCE_LOGDIR:-$PERFORCE_HOME/log}
+PERFORCE_ROOT=${PERFORCE_ROOT:-$PERFORCE_HOME/root}
+
+case $2 in
+PRE-INSTALL)
+	USER=${PERFORCE_USER}
+	GROUP=${PERFORCE_GROUP}
+	UID=${PERFORCE_UID}
+	GID=${PERFORCE_GID}
+
+	if pw group show "${GROUP}" 2>/dev/null; then
+		echo "You already have a group \"${GROUP}\", so I will use it."
+	else
+		if pw groupadd ${GROUP} -g ${GID}; then
+			echo "Added group \"${GROUP}\"."
+		else
+			echo "Adding group \"${GROUP}\" failed..."
+			exit 1
+		fi
+	fi
+
+	if pw user show "${USER}" 2>/dev/null; then
+		echo "You already have a user \"${USER}\", so I will use it."
+	else
+		if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
+			-d ${PERFORCE_HOME} -c "Perforce admin" -s /sbin/nologin
+		then
+			echo "Added user \"${USER}\"."
+		else
+			echo "Adding user \"${USER}\" failed..."
+			exit 1
+		fi
+	fi
+
+	if [ ! -d $PERFORCE_HOME ] ; then 
+echo hey
+		mkdir -p $PERFORCE_HOME $PERFORCE_LOGS $PERFORCE_ROOT
+		chown -R $USER:$GROUP $PERFORCE_HOME
+	fi
+	;;
+esac
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/devel/perforce/pkg-plist,v
retrieving revision 1.2
diff -u -r1.2 pkg-plist
--- pkg-plist	28 Oct 2000 01:32:50 -0000	1.2
+++ pkg-plist	1 Sep 2001 18:04:03 -0000
@@ -1,5 +1,4 @@
-bin/p4
-bin/p4web
-sbin/p4d
-etc/perforce
+@unexec if cmp -s %D/etc/perforce.conf %D/etc/perforce.conf.default; then rm -f %D/etc/perforce.conf; fi
+etc/perforce.conf.default
+@exec [ ! -f %B/perforce.conf ] && cp -p %B/%f %B/perforce.conf || true
 etc/rc.d/perforce.sh
Index: files/perforce
===================================================================
RCS file: files/perforce
diff -N files/perforce
--- files/perforce	23 Apr 2001 17:59:28 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-#
-# Perforce FreeBSD configuration file
-#
-
-#
-# Perforce ROOT
-#
-PERFORCE_ROOT="/usr/p4root"
-
-#
-# Perforce options (see man p4d)
-#
-PERFORCE_OPTIONS="-d -v server=1 -L /var/log/perforce"
-
-#
-# Uncomment this line to have the server started automatically
-#
-#PERFORCE_START=yes
Index: files/perforce.conf.in
===================================================================
RCS file: files/perforce.conf.in
diff -N files/perforce.conf.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/perforce.conf.in	1 Sep 2001 17:49:46 -0000
@@ -0,0 +1,40 @@
+#
+# Perforce FreeBSD configuration file
+#
+#
+# $FreeBSD$
+
+#
+# Perforce ROOT
+#
+PERFORCE_ROOT="@PERFORCE_ROOT@"
+
+#
+# Perforce user (it is recommended to run p4d as a non-root user)
+#
+PERFORCE_USER="@PERFORCE_USER@"
+
+#
+# p4d port (default: 1666)
+#
+PERFORCE_PORT="@PERFORCE_PORT@"
+
+#
+# p4d options (see man p4d)
+#
+PERFORCE_OPTIONS="-d -p $PERFORCE_PORT -v server=1 -L @PERFORCE_LOGS@/p4d.log"
+
+#
+# Uncomment this line to have the server started automatically
+#
+#PERFORCE_START=yes
+
+#
+# p4ftpd options (see p4ftpd -h)
+#
+PERFORCE_FTPD_OPTIONS="-d -p $PERFORCE_PORT -v server=1 -L @PERFORCE_LOGS@/p4ftpd.log"
+
+#
+# Uncomment this line to have the server started automatically
+#
+#PERFORCE_FTPD_START=yes
Index: files/perforce.sh.in
===================================================================
RCS file: /home/ncvs/ports/devel/perforce/files/perforce.sh.in,v
retrieving revision 1.2
diff -u -r1.2 perforce.sh.in
--- files/perforce.sh.in	9 Jan 2001 12:29:27 -0000	1.2
+++ files/perforce.sh.in	1 Sep 2001 17:55:42 -0000
@@ -1,14 +1,38 @@
 #!/bin/sh
+#
+# $FreeBSD$
+
+p4d=@PREFIX@/sbin/p4d
+p4ftpd=@PREFIX@/sbin/p4ftpd
+
 case $1 in
-  start)
-    [ -f @PREFIX@/etc/perforce ] && . @PREFIX@/etc/perforce
-    if [ x$PERFORCE_START = xyes ]; then
-      echo -n ' perforce'
-      p4d -r $PERFORCE_ROOT $PERFORCE_OPTIONS
+start)
+    [ -f @PREFIX@/etc/perforce.conf ] && . @PREFIX@/etc/perforce.conf
+    if [ -x $p4d -a x$PERFORCE_START = xyes ]; then
+	echo -n ' p4d'
+	su -fm $PERFORCE_USER -c "$p4d -r $PERFORCE_ROOT $PERFORCE_OPTIONS"
     fi
+    if [ -x $p4ftpd -a x$PERFORCE_FTPD_START = xyes ]; then
+	echo -n ' p4ftpd'
+	$p4ftpd $PERFORCE_FTPD_OPTIONS
+    fi
+    ;;
+stop)
+    [ -f @PREFIX@/etc/perforce.conf ] && . @PREFIX@/etc/perforce.conf
+    if [ -x $p4ftpd ]; then
+	killall -u 0 p4ftpd >/dev/null 2>&1 && echo -n ' p4ftpd'
+    fi
+    if [ -x $p4d ]; then
+	killall -u $PERFORCE_USER p4d >/dev/null 2>&1 && echo -n ' p4d'
+    fi
+    ;;
+restart)
+    $0 stop
+    sleep 1
+    $0 start
     ;;
-  stop)
-    killall p4d && echo -n ' perforce'
+*)
+    echo "usage: $0 {start|stop|restart}"
+    exit 64
     ;;
-  *) ;;
 esac

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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