1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-22 00:35:15 +00:00

- Fix with newer Django [1] [2]

- Lots of other cleanups and improvements, including moving the data to a more
  standard location
- Take maintainership, maintainer has not responded to PRs in many months

PR:		ports/184969 [1]
PR:		ports/185146 [2]
Submitted by:	brd [1]
Submitted by:	swills (myself) [2]
Approved by:	maintainer timeout (bsdports@wayfair.com, >3 months)
This commit is contained in:
Steve Wills 2014-02-18 15:48:34 +00:00
parent 096a5469d0
commit e8c000e06f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=344913
23 changed files with 927 additions and 716 deletions

View File

@ -3,32 +3,51 @@
PORTNAME= graphite-web
PORTVERSION= 0.9.12
PORTREVISION= 1
CATEGORIES= www python
MASTER_SITES= https://github.com/graphite-project/${PORTNAME}/archive/${PORTVERSION}.tar.gz?dummy=
MASTER_SITES= http://github.com/graphite-project/${PORTNAME}/archive/${PORTVERSION}.tar.gz?dummy=/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
MAINTAINER= bsdports@wayfair.com
MAINTAINER= swills@FreeBSD.org
COMMENT= Enterprise scalable realtime graphing platform
LICENSE= APACHE20
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}cairo>=1.8.10:${PORTSDIR}/graphics/py-cairo \
${PYTHON_PKGNAMEPREFIX}carbon>=${PORTVERSION}:${PORTSDIR}/databases/py-carbon \
${PYTHON_PKGNAMEPREFIX}django>=1.4:${PORTSDIR}/www/py-django \
${PYTHON_PKGNAMEPREFIX}django-tagging>=0.3.1:${PORTSDIR}/www/py-django-tagging
${PYTHON_PKGNAMEPREFIX}django-tagging>=0.3.1:${PORTSDIR}/www/py-django-tagging \
xorg-fonts-truetype>=0:${PORTSDIR}/x11-fonts/xorg-fonts-truetype
FETCH_ARGS= -o ${DISTNAME}${EXTRACT_SUFX}
USE_PYTHON= 2
USE_PYDISTUTILS=yes
SUB_FILES= pkg-message
SUB_LIST+= PYTHON_SITELIBDIR=${PYTHON_SITELIBDIR} WWWOWN=${WWWOWN} \
WWWGRP=${WWWGRP} DATADIR=${DATADIR}
PLIST_SUB+= RESETPREFIX=${PREFIX}
NO_STAGE= yes
post-patch:
@${MKDIR} ${WRKSRC}/graphite/webapp/
@${CP} -LR ${WRKSRC}/webapp/content ${WRKSRC}/graphite/webapp
@${RM} ${WRKSRC}/bin/build-index.sh.orig
@${RM} ${WRKSRC}/bin/run-graphite-devel-server.py
@${REINPLACE_CMD} -i '' -e 's|%%PREFIX%%|${PREFIX}|' \
-e 's|%%DATADIR%%|${DATADIR}|' \
${WRKSRC}/bin/build-index.sh \
${WRKSRC}/conf/graphite.wsgi.example \
${WRKSRC}/setup.cfg \
${WRKSRC}/setup.py \
${WRKSRC}/webapp/graphite/local_settings.py.example
post-install:
@${ECHO} ${PYTHON_SITELIBDIR}
${CHOWN} ${WWWOWN} ${PREFIX}/graphite/storage
${CHOWN} ${WWWOWN} ${PREFIX}/graphite/storage/log/webapp
@${CAT} ${PKGMESSAGE}
@${MKDIR} ${STAGEDIR}${DATADIR}/examples
@(cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/examples)
@${MKDIR} ${STAGEDIR}${DATADIR}/content
@(cd ${WRKSRC}/webapp/content && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/content)
@${MKDIR} -p ${STAGEDIR}/var/log/graphite/webapp
@${MKDIR} -p ${STAGEDIR}/var/db/graphite
@${CHOWN} ${WWWOWN} ${STAGEDIR}/var/log/graphite
@${CHOWN} ${WWWOWN} ${STAGEDIR}/var/db/graphite
@${CP} ${STAGEDIR}${PYTHON_SITELIBDIR}/graphite/local_settings.py.example ${STAGEDIR}${PREFIX}/etc/graphite/local_settings.py.example
@${LN} -s ${PREFIX}/etc/graphite/local_settings.py ${STAGEDIR}${PYTHON_SITELIBDIR}/graphite/local_settings.py
.include <bsd.port.mk>

View File

