Ticket #28938: Portfile

File Portfile, 9.2 KB (added by mmpestorich (Mike M Pestorich), 12 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 97894 2012-09-19 02:07:44Z rmstonecipher@macports.org $
3
4PortSystem 1.0
5
6name            tomcat7
7version         7.0.35
8revision        1
9
10categories      java www
11maintainers     openmaintainer
12license         Apache-2
13platforms       darwin
14
15homepage        http://tomcat.apache.org/
16description     Tomcat 6 HTTP Server and Java Servlet Container.
17long_description \
18                Tomcat is the servlet container that is used in the official \
19                Reference Implementation for the Java Servlet and JavaServer \
20                                Pages technologies.
21
22distname        apache-tomcat-${version}-src
23master_sites    apache:tomcat/tomcat-7/v${version}/src/
24
25checksums       md5     ccc93c9eff76c16f9133148e171c94e3 \
26                sha1    f1bd2351863e12e461dc6e9395eecf45a1a9610f \
27                rmd160  245b29930a03ab866e74b2d3b7a88ccc2ad01c99
28
29patchfiles      patch-bin-catalina.sh \
30                patch-build.xml.diff
31
32depends_build   bin:ant:apache-ant
33depends_lib     bin:java:kaffe \
34                bin:jsvc:commons-daemon \
35                port:jakarta-taglibs-standard-11 \
36                port:commons-beanutils \
37                port:commons-collections \
38                port:commons-launcher \
39                port:commons-daemon \
40                port:commons-digester \
41                port:commons-el \
42                port:commons-logging \
43                port:commons-modeler \
44                port:commons-httpclient \
45                port:commons-pool \
46                port:commons-dbcp \
47                port:commons-fileupload \
48                port:commons-io \
49                port:jakarta-regexp \
50                port:xercesj \
51                port:jakarta-log4j \
52                port:mx4j \
53                port:junit \
54                port:saxpath
55
56# Tomcat can only be built using java version 1.6.
57set java_home   JAVA_HOME=[exec /usr/libexec/java_home -v 1.6]
58
59set javaLibs    ${prefix}/share/java
60set home        share/java/tomcat7
61set tomcatuser  www
62set tomcatgroup www
63
64use_configure   no
65
66build.cmd       ${java_home} ant
67build.target    download-dist
68set antArgs     [join "
69                       -Dversion=${version}
70                       -Dversion.build=[lindex [split ${version} .] 2]
71                       -Dnsis.exe=${worksrcpath}/.bogus
72                       -Dbase.path=${worksrcpath}/Repository
73                       -Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar
74                       -Dcommons-collections.jar=${javaLibs}/commons-collections.jar
75                       -Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar
76                       -Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar
77                       -Dcommons-digester.jar=${javaLibs}/commons-digester.jar
78                       -Dcommons-el.jar=${javaLibs}/commons-el.jar
79                       -Dcommons-logging.jar=${javaLibs}/commons-logging.jar
80                       -Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar
81                       -Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar
82                       -Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar
83                       -Dcommons-pool.jar=${javaLibs}/commons-pool.jar
84                       -Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar
85                       -Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar
86                       -Dregexp.jar=${javaLibs}/jakarta-regexp.jar
87                       -DxercesImpl.jar=${javaLibs}/xercesImpl.jar
88                       -Dxml-apis.jar=${javaLibs}/xml-apis.jar
89                       -Dlog4j.jar=${javaLibs}/jakarta-log4j.jar
90                       -Djmx.lib=${javaLibs}
91                       -Djunit.jar=${javaLibs}/junit.jar
92                       -Dsaxpath.jar=${javaLibs}/saxpath.jar
93                       -Djasper.home=${worksrcpath}/../jasper
94                      "]
95
96build.args      $antArgs
97
98pre-build {
99    #
100    # Tomcat in this version requires ant 1.6.5.
101    # If the current version of ant is not at least 1.6.5 then
102    # tell the user and fail.
103    #
104    if { [string length [auto_execok ant]] } {
105        set verOutput [exec ant -version]
106        regexp {version (\d+(\.\d+)*)} $verOutput -> antVersion
107        if { [vercmp $antVersion "1.6.5"] < 0 } {
108            return -code error "This version of tomcat requires ant version 1.6.5 or better. Please install a newer ant before proceeding."
109        }
110    }
111
112    system "mkdir -p ${worksrcpath}/Repository"
113
114    # Make a bogus file to prevent nsis.exe from downloading
115    system "touch ${worksrcpath}/.bogus"
116}
117
118destroot {
119    set target ${destroot}${prefix}/${home}
120    xinstall -m 755 -d ${target}
121
122    # Ensure we've got needed directories
123    ui_msg "# setting up needed dirs"
124    xinstall -m 755 -d \
125        ${destroot}${prefix}/share/java \
126        ${destroot}${prefix}/share/doc \
127        ${destroot}${prefix}/etc/rc.d
128
129    # Create the tomcat user
130    addgroup ${tomcatgroup}
131    set gid [existsgroup ${tomcatgroup}]
132    add_users ${tomcatuser} gid=${gid} realname={Web Server}
133
134    # Install Tomcat
135    ui_msg "# installing tomcat..."
136    system "cd ${worksrcpath} && ${java_home} ant $antArgs deploy"
137    ## build space:
138    file copy ${worksrcpath}/output/build/bin ${target}
139    file copy ${worksrcpath}/output/build/conf ${target}
140    file copy ${worksrcpath}/output/build/lib ${target}
141    file copy ${worksrcpath}/output/build/temp ${target}
142    file copy ${worksrcpath}/output/build/webapps ${target}
143    ## and classes:
144    file copy ${worksrcpath}/output/classes ${target}/shared/
145
146    # Add the jstl libs to tomcat6/shared/lib so that they're
147    # available to all
148    ui_msg "# adding the jstl libs "
149    xinstall -m 755 -d ${target}/shared/lib
150    xinstall -m 644 \
151        ${prefix}/share/java/jstl.jar \
152        ${prefix}/share/java/standard.jar \
153        ${target}/shared/lib
154
155    # Remove unwanted files
156    foreach f [glob -directory ${target}/bin *.bat] { file delete $f }
157
158    # Maintain empty directories
159    ui_msg "# maint. empty dirs... "
160    xinstall -m 755 -d ${target}/work
161    xinstall -m 755 -d ${target}/logs
162    destroot.keepdirs-append \
163        ${target}/logs \
164        ${target}/temp \
165        ${target}/work \
166        ${target}/shared/classes \
167        ${target}/common/classes
168
169    # Install our scripts
170    ui_msg "# adding our scripts "
171    xinstall -m 755 \
172        ${filespath}/tomcatctl \
173        ${filespath}/conf_setup.sh \
174        ${filespath}/setenv.sh \
175        ${target}/bin
176    xinstall -m 755 \
177        ${filespath}/setenv.local \
178        ${target}/conf
179
180    # Add a symlink from bin directory to tomcatctl
181    system "cd ${destroot}${prefix}/bin && ln -s ../${home}/bin/tomcatctl"
182
183    # Configure the scripts
184    reinplace s|PREFIX=$|PREFIX=${prefix}| ${target}/bin/tomcatctl
185    reinplace s|TOMCAT_USER=$|TOMCAT_USER=${tomcatuser}| ${target}/bin/tomcatctl
186
187    # Rename certain files as .sample to avoid replacing them on update
188    # These will be "repaired" by conf_setup.sh on first run
189    foreach f "
190               catalina.policy
191               catalina.properties
192               server.xml
193               tomcat-users.xml
194               web.xml
195               setenv.local
196              " {
197        file rename ${target}/conf/${f} ${target}/conf/${f}.sample
198    }
199
200    # Fix ownership of some directories tomcat really needs to write to
201    system "chown -R ${tomcatuser}:${tomcatgroup} \
202            ${target}/conf \
203            ${target}/logs \
204            ${target}/temp \
205            ${target}/webapps \
206            ${target}/work"
207
208    # Install the docs
209    file copy ${worksrcpath}/webapps/docs \
210        ${destroot}${prefix}/share/doc/${name}
211}
212
213
214post-install {
215    ui_msg "#"
216    ui_msg "# Configuration files in ${prefix}/${home}/conf have been"
217    ui_msg "# installed with a .sample extension so that they won't be replaced by a"
218    ui_msg "# port update. Each will be copied to its proper location during the"
219    ui_msg "# first startup of tomcat by catalina.sh or tomcatctl if you don't"
220    ui_msg "# do this yourself first. If this _is_ an update, you might do a diff to"
221    ui_msg "# verify that you're not missing anything in the newer .sample versions"
222    ui_msg "# of these files."
223    ui_msg "#"
224    ui_msg "# The script ${prefix}/${home}/bin/tomcatctl has been installed to"
225    ui_msg "# facilitate start and stop of tomcat using the jsvc utility, which allows you to"
226    ui_msg "# start tomcat as a true daemon process. Once tomcat has acquired its TCP socket,"
227    ui_msg "# jsvc will drop its root privileges and run as user ${tomcatuser}."
228    ui_msg "#"
229    ui_msg "# Under Apple Java, control over the Java version used to launch ${name} is"
230    ui_msg "# through the shell variable JAVA_JVM_VERSION. This variable should be set"
231    ui_msg "# to a java version such as 1.5, 1.6, or CurrentJDK (for the default version)."
232    ui_msg "# You may set JAVA_JVM_VERSION in ${prefix}/${home}/bin/setenv.sh."
233    ui_msg "#"
234}
235
236startupitem.create      yes
237startupitem.executable  "${prefix}/bin/tomcatctl" start
238startupitem.pidfile     clean "${prefix}/share/java/tomcat7/logs/${name}.pid"
239
240livecheck.type          regex
241livecheck.url           ${homepage}/download-60.cgi
242livecheck.regex         "apache-tomcat-(\\d+\\.\\d+(\\.\\d+)?)-src.tar.gz"