pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Clean up py-carbon package:



Module Name:	pkgsrc-wip
Committed By:	Jeff Rizzo <riz%tastylime.net@localhost>
Pushed By:	riz
Date:		Fri Dec 4 14:27:51 2015 -0800
Changeset:	417acd1a41a4d85bcfb942e97b91b525df5a871d

Modified Files:
	py-carbon/Makefile
	py-carbon/PLIST
	py-carbon/distinfo
	py-carbon/patches/patch-setup.py
Added Files:
	py-carbon/files/carbon-aggregator.sh
	py-carbon/files/carbon-cache.sh
	py-carbon/files/carbon-relay.sh
	py-carbon/patches/patch-carbon_conf_example

Log Message:
Clean up py-carbon package:

- create rc scripts for all three daemons
- set defaults a little more cleverly
- don't install the redhat-specific rc scripts.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=417acd1a41a4d85bcfb942e97b91b525df5a871d

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 py-carbon/Makefile                          | 25 ++++++----
 py-carbon/PLIST                             |  3 --
 py-carbon/distinfo                          |  3 +-
 py-carbon/files/carbon-aggregator.sh        | 73 +++++++++++++++++++++++++++++
 py-carbon/files/carbon-cache.sh             | 73 +++++++++++++++++++++++++++++
 py-carbon/files/carbon-relay.sh             | 73 +++++++++++++++++++++++++++++
 py-carbon/patches/patch-carbon_conf_example | 51 ++++++++++++++++++++
 py-carbon/patches/patch-setup.py            | 22 +++++----
 8 files changed, 300 insertions(+), 23 deletions(-)

diffs:
diff --git a/py-carbon/Makefile b/py-carbon/Makefile
index b7217b6..67eb880 100644
--- a/py-carbon/Makefile
+++ b/py-carbon/Makefile
@@ -24,26 +24,31 @@ BUILD_DEFS+=	VARBASE GRAPHITE_USER GRAPHITE_GROUP GRAPHITE_DIR
 
 GRAPHITE_USER?=		graphite
 GRAPHITE_GROUP?=	graphite
+GRAPHITE_DIR?=		${VARBASE}/graphite
+GRAPHITE_EGDIR?=	share/examples/graphite
 
 PKG_GROUPS+=			${GRAPHITE_GROUP}
 PKG_USERS+=			${GRAPHITE_USER}:${GRAPHITE_GROUP}
 PKG_GECOS.${GRAPHITE_USER}=	Graphite Carbon user
 
-GRAPHITE_DIR?=		${VARBASE}/graphite
-GRAPHITE_EGDIR?=	share/examples/graphite
-GRAPHITE_RCD?=		share/examples/rc.d
+RCD_SCRIPTS=		carbon-aggregator carbon-cache carbon-relay
+FILES_SUBST+=		GRAPHITE_USER=${GRAPHITE_USER} GRAPHITE_GROUP=${GRAPHITE_GROUP} \
+			GRAPHITE_DIR=${GRAPHITE_DIR}
+
+OWN_DIRS_PERMS+= ${GRAPHITE_DIR} ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
+OWN_DIRS_PERMS+= ${GRAPHITE_DIR}/lists ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
+OWN_DIRS_PERMS+= ${GRAPHITE_DIR}/rrd ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
+OWN_DIRS_PERMS+= ${GRAPHITE_DIR}/whisper ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
+OWN_DIRS_PERMS+= ${VARBASE}/log/graphite ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
+OWN_DIRS_PERMS+= ${VARBASE}/run/graphite ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
 
-OWN_DIRS_PERMS+=	${GRAPHITE_DIR} ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
-OWN_DIRS_PERMS+=	${GRAPHITE_DIR}/lists ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
-OWN_DIRS_PERMS+=	${GRAPHITE_DIR}/log ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
-OWN_DIRS_PERMS+=	${GRAPHITE_DIR}/rrd ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
-OWN_DIRS_PERMS+=	${GRAPHITE_DIR}/whisper ${GRAPHITE_USER} ${GRAPHITE_GROUP} 0755
 
 SUBST_CLASSES+=		dirs
 SUBST_STAGE.dirs=	pre-configure
 SUBST_MESSAGE.dirs=	Patching default storage directory
