Bug 171569 - net/boinc-client clang update
Summary: net/boinc-client clang update
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: Pav Lucistnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-12 12:20 UTC by Andrey Simonenko
Modified: 2012-10-18 20:22 UTC (History)
0 users

See Also:


Attachments
file.diff (744 bytes, patch)
2012-09-12 12:20 UTC, Andrey Simonenko
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Simonenko 2012-09-12 12:20:03 UTC
The following change allows to build net/boinc-client with clang from the base system.

Fix: Patch attached with submission follows:
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-09-12 12:20:21 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pav

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Andrey Simonenko 2012-09-21 12:44:44 UTC
The following change corrects and improves rc.d/boinc-client:

1. Now it is possible to add additional flags for boinc_client using
   the boinc_client_flags rc.conf variable.

2. Check whether the boinc-client rc.d script was started is moved to
   the boinc_client_running() function.

3. Removed check for the boinc_client_enable variable in
   the boinc_client_start() function.

4. Now the boinc_client_stop() function sends SIGTERM to all boinc_client
   processes run by ${boinc_client_user}.  Previous approach with
   "boinccmd --quit" will not work if a user specifies "--no_gui_rpc"
   for boinc_client.

5. Added the boinc_client_status() function.

diff -ruN boinc-client.orig/files/boinc-client.in boinc-client/files/boinc-client.in
--- boinc-client.orig/files/boinc-client.in	2012-04-15 15:57:50.000000000 +0300
+++ boinc-client/files/boinc-client.in	2012-09-21 14:13:20.000000000 +0300
@@ -6,52 +6,71 @@
 # REQUIRE: LOGIN
 # KEYWORD: shutdown
 #
-# Add the following line to /etc/rc.conf to enable the BOINC client:
-#
-# boinc_client_enable="YES"
+# Add the following lines to /etc/rc.conf to enable the BOINC client:
 #
+# boinc_client_enable (boolean)		Set to "YES" to enable boinc-client
+#					(default is "NO").
+# boinc_client_flags (string)		Additional flags for boinc_client.
 
 . /etc/rc.subr
 
 name="boinc-client"
 rcvar=boinc_client_enable
 
+load_rc_config $name
+: ${boinc_client_enable="NO"}
+
 boinc_client_user=%%BOINC_CLIENT_USER%%
 boinc_client_home=%%BOINC_CLIENT_HOME%%
-boinc_client_flags="--daemon --dir ${boinc_client_home}"
+boinc_client_flags="${boinc_client_flags} --daemon --dir ${boinc_client_home}"
 
 active_file="/var/run/${name}.active"
 
-load_rc_config $name
-: ${boinc_client_enable="NO"}
-
 start_cmd=boinc_client_start
 stop_cmd=boinc_client_stop
+status_cmd=boinc_client_status
+
+boinc_client_running()
+{
+	if [ -f ${active_file} ]; then
+		return 0
+	else
+		return 1
+	fi
+}
 
 boinc_client_start()
 {
-	if checkyesno boinc_client_enable; then
-		if [ -f ${active_file} ]; then
-			echo 1>&2 "${name} already running?"
-			return 1
-		fi
-		echo "Starting ${name}."
-		idprio 31 su - ${boinc_client_user} -c \
-		    "%%PREFIX%%/bin/boinc_client ${boinc_client_flags}"
+	if boinc_client_running; then
+		echo 1>&2 "${name} already running?"
+		return 1
+	fi
+	echo "Starting ${name}."
+	idprio 31 su - ${boinc_client_user} -c \
+	    "%%PREFIX%%/bin/boinc_client ${boinc_client_flags}"
+	if [ $? -eq 0 ]; then
 		touch ${active_file}
 	fi
 }
 
 boinc_client_stop()
 {
-	if [ ! -f ${active_file} ]; then
+	if ! boinc_client_running; then
 		echo 1>&2 "${name} is not running."
 		return 1
 	fi
 	echo "Stopping ${name}."
-	su - ${boinc_client_user} -c \
-	    "cd ${boinc_client_home} && %%PREFIX%%/bin/boinccmd --quit"
+	pkill -U ${boinc_client_user} boinc_client
 	rm ${active_file}
 }
 
+boinc_client_status()
+{
+	if boinc_client_running; then
+		echo 1>&2 "${name} is running."
+	else
+		echo 1>&2 "${name} is not running."
+	fi
+}
+
 run_rc_command "$1"
