# Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="7" IUSE="doc extra-webapps" inherit eutils java-pkg-2 prefix user MY_P="apache-${P/-bin}" MY_PN="${PN/-bin}" SLOT="${PV%.*}" DESCRIPTION="Tomcat Servlet-3.1/JSP-2.3 Container" HOMEPAGE="http://tomcat.apache.org/" SRC_URI="mirror://apache/tomcat/tomcat-${PV%%.*}/v${PV}/bin/${MY_P}.tar.gz" LICENSE="Apache-2.0" KEYWORDS="amd64 x86" RDEPEND=">=virtual/jre-1.7" DEPEND="!!www-servers/tomcat sys-apps/sed ${RDEPEND}" TOMCAT_NAME="${MY_PN}${SLOT}" TOMCAT_HOME="/opt/${TOMCAT_NAME}" TOMCAT_BASE="/var/lib//${TOMCAT_NAME}" S="${WORKDIR}/${MY_P}" # revision of the instance-manager script IM_REV="-r1" pkg_setup() { java-pkg-2_pkg_setup enewgroup tomcat 265 enewuser tomcat 265 -1 /dev/null tomcat } src_prepare() { eapply_user # For use of catalina.sh in netbeans sed -i -e "/^# ----- Execute The Requested Command/ a\ CLASSPATH=\`java-config --classpath ${PN}-${SLOT}\`" \ bin/catalina.sh || die } src_install() { java-pkg_jarinto "${TOMCAT_HOME}/bin" java-pkg_dojar bin/*.jar exeinto "${TOMCAT_HOME}/bin" doexe bin/*.sh java-pkg_jarinto "${TOMCAT_HOME}/lib" java-pkg_dojar lib/*.jar dodoc RELEASE-NOTES RUNNING.txt use doc && java-pkg_dojavadoc dist/webapps/docs/api ### Webapps ### insinto "${TOMCAT_HOME}"/webapps doins -r webapps/{host-manager,manager,ROOT} use extra-webapps && doins -r webapps/{docs,examples} ### Config ### # replace the default pw with a random one, see #92281 local randpw=$(echo ${RANDOM}|md5sum|cut -c 1-15) sed -i -e "s|SHUTDOWN|${randpw}|" conf/server.xml || die insinto "/etc/${TOMCAT_NAME}" doins -r conf/* dodoc -r conf fperms 640 "/etc/${TOMCAT_NAME}/"{tomcat-users.xml,server.xml} ### rc ### cp "${FILESDIR}"/${SLOT}/tomcat{.conf,.init,.systemd,-instance-manager${IM_REV}.bash} "${T}" || die eprefixify "${T}"/tomcat{.conf,.init,.systemd,-instance-manager${IM_REV}.bash} sed -i -e "s|@SLOT@|${SLOT}|g" "${T}"/tomcat{.conf,.init,.systemd,-instance-manager${IM_REV}.bash} || die # Unsupported for now # insinto "${TOMCAT_HOME}/gentoo" # doins "${T}"/tomcat.conf # exeinto "${TOMCAT_HOME}/gentoo" # doexe "${T}"/tomcat.init # newexe "${T}"/tomcat-instance-manager${IM_REV}.bash tomcat-instance-manager.bash # create default instance sed -i \ -e "s|@INSTANCE_USER@|tomcat|g" \ -e "s|@INSTANCE_GROUP@|tomcat|g" \ -e "s|@INSTANCE_GROUP@|tomcat|g" \ -e "s|@INSTANCE_NAME@|tomcat${SLOT}|g" \ "${T}"/tomcat.{conf,init,systemd} || die newinitd "${T}"/tomcat.init "tomcat${SLOT}" newconfd "${T}"/tomcat.conf "tomcat${SLOT}" newexe "${T}"/tomcat.systemd "tomcat${SLOT}-systemd" dosym "${TOMCAT_HOME}/webapps" "${TOMCAT_BASE}/webapps" keepdir "${TOMCAT_BASE}/"{bin,work} "/var/tmp/${TOMCAT_NAME}" "/var/log/${TOMCAT_NAME}" dosym "/var/tmp/${TOMCAT_NAME}" "${TOMCAT_BASE}/temp" dosym "/var/log/${TOMCAT_NAME}" "${TOMCAT_BASE}/logs" dosym "/etc/${TOMCAT_NAME}" "${TOMCAT_BASE}/conf" } pkg_preinst() { fperms 750 "${TOMCAT_BASE}" fowners -R root:tomcat "${TOMCAT_BASE}" fowners -R tomcat:tomcat "${TOMCAT_BASE}/work" fperms 750 "${TOMCAT_HOME}" fowners -R root:tomcat "${TOMCAT_HOME}" fperms 750 "/etc/${TOMCAT_NAME}" fowners -R root:tomcat "/etc/${TOMCAT_NAME}" fperms 750 "/var/tmp/${TOMCAT_NAME}" fowners -R tomcat:tomcat "/var/tmp/${TOMCAT_NAME}" fperms 750 "/var/log/${TOMCAT_NAME}" fowners -R tomcat:tomcat "/var/log/${TOMCAT_NAME}" } pkg_postinst() { elog "New ebuilds of Tomcat support running multiple instances. If you used prior version" elog "of Tomcat (<7.0.32), you have to migrate your existing instance to work with new Tomcat." elog "You can find more information at https://wiki.gentoo.org/wiki/Apache_Tomcat" elog "To manage Tomcat instances, run:" elog " ${EPREFIX}/${TOMCAT_HOME}/gentoo/tomcat-instance-manager.bash --help" ewarn "tomcat-dbcp.jar is not built at this time. Please fetch jar" ewarn "from upstream binary if you need it. Gentoo Bug # 144276" }