-SUBST_FILES.dirs=	setup.py
-SUBST_VARS.dirs=	GRAPHITE_DIR GRAPHITE_EGDIR GRAPHITE_RCD PREFIX
+SUBST_FILES.dirs=	setup.py conf/*
+SUBST_VARS.dirs=	GRAPHITE_DIR GRAPHITE_EGDIR GRAPHITE_USER PREFIX \
+			PKG_SYSCONFDIR VARBASE
 
 PKG_SYSCONFSUBDIR=	graphite
 
diff --git a/py-carbon/PLIST b/py-carbon/PLIST
index 0c6dc7e..46051f0 100644
--- a/py-carbon/PLIST
+++ b/py-carbon/PLIST
@@ -105,6 +105,3 @@ share/examples/graphite/rewrite-rules.conf.example
 share/examples/graphite/storage-aggregation.conf.example
 share/examples/graphite/storage-schemas.conf.example
 share/examples/graphite/whitelist.conf.example
-share/examples/rc.d/carbon-aggregator
-share/examples/rc.d/carbon-cache
-share/examples/rc.d/carbon-relay
diff --git a/py-carbon/distinfo b/py-carbon/distinfo
index d5b0738..3d894d2 100644
--- a/py-carbon/distinfo
+++ b/py-carbon/distinfo
@@ -4,4 +4,5 @@ SHA1 (carbon-0.9.15.tar.gz) = 204e837684c29ac09069d740d009f070bfb942d3
 RMD160 (carbon-0.9.15.tar.gz) = 4a1b11d8ba06357f44e6eca3d45ee0f89dfef98a
 SHA512 (carbon-0.9.15.tar.gz) = cc56257e703fc262dd27019d4a4e86d483daf55bb4c0792200be82533fc721b087b9eb5926cd007bf1e1c0f799729de871de5182f807fa9e0394ba08eccfa2fe
 Size (carbon-0.9.15.tar.gz) = 57328 bytes
-SHA1 (patch-setup.py) = b3f5d9c312b295d5e0ccf08a5364eaf313bf32ee
+SHA1 (patch-carbon_conf_example) = e38fea6ccedb662e5708b594ec237f2eeef1ffd7
+SHA1 (patch-setup.py) = c9d08fcc91db9329b35ff79fdb08c1aa4bc0fd8d
diff --git a/py-carbon/files/carbon-aggregator.sh b/py-carbon/files/carbon-aggregator.sh
new file mode 100644
index 0000000..18ba342
--- /dev/null
+++ b/py-carbon/files/carbon-aggregator.sh
@@ -0,0 +1,73 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD$
+#
+# PROVIDE: carbon-aggregator
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="carbon_aggregator"
+rcvar=$name
+command="@PREFIX@/bin/carbon-aggregator.py"
+config="--config=@PKG_SYSCONFDIR@/carbon.conf"
+graphite_user="@GRAPHITE_USER@"
+graphite_group="@GRAPHITE_GROUP@"
+graphite_dir="@GRAPHITE_DIR@"
+extra_commands="status"
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+start_precmd='setproclimits'
+
+setproclimits()
+{
+	local climit
+	climit=$(ulimit -n)
+	if [ "$climit" -lt 4096 ]; then
+		ulimit -n 4096
+	fi
+}
+
+carbon_aggregator_start()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config}  start"
+}
+
+carbon_aggregator_stop()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} stop"
+}
+
+carbon_aggregator_status()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} status"
+}
+
+
+if [ -f /etc/rc.subr -a -f /etc/rc.conf ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	if [ -f /etc/rc.conf ]; then
+		. /etc/rc.conf
+	fi
+	case $1 in
+	start)
+		${start_cmd}
+		;;
+	stop)
+		${stop_cmd}
+		;;
+	restart)
+		${stop_cmd} && ${start_cmd}
+		;;
+	*)
+		@ECHO@ "Usage: $0 {start|stop|restart}" 1>&2
+		exit 64
+		;;
+	esac
+fi
diff --git a/py-carbon/files/carbon-cache.sh b/py-carbon/files/carbon-cache.sh
new file mode 100644
index 0000000..e1656db
--- /dev/null
+++ b/py-carbon/files/carbon-cache.sh
@@ -0,0 +1,73 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD$
+#
+# PROVIDE: carbon-cache
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="carbon_cache"
+rcvar=$name
+command="@PREFIX@/bin/carbon-cache.py"
+config="--config=@PKG_SYSCONFDIR@/carbon.conf"
+graphite_user="@GRAPHITE_USER@"
+graphite_group="@GRAPHITE_GROUP@"
+graphite_dir="@GRAPHITE_DIR@"
+extra_commands="status"
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+start_precmd='setproclimits'
+
+setproclimits()
+{
+	local climit
+	climit=$(ulimit -n)
+	if [ "$climit" -lt 4096 ]; then
+		ulimit -n 4096
+	fi
+}
+
+carbon_cache_start()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config}  start"
+}
+
+carbon_cache_stop()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} stop"
+}
+
+carbon_cache_status()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} status"
+}
+
+
+if [ -f /etc/rc.subr -a -f /etc/rc.conf ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	if [ -f /etc/rc.conf ]; then
+		. /etc/rc.conf
+	fi
+	case $1 in
+	start)
+		${start_cmd}
+		;;
+	stop)
+		${stop_cmd}
+		;;
+	restart)
+		${stop_cmd} && ${start_cmd}
+		;;
+	*)
+		@ECHO@ "Usage: $0 {start|stop|restart}" 1>&2
+		exit 64
+		;;
+	esac
+fi
diff --git a/py-carbon/files/carbon-relay.sh b/py-carbon/files/carbon-relay.sh
new file mode 100644
index 0000000..f545123
--- /dev/null
+++ b/py-carbon/files/carbon-relay.sh
@@ -0,0 +1,73 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD$
+#
+# PROVIDE: carbon-relay
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+fi
+
+name="carbon_relay"
+rcvar=$name
+command="@PREFIX@/bin/carbon-relay.py"
+config="--config=@PKG_SYSCONFDIR@/carbon.conf"
+graphite_user="@GRAPHITE_USER@"
+graphite_group="@GRAPHITE_GROUP@"
+graphite_dir="@GRAPHITE_DIR@"
+extra_commands="status"
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+start_precmd='setproclimits'
+
+setproclimits()
+{
+	local climit
+	climit=$(ulimit -n)
+	if [ "$climit" -lt 4096 ]; then
+		ulimit -n 4096
+	fi
+}
+
+carbon_relay_start()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config}  start"
+}
+
+carbon_relay_stop()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} stop"
+}
+
+carbon_relay_status()
+{
+	@SU@ -m ${graphite_user} -c "${command} ${config} status"
+}
+
+
+if [ -f /etc/rc.subr -a -f /etc/rc.conf ]; then
+	load_rc_config $name
+	run_rc_command "$1"
+else
+	if [ -f /etc/rc.conf ]; then
+		. /etc/rc.conf
+	fi
+	case $1 in
+	start)
+		${start_cmd}
+		;;
+	stop)
+		${stop_cmd}
+		;;
+	restart)
+		${stop_cmd} && ${start_cmd}
+		;;
+	*)
+		@ECHO@ "Usage: $0 {start|stop|restart}" 1>&2
+		exit 64
+		;;
+	esac
+fi
diff --git a/py-carbon/patches/patch-carbon_conf_example b/py-carbon/patches/patch-carbon_conf_example
new file mode 100644
index 0000000..f29675c
--- /dev/null
+++ b/py-carbon/patches/patch-carbon_conf_example
@@ -0,0 +1,51 @@
+$NetBSD$
+
+Set package-appropriate defaults
+
+--- conf/carbon.conf.example.orig	2015-11-27 10:37:07.000000000 -0800
++++ conf/carbon.conf.example	2015-12-04 14:20:31.000000000 -0800
+@@ -30,6 +30,11 @@
+ #
+ #LOCAL_DATA_DIR = /opt/graphite/storage/whisper/
+ 
++STORAGE_DIR	= @GRAPHITE_DIR@
++CONF_DIR	= @PKG_SYSCONFDIR@
++LOG_DIR		= @VARBASE@/log/graphite/
++PID_DIR		= @VARBASE@/run/graphite/
++
+ # Enable daily log rotation. If disabled, carbon will automatically re-open
+ # the file if it's rotated out of place (e.g. by logrotate daemon)
+ ENABLE_LOGROTATION = True
+@@ -37,7 +42,7 @@
+ # Specify the user to drop privileges to
+ # If this is blank carbon runs as the user that invokes it
+ # This user must have write access to the local data directory
+-USER =
++USER = @GRAPHITE_USER@
+ #
+ # NOTE: The above settings must be set under [relay] and [aggregator]
+ #       to take effect for those daemons as well
+@@ -235,6 +240,11 @@
+ 
+ 
+ [relay]
++STORAGE_DIR	= @GRAPHITE_DIR@
++CONF_DIR	= @PKG_SYSCONFDIR@
++LOG_DIR		= @VARBASE@/log/graphite/
++PID_DIR		= @VARBASE@/run/graphite/
++USER = @GRAPHITE_USER@
+ LINE_RECEIVER_INTERFACE = 0.0.0.0
+ LINE_RECEIVER_PORT = 2013
+ PICKLE_RECEIVER_INTERFACE = 0.0.0.0
+@@ -322,6 +332,11 @@
+ 
+ 
+ [aggregator]
++STORAGE_DIR	= @GRAPHITE_DIR@
++CONF_DIR	= @PKG_SYSCONFDIR@
++LOG_DIR		= @VARBASE@/log/graphite/
++PID_DIR		= @VARBASE@/run/graphite/
++USER = @GRAPHITE_USER@
+ LINE_RECEIVER_INTERFACE = 0.0.0.0
+ LINE_RECEIVER_PORT = 2023
+ 
diff --git a/py-carbon/patches/patch-setup.py b/py-carbon/patches/patch-setup.py
index 421a417..801fe23 100644
--- a/py-carbon/patches/patch-setup.py
+++ b/py-carbon/patches/patch-setup.py
@@ -1,8 +1,10 @@
 $NetBSD$
 
+Rearrange installation dirs for pkgsrc, and don't install redhat files
+
 --- setup.py.orig	2015-11-27 10:37:07.000000000 -0800
-+++ setup.py	2015-12-03 10:56:59.000000000 -0800
-@@ -13,15 +13,16 @@
++++ setup.py	2015-12-04 12:53:42.000000000 -0800
+@@ -13,19 +13,12 @@
    setup_kwargs = dict()
  
  
@@ -15,11 +17,13 @@ $NetBSD$
  
  install_files = storage_dirs + conf_files
  
- # Let's include redhat init scripts, despite build platform
- # but won't put them in /etc/init.d/ automatically anymore
+-# Let's include redhat init scripts, despite build platform
+-# but won't put them in /etc/init.d/ automatically anymore
 -init_scripts = [ ('examples/init.d', ['distro/redhat/init.d/carbon-cache',
-+init_scripts = [ ('@GRAPHITE_RCD@',
-+                                     ['distro/redhat/init.d/carbon-cache',
-                                       'distro/redhat/init.d/carbon-relay',
-                                       'distro/redhat/init.d/carbon-aggregator']) ]
- install_files += init_scripts
+-                                      'distro/redhat/init.d/carbon-relay',
+-                                      'distro/redhat/init.d/carbon-aggregator']) ]
+-install_files += init_scripts
+-
+ 
+ setup(
+   name='carbon',


Home | Main Index | Thread Index | Old Index