Comment 3 Andrey Simonenko 2012-09-21 13:07:18 UTC
I think that if a home directory for the client is created by
the pkg-install script, then its default permissions should be
enabled only for a user.  Also added header with revision number.

--- pkg-install.in.orig	2012-04-15 15:57:50.000000000 +0300
+++ pkg-install.in	2012-09-21 14:56:15.000000000 +0300
@@ -1,4 +1,7 @@
 #!/bin/sh
+#
+# $FreeBSD:$
+#
 
 PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
 
@@ -22,7 +25,7 @@
     else
 	echo "BOINC client user found.  Using found account."
     fi
-    mkdir -p ${home}
+    mkdir -m u=rwx,go= -p ${home}
     if [ ! -e ${home}/skins -a ! -L ${home}/skins ]; then
 	ln -s %%PREFIX%%/share/boinc/skins ${home}/skins
 	chown -h ${user}:${group} ${home}/skins
Comment 4 Andrey Simonenko 2012-10-03 13:31:43 UTC
I modified previous changes and unite them in one diff file:

1. Corrected building of the port with clang.

2. pkg-install: allow access to BOINC_CLIENT_HOME directory only
   for the owner, allow to specify spaces in pathnames.

3. boinc-client: corrected "name", now PID file is created, allow to
   specify additional flags in boinc_client_flags, allow to specify
   spaces in pathnames.

4. pkg-plist: allow to specify spaces in pathnames.

What if pkg-install will change the owner of all files under the
BOINC_CLIENT_HOME directory (now it changes only the owner of the
top directory)?  I.e. "chown -R ${user}:${group} "${home}" and remove
all other chown commands from pkg-install.

diff -ruN boinc-client.orig/Makefile boinc-client/Makefile
--- boinc-client.orig/Makefile	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/Makefile	2012-10-03 14:29:48.000000000 +0300
@@ -7,6 +7,7 @@
 
 PORTNAME=	boinc-client
 PORTVERSION=	7.0.28
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_LOCAL}
 MASTER_SITE_SUBDIR=	pav
diff -ruN boinc-client.orig/files/boinc-client.in boinc-client/files/boinc-client.in
--- boinc-client.orig/files/boinc-client.in	2012-04-15 15:57:50.000000000 +0300
+++ boinc-client/files/boinc-client.in	2012-10-03 13:45:30.000000000 +0300
@@ -6,52 +6,49 @@
 # REQUIRE: LOGIN
 # KEYWORD: shutdown
 #
-# Add the following line to /etc/rc.conf to enable the BOINC client:
-#
-# boinc_client_enable="YES"
+# Add the following lines to /etc/rc.conf to enable the BOINC client:
 #
+# boinc_client_enable (boolean)		Set to "YES" to enable boinc_client
+#					(default is "NO").
+# boinc_client_flags (string)		Additional flags for boinc_client.
 
 . /etc/rc.subr
 
-name="boinc-client"
+name="boinc_client"
 rcvar=boinc_client_enable
 
-boinc_client_user=%%BOINC_CLIENT_USER%%
-boinc_client_home=%%BOINC_CLIENT_HOME%%
-boinc_client_flags="--daemon --dir ${boinc_client_home}"
+load_rc_config ${name}
+: ${boinc_client_enable="NO"}
 
-active_file="/var/run/${name}.active"
+command="%%PREFIX%%/bin/boinc_client"
+pidfile="/var/run/${name}.pid"
 
-load_rc_config $name
-: ${boinc_client_enable="NO"}
+boinc_client_user=%%BOINC_CLIENT_USER%%
+boinc_client_home="%%BOINC_CLIENT_HOME%%"
+command_args="--daemon --dir \"${boinc_client_home}\""
 
 start_cmd=boinc_client_start
-stop_cmd=boinc_client_stop
+stop_postcmd=boinc_client_poststop
 
 boinc_client_start()
 {
-	if checkyesno boinc_client_enable; then
-		if [ -f ${active_file} ]; then
-			echo 1>&2 "${name} already running?"
-			return 1
-		fi
-		echo "Starting ${name}."
-		idprio 31 su - ${boinc_client_user} -c \
-		    "%%PREFIX%%/bin/boinc_client ${boinc_client_flags}"
-		touch ${active_file}
+	local pid
+
+	pid=$(check_pidfile "${pidfile}" "${command}")
+	if [ -n "${pid}" ]; then
+		echo 1>&2 "${name} already running? (pid=${pid})."
+		return 1
 	fi
+	echo "Starting ${name}."
+	idprio 31 su - ${boinc_client_user} -c \
+	    "\"${command}\" ${boinc_client_flags} ${command_args}" || return 1
+	pgrep -U ${boinc_client_user} -n -t - '^boinc_client$' \
+	    > "${pidfile}" || return 1
 }
 
