1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 JAVA_PKG_IUSE="doc source test"
9 inherit eutils java-pkg-2 java-ant-2 prefix user
11 MY_P="apache-${P}-src"
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"
19 KEYWORDS="amd64 ppc ppc64 x86 ~x86-freebsd ~amd64-linux ~x86-linux ~x86-solaris"
20 IUSE="extra-webapps websockets"
22 RESTRICT="test" # can we run them on a production system?
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"
34 websockets? ( >=virtual/jdk-1.6 )
35 !websockets? ( >=virtual/jdk-1.6 )
36 >=dev-java/ant-core-1.8.1:0
47 enewuser tomcat 265 -1 /dev/null tomcat
51 find -type f -name '*.jar' -exec rm -frv {} + || die
52 epatch "${FILESDIR}/${P}-build.xml.patch"
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
60 JAVA_ANT_REWRITE_CLASSPATH="true"
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"
68 # revision of the instance-manager script
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
77 EANT_TEST_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH},junit-4"
84 local dest="/usr/share/${PN}-${SLOT}"
86 java-pkg_jarinto "${dest}"/bin
87 java-pkg_dojar output/build/bin/*.jar
89 doexe output/build/bin/*.sh
91 java-pkg_jarinto "${dest}"/lib
92 java-pkg_dojar output/build/lib/*.jar
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})"
98 dodoc RELEASE-NOTES RUNNING.txt
99 use doc && java-pkg_dojavadoc output/dist/webapps/docs/api
100 use source && java-pkg_dosrc java/*
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}
110 # create "logs" directory in $CATALINA_BASE
111 # and set correct perms, see #458890
113 fperms 0750 "${dest}"/logs
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
120 doins -r output/build/conf
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
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
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"
140 elog "To manage Tomcat instances, run:"
141 elog " ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help"
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"
146 # einfo "Please read https://www.gentoo.org/proj/en/java/tomcat6-guide.xml for more information."