net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / horde.eclass
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4 #
5 # Help manage the horde project http://www.horde.org/
6 #
7 # Author: Mike Frysinger <vapier@gentoo.org>
8 # CVS additions by Chris Aniszczyk <zx@mea-culpa.net>
9 # SNAP additions by Jonathan Polansky <jpolansky@lsit.ucsb.edu>
10 #
11 # This eclass provides generic functions to make the writing of horde
12 # ebuilds fairly trivial since there are many horde applications and
13 # they all share the same basic install process.
14
15 # EHORDE_SNAP
16 # This variable tracks whether the user is using a snapshot version
17 #
18 # EHORDE_SNAP_BRANCH
19 # You set this via the ebuild to whatever branch you wish to grab a
20 # snapshot of.  Typically this is 'HEAD' or 'RELENG'.
21 #
22 # EHORDE_CVS
23 # This variable tracks whether the user is using a cvs version
24
25 inherit webapp eutils
26 [[ ${PN} != ${PN/-cvs} ]] && inherit cvs
27
28 IUSE="vhosts"
29
30 EXPORT_FUNCTIONS pkg_setup src_unpack src_install pkg_postinst
31
32 [[ -z ${HORDE_PN} ]] && HORDE_PN="${PN/horde-}"
33 [[ -z ${HORDE_MAJ} ]] && HORDE_MAJ=""
34
35 EHORDE_CVS="false"
36 EHORDE_SNAP="false"
37 if [[ ${PN} != ${PN/-cvs} ]] ; then
38         EHORDE_CVS="true"
39         HORDE_PN=${HORDE_PN/-cvs}
40
41         ECVS_SERVER="anoncvs.horde.org:/repository"
42         ECVS_MODULE="${HORDE_PN}"
43         ECVS_TOP_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/cvs-src/${PN}"
44         ECVS_USER="cvsread"
45         ECVS_PASS="horde"
46
47         SRC_URI=""
48         S=${WORKDIR}/${HORDE_PN}
49
50 elif [[ ${PN} != ${PN/-snap} ]] ; then
51         EHORDE_SNAP="true"
52         EHORDE_SNAP_BRANCH=${EHORDE_SNAP_BRANCH:-HEAD}
53         SNAP_PV=${PV:0:4}-${PV:4:2}-${PV:6:2}
54
55         HORDE_PN=${HORDE_PN/-snap}
56
57         SRC_URI="http://ftp.horde.org/pub/snaps/${SNAP_PV}/${HORDE_PN}-${EHORDE_SNAP_BRANCH}-${SNAP_PV}.tar.gz"
58         S=${WORKDIR}/${HORDE_PN}
59
60 else
61         SRC_URI="http://ftp.horde.org/pub/${HORDE_PN}/${HORDE_PN}${HORDE_MAJ}-${PV/_/-}.tar.gz"
62         S=${WORKDIR}/${HORDE_PN}${HORDE_MAJ}-${PV/_/-}
63 fi
64 HOMEPAGE="http://www.horde.org/${HORDE_PN}"
65
66 LICENSE="LGPL-2"
67
68 # INSTALL_DIR is used by webapp.eclass when USE=-vhosts
69 INSTALL_DIR="/horde"
70 [[ ${HORDE_PN} != "horde" && ${HORDE_PN} != "horde-groupware" && ${HORDE_PN} != "horde-webmail" ]] && INSTALL_DIR="${INSTALL_DIR}/${HORDE_PN}"
71
72 HORDE_APPLICATIONS="${HORDE_APPLICATIONS} ."
73
74 horde_pkg_setup() {
75         webapp_pkg_setup
76
77         if [[ ! -z ${HORDE_PHP_FEATURES} ]] ; then
78                 local param
79                 if [[ ${HORDE_PHP_FEATURES:0:2} = "-o" ]] ; then
80                         param="-o"
81                         HORDE_PHP_FEATURES=${HORDE_PHP_FEATURES:2}
82                 fi
83                 if ! built_with_use ${param} dev-lang/php ${HORDE_PHP_FEATURES} ; then
84                         echo
85                         if [[ ${param} == "-o" ]] ; then
86                                 eerror "You MUST re-emerge php with at least one of"
87                         else
88                                 eerror "You MUST re-emerge php with all of"
89                         fi
90                         eerror "the following options in your USE:"
91                         eerror " ${HORDE_PHP_FEATURES}"
92                         die "current php install cannot support ${HORDE_PN}"
93                 fi
94         fi
95 }
96
97 horde_src_unpack() {
98         if [[ ${EHORDE_CVS} = "true" ]] ; then
99                 cvs_src_unpack
100         else
101                 unpack ${A}
102         fi
103         cd "${S}"
104
105         [[ -n ${EHORDE_PATCHES} ]] && epatch ${EHORDE_PATCHES}
106
107         for APP in ${HORDE_APPLICATIONS}
108         do
109                 [[ -f ${APP}/test.php ]] && chmod 000 ${APP}/test.php
110         done
111 }
112
113 horde_src_install() {
114         webapp_src_preinst
115
116         local destdir=${MY_HTDOCSDIR}
117
118         # Work-around when dealing with CVS sources
119         [[ ${EHORDE_CVS} = "true" ]] && cd ${HORDE_PN}
120
121         # Install docs and then delete them (except for CREDITS which
122         # many horde apps include in their help page #121003)
123         dodoc README docs/*
124         mv docs/CREDITS "${T}"/
125         rm -rf COPYING LICENSE README docs/*
126         mv "${T}"/CREDITS docs/
127
128         dodir ${destdir}
129         cp -r . "${D}"/${destdir}/ || die "install files"
130
131         for APP in ${HORDE_APPLICATIONS}
132         do
133                 for DISTFILE in ${APP}/config/*.dist
134                 do
135                         if [[ -f ${DISTFILE/.dist/} ]] ; then
136                                 webapp_configfile "${MY_HTDOCSDIR}"/${DISTFILE/.dist/}
137                         fi
138                 done
139                 if [[ -f ${APP}/config/conf.php ]] ; then
140                         webapp_serverowned "${MY_HTDOCSDIR}"/${APP}/config/conf.php
141                         webapp_configfile "${MY_HTDOCSDIR}"/${APP}/config/conf.php
142                 fi
143         done
144
145         [[ -n ${HORDE_RECONFIG} ]] && webapp_hook_script ${HORDE_RECONFIG}
146         [[ -n ${HORDE_POSTINST} ]] && webapp_postinst_txt en ${HORDE_POSTINST}
147
148         webapp_src_install
149 }
150
151 horde_pkg_postinst() {
152         if [ -e ${ROOT}/usr/share/doc/${PF}/INSTALL* ] ; then
153                 elog "Please read the INSTALL file in /usr/share/doc/${PF}."
154         fi
155
156         einfo "Before this package will work, you have to setup the configuration files."
157         einfo "Please review the config/ subdirectory of ${HORDE_PN} in the webroot."
158
159         if [ -e ${ROOT}/usr/share/doc/${PF}/SECURITY* ] ; then
160                 ewarn
161                 ewarn "Users are HIGHLY recommended to consult the SECURITY guide in"
162                 ewarn "/usr/share/doc/${PF} before going into production with Horde."
163         fi
164
165         if [[ ${HORDE_PN} != "horde" && ${HORDE_PN} != "horde-groupware" && ${HORDE_PN} != "horde-webmail" ]] ; then
166                 ewarn
167                 ewarn "Make sure ${HORDE_PN} is accounted for in Horde's root"
168                 ewarn "    config/registry.php"
169         fi
170
171         if [[ ${EHORDE_CVS} = "true" ]] ; then
172                 ewarn
173                 ewarn "Use these CVS versions at your own risk."
174                 ewarn "They tend to break things when working with the non CVS versions of horde."
175         fi
176
177         if use vhosts ; then
178                 ewarn
179                 ewarn "When installing Horde into a vhost dir, you will need to use the"
180                 ewarn "-d option so that it is installed into the proper location."
181         fi
182
183         webapp_pkg_postinst
184 }