-boinc_client_stop()
+boinc_client_poststop()
 {
-	if [ ! -f ${active_file} ]; then
-		echo 1>&2 "${name} is not running."
-		return 1
-	fi
-	echo "Stopping ${name}."
-	su - ${boinc_client_user} -c \
-	    "cd ${boinc_client_home} && %%PREFIX%%/bin/boinccmd --quit"
-	rm ${active_file}
+	rm -f "${pidfile}"
 }
 
 run_rc_command "$1"
diff -ruN boinc-client.orig/files/patch-zip-unzip-extract.c boinc-client/files/patch-zip-unzip-extract.c
--- boinc-client.orig/files/patch-zip-unzip-extract.c	1970-01-01 03:00:00.000000000 +0300
+++ boinc-client/files/patch-zip-unzip-extract.c	2012-09-12 14:05:18.000000000 +0300
@@ -0,0 +1,11 @@
+--- zip/unzip/extract.c.orig	2012-04-09 13:58:50.000000000 +0300
++++ zip/unzip/extract.c		2012-09-12 14:05:07.000000000 +0300
+@@ -218,7 +218,7 @@
+ static ZCONST char Far InvalidComprData[] = "invalid compressed data to ";
+ static ZCONST char Far Inflate[] = "inflate_boinc";
+ 
+-extern int inflate_boinc(__G__ is_defl64);
++extern int inflate_boinc(__GPRO__ int is_defl64);
+ 
+ #ifndef SFX
+    static ZCONST char Far Explode[] = "explode";
diff -ruN boinc-client.orig/files/pkg-install.in boinc-client/files/pkg-install.in
--- boinc-client.orig/files/pkg-install.in	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/files/pkg-install.in	2012-10-03 13:06:40.000000000 +0300
@@ -1,16 +1,19 @@
 #!/bin/sh
+#
+# $FreeBSD:$
+#
 
 PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
 
 user=%%BOINC_CLIENT_USER%%
 group=%%BOINC_CLIENT_GROUP%%
-home=%%BOINC_CLIENT_HOME%%
+home="%%BOINC_CLIENT_HOME%%"
 shell=/bin/sh
 
 case $2 in
 POST-INSTALL)
     if ! pw usershow ${user} >/dev/null 2>&1; then
-	if ! pw useradd ${user} -g ${group} -c "BOINC client user" -d ${home} -s ${shell}; then
+	if ! pw useradd ${user} -g ${group} -c "BOINC client user" -d "${home}" -s ${shell}; then
 		err=$?
 		echo "WARNING: Unable to create user ${user}.  pw returned ${err}"
 		echo "You will need to create a BOINC client user and"
@@ -22,15 +25,15 @@
     else
 	echo "BOINC client user found.  Using found account."
     fi
-    mkdir -p ${home}
-    if [ ! -e ${home}/skins -a ! -L ${home}/skins ]; then
-	ln -s %%PREFIX%%/share/boinc/skins ${home}/skins
-	chown -h ${user}:${group} ${home}/skins
+    mkdir -m u=rwx,go= -p "${home}"
+    if [ ! -e "${home}/skins" -a ! -L "${home}/skins" ]; then
+	ln -s "%%PREFIX%%/share/boinc/skins" "${home}/skins"
+	chown -h ${user}:${group} "${home}/skins"
     fi
-    if [ ! -e ${home}/ca-bundle.crt -a ! -L ${home}/ca-bundle.crt ]; then
-	ln -s %%LOCALBASE%%/share/certs/ca-root-nss.crt ${home}/ca-bundle.crt
-	chown -h ${user}:${group} ${home}/ca-bundle.crt
+    if [ ! -e "${home}/ca-bundle.crt" -a ! -L "${home}/ca-bundle.crt" ]; then
+	ln -s "%%LOCALBASE%%/share/certs/ca-root-nss.crt" "${home}/ca-bundle.crt"
+	chown -h ${user}:${group} "${home}/ca-bundle.crt"
     fi
-    chown ${user}:${group} ${home}
+    chown ${user}:${group} "${home}"
     ;;
 esac
