Bug 171716 - [patch] finance/trytond: some tunning
Summary: [patch] finance/trytond: some tunning
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Wen Heping
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-17 17:10 UTC by Boris Samorodov
Modified: 2012-09-18 02:00 UTC (History)
0 users

See Also:


Attachments
file.diff (3.80 KB, patch)
2012-09-17 17:10 UTC, Boris Samorodov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Samorodov freebsd_committer freebsd_triage 2012-09-17 17:10:08 UTC
Great work was done to create the port. However some tunning should be done to let the port run at vanilla system. Those are the problems I tried to overcome.

The rc.d script exists at the files directory but is not used so far.
The configuration file exists at the distribution file but is not used so far.
There is no definition at UIDs file for the user "trytond" defined at rc.d script (the script can not start without that definition).
Commands "stop" and "status" can not be used for rc.d script.
The option for py-OpenSSL is misspelled.

Fix: . create gid and uid for tryton daemon and use them via USERS and GROUPS variables at Makefile;
. install the existing rc.d script (define USE_RC_SUBR at Makefile);
. define the command_interpreter variable at the rc.d script (stop and status commands need it);
. create needed directories at trytond_prestart (rc.d script) with appropriate gid and launch install once;
. rename option OPENSSL -> PYOPENSSL (the former is used for OpenSSL itself);
. make use of configuration and sample file (both for the port and for the package);

Note: 
Since now a configuration file is installed, seems that pkg-message "2)"
may be changed to smth like "Use the configuration file %%PREFIX%%/etc/trytond.conf
to customize the daemon."

Patch attached with submission follows:
How-To-Repeat: Install the port at vanilla system.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-09-17 17:10:16 UTC
Maintainer of finance/trytond,

Please note that PR ports/171716 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/171716

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2012-09-17 17:10:18 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Boris Samorodov freebsd_committer freebsd_triage 2012-09-17 19:27:52 UTC
Responsible Changed
From-To: freebsd-ports-bugs->wen

Over to the port's maintainer.
Comment 4 dfilter service freebsd_committer freebsd_triage 2012-09-18 01:57:27 UTC
Author: wen
Date: Tue Sep 18 00:57:12 2012
New Revision: 304423
URL: http://svn.freebsd.org/changeset/ports/304423

Log:
  - Create gid and uid for tryton daemon and use them via USERS and GROUPS variables at Makefile
  - Install the existing rc.d script (define USE_RC_SUBR at Makefile)
  - Define the command_interpreter variable at the rc.d script (stop and status commands need it)
  - Create needed directories at trytond_prestart (rc.d script) with appropriate gid and launch install once
  - Rename option OPENSSL -> PYOPENSSL
  - Make use of configuration and sample file (both for the port and for the package)
  
  PR:		171716
  Submitted by:	bsam@, Matthias Petermann <matthias@d2ux.net>(via Email)

Modified:
  head/GIDs
  head/UIDs
  head/finance/trytond/Makefile
  head/finance/trytond/files/pkg-message.in
  head/finance/trytond/files/trytond.in
  head/finance/trytond/pkg-plist

Modified: head/GIDs
==============================================================================
--- head/GIDs	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/GIDs	Tue Sep 18 00:57:12 2012	(r304423)
@@ -238,5 +238,6 @@ pandora:*:956:
 razorback:*:957:
 gnunet:*:958:
 c_icap:*:959:
+trytond:*:960:
 nogroup:*:65533:
 nobody:*:65534:

Modified: head/UIDs
==============================================================================
--- head/UIDs	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/UIDs	Tue Sep 18 00:57:12 2012	(r304423)
@@ -242,4 +242,5 @@ pandora:*:956:956::0:0:Pandora FMS user:
 razorback:*:957:957::0:0:Razorback user:/var/run/razorback:/usr/sbin/nologin
 gnunet:*:958:958::0:0:GNUnet daemon:/var/lib/gnunet:/usr/sbin/nologin
 c_icap:*:959:959::0:0:c-icap daemon:/var/empty:/usr/sbin/nologin
+trytond:*:960:960::0:0:trytond daemon:/var/empty:/usr/sbin/nologin
 nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin

Modified: head/finance/trytond/Makefile
==============================================================================
--- head/finance/trytond/Makefile	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/finance/trytond/Makefile	Tue Sep 18 00:57:12 2012	(r304423)
@@ -7,7 +7,7 @@
 
 PORTNAME=	trytond
 PORTVERSION=	2.4.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	finance python
 MASTER_SITES=	http://downloads2.tryton.org/${PORTVERSION:R}/
 
@@ -24,15 +24,20 @@ BUILD_DEPENDS=	${PYTHON_SITELIBDIR}/mx/_
 		${PYTHON_PKGNAMEPREFIX}polib>=0.7.0:${PORTSDIR}/devel/py-polib
 RUN_DEPENDS:=	${BUILD_DEPENDS}
 
-OPTIONS_DEFINE=	WEBDAV OPENSSL PYDOT PYTZ
+USERS=		trytond
+GROUPS=		trytond
+
+OPTIONS_DEFINE=	WEBDAV PYOPENSSL PYDOT PYTZ
 WEBDAV_DESC=	Add support for pywebdav
