1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 JAVA_PKG_IUSE="source test"
9 inherit eutils java-pkg-2 java-ant-2 prefix user
11 MY_P="apache-${P}-src"
13 DESCRIPTION="Tomcat Servlet-2.5/JSP-2.1 Container"
14 HOMEPAGE="http://tomcat.apache.org/"
15 SRC_URI="mirror://apache/${PN}/tomcat-6/v${PV}/src/${MY_P}.tar.gz"
19 KEYWORDS="amd64 ppc ppc64 x86 ~x86-fbsd"
27 CDEPEND="dev-java/eclipse-ecj:${ECJ_SLOT}
28 dev-java/tomcat-servlet-api:${SAPI_SLOT}"
31 !<dev-java/tomcat-native-1.1.20"
34 >=dev-java/ant-core-1.8.1:0
45 enewuser tomcat 265 -1 /dev/null tomcat
49 find -name '*.jar' -exec rm -v {} + || die
50 epatch "${FILESDIR}/${P}-build.xml.patch"
52 # For use of catalina.sh in netbeans
53 sed -i -e "/^# ----- Execute The Requested Command/ a\
54 CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \
55 bin/catalina.sh || die
58 JAVA_ANT_REWRITE_CLASSPATH="true"
60 EANT_BUILD_TARGET="deploy"
62 EANT_GENTOO_CLASSPATH="tomcat-servlet-api-${SAPI_SLOT},eclipse-ecj-${ECJ_SLOT}"
63 EANT_GENTOO_CLASSPATH_EXTRA="${S}/output/classes"
64 EANT_NEEDS_TOOLS="true"
65 EANT_EXTRA_ARGS="-Dversion=${PV}-gentoo -Dversion.number=${PV} -Dcompile.debug=false"
67 # revision of the instance-manager script
71 EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjar --build-only ant-core ant.jar)"
72 java-pkg-2_src_compile
75 EANT_TEST_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH},junit-4"
82 local dest="/usr/share/${PN}-${SLOT}"
84 java-pkg_jarinto "${dest}"/bin
85 java-pkg_dojar output/build/bin/*.jar
87 doexe output/build/bin/*.sh
89 java-pkg_jarinto "${dest}"/lib
90 java-pkg_dojar output/build/lib/*.jar
92 # so we don't have to call java-config with --with-dependencies, which might
93 # bring in more jars than actually desired.
94 java-pkg_addcp "$(java-pkg_getjars eclipse-ecj-${ECJ_SLOT},tomcat-servlet-api-${SAPI_SLOT})"
96 dodoc RELEASE-NOTES RUNNING.txt
97 use source && java-pkg_dosrc java/*
101 insinto "${dest}"/webapps
102 doins -r output/build/webapps/{host-manager,manager,ROOT}
103 use extra-webapps && doins -r output/build/webapps/{docs,examples}
107 # create "logs" directory in $CATALINA_BASE
108 # and set correct perms, see #458890
110 fperms 0750 "${dest}"/logs
112 # replace the default pw with a random one, see #92281
113 local randpw=$(echo ${RANDOM}|md5sum|cut -c 1-15)
114 sed -i -e "s|SHUTDOWN|${randpw}|" output/build/conf/server.xml || die
117 doins -r output/build/conf
121 cp "${FILESDIR}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash} "${T}" || die
122 eprefixify "${T}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash}
123 sed -i -e "s|@SLOT@|${SLOT}|g" "${T}"/tomcat{.conf,.init,-instance-manager${IM_REV}.bash} || die
125 insinto "${dest}"/gentoo
126 doins "${T}"/tomcat.conf
127 exeinto "${dest}"/gentoo
128 doexe "${T}"/tomcat.init
129 newexe "${T}"/tomcat-instance-manager${IM_REV}.bash tomcat-instance-manager.bash
133 elog "New ebuilds of Tomcat support running multiple instances. If you used prior version"
134 elog "of Tomcat (<6.0.36), you have to migrate your existing instance to work with new Tomcat."
135 elog "You can find more information at https://wiki.gentoo.org/wiki/Apache_Tomcat"
137 elog "To manage Tomcat instances, run:"
138 elog " ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help"
140 ewarn "tomcat-dbcp.jar is not built at this time. Please fetch jar"
141 ewarn "from upstream binary if you need it. Gentoo Bug # 144276"
143 # einfo "Please read https://www.gentoo.org/proj/en/java/tomcat6-guide.xml for more information."