diff -ruN boinc-client.orig/pkg-plist boinc-client/pkg-plist
--- boinc-client.orig/pkg-plist	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/pkg-plist	2012-10-03 14:07:02.000000000 +0300
@@ -448,6 +448,6 @@
 %%X11%%@dirrm share/boinc
 %%NLS%%@dirrmtry share/locale/sv_SE/LC_MESSAGES
 %%NLS%%@dirrmtry share/locale/sv_SE
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo "If you are deinstalling boinc-client completely, remove the %%BOINC_CLIENT_HOME%% directory."; fi
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo -n "Also, d"; else echo -n "D"; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo "If you are deinstalling boinc-client completely, remove the \"%%BOINC_CLIENT_HOME%%\" directory."; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo -n "Also, d"; else echo -n "D"; fi
 %%USER%%@unexec echo "on't forget to remove the BOINC client user \"%%BOINC_CLIENT_USER%%\"."
Comment 5 Andrey Simonenko 2012-10-08 13:47:57 UTC
Updated version:

1. Corrected building of the port with clang.

2. pkg-install: call it in pre-install, allow access to BOINC_CLIENT_HOME
   directory only for the owner, allow to specify spaces in pathnames,
   adjust file ownership for the entire BOINC_CLIENT_HOME directory.

3. boinc-client: corrected "name", now PID file is created, allow to
   specify additional flags in boinc_client_flags, allow to specify
   spaces in pathnames.

4. pkg-plist: allow to specify spaces in pathnames.

diff -ruN boinc-client.orig/Makefile boinc-client/Makefile
--- boinc-client.orig/Makefile	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/Makefile	2012-10-08 14:25:17.000000000 +0300
@@ -7,6 +7,7 @@
 
 PORTNAME=	boinc-client
 PORTVERSION=	7.0.28
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_LOCAL}
 MASTER_SITE_SUBDIR=	pav
@@ -148,6 +149,11 @@
 	@${REINPLACE_CMD} -e 's|@BUILD_GRAPHICS_API_TRUE@|#&|' ${WRKSRC}/api/Makefile.in
 .endif
 
+pre-install:
+.if ${PORT_OPTIONS:MUSER}
+	@PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+.endif
+
 post-install:
 .if ${PORT_OPTIONS:MMANAGER}
 	${MKDIR} ${PREFIX}/share/boinc
@@ -175,8 +181,5 @@
 . endif
 	${CP} -R ${WRKSRC}/api/txf ${PREFIX}/share/boinc
 .endif
-.if ${PORT_OPTIONS:MUSER}
-	@PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
-.endif
 
 .include <bsd.port.post.mk>
diff -ruN boinc-client.orig/files/boinc-client.in boinc-client/files/boinc-client.in
--- boinc-client.orig/files/boinc-client.in	2012-04-15 15:57:50.000000000 +0300
+++ boinc-client/files/boinc-client.in	2012-10-03 13:45:30.000000000 +0300
@@ -6,52 +6,49 @@
 # REQUIRE: LOGIN
 # KEYWORD: shutdown
 #
-# Add the following line to /etc/rc.conf to enable the BOINC client:
-#
-# boinc_client_enable="YES"
+# Add the following lines to /etc/rc.conf to enable the BOINC client:
 #
+# boinc_client_enable (boolean)		Set to "YES" to enable boinc_client
+#					(default is "NO").
+# boinc_client_flags (string)		Additional flags for boinc_client.
 
 . /etc/rc.subr
 
-name="boinc-client"
+name="boinc_client"
 rcvar=boinc_client_enable
 
-boinc_client_user=%%BOINC_CLIENT_USER%%
-boinc_client_home=%%BOINC_CLIENT_HOME%%
-boinc_client_flags="--daemon --dir ${boinc_client_home}"
+load_rc_config ${name}
+: ${boinc_client_enable="NO"}
 
-active_file="/var/run/${name}.active"
+command="%%PREFIX%%/bin/boinc_client"
+pidfile="/var/run/${name}.pid"
 
-load_rc_config $name
-: ${boinc_client_enable="NO"}
+boinc_client_user=%%BOINC_CLIENT_USER%%
+boinc_client_home="%%BOINC_CLIENT_HOME%%"
+command_args="--daemon --dir \"${boinc_client_home}\""
 
 start_cmd=boinc_client_start
