1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 JAVA_PKG_IUSE="doc source test"
8 inherit eutils java-pkg-2 java-ant-2 prefix user
10 MY_P="apache-${P}-src"
12 DESCRIPTION="Tomcat Servlet-3.0/JSP-2.2 Container"
13 HOMEPAGE="https://tomcat.apache.org/"
14 SRC_URI="mirror://apache/${PN}/tomcat-7/v${PV}/src/${MY_P}.tar.gz"
18 KEYWORDS="amd64 ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x86-solaris"
19 IUSE="extra-webapps websockets"
21 RESTRICT="test" # can we run them on a production system?
26 COMMON_DEP="dev-java/eclipse-ecj:${ECJ_SLOT}
27 dev-java/tomcat-servlet-api:${SAPI_SLOT}"
28 RDEPEND="${COMMON_DEP}
30 !<dev-java/tomcat-native-1.1.24"
33 test? ( dev-java/ant-junit:0 )"
40 enewuser tomcat 265 -1 /dev/null tomcat
46 # Remove bundled servlet-api
47 rm -rv java/javax/{el,servlet} || die
51 eapply "${FILESDIR}/${PN}-7.0.84-build.xml.patch"
53 # For use of catalina.sh in netbeans
54 sed -i -e "/^# ----- Execute The Requested Command/ a\
55 CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \
56 bin/catalina.sh || die
58 java-pkg-2_src_prepare
61 JAVA_ANT_REWRITE_CLASSPATH="true"
63 EANT_BUILD_TARGET="deploy"
64 EANT_GENTOO_CLASSPATH="eclipse-ecj-${ECJ_SLOT},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"
69 # revisions of the scripts
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
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 dodoc RELEASE-NOTES RUNNING.txt
95 use doc && java-pkg_dojavadoc output/dist/webapps/docs/api
96 use source && java-pkg_dosrc java/*
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}
106 # create "logs" directory in $CATALINA_BASE
107 # and set correct perms, see #458890
109 fperms 0750 "${dest}"/logs
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
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
119 doins -r output/build/conf
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
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
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"
139 elog "To manage Tomcat instances, run:"
140 elog " ${EPREFIX}/usr/share/${PN}-${SLOT}/gentoo/tomcat-instance-manager.bash --help"
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"
145 einfo "Please read https://wiki.gentoo.org/wiki/Apache_Tomcat and"
146 einfo "https://wiki.gentoo.org/wiki/Project:Java/Tomcat_6_Guide for more information."