@ -1,30 +0,0 @@
--- bin/build-index.sh.orig 2012-05-31 07:28:54.000000000 +0100
+++ bin/build-index.sh 2012-11-06 20:13:04.887047813 +0000
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/sh
if [ "$GRAPHITE_ROOT" = "" ]
then
- GRAPHITE_ROOT="/opt/graphite"
+ GRAPHITE_ROOT="/usr/local/graphite"
fi
if [ "$GRAPHITE_STORAGE_DIR" = "" ]
@@ -11,7 +11,7 @@
fi
-WHISPER_DIR="${GRAPHITE_STORAGE_DIR}/whisper"
+WHISPER_DIR="/usr/local/storage/whisper"
if [ ! -d "$WHISPER_DIR" ]
then
@@ -26,6 +26,6 @@
cd $WHISPER_DIR
touch $INDEX_FILE
echo "[`date`] building index..."
-find -L . -name '*.wsp' | perl -pe 's!^[^/]+/(.+)\.wsp$!$1!; s!/!.!g' > $TMP_INDEX
+find -L . -name '*.wsp' | sed -E 's!^[^/]+/(.+)\.wsp$!\1!; s!/!.!g' > $TMP_INDEX
echo "[`date`] complete, switching to new index file"
mv -f $TMP_INDEX $INDEX_FILE

View File

@ -0,0 +1,48 @@
--- bin/build-index.sh.orig 2014-02-14 15:05:38.180621787 +0000
+++ bin/build-index.sh 2014-02-14 15:31:54.580513137 +0000
@@ -1,17 +1,19 @@
-#!/bin/bash
+#!/bin/sh
if [ "$GRAPHITE_ROOT" = "" ]
then
- GRAPHITE_ROOT="/opt/graphite"
+ GRAPHITE_ROOT="%%PREFIX%%/graphite"
fi
if [ "$GRAPHITE_STORAGE_DIR" = "" ]
then
- GRAPHITE_STORAGE_DIR="${GRAPHITE_ROOT}/storage"
+ GRAPHITE_STORAGE_DIR="/var/db/graphite"
fi
-
-WHISPER_DIR="${GRAPHITE_STORAGE_DIR}/whisper"
+if [ "$WHISPER_DIR" = "" ]
+then
+ WHISPER_DIR="/var/db/carbon/whisper/"
+fi
if [ ! -d "$WHISPER_DIR" ]
then
@@ -19,13 +21,17 @@
exit 1
fi
-INDEX_FILE="${GRAPHITE_STORAGE_DIR}/index"
-TMP_INDEX="${GRAPHITE_STORAGE_DIR}/.index.tmp"
+if [ "$INDEX_FILE" = "" ]
+then
+ INDEX_FILE="${GRAPHITE_STORAGE_DIR}/index"
+fi
+
+TMP_INDEX=${INDEX_FILE%%index}.index.tmp
rm -f $TMP_INDEX
cd $WHISPER_DIR
touch $INDEX_FILE
echo "[`date`] building index..."
-find -L . -name '*.wsp' | perl -pe 's!^[^/]+/(.+)\.wsp$!$1!; s!/!.!g' > $TMP_INDEX
+find -L . -name '*.wsp' | sed -E 's!^[^/]+/(.+)\.wsp$!\1!; s!/!.!g' > $TMP_INDEX
echo "[`date`] complete, switching to new index file"
mv -f $TMP_INDEX $INDEX_FILE

View File

@ -1,9 +0,0 @@
--- conf/graphite.wsgi.example.ori 2012-10-12 19:34:56.000000000 -0600
+++ conf/graphite.wsgi.example 2012-10-12 19:35:07.000000000 -0600
@@ -1,5 +1,5 @@
import os, sys
-sys.path.append('/opt/graphite/webapp')
+sys.path.append('/usr/local/graphite/webapp')
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi

View File

@ -0,0 +1,9 @@
--- ./conf/graphite.wsgi.example.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./conf/graphite.wsgi.example 2014-02-12 20:50:27.343398788 +0000
@@ -1,5 +1,5 @@
import os, sys
-sys.path.append('/opt/graphite/webapp')
+sys.path.append('%%PREFIX%%/graphite/webapp')
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi

View File

@ -1,6 +1,9 @@
--- setup.cfg.orig 2011-05-22 15:39:18.000003000 -0400
+++ setup.cfg 2011-05-22 15:40:14.000002000 -0400
@@ -1,3 +1 @@
--- ./setup.cfg.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./setup.cfg 2014-02-12 20:50:27.345399259 +0000
@@ -1,6 +1,4 @@
[install]
-prefix = /opt/graphite
-install-lib = %(prefix)s/webapp
[bdist_rpm]
requires = Django => 1.1.4

View File