-stop_cmd=boinc_client_stop
+stop_postcmd=boinc_client_poststop
 
 boinc_client_start()
 {
-	if checkyesno boinc_client_enable; then
-		if [ -f ${active_file} ]; then
-			echo 1>&2 "${name} already running?"
-			return 1
-		fi
-		echo "Starting ${name}."
-		idprio 31 su - ${boinc_client_user} -c \
-		    "%%PREFIX%%/bin/boinc_client ${boinc_client_flags}"
-		touch ${active_file}
+	local pid
+
+	pid=$(check_pidfile "${pidfile}" "${command}")
+	if [ -n "${pid}" ]; then
+		echo 1>&2 "${name} already running? (pid=${pid})."
+		return 1
 	fi
+	echo "Starting ${name}."
+	idprio 31 su - ${boinc_client_user} -c \
+	    "\"${command}\" ${boinc_client_flags} ${command_args}" || return 1
+	pgrep -U ${boinc_client_user} -n -t - '^boinc_client$' \
+	    > "${pidfile}" || return 1
 }
 
-boinc_client_stop()
+boinc_client_poststop()
 {
-	if [ ! -f ${active_file} ]; then
-		echo 1>&2 "${name} is not running."
-		return 1
-	fi
-	echo "Stopping ${name}."
-	su - ${boinc_client_user} -c \
-	    "cd ${boinc_client_home} && %%PREFIX%%/bin/boinccmd --quit"
-	rm ${active_file}
+	rm -f "${pidfile}"
 }
 
 run_rc_command "$1"
diff -ruN boinc-client.orig/files/patch-zip-unzip-extract.c boinc-client/files/patch-zip-unzip-extract.c
--- boinc-client.orig/files/patch-zip-unzip-extract.c	1970-01-01 03:00:00.000000000 +0300
+++ boinc-client/files/patch-zip-unzip-extract.c	2012-09-12 14:05:18.000000000 +0300
@@ -0,0 +1,11 @@
+--- zip/unzip/extract.c.orig	2012-04-09 13:58:50.000000000 +0300
++++ zip/unzip/extract.c		2012-09-12 14:05:07.000000000 +0300
+@@ -218,7 +218,7 @@
+ static ZCONST char Far InvalidComprData[] = "invalid compressed data to ";
+ static ZCONST char Far Inflate[] = "inflate_boinc";
+ 
+-extern int inflate_boinc(__G__ is_defl64);
++extern int inflate_boinc(__GPRO__ int is_defl64);
+ 
+ #ifndef SFX
+    static ZCONST char Far Explode[] = "explode";
diff -ruN boinc-client.orig/files/pkg-install.in boinc-client/files/pkg-install.in
--- boinc-client.orig/files/pkg-install.in	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/files/pkg-install.in	2012-10-08 15:07:34.000000000 +0300
@@ -1,36 +1,42 @@
 #!/bin/sh
+#
+# $FreeBSD:$
+#
 
 PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
 
 user=%%BOINC_CLIENT_USER%%
 group=%%BOINC_CLIENT_GROUP%%
-home=%%BOINC_CLIENT_HOME%%
+home="%%BOINC_CLIENT_HOME%%"
 shell=/bin/sh
 
 case $2 in
-POST-INSTALL)
-    if ! pw usershow ${user} >/dev/null 2>&1; then
-	if ! pw useradd ${user} -g ${group} -c "BOINC client user" -d ${home} -s ${shell}; then
-		err=$?
-		echo "WARNING: Unable to create user ${user}.  pw returned ${err}"
-		echo "You will need to create a BOINC client user and"
-		echo "chown the BOINC client user directory."
-		exit ${err}
+PRE-INSTALL)
+	if ! pw usershow ${user} 2>/dev/null 1>&2; then
+		if ! pw useradd ${user} -g ${group} -c "BOINC client user" \
+		    -d "${home}" -s ${shell}; then
+			echo "Failed to create user \"${user}\"." >&2
+			exit 1
+		else
+			echo "User \"${user}\" created successfully:"
+		fi
 	else
-		echo "BOINC client user created."
+		echo "Using existent user \"${user}\":"
 	fi
