source: trunk/dports/java/tomcat5/Portfile @ 8862

Last change on this file since 8862 was 8862, checked in by jberry, 16 years ago

New port tomcat5 -- Tomcat 5 is a Java-based webserver and servlet container
with support for JSP 2.0. This port also provides variants to build and install
the jk2 connector which allows Tomcat to team directly with apache.

  • Property svn:eol-style set to native
File size: 8.0 KB
Line 
1# $Id: Portfile,v 1.1 2004/10/21 23:12:13 jberry Exp $
2
3PortSystem 1.0
4
5name                            tomcat5
6version                         5.0.29
7
8categories                      java www
9maintainers                     jberry@opendarwin.org
10platforms                       darwin
11
12description                     Tomcat 5 HTTP Server and Java Servlet Container.
13long_description        Tomcat is the servlet container that is used in the official \
14                                        Reference Implementation for the Java Servlet and JavaServer \
15                                        Pages technologies.
16homepage                        http://jakarta.apache.org/tomcat/
17
18distname                        jakarta-tomcat-${version}-src
19master_sites            apache:jakarta/tomcat-5/v${version}/src/
20checksums                       md5 7499866b9d37fd4a3bfd17ac0163ddc7
21
22patchfiles                      patch-setclasspath.sh.diff \
23                                        patch-jk2.properties.diff \
24                                        patch-workers2.properties.minimal.diff
25
26depends_build           bin:ant:apache-ant
27depends_lib                     bin:java:kaffe \
28                                        bin:jsvc:commons-daemon \
29                                        lib:pcre:pcre \
30                                        lib:XXX:commons-beanutils \
31                                        lib:XXX:commons-collections \
32                                        lib:XXX:commons-launcher \
33                                        lib:XXX:commons-daemon \
34                                        lib:XXX:commons-digester \
35                                        lib:XXX:commons-el \
36                                        lib:XXX:commons-logging \
37                                        lib:XXX:commons-modeler \
38                                        lib:XXX:jakarta-regexp \
39                                        lib:XXX:xercesj \
40                                        lib:XXX:jakarta-log4j \
41                                        lib:XXX:commons-httpclient \
42                                        lib:XXX:commons-pool \
43                                        lib:XXX:commons-dbcp \
44                                        lib:XXX:commons-fileupload \
45                                        lib:XXX:MX4J \
46                                        lib:XXX:junit \
47                                        lib:XXX:jaxen \
48                                        lib:XXX:saxpath
49                                       
50                                        #lib:XXX:struts
51                               
52set javaLibs            ${prefix}/share/java
53set tomcatpath          ${worksrcpath}/jakarta-tomcat-5
54set jk2path                     ${worksrcpath}/jakarta-tomcat-connectors/jk/native2
55set home                        share/java/tomcat5
56set tomcatuser          www
57set tomcatgroup         www
58
59# Determine a reasonable JAVA_HOME value
60if { [llength [array get env "JAVA_HOME"]] > 0 } {
61        set javahome $env(JAVA_HOME)
62} else {
63        set javahome ""
64}
65if { ![file isdirectory ${javahome}] } {
66        if { [variant_isset darwin] } {
67                set javahome "/Library/Java/Home"
68        } else {
69                error "This port needs a reasonable value for JAVA_HOME, but couldn't automatically determine one: please set the environment variable."
70        }
71}
72
73# Variant jk2 builds the jk2 connector
74variant jk2 {
75        if { ![variant_isset apache2] } {
76                error "Variant jk2 may be built only together with variant apache2 for now"
77        }
78       
79        configure.cmd                   ./configure
80        build.cmd                               make
81}
82
83# Variant apache2 specifies use with apache2
84variant apache2 {
85        depends_lib-append              path:${prefix}/apache2/bin/httpd:apache2
86        configure.args-append   --with-apxs2=${prefix}/apache2/bin/apxs \
87                                                        --with-jni \
88                                                        --with-java-home=${javahome}
89}
90                                       
91post-patch {
92        # Clean up the the buildconf script
93        reinplace s|libtoolize|glibtoolize| ${jk2path}/buildconf.sh
94
95        # Fix link
96        reinplace s|-lcrypt|| ${jk2path}/server/apache2/Makefile.in
97}
98
99pre-configure {
100
101        # Check to be sure the apache2 port has been updated, and
102        # warn the user if it hasn't been.
103        # In port versions prior to 2.0.52_1, apxs didn't know where libdir was.
104        # That information is needed by the jk2 configure script.
105
106        if { [variant_isset apache2] } {
107                set apxs ${prefix}/apache2/bin/apxs
108                if { [file executable ${apxs}] } {
109                        set libdir [exec ${apxs} -q LIBDIR]
110                        if { 0 == [string length ${libdir}] || ![file isdirectory ${libdir}] } {
111                                error "Your apache2 installation doesn't know where its library directory is. Please update your apache2 port."
112                        }
113                }
114        }
115       
116        # Configure jk2
117        file attributes ${jk2path}/buildconf.sh -permissions ug+x
118        system "cd ${jk2path} && ./buildconf.sh"       
119}
120
121# configure/make build is used to build the jk2 connector, while the primary
122# java build is done in post-build.
123
124configure.dir           ${jk2path}
125configure.cmd           true
126configure.args          --with-pcre
127
128build.dir                       ${jk2path}
129build.cmd                       true
130
131# Run an ant build
132proc ant_build { dir {target ""} {args ""} {env ""} } {
133        set cmdLine "cd ${dir} && ${env} ant ${target} ${args}"
134        system ${cmdLine}
135}
136
137post-build {
138        # Build the java code as a post-build process
139        ui_msg "--->  Building ${name} Java code"
140        ant_build ${tomcatpath} "download dist" [join "
141                -Dbase.path=${worksrcpath}/Repository
142                -Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar
143                -Dcommons-collections.jar=${javaLibs}/commons-collections.jar
144                -Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar
145                -Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar
146                -Dcommons-digester.jar=${javaLibs}/commons-digester.jar
147                -Dcommons-el.jar=${javaLibs}/commons-el.jar
148                -Dcommons-logging.jar=${javaLibs}/commons-logging.jar
149                -Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar
150                -Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar
151                -Dregexp.jar=${javaLibs}/jakarta-regexp.jar
152                -DxercesImpl.jar=${javaLibs}/xercesImpl.jar
153                -Dxml-apis.jar=${javaLibs}/xml-apis.jar
154                -Dlog4j.jar=${javaLibs}/jakarta-log4j.jar
155                -Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar
156                -Dcommons-pool.jar=${javaLibs}/commons-pool.jar
157                -Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar
158                -Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar
159                -Djmx.jar=${javaLibs}/mx4j.jar
160                -Djunit.jar=${javaLibs}/junit.jar
161                -Djaxen.jar=${javaLibs}/jaxen-core.jar
162                -Dsaxpath.jar=${javaLibs}/saxpath.jar
163                "]
164
165                #-Dstruts.lib=${javaLibs}/struts/lib
166}
167
168destroot        {
169        set target ${destroot}${prefix}/${home}
170
171        # Ensure we've got needed directories
172        xinstall -m 755 -d ${destroot}${prefix}/share/java \
173                ${destroot}${prefix}/share/doc \
174                ${destroot}${prefix}/var/run \
175                ${destroot}${prefix}/etc/rc.d
176               
177        # Create the tomcat user
178        addgroup ${tomcatgroup}
179        set gid [existsgroup ${tomcatgroup}]
180        adduser ${tomcatgroup} gid=${gid} realname=Web Server
181       
182        # Install Tomcat
183        file copy ${tomcatpath}/dist ${target}
184       
185        # Remove unwanted files
186        foreach f [glob -directory ${target}/bin *.bat] { file delete $f }
187       
188        # Add turds to maintain empty directories
189        system "touch ${destroot}${prefix}/var/run/.turd \
190                ${target}/logs/.turd \
191                ${target}/temp/.turd \
192                ${target}/work/.turd"
193               
194        # Install our scripts
195        xinstall -m 755 ${filespath}/tomcatctl \
196                ${filespath}/setenv.sh \
197                ${target}/bin
198        xinstall -m 755 ${filespath}/tomcat5.sh \
199                ${destroot}${prefix}/etc/rc.d
200               
201        # Add a symlink from bin directory to tomcatctl
202        system "cd ${destroot}${prefix}/bin && ln -s ../${home}/bin/tomcatctl"
203       
204        # Configure the scripts
205        reinplace s|PREFIX=$|PREFIX=${prefix}| ${target}/bin/tomcatctl
206        reinplace s|TOMCAT_USER=$|TOMCAT_USER=${tomcatuser}| ${target}/bin/tomcatctl
207        reinplace s|TOMCATPREFIX=$|TOMCATPREFIX=${prefix}/${home}| ${destroot}${prefix}/etc/rc.d/tomcat5.sh
208       
209        # Fix permissions
210        system "chown -R ${tomcatuser}:${tomcatgroup} \
211                ${target}/conf \
212                ${target}/logs \
213                ${target}/temp \
214                ${target}/work"
215       
216        # Install the docs
217        file copy ${tomcatpath}/build/docs \
218                ${destroot}${prefix}/share/doc/${name}
219               
220        # Install the jk2 connector for apache2
221        if { [variant_isset apache2] && [variant_isset jk2] } {
222                xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \
223                        ${destroot}${prefix}/apache2/conf
224                       
225                xinstall -m 644 ${jk2path}/../build/jk2/apache2/mod_jk2.so \
226                        ${destroot}${prefix}/apache2/modules
227                       
228                xinstall -m 644 ${jk2path}/../build/jk2/apache2/libjkjni.so \
229                        ${target}/server/lib
230                       
231                xinstall -m 644 ${jk2path}/../conf/jk2.properties \
232                        ${target}/conf
233                xinstall -m 644 ${jk2path}/../conf/workers2.properties.minimal \
234                        ${destroot}/${prefix}/apache2/conf/workers2.properties
235               
236                reinplace s|@@PREFIX@@|${prefix}|g \
237                        ${target}/conf/jk2.properties
238        }
239}
240
241
242post-install {
243        if { [variant_isset apache2] && [variant_isset jk2] } {
244                ui_msg "
245Example files ${prefix}/apache2/conf/workers2.properties and
246${prefix}/${home}/conf/jk2.properties have been installed to illustrate
247use of the jk2 connector between apache2 and tomcat over a unix domain socket.
248You will want to configure the uri mappings in workers2.properties
249or using JkUriSet in httpd.conf.
250
251Be sure to add the following line to your httpd.conf:
252
253        LoadModule jk2_module modules/mod_jk2.so
254"
255        }
256       
257        ui_msg "
258The script ${prefix}/${home}/tomcatctl has been installed to facilitate
259start and stop of tomcat using the jsvc utility, which allows you to
260start tomcat as a true daemon process. Once it has acquired its TCP socket,
261jsvc will drop its root privileges and run as user ${tomcatuser}.
262"
263}
Note: See TracBrowser for help on using the repository browser.