@ -1,5 +1,5 @@
--- setup.py.ori 2012-06-21 15:38:54.044808453 -0700
+++ setup.py 2012-06-21 15:41:16.067809618 -0700
--- setup.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ setup.py 2014-02-14 04:44:44.290189349 +0000
@@ -15,11 +15,11 @@
storage_dirs = []
@ -23,3 +23,11 @@
examples = [ ('examples', glob('examples/example-*')) ]
setup(
@@ -60,6 +60,6 @@
package_data={'graphite' :
['templates/*', 'local_settings.py.example']},
scripts=glob('bin/*'),
- data_files=webapp_content.items() + storage_dirs + conf_files + examples,
+ data_files=conf_files,
**setup_kwargs
)

View File

@ -1,41 +0,0 @@
--- webapp/graphite/local_settings.py.example.orig 2012-05-31 00:28:54.000000000 -0600
+++ webapp/graphite/local_settings.py.example 2012-10-12 19:39:54.000000000 -0600
@@ -44,6 +44,7 @@
# Change only GRAPHITE_ROOT if your install is merely shifted from /opt/graphite
# to somewhere else
#GRAPHITE_ROOT = '/opt/graphite'
+GRAPHITE_ROOT = '/usr/local/graphite'
# Most installs done outside of a separate tree such as /opt/graphite will only
# need to change these three settings. Note that the default settings for each
@@ -51,6 +52,9 @@
#CONF_DIR = '/opt/graphite/conf'
#STORAGE_DIR = '/opt/graphite/storage'
#CONTENT_DIR = '/opt/graphite/webapp/content'
+CONF_DIR = '/usr/local/etc/graphite'
+STORAGE_DIR = '/usr/local/storage'
+CONTENT_DIR = '/usr/local/graphite/webapp/content'
# To further or fully customize the paths, modify the following. Note that the
# default settings for each of these are relative to CONF_DIR and STORAGE_DIR
@@ -58,6 +62,8 @@
## Webapp config files
#DASHBOARD_CONF = '/opt/graphite/conf/dashboard.conf'
#GRAPHTEMPLATES_CONF = '/opt/graphite/conf/graphTemplates.conf'
+DASHBOARD_CONF = '/usr/local/etc/graphite/dashboard.conf'
+GRAPHTEMPLATES_CONF = '/usr/local/etc/graphite/graphTemplates.conf'
## Data directories
# NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing
@@ -66,6 +72,11 @@
#DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
#LOG_DIR = '/opt/graphite/storage/log/webapp'
#INDEX_FILE = '/opt/graphite/storage/index' # Search index file
+WHISPER_DIR = '/usr/local/storage/whisper'
+RRD_DIR = '/usr/local/graphite/storage/rrd'
+DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
+LOG_DIR = '/usr/local/graphite/storage/log/webapp'
+INDEX_FILE = '/usr/local/graphite/storage/index' # Search index file
#####################################

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/account/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/account/urls.py 2014-02-13 02:01:59.480110302 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.account.views',
('^login/?$', 'loginView'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/browser/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/browser/urls.py 2014-02-13 02:01:59.481111098 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.browser.views',
('^header/?$', 'header'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/cli/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/cli/urls.py 2014-02-13 02:01:59.481111098 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.cli.views',
(r'^autocomplete/?$', 'autocomplete'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/composer/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/composer/urls.py 2014-02-13 02:01:59.481111098 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.composer.views',
('send_email','send_email'),

View File

@ -0,0 +1,8 @@
--- ./webapp/graphite/dashboard/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/dashboard/urls.py 2014-02-13 02:01:59.482110196 +0000
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.dashboard.views',
('^save/(?P<name>[^/]+)', 'save'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/events/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/events/urls.py 2014-02-13 02:01:59.482110196 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.events.views',
('^get_data?$', 'get_data'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/graphlot/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/graphlot/urls.py 2014-02-13 02:01:59.482110196 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.graphlot.views',
('^rawdata/?$', 'get_data'),

View File

@ -0,0 +1,48 @@
--- webapp/graphite/local_settings.py.example.orig 2013-08-21 17:11:04.000000000 +0000
+++ webapp/graphite/local_settings.py.example 2014-02-14 05:02:05.550117395 +0000
@@ -62,6 +62,9 @@
#CONF_DIR = '/opt/graphite/conf'
#STORAGE_DIR = '/opt/graphite/storage'
#CONTENT_DIR = '/opt/graphite/webapp/content'
+CONF_DIR = '%%PREFIX%%/etc/graphite'
+STORAGE_DIR = '/var/db/carbon'
+CONTENT_DIR = '%%DATADIR%%/content'
# To further or fully customize the paths, modify the following. Note that the
# default settings for each of these are relative to CONF_DIR and STORAGE_DIR
@@ -69,6 +72,8 @@
## Webapp config files
#DASHBOARD_CONF = '/opt/graphite/conf/dashboard.conf'
#GRAPHTEMPLATES_CONF = '/opt/graphite/conf/graphTemplates.conf'
+DASHBOARD_CONF = '%%PREFIX%%/etc/graphite/dashboard.conf'
+GRAPHTEMPLATES_CONF = '%%PREFIX%%/etc/graphite/graphTemplates.conf'
## Data directories
# NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing
@@ -77,7 +82,11 @@
#DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
#LOG_DIR = '/opt/graphite/storage/log/webapp'
#INDEX_FILE = '/opt/graphite/storage/index' # Search index file
-
+WHISPER_DIR = '/var/db/carbon/whisper'
+RRD_DIR = '/var/db/carbon/rrd'
+DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
+LOG_DIR = '/var/log/graphite'
+INDEX_FILE = '/var/db/graphite/index' # Search index file
#####################################
# Email Configuration #
@@ -158,7 +167,12 @@
# }
#}
#
-
+DATABASES = {
+ 'default': {
+ 'NAME': '/var/db/graphite/graphite.db',
+ 'ENGINE': 'django.db.backends.sqlite3',
+ }
+}
#########################
# Cluster Configuration #

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/metrics/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/metrics/urls.py 2014-02-13 02:01:59.483113296 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.metrics.views',
('^index\.json$', 'index_json'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/render/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/render/urls.py 2014-02-13 02:01:59.483113296 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.render.views',
('local/?$','renderLocalView'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/urls.py 2014-02-13 02:01:59.484110692 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
from django.conf import settings
from django.contrib import admin

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/version/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/version/urls.py 2014-02-13 02:01:59.484110692 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.version.views',
('', 'index'),

View File

@ -0,0 +1,11 @@
--- ./webapp/graphite/whitelist/urls.py.orig 2013-08-21 17:11:04.000000000 +0000
+++ ./webapp/graphite/whitelist/urls.py 2014-02-13 02:01:59.484110692 +0000
@@ -12,7 +12,7 @@
See the License for the specific language governing permissions and
limitations under the License."""
-from django.conf.urls.defaults import *
+from django.conf.urls import *
urlpatterns = patterns('graphite.whitelist.views',
('add','add'),

View File

@ -1,26 +1,24 @@
==============================================================================
In /usr/local/etc/graphite/ copy the graphite.wsgi.example to graphite.wsgi
To run graphite, you will need to setup Apache by creating a vhost similar to
the following:
WSGIImportScript /usr/local/etc/graphite/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/usr/local/graphite/webapp"
DocumentRoot "%%DATADIR%%/content/"
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
WSGIDaemonProcess graphite processes=5 threads=5 inactivity-timeout=120 display-name=graphite
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIApplicationGroup graphite
WSGIImportScript %%PREFIX%%/etc/graphite/graphite.wsgi process-group=graphite application-group=graphite
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /usr/local/etc/graphite/graphite.wsgi
WSGIScriptAlias / %%PREFIX%%/etc/graphite/graphite.wsgi
Alias /content/ /usr/local/graphite/webapp/content/
Alias /content/ %%DATADIR%%/content/
<Location "/content/">
SetHandler None
</Location>
@ -30,27 +28,47 @@ WSGIImportScript /usr/local/etc/graphite/graphite.wsgi process-group=graphite ap
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
#Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
Alias /media/ ${${PYTHON_SITELIBDIR}}/django
Alias /media/ %%PYTHON_SITELIBDIR%%/django
<Location "/media/">
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory /usr/local/etc/graphite/>
Alias /static/ "%%PYTHON_SITELIBDIR%%/django/contrib/admin/static/"
<Location "/static/">
SetHandler None
</Location>
<Directory "%%PYTHON_SITELIBDIR%%/django/contrib/admin/static/">
Order deny,allow
Allow from all
</Directory>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory %%PREFIX%%/etc/graphite/>
Order deny,allow
Allow from all
</Directory>
<Directory %%DATADIR%%/content/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
You should set the SECRET_KEY in %%PREFIX%%/etc/graphite/local_settings.py
Then initialize the sqllite user database and create the admin user:
Then initialize the sqlite user database and create the admin user:
python ${PYTHON_SITELIBDIR}/graphite/manage.py syncdb
python2 %%PYTHON_SITELIBDIR%%/graphite/manage.py syncdb
Then build the index:
%%PREFIX%%/bin/build-index.sh
Change the ownership of the user database so the webapp can write to it:
chown ${WWWOWN} ${PREFIX}/graphite/storage/graphite.db
chown -R %%WWWOWN%%:%%WWWGRP%% /var/db/graphite/ /var/log/graphite/
Now you should be able to access the graphite virtual host you created in the
first step.

File diff suppressed because it is too large Load Diff