summaryrefslogtreecommitdiff
blob: b4c8296afeef25a0189641f1820d28da9d8d2842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-php/jpgraph/jpgraph-1.19.ebuild,v 1.1 2005/07/16 14:08:14 sebastian Exp $

inherit php-lib

DESCRIPTION="fully OO graph drawing library for PHP"
HOMEPAGE="http://www.aditus.nu/jpgraph/"
SRC_URI="http://members.chello.se/jpgraph/jpgdownloads/${P}.tar.gz"

LICENSE="QPL-1.0"
SLOT="0"
KEYWORDS="~x86 ~ppc ~sparc ~alpha ~amd64"
IUSE=""

DEPEND="$DEPEND =dev-php/php-4*"
RDEPEND="virtual/php"

JPGRAPH_CACHE_DIR="/var/cache/jpgraph"

HTTPD_USER=root
HTTPD_GROUP=root

has_version "net-www/apache" && USE_APACHE=1 && inherit webapp-apache
[ -n "${USE_APACHE}" ] && webapp-detect || NO_WEBSERVER=1

pkg_setup() {
	if [ "${NO_WEBSERVER}" = "1" ]; then
		ewarn "No webserver detected - ${JPGRAPH_CACHE_DIR} will be"
		ewarn "owned by ${HTTPD_USER} instead"
	else
		einfo "Configuring cache dir ${JPGRAPH_CACHE_DIR} for ${WEBAPP_SERVER}"
	fi
}

src_install() {
	einfo "Patching jpgraph.php"

	# patch 1:
	# make jpgraph use the correct group for file permissions

	sed -i "s|^DEFINE(\"CACHE_FILE_GROUP\",\"wwwadmin\");|DEFINE(\"CACHE_FILE_GROUP\", \"${HTTPD_GROUP}\");|" src/jpgraph.php

	# patch 2:
	# make jpgraph use the correct directory for caching

	sed -i "s|/tmp/jpgraph_cache/|${JPGRAPH_CACHE_DIR}/|g;" src/jpgraph.php

	# patch 3:
	# switch off the directory cache

	sed -i 's|^DEFINE("USE_CACHE",false);|if (!defined("USE_CACHE")) DEFINE("USE_CACHE", false);|' src/jpgraph.php

	# patch 4:
	# don't read the READ_CACHE if we're not creating any images in the
	# cache in the first place (doh)

	sed -i 's|DEFINE("READ_CACHE",true);|DEFINE("READ_CACHE", USE_CACHE);|' src/jpgraph.php

	# install php files
	einfo "Building list of files to install"
	php-lib_src_install src `cd src ; find . -type f -print`

	# install documentation
	dodoc README QPL.txt
	dohtml -r docs/*

	# setup the cache dir
	# cachedir must be world-writable, because PHP/CLI doesn't run
	# as the apache user!

	keepdir "${JPGRAPH_CACHE_DIR}"
	fowners ${HTTPD_USER}:${HTTPD_GROUP} "${JPGRAPH_CACHE_DIR}"
	fperms 700 "${JPGRAPH_CACHE_DIR}"
}