Use https by default
[gentoo.git] / www-servers / tomcat / tomcat-7.0.63.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 JAVA_PKG_IUSE="doc source test"
8
9 inherit eutils java-pkg-2 java-ant-2 prefix user
10
11 MY_P="apache-${P}-src"
12
13 DESCRIPTION="Tomcat Servlet-3.0/JSP-2.2 Container"
14 HOMEPAGE="http://tomcat.apache.org/"
15 SRC_URI="mirror://apache/${PN}/tomcat-7/v${PV}/src/${MY_P}.tar.gz"
16
17 LICENSE="Apache-2.0"
18 SLOT="7"
19 KEYWORDS="~amd64 ~ppc ~ppc64 ~x86 ~x86-freebsd ~amd64-linux ~x86-linux ~x86-solaris"
20 IUSE="extra-webapps websockets"
21
22 RESTRICT="test" # can we run them on a production system?
23
24 ECJ_SLOT="4.4"
25 SAPI_SLOT="3.0"
26
27 COMMON_DEP="dev-java/eclipse-ecj:${ECJ_SLOT}
28         dev-java/oracle-javamail:0
29         dev-java/tomcat-servlet-api:${SAPI_SLOT}"
30 RDEPEND="${COMMON_DEP}
31         websockets? ( >=virtual/jre-1.7 )
32         !websockets? ( >=virtual/jre-1.6 )
33         !<dev-java/tomcat-native-1.1.24"
34 DEPEND="${COMMON_DEP}
35         websockets? ( >=virtual/jdk-1.7 )
36         !websockets? ( >=virtual/jdk-1.6 )
37         test? ( dev-java/ant-junit:0 )"
38
39 S=${WORKDIR}/${MY_P}
40
41 pkg_setup() {
42         java-pkg-2_pkg_setup
43         enewgroup tomcat 265
44         enewuser tomcat 265 -1 /dev/null tomcat
45 }
46
47 java_prepare() {
48         find -name '*.jar' -type f -delete -print || die
49
50         # Remove bundled javamail, servlet-api
51         rm -rv java/javax/{el,mail,servlet} || die
52
53         epatch "${FILESDIR}/${P}-build.xml.patch"
54
55         # For use of catalina.sh in netbeans
56         sed -i -e "/^# ----- Execute The Requested Command/ a\
57                 CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \
58                 bin/catalina.sh || die
59 }
60
61 JAVA_ANT_REWRITE_CLASSPATH="true"
62
63 EANT_BUILD_TARGET="deploy"
64 EANT_GENTOO_CLASSPATH="eclipse-ecj-${ECJ_SLOT},oracle-javamail,tomcat-servlet-api-${SAPI_SLOT}"
65 EANT_GENTOO_CLASSPATH_EXTRA="${S}/output/classes"
66 EANT_NEEDS_TOOLS="true"
67 EANT_EXTRA_ARGS="-Dversion=${PV}-gentoo -Dversion.number=${PV} -Dcompile.debug=false"
68
69 # revisions of the scripts
70 IM_REV="-r1"
71 INIT_REV="-r1"
72
73 src_compile() {
74         use websockets && EANT_EXTRA_ARGS+=" -Djava.7.home=${JAVA_HOME}"
75         EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjar --build-only ant-core ant.jar)"
76         java-pkg-2_src_compile
77 }
78
79 src_test() {
80         java-pkg-2_src_test
81 }
82
83 src_install() {
84         local dest="/usr/share/${PN}-${SLOT}"
85
86         java-pkg_jarinto "${dest}"/bin
87         java-pkg_dojar output/build/bin/*.jar
88         exeinto "${dest}"/bin
89         doexe output/build/bin/*.sh
90
91         java-pkg_jarinto "${dest}"/lib
92         java-pkg_dojar output/build/lib/*.jar
93
94         dodoc RELEASE-NOTES RUNNING.txt
95         use doc && java-pkg_dojavadoc output/dist/webapps/docs/api
96         use source && java-pkg_dosrc java/*
97
98         ### Webapps ###
99
100         insinto "${dest}"/webapps
101         doins -r output/build/webapps/{host-manager,manager,ROOT}
102         use extra-webapps && doins -r output/build/webapps/{docs,examples}
103
104         ### Config ###
105
106         # create "logs" directory in $CATALINA_BASE
107         # and set correct perms, see #458890
108         dodir "${dest}"/logs
109         fperms 0750 "${dest}"/logs
110
111         # replace the default pw with a random one, see #92281
112         local randpw=$(echo ${RANDOM}|md5sum|cut -c 1-15)
113         sed -i -e "s|SHUTDOWN|${randpw}|" output/build/conf/server.xml || die
114
115         # prepend gentoo.classpath to common.loader, see #453212
116         sed -i -e 's/^common\.loader=/\0${gentoo.classpath},/' output/build/conf/catalina.properties || die
117
118         insinto "${dest}"
119         doins -r output/build/conf
120
121         ### rc ###
122
123         cp "${FILESDIR}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash} "${T}" || die
124         eprefixify "${T}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash}
125         sed -i -e "s|@SLOT@|${SLOT}|g" "${T}"/tomcat{.conf,${INIT_REV}.init,-instance-manager${IM_REV}.bash} || die
126
127         insinto "${dest}"/gentoo
128         doins "${T}"/tomcat.conf
129         exeinto "${dest}"/gentoo
130         newexe "${T}"/tomcat${INIT_REV}.init tomcat.init
131         newexe "${T}"/tomcat-instance-manager${IM_REV}.bash tomcat-instance-manager.bash
132 }
133
134 pkg_postinst() {
135         elog "New ebuilds of Tomcat support running multiple instances. If you used prior version"
136         elog "of Tomcat (<7.0.32), you have to migrate your existing instance to work with new Tomcat."
137         elog "You can find more information at https://wiki.gentoo.org/wiki/Apache_Tomcat"
138
139         elog "To manage Tomcat instances, run:"
140         elog "  ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help"
141
142         ewarn "tomcat-dbcp.jar is not built at this time. Please fetch jar"
143         ewarn "from upstream binary if you need it. Gentoo Bug # 144276"
144
145 #       einfo "Please read https://www.gentoo.org/proj/en/java/tomcat6-guide.xml for more information."
146 }