-    else
-	echo "BOINC client user found.  Using found account."
-    fi
-    mkdir -p ${home}
-    if [ ! -e ${home}/skins -a ! -L ${home}/skins ]; then
-	ln -s %%PREFIX%%/share/boinc/skins ${home}/skins
-	chown -h ${user}:${group} ${home}/skins
-    fi
-    if [ ! -e ${home}/ca-bundle.crt -a ! -L ${home}/ca-bundle.crt ]; then
-	ln -s %%LOCALBASE%%/share/certs/ca-root-nss.crt ${home}/ca-bundle.crt
-	chown -h ${user}:${group} ${home}/ca-bundle.crt
-    fi
-    chown ${user}:${group} ${home}
-    ;;
+	pw usershow ${user}
+	mkdir -m u=rwx,go= -p "${home}"
+	if [ ! -e "${home}/skins" -a ! -L "${home}/skins" ]; then
+		ln -s "%%PREFIX%%/share/boinc/skins" "${home}/skins"
+	fi
+	if [ ! -e "${home}/ca-bundle.crt" -a ! -L "${home}/ca-bundle.crt" ]; then
+		ln -s "%%LOCALBASE%%/share/certs/ca-root-nss.crt" "${home}/ca-bundle.crt"
+	fi
+	echo "Adjusting file ownership in \"${home}\" to ${user}:${group}"
+	chown -Rh ${user}:${group} "${home}"
+        ;;
+*)
+	exit 64
+	;;
 esac
+
+exit 0
diff -ruN boinc-client.orig/pkg-plist boinc-client/pkg-plist
--- boinc-client.orig/pkg-plist	2012-10-03 11:44:01.000000000 +0300
+++ boinc-client/pkg-plist	2012-10-03 14:07:02.000000000 +0300
@@ -448,6 +448,6 @@
 %%X11%%@dirrm share/boinc
 %%NLS%%@dirrmtry share/locale/sv_SE/LC_MESSAGES
 %%NLS%%@dirrmtry share/locale/sv_SE
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo "If you are deinstalling boinc-client completely, remove the %%BOINC_CLIENT_HOME%% directory."; fi
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo -n "Also, d"; else echo -n "D"; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo "If you are deinstalling boinc-client completely, remove the \"%%BOINC_CLIENT_HOME%%\" directory."; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo -n "Also, d"; else echo -n "D"; fi
 %%USER%%@unexec echo "on't forget to remove the BOINC client user \"%%BOINC_CLIENT_USER%%\"."
Comment 6 Andrey Simonenko 2012-10-11 08:50:22 UTC
Updated version:

1. Corrected building of the port with clang.

2. pkg-install: call it in pre-install, allow access to BOINC_CLIENT_HOME
   directory only for the owner, allow to specify spaces in pathnames,
   adjust file ownership for the entire BOINC_CLIENT_HOME directory.

3. boinc-client: corrected "name", now PID file is created, allow to
   specify additional flags in boinc_client_flags, allow to specify
   spaces in pathnames, optimized number of variables.

4. pkg-plist: allow to specify spaces in pathnames.

diff -ruN boinc-client.orig/Makefile boinc-client/Makefile
--- boinc-client.orig/Makefile	2012-10-10 11:24:38.000000000 +0300
+++ boinc-client/Makefile	2012-10-08 14:25:17.000000000 +0300
@@ -2,11 +2,12 @@
 # Date created:				01 October 2004
 # Whom:					J.R. Oldroyd <fbsd@opal.com>
 #
-# $FreeBSD: ports/net/boinc-client/Makefile,v 1.58 2012/10/09 22:12:13 linimon Exp $
+# $FreeBSD: ports/net/boinc-client/Makefile,v 1.57 2012/08/27 13:24:03 pav Exp $
 #
 
 PORTNAME=	boinc-client
 PORTVERSION=	7.0.28
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_LOCAL}
 MASTER_SITE_SUBDIR=	pav
@@ -14,7 +15,6 @@
 MAINTAINER=	pav@FreeBSD.org
 COMMENT=	Berkeley Open Infrastructure for Network Computing client
 
-USE_GCC=	any
 USE_XZ=		yes
 GNU_CONFIGURE=	yes
 USE_LDCONFIG=	yes
@@ -149,6 +149,11 @@
 	@${REINPLACE_CMD} -e 's|@BUILD_GRAPHICS_API_TRUE@|#&|' ${WRKSRC}/api/Makefile.in
 .endif
 
+pre-install:
+.if ${PORT_OPTIONS:MUSER}
+	@PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+.endif
+
 post-install:
 .if ${PORT_OPTIONS:MMANAGER}
 	${MKDIR} ${PREFIX}/share/boinc
@@ -176,8 +181,5 @@
 . endif
 	${CP} -R ${WRKSRC}/api/txf ${PREFIX}/share/boinc
 .endif
