# $Id: Portfile,v 1.1 2004/10/21 23:12:13 jberry Exp $ PortSystem 1.0 name tomcat5 version 5.0.29 categories java www maintainers jberry@opendarwin.org platforms darwin description Tomcat 5 HTTP Server and Java Servlet Container. long_description Tomcat is the servlet container that is used in the official \ Reference Implementation for the Java Servlet and JavaServer \ Pages technologies. homepage http://jakarta.apache.org/tomcat/ distname jakarta-tomcat-${version}-src master_sites apache:jakarta/tomcat-5/v${version}/src/ checksums md5 7499866b9d37fd4a3bfd17ac0163ddc7 patchfiles patch-setclasspath.sh.diff \ patch-jk2.properties.diff \ patch-workers2.properties.minimal.diff depends_build bin:ant:apache-ant depends_lib bin:java:kaffe \ bin:jsvc:commons-daemon \ lib:pcre:pcre \ lib:XXX:commons-beanutils \ lib:XXX:commons-collections \ lib:XXX:commons-launcher \ lib:XXX:commons-daemon \ lib:XXX:commons-digester \ lib:XXX:commons-el \ lib:XXX:commons-logging \ lib:XXX:commons-modeler \ lib:XXX:jakarta-regexp \ lib:XXX:xercesj \ lib:XXX:jakarta-log4j \ lib:XXX:commons-httpclient \ lib:XXX:commons-pool \ lib:XXX:commons-dbcp \ lib:XXX:commons-fileupload \ lib:XXX:MX4J \ lib:XXX:junit \ lib:XXX:jaxen \ lib:XXX:saxpath #lib:XXX:struts set javaLibs ${prefix}/share/java set tomcatpath ${worksrcpath}/jakarta-tomcat-5 set jk2path ${worksrcpath}/jakarta-tomcat-connectors/jk/native2 set home share/java/tomcat5 set tomcatuser www set tomcatgroup www # Determine a reasonable JAVA_HOME value if { [llength [array get env "JAVA_HOME"]] > 0 } { set javahome $env(JAVA_HOME) } else { set javahome "" } if { ![file isdirectory ${javahome}] } { if { [variant_isset darwin] } { set javahome "/Library/Java/Home" } else { error "This port needs a reasonable value for JAVA_HOME, but couldn't automatically determine one: please set the environment variable." } } # Variant jk2 builds the jk2 connector variant jk2 { if { ![variant_isset apache2] } { error "Variant jk2 may be built only together with variant apache2 for now" } configure.cmd ./configure build.cmd make } # Variant apache2 specifies use with apache2 variant apache2 { depends_lib-append path:${prefix}/apache2/bin/httpd:apache2 configure.args-append --with-apxs2=${prefix}/apache2/bin/apxs \ --with-jni \ --with-java-home=${javahome} } post-patch { # Clean up the the buildconf script reinplace s|libtoolize|glibtoolize| ${jk2path}/buildconf.sh # Fix link reinplace s|-lcrypt|| ${jk2path}/server/apache2/Makefile.in } pre-configure { # Check to be sure the apache2 port has been updated, and # warn the user if it hasn't been. # In port versions prior to 2.0.52_1, apxs didn't know where libdir was. # That information is needed by the jk2 configure script. if { [variant_isset apache2] } { set apxs ${prefix}/apache2/bin/apxs if { [file executable ${apxs}] } { set libdir [exec ${apxs} -q LIBDIR] if { 0 == [string length ${libdir}] || ![file isdirectory ${libdir}] } { error "Your apache2 installation doesn't know where its library directory is. Please update your apache2 port." } } } # Configure jk2 file attributes ${jk2path}/buildconf.sh -permissions ug+x system "cd ${jk2path} && ./buildconf.sh" } # configure/make build is used to build the jk2 connector, while the primary # java build is done in post-build. configure.dir ${jk2path} configure.cmd true configure.args --with-pcre build.dir ${jk2path} build.cmd true # Run an ant build proc ant_build { dir {target ""} {args ""} {env ""} } { set cmdLine "cd ${dir} && ${env} ant ${target} ${args}" system ${cmdLine} } post-build { # Build the java code as a post-build process ui_msg "---> Building ${name} Java code" ant_build ${tomcatpath} "download dist" [join " -Dbase.path=${worksrcpath}/Repository -Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar -Dcommons-collections.jar=${javaLibs}/commons-collections.jar -Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar -Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar -Dcommons-digester.jar=${javaLibs}/commons-digester.jar -Dcommons-el.jar=${javaLibs}/commons-el.jar -Dcommons-logging.jar=${javaLibs}/commons-logging.jar -Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar -Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar -Dregexp.jar=${javaLibs}/jakarta-regexp.jar -DxercesImpl.jar=${javaLibs}/xercesImpl.jar -Dxml-apis.jar=${javaLibs}/xml-apis.jar -Dlog4j.jar=${javaLibs}/jakarta-log4j.jar -Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar -Dcommons-pool.jar=${javaLibs}/commons-pool.jar -Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar -Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar -Djmx.jar=${javaLibs}/mx4j.jar -Djunit.jar=${javaLibs}/junit.jar -Djaxen.jar=${javaLibs}/jaxen-core.jar -Dsaxpath.jar=${javaLibs}/saxpath.jar "] #-Dstruts.lib=${javaLibs}/struts/lib } destroot { set target ${destroot}${prefix}/${home} # Ensure we've got needed directories xinstall -m 755 -d ${destroot}${prefix}/share/java \ ${destroot}${prefix}/share/doc \ ${destroot}${prefix}/var/run \ ${destroot}${prefix}/etc/rc.d # Create the tomcat user addgroup ${tomcatgroup} set gid [existsgroup ${tomcatgroup}] adduser ${tomcatgroup} gid=${gid} realname=Web Server # Install Tomcat file copy ${tomcatpath}/dist ${target} # Remove unwanted files foreach f [glob -directory ${target}/bin *.bat] { file delete $f } # Add turds to maintain empty directories system "touch ${destroot}${prefix}/var/run/.turd \ ${target}/logs/.turd \ ${target}/temp/.turd \ ${target}/work/.turd" # Install our scripts xinstall -m 755 ${filespath}/tomcatctl \ ${filespath}/setenv.sh \ ${target}/bin xinstall -m 755 ${filespath}/tomcat5.sh \ ${destroot}${prefix}/etc/rc.d # Add a symlink from bin directory to tomcatctl system "cd ${destroot}${prefix}/bin && ln -s ../${home}/bin/tomcatctl" # Configure the scripts reinplace s|PREFIX=$|PREFIX=${prefix}| ${target}/bin/tomcatctl reinplace s|TOMCAT_USER=$|TOMCAT_USER=${tomcatuser}| ${target}/bin/tomcatctl reinplace s|TOMCATPREFIX=$|TOMCATPREFIX=${prefix}/${home}| ${destroot}${prefix}/etc/rc.d/tomcat5.sh # Fix permissions system "chown -R ${tomcatuser}:${tomcatgroup} \ ${target}/conf \ ${target}/logs \ ${target}/temp \ ${target}/work" # Install the docs file copy ${tomcatpath}/build/docs \ ${destroot}${prefix}/share/doc/${name} # Install the jk2 connector for apache2 if { [variant_isset apache2] && [variant_isset jk2] } { xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \ ${destroot}${prefix}/apache2/conf xinstall -m 644 ${jk2path}/../build/jk2/apache2/mod_jk2.so \ ${destroot}${prefix}/apache2/modules xinstall -m 644 ${jk2path}/../build/jk2/apache2/libjkjni.so \ ${target}/server/lib xinstall -m 644 ${jk2path}/../conf/jk2.properties \ ${target}/conf xinstall -m 644 ${jk2path}/../conf/workers2.properties.minimal \ ${destroot}/${prefix}/apache2/conf/workers2.properties reinplace s|@@PREFIX@@|${prefix}|g \ ${target}/conf/jk2.properties } } post-install { if { [variant_isset apache2] && [variant_isset jk2] } { ui_msg " Example files ${prefix}/apache2/conf/workers2.properties and ${prefix}/${home}/conf/jk2.properties have been installed to illustrate use of the jk2 connector between apache2 and tomcat over a unix domain socket. You will want to configure the uri mappings in workers2.properties or using JkUriSet in httpd.conf. Be sure to add the following line to your httpd.conf: LoadModule jk2_module modules/mod_jk2.so " } ui_msg " The script ${prefix}/${home}/tomcatctl has been installed to facilitate start and stop of tomcat using the jsvc utility, which allows you to start tomcat as a true daemon process. Once it has acquired its TCP socket, jsvc will drop its root privileges and run as user ${tomcatuser}. " }