-OPENSSL_DESC=	Add support for pyOpenSSL
+PYOPENSSL_DESC=	Add support for pyOpenSSL
 PYDOT_DESC=	Add support for pydot
 PYTZ_DESC=	Add support for pytz
 
+USE_RC_SUBR=	${PORTNAME}
 SUB_FILES=	pkg-message
 SUB_LIST=	PYTHON_SITELIBDIR=${PYTHON_SITELIBDIR} \
-		PYEASYINSTALL_EGG=${PYEASYINSTALL_EGG}
+		PYEASYINSTALL_EGG=${PYEASYINSTALL_EGG} \
+		PYTHON=${PYTHON_CMD}
 
 USE_PYTHON=	yes
 USE_PYDISTUTILS=easy_install
@@ -43,7 +48,7 @@ USE_PYDISTUTILS=easy_install
 RUN_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}PyWebDAV>=0:${PORTSDIR}/www/py-pywebdav
 .endif
 
-.if ${PORT_OPTIONS:MOPENSSL}
+.if ${PORT_OPTIONS:MPYOPENSSL}
 RUN_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}openssl>=0:${PORTSDIR}/security/py-openssl
 .endif
 
@@ -56,6 +61,11 @@ RUN_DEPENDS+=	${PYTHON_PKGNAMEPREFIX}pyt
 .endif
 
 post-install:
-		@${CAT} ${PKGMESSAGE}
+	${CP} -p ${WRKSRC}/etc/${PORTNAME}.conf ${PREFIX}/etc/${PORTNAME}.conf.sample
+	@if [ ! -f ${PREFIX}/etc/${PORTNAME}.conf ]; then \
+		${CP} -p ${PREFIX}/etc/${PORTNAME}.conf.sample ${PREFIX}/etc/${PORTNAME}.conf ; \
+	fi
+
+	@${CAT} ${PKGMESSAGE}
 
 .include <bsd.port.mk>

Modified: head/finance/trytond/files/pkg-message.in
==============================================================================
--- head/finance/trytond/files/pkg-message.in	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/finance/trytond/files/pkg-message.in	Tue Sep 18 00:57:12 2012	(r304423)
@@ -5,9 +5,8 @@ Before you start the trytond server, you
 
 1) Install a PostgreSQL server.
 
-2) Edit the file :
-%%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/config.py
-based on the configuration of your PostgreSQL server.
+2) Use the configuration file %%PREFIX%%/etc/trytond.conf
+to customize the daemon.
 
 For more information, see the DOCUMENTATION:
 

Modified: head/finance/trytond/files/trytond.in
==============================================================================
--- head/finance/trytond/files/trytond.in	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/finance/trytond/files/trytond.in	Tue Sep 18 00:57:12 2012	(r304423)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# $FreeBSD$
+# $FreeBSD: ports/finance/trytond/files/trytond.in,v 1.1 2012/08/18 07:18:24 wen Exp $
 #
 # PROVIDE: trytond
 # REQUIRE: postgresql LOGIN
@@ -25,6 +25,7 @@ trytond_user="${trytond_user:-"trytond"}
 trytond_logdir="${trytond_logdir:-"$(dirname `grep logfile %%PREFIX%%/etc/trytond.conf | awk -F "=" ' { print $2 } ' `)"}"
 
 command=%%PREFIX%%/bin/trytond
+command_interpreter=%%PYTHON%%
 command_args="--config=${trytond_config} >/dev/null 2>&1 &"
 
 pidfile="${trytond_pidfile:-"$(grep pidfile %%PREFIX%%/etc/trytond.conf | awk -F "=" ' { print $2 } ' |sed 's/[ ]//g' )"}"
@@ -34,8 +35,7 @@ start_precmd="${name}_prestart"
 
 trytond_prestart ()
 {
-	install -d -o ${trytond_user} $(dirname "${trytond_pidfile}")
-	install -d -o ${trytond_user} ${trytond_logdir}
+	install -d -o ${trytond_user} -g ${trytond_user} $(dirname "${pidfile}") "${trytond_logdir}"
 }
 
 run_rc_command "$1"

Modified: head/finance/trytond/pkg-plist
==============================================================================
--- head/finance/trytond/pkg-plist	Mon Sep 17 20:47:33 2012	(r304422)
+++ head/finance/trytond/pkg-plist	Tue Sep 18 00:57:12 2012	(r304423)
@@ -494,6 +494,9 @@ bin/trytond
 %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/wizard/wizard.py
 %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/wizard/wizard.pyc
 %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/wizard/wizard.pyo
+@unexec if cmp -s %D/etc/trytond.conf.sample %D/etc/trytond.conf; then rm -f %D/etc/trytond.conf; fi
+etc/trytond.conf.sample
+@exec if [ ! -f %D/etc/trytond.conf ] ; then cp -p %D/%F %B/trytond.conf; fi
 @dirrm %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/wizard
 @dirrm %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/webdav/locale
 @dirrm %%PYTHON_SITELIBDIR%%/%%PYEASYINSTALL_EGG%%/trytond/webdav
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 5 Wen Heping freebsd_committer freebsd_triage 2012-09-18 01:59:19 UTC
State Changed
From-To: feedback->closed

Committed, with minor changes. Thanks!