-.if ${PORT_OPTIONS:MUSER}
-	@PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
-.endif
 
 .include <bsd.port.post.mk>
diff -ruN boinc-client.orig/files/boinc-client.in boinc-client/files/boinc-client.in
--- boinc-client.orig/files/boinc-client.in	2012-04-15 15:57:50.000000000 +0300
+++ boinc-client/files/boinc-client.in	2012-10-11 10:35:49.000000000 +0300
@@ -6,52 +6,48 @@
 # REQUIRE: LOGIN
 # KEYWORD: shutdown
 #
-# Add the following line to /etc/rc.conf to enable the BOINC client:
-#
-# boinc_client_enable="YES"
+# Add the following lines to /etc/rc.conf to enable the BOINC client:
 #
+# boinc_client_enable (boolean)		Set to "YES" to enable boinc_client
+#					(default is "NO").
+# boinc_client_flags (string)		Additional flags for boinc_client.
 
 . /etc/rc.subr
 
-name="boinc-client"
+name="boinc_client"
 rcvar=boinc_client_enable
 
-boinc_client_user=%%BOINC_CLIENT_USER%%
-boinc_client_home=%%BOINC_CLIENT_HOME%%
-boinc_client_flags="--daemon --dir ${boinc_client_home}"
+load_rc_config ${name}
+: ${boinc_client_enable="NO"}
 
-active_file="/var/run/${name}.active"
+command="%%PREFIX%%/bin/boinc_client"
+pidfile="/var/run/${name}.pid"
 
-load_rc_config $name
-: ${boinc_client_enable="NO"}
+boinc_client_user=%%BOINC_CLIENT_USER%%
+command_args="--daemon --dir \"%%BOINC_CLIENT_HOME%%\""
 
 start_cmd=boinc_client_start
-stop_cmd=boinc_client_stop
+stop_postcmd=boinc_client_poststop
 
 boinc_client_start()
 {
-	if checkyesno boinc_client_enable; then
-		if [ -f ${active_file} ]; then
-			echo 1>&2 "${name} already running?"
-			return 1
-		fi
-		echo "Starting ${name}."
-		idprio 31 su - ${boinc_client_user} -c \
-		    "%%PREFIX%%/bin/boinc_client ${boinc_client_flags}"
-		touch ${active_file}
+	local pid
+
+	pid=$(check_pidfile "${pidfile}" "${command}")
+	if [ -n "${pid}" ]; then
+		echo 1>&2 "${name} already running? (pid=${pid})."
+		return 1
 	fi
+	echo "Starting ${name}."
+	idprio 31 su - ${boinc_client_user} -c \
+	    "\"${command}\" ${boinc_client_flags} ${command_args}" || return 1
+	pgrep -U ${boinc_client_user} -n -t - '^boinc_client$' \
+	    > "${pidfile}" || return 1
 }
 
-boinc_client_stop()
+boinc_client_poststop()
 {
-	if [ ! -f ${active_file} ]; then
-		echo 1>&2 "${name} is not running."
-		return 1
-	fi
-	echo "Stopping ${name}."
-	su - ${boinc_client_user} -c \
-	    "cd ${boinc_client_home} && %%PREFIX%%/bin/boinccmd --quit"
-	rm ${active_file}
+	rm -f "${pidfile}"
 }
 
 run_rc_command "$1"
diff -ruN boinc-client.orig/files/patch-zip-unzip-extract.c boinc-client/files/patch-zip-unzip-extract.c
--- boinc-client.orig/files/patch-zip-unzip-extract.c	1970-01-01 03:00:00.000000000 +0300
+++ boinc-client/files/patch-zip-unzip-extract.c	2012-09-12 14:05:18.000000000 +0300
@@ -0,0 +1,11 @@
+--- zip/unzip/extract.c.orig	2012-04-09 13:58:50.000000000 +0300
++++ zip/unzip/extract.c		2012-09-12 14:05:07.000000000 +0300
+@@ -218,7 +218,7 @@
+ static ZCONST char Far InvalidComprData[] = "invalid compressed data to ";
+ static ZCONST char Far Inflate[] = "inflate_boinc";
+ 
+-extern int inflate_boinc(__G__ is_defl64);
++extern int inflate_boinc(__GPRO__ int is_defl64);
+ 
+ #ifndef SFX
+    static ZCONST char Far Explode[] = "explode";
diff -ruN boinc-client.orig/files/pkg-install.in boinc-client/files/pkg-install.in
--- boinc-client.orig/files/pkg-install.in	2012-04-15 15:57:50.000000000 +0300
+++ boinc-client/files/pkg-install.in	2012-10-11 10:35:34.000000000 +0300
@@ -1,36 +1,42 @@
 #!/bin/sh
