Use https by default
[gentoo.git] / www-servers / tomcat / tomcat-7.0.59-r2.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/tomcat-servlet-api:${SAPI_SLOT}"
29 RDEPEND="${COMMON_DEP}
30         websockets? ( >=virtual/jre-1.6 )
31         !websockets? ( >=virtual/jre-1.6 )
32         !<dev-java/tomcat-native-1.1.24"
33 DEPEND="${COMMON_DEP}
34         websockets? ( >=virtual/jdk-1.6 )
35         !websockets? ( >=virtual/jdk-1.6 )
36         >=dev-java/ant-core-1.8.1:0
37         test? (
38                 dev-java/ant-junit:0
39                 dev-java/junit:4
40         )"
41
42 S=${WORKDIR}/${MY_P}
43
44 pkg_setup() {
45         java-pkg-2_pkg_setup
46         enewgroup tomcat 265
47         enewuser tomcat 265 -1 /dev/null tomcat
48 }
49
50 java_prepare() {
51         find -type f -name '*.jar' -exec rm -frv {} + || die
52         epatch "${FILESDIR}/${P}-build.xml.patch"
53
54         # For use of catalina.sh in netbeans
55         sed -i -e "/^# ----- Execute The Requested Command/ a\
56                 CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \
57                 bin/catalina.sh || die
58 }
59
60 JAVA_ANT_REWRITE_CLASSPATH="true"
61
62 EANT_BUILD_TARGET="deploy"
63 EANT_GENTOO_CLASSPATH="tomcat-servlet-api-${SAPI_SLOT},eclipse-ecj-${ECJ_SLOT}"
64 EANT_GENTOO_CLASSPATH_EXTRA="${S}/output/classes"
65 EANT_NEEDS_TOOLS="true"
66 EANT_EXTRA_ARGS="-Dversion=${PV}-gentoo -Dversion.number=${PV} -Dcompile.debug=false"
67
68 # revision of the instance-manager script
69 IM_REV="-r1"
70
71 src_compile() {
72         EANT_EXTRA_ARGS+=" -Djava.7.home=${JAVA_HOME}"
73         EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjar --build-only ant-core ant.jar)"
74         java-pkg-2_src_compile
75 }
76
77 EANT_TEST_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH},junit-4"
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         # so we don't have to call java-config with --with-dependencies, which might
95         # bring in more jars then actually desired.
96         java-pkg_addcp "$(java-pkg_getjars eclipse-ecj-${ECJ_SLOT},tomcat-servlet-api-${SAPI_SLOT})"
97
98         dodoc RELEASE-NOTES RUNNING.txt
99         use doc && java-pkg_dojavadoc output/dist/webapps/docs/api
100         use source && java-pkg_dosrc java/*
101
102         ### Webapps ###
103
104         insinto "${dest}"/webapps
105         doins -r output/build/webapps/{host-manager,manager,ROOT}
106         use extra-webapps && doins -r output/build/webapps/{docs,examples}
107
108         ### Config ###
109
110         # create "logs" directory in $CATALINA_BASE
111         # and set correct perms, see #458890
112         dodir "${dest}"/logs
113         fperms 0750 "${dest}"/logs
114
115         # replace the default pw with a random one, see #92281
116         local randpw=$(echo ${RANDOM}|md5sum|cut -c 1-15)
117         sed -i -e "s|SHUTDOWN|${randpw}|" output/build/conf/server.xml || die
118
119         insinto "${dest}"
120         doins -r output/build/conf
121
122         ### rc ###
123
124         cp "${FILESDIR}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash} "${T}" || die
125         eprefixify "${T}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash}
126         sed -i -e "s|@SLOT@|${SLOT}|g" "${T}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash} || die
127
128         insinto "${dest}"/gentoo
129         doins "${T}"/tomcat.conf
130         exeinto "${dest}"/gentoo
131         doexe "${T}"/tomcat.init
132         newexe "${T}"/tomcat-instance-manager${IM_REV}.bash tomcat-instance-manager.bash
133 }
134
135 pkg_postinst() {
136         elog "New ebuilds of Tomcat support running multiple instances. If you used prior version"
137         elog "of Tomcat (<7.0.32), you have to migrate your existing instance to work with new Tomcat."
138         elog "You can find more information at https://wiki.gentoo.org/wiki/Apache_Tomcat"
139
140         elog "To manage Tomcat instances, run:"
141         elog "  ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help"
142
143         ewarn "tomcat-dbcp.jar is not built at this time. Please fetch jar"
144         ewarn "from upstream binary if you need it. Gentoo Bug # 144276"
145
146 #       einfo "Please read https://www.gentoo.org/proj/en/java/tomcat6-guide.xml for more information."
147 }