+#
+# $FreeBSD:$
+#
 
 PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
 
 user=%%BOINC_CLIENT_USER%%
 group=%%BOINC_CLIENT_GROUP%%
-home=%%BOINC_CLIENT_HOME%%
+home="%%BOINC_CLIENT_HOME%%"
 shell=/bin/sh
 
 case $2 in
-POST-INSTALL)
-    if ! pw usershow ${user} >/dev/null 2>&1; then
-	if ! pw useradd ${user} -g ${group} -c "BOINC client user" -d ${home} -s ${shell}; then
-		err=$?
-		echo "WARNING: Unable to create user ${user}.  pw returned ${err}"
-		echo "You will need to create a BOINC client user and"
-		echo "chown the BOINC client user directory."
-		exit ${err}
+PRE-INSTALL)
+	if ! pw usershow ${user} 2>/dev/null 1>&2; then
+		if ! pw useradd ${user} -g ${group} -c "BOINC client user" \
+		    -d "${home}" -s ${shell}; then
+			echo "Failed to create user \"${user}\"." >&2
+			exit 1
+		else
+			echo "User \"${user}\" created successfully:"
+		fi
 	else
-		echo "BOINC client user created."
+		echo "Using existent user \"${user}\":"
 	fi
-    else
-	echo "BOINC client user found.  Using found account."
-    fi
-    mkdir -p ${home}
-    if [ ! -e ${home}/skins -a ! -L ${home}/skins ]; then
-	ln -s %%PREFIX%%/share/boinc/skins ${home}/skins
-	chown -h ${user}:${group} ${home}/skins
-    fi
-    if [ ! -e ${home}/ca-bundle.crt -a ! -L ${home}/ca-bundle.crt ]; then
-	ln -s %%LOCALBASE%%/share/certs/ca-root-nss.crt ${home}/ca-bundle.crt
-	chown -h ${user}:${group} ${home}/ca-bundle.crt
-    fi
-    chown ${user}:${group} ${home}
-    ;;
+	pw usershow ${user}
+	mkdir -m u=rwx,go= -p "${home}"
+	if [ ! -e "${home}/skins" -a ! -L "${home}/skins" ]; then
+		ln -s "%%PREFIX%%/share/boinc/skins" "${home}/skins"
+	fi
+	if [ ! -e "${home}/ca-bundle.crt" -a ! -L "${home}/ca-bundle.crt" ]; then
+		ln -s "%%LOCALBASE%%/share/certs/ca-root-nss.crt" "${home}/ca-bundle.crt"
+	fi
+	echo "Adjusting file ownership in \"${home}\" to ${user}:${group}"
+	chown -hR ${user}:${group} "${home}"
+        ;;
+*)
+	exit 64
+	;;
 esac
+
+exit 0
diff -ruN boinc-client.orig/pkg-plist boinc-client/pkg-plist
--- boinc-client.orig/pkg-plist	2012-08-27 16:24:03.000000000 +0300
+++ boinc-client/pkg-plist	2012-10-03 14:07:02.000000000 +0300
@@ -448,6 +448,6 @@
 %%X11%%@dirrm share/boinc
 %%NLS%%@dirrmtry share/locale/sv_SE/LC_MESSAGES
 %%NLS%%@dirrmtry share/locale/sv_SE
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo "If you are deinstalling boinc-client completely, remove the %%BOINC_CLIENT_HOME%% directory."; fi
-%%USER%%@unexec if [ -d %%BOINC_CLIENT_HOME%% ]; then echo -n "Also, d"; else echo -n "D"; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo "If you are deinstalling boinc-client completely, remove the \"%%BOINC_CLIENT_HOME%%\" directory."; fi
+%%USER%%@unexec if [ -d "%%BOINC_CLIENT_HOME%%" ]; then echo -n "Also, d"; else echo -n "D"; fi
 %%USER%%@unexec echo "on't forget to remove the BOINC client user \"%%BOINC_CLIENT_USER%%\"."
Comment 7 Pav Lucistnik freebsd_committer freebsd_triage 2012-10-18 19:53:25 UTC
State Changed
From-To: open->closed

Committed, thanks! 

Would you like to take over this port formally? You already did in practice...