Ignore:
Timestamp:
Oct 28, 2004, 10:23:47 PM (16 years ago)
Author:
jberry
Message:

Alteration of tomcat5 port.

Changes:

(1) jk2 support has been split out into separate port mod_jk2, which

needs to be installed separately. This simplifies the tomcat5 port.
Thanks, Landon, for the suggestion.

(2) Configuration files, apt to be modified by the user, are now installed

as .sample files. On each run of tomcat using supplied scripts
these files are copied to their proper names if they don't exist.
Thus updates to the port should not destroy these files and any
user configuration within them.

(3) tomcat.pid file moved to tomcat/logs directory to best support multiple

tomcat instances using CATALINA_BASE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/java/tomcat5/Portfile

    r8922 r9016  
    1 # $Id: Portfile,v 1.3 2004/10/25 02:41:23 jberry Exp $
     1# $Id: Portfile,v 1.4 2004/10/28 22:23:46 jberry Exp $
    22
    33PortSystem 1.0
     
    55name                            tomcat5
    66version                         5.0.29
    7 revision                        2
     7revision                        3
    88
    99categories                      java www
     
    2222
    2323patchfiles                      patch-setclasspath.sh.diff \
    24                                         patch-jk2.properties.diff \
    25                                         patch-workers2.properties.minimal.diff
     24                                        patch-catalina.sh.diff \
     25                                        patch-jk2.properties.diff
    2626
    2727depends_build           bin:ant:apache-ant
     
    5050                                        lib:XXX:saxpath
    5151                                       
     52                                        # Support to build w/struts 1.2 versions, like we may have
     53                                        # installed, should be available in tomcat 5.0.30.
    5254                                        #lib:XXX:struts
    5355                               
     56worksrcdir                      ${distname}/jakarta-tomcat-5
     57
    5458set javaLibs            ${prefix}/share/java
    55 set tomcatpath          ${worksrcpath}/jakarta-tomcat-5
    56 set jk2path                     ${worksrcpath}/jakarta-tomcat-connectors/jk/native2
    5759set home                        share/java/tomcat5
    5860set tomcatuser          www
    5961set tomcatgroup         www
    6062
    61 # Determine a reasonable JAVA_HOME value
    62 if { [llength [array get env "JAVA_HOME"]] > 0 } {
    63         set javahome $env(JAVA_HOME)
    64 } else {
    65         set javahome ""
    66 }
    67 if { ![file isdirectory ${javahome}] } {
    68         if { [variant_isset darwin] } {
    69                 set javahome "/Library/Java/Home"
    70         } else {
    71                 error "This port needs a reasonable value for JAVA_HOME, but couldn't automatically determine one: please set the environment variable."
    72         }
     63use_configure           no
     64
     65build.cmd                       ant
     66build.target            download dist
     67build.args                      [join "
     68                                        -Dbase.path=${worksrcpath}/Repository
     69                                        -Dnsis.exe=${worksrcpath}/.turd
     70                                        -Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar
     71                                        -Dcommons-collections.jar=${javaLibs}/commons-collections.jar
     72                                        -Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar
     73                                        -Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar
     74                                        -Dcommons-digester.jar=${javaLibs}/commons-digester.jar
     75                                        -Dcommons-el.jar=${javaLibs}/commons-el.jar
     76                                        -Dcommons-logging.jar=${javaLibs}/commons-logging.jar
     77                                        -Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar
     78                                        -Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar
     79                                        -Dregexp.jar=${javaLibs}/jakarta-regexp.jar
     80                                        -DxercesImpl.jar=${javaLibs}/xercesImpl.jar
     81                                        -Dxml-apis.jar=${javaLibs}/xml-apis.jar
     82                                        -Dlog4j.jar=${javaLibs}/jakarta-log4j.jar
     83                                        -Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar
     84                                        -Dcommons-pool.jar=${javaLibs}/commons-pool.jar
     85                                        -Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar
     86                                        -Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar
     87                                        -Djmx.jar=${javaLibs}/mx4j.jar
     88                                        -Djunit.jar=${javaLibs}/junit.jar
     89                                        -Djaxen.jar=${javaLibs}/jaxen-core.jar
     90                                        -Dsaxpath.jar=${javaLibs}/saxpath.jar
     91                                        "]
     92
     93                                        #-Dstruts.lib=${javaLibs}/struts/lib
     94
     95pre-build {
     96        # Make a bogus file to prevent nsis.exe from downloading
     97        system "touch ${worksrcpath}/.turd"
    7398}
    7499
    75 # Variant jk2 builds the jk2 connector
    76 variant jk2 {
    77         if { ![variant_isset apache2] } {
    78                 error "Variant jk2 may be built only together with variant apache2 for now"
    79         }
    80        
    81         configure.cmd                   ./configure
    82         build.cmd                               make
    83 }
    84 
    85 # Variant apache2 specifies use with apache2
    86 variant apache2 {
    87         depends_lib-append              path:${prefix}/apache2/bin/httpd:apache2
    88         configure.args-append   --with-apxs2=${prefix}/apache2/bin/apxs \
    89                                                         --with-jni \
    90                                                         --with-java-home=${javahome}
    91 }
    92                                        
    93 post-patch {
    94         # Clean up the the buildconf script
    95         reinplace s|libtoolize|glibtoolize| ${jk2path}/buildconf.sh
    96 
    97         # Fix link
    98         reinplace s|-lcrypt|| ${jk2path}/server/apache2/Makefile.in
    99 }
    100 
    101 pre-configure {
    102 
    103         # Check to be sure the apache2 port has been updated, and
    104         # warn the user if it hasn't been.
    105         # In port versions prior to 2.0.52_1, apxs didn't know where libdir was.
    106         # That information is needed by the jk2 configure script.
    107 
    108         if { [variant_isset apache2] } {
    109                 set apxs ${prefix}/apache2/bin/apxs
    110                 if { [file executable ${apxs}] } {
    111                         set libdir [exec ${apxs} -q LIBDIR]
    112                         if { 0 == [string length ${libdir}] || ![file isdirectory ${libdir}] } {
    113                                 error "Your apache2 installation doesn't know where its library directory is. Please update your apache2 port."
    114                         }
    115                 }
    116         }
    117        
    118         # Configure jk2
    119         file attributes ${jk2path}/buildconf.sh -permissions ug+x
    120         system "cd ${jk2path} && ./buildconf.sh"       
    121 }
    122 
    123 # configure/make build is used to build the jk2 connector, while the primary
    124 # java build is done in post-build.
    125 
    126 configure.dir           ${jk2path}
    127 configure.cmd           true
    128 configure.args          --with-pcre
    129 
    130 build.dir                       ${jk2path}
    131 build.cmd                       true
    132 
    133 # Run an ant build
    134 proc ant_build { dir {target ""} {args ""} {env ""} } {
    135         set cmdLine "cd ${dir} && ${env} ant ${target} ${args}"
    136         system ${cmdLine}
    137 }
    138 
    139 post-build {
    140         # Build the java code as a post-build process
    141         ui_msg "--->  Building ${name} Java code"
    142         ant_build ${tomcatpath} "download dist" [join "
    143                 -Dbase.path=${worksrcpath}/Repository
    144                 -Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar
    145                 -Dcommons-collections.jar=${javaLibs}/commons-collections.jar
    146                 -Dcommons-launcher.jar=${javaLibs}/commons-launcher.jar
    147                 -Dcommons-daemon.jar=${javaLibs}/commons-daemon.jar
    148                 -Dcommons-digester.jar=${javaLibs}/commons-digester.jar
    149                 -Dcommons-el.jar=${javaLibs}/commons-el.jar
    150                 -Dcommons-logging.jar=${javaLibs}/commons-logging.jar
    151                 -Dcommons-logging-api.jar=${javaLibs}/commons-logging-api.jar
    152                 -Dcommons-modeler.jar=${javaLibs}/commons-modeler.jar
    153                 -Dregexp.jar=${javaLibs}/jakarta-regexp.jar
    154                 -DxercesImpl.jar=${javaLibs}/xercesImpl.jar
    155                 -Dxml-apis.jar=${javaLibs}/xml-apis.jar
    156                 -Dlog4j.jar=${javaLibs}/jakarta-log4j.jar
    157                 -Dcommons-httpclient.jar=${javaLibs}/commons-httpclient.jar
    158                 -Dcommons-pool.jar=${javaLibs}/commons-pool.jar
    159                 -Dcommons-dbcp.jar=${javaLibs}/commons-dbcp.jar
    160                 -Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar
    161                 -Djmx.jar=${javaLibs}/mx4j.jar
    162                 -Djunit.jar=${javaLibs}/junit.jar
    163                 -Djaxen.jar=${javaLibs}/jaxen-core.jar
    164                 -Dsaxpath.jar=${javaLibs}/saxpath.jar
    165                 "]
    166 
    167                 #-Dstruts.lib=${javaLibs}/struts/lib
    168 }
    169 
    170 destroot        {
     100destroot {
    171101        set target ${destroot}${prefix}/${home}
    172102
     
    175105                ${destroot}${prefix}/share/java \
    176106                ${destroot}${prefix}/share/doc \
    177                 ${destroot}${prefix}/var/run \
    178107                ${destroot}${prefix}/etc/rc.d
    179108               
     
    184113       
    185114        # Install Tomcat
    186         file copy ${tomcatpath}/dist ${target}
     115        file copy ${worksrcpath}/dist ${target}
    187116       
    188117        # Add the jstl libs to tomcat5/shared/lib so that they're available to all
     
    197126        # Add turds to maintain empty directories
    198127        foreach d       "
    199                                 ${destroot}${prefix}/var/run
    200128                                ${target}/logs
    201129                                ${target}/temp
     
    210138        xinstall -m 755 \
    211139                ${filespath}/tomcatctl \
     140                ${filespath}/conf_setup.sh \
    212141                ${filespath}/setenv.sh \
    213142                ${target}/bin
     
    223152        reinplace s|TOMCATPREFIX=$|TOMCATPREFIX=${prefix}/${home}| ${destroot}${prefix}/etc/rc.d/tomcat5.sh
    224153       
     154        # Rename certain files as .sample to avoid replacing them on update
     155        # These will be "repaired" by conf_setup.sh on first run
     156        foreach f       "
     157                                catalina.policy
     158                                catalina.properties
     159                                jk2.properties
     160                                server.xml
     161                                tomcat-users.xml
     162                                web.xml
     163                                " {
     164                file rename ${target}/conf/${f} ${target}/conf/${f}.sample
     165        }
     166        reinplace s|@@PREFIX@@|${prefix}|g ${target}/conf/jk2.properties.sample
     167
    225168        # Fix ownership of some directories tomcat really needs to write to
    226169        system "chown -R ${tomcatuser}:${tomcatgroup} \
     
    232175       
    233176        # Install the docs
    234         file copy ${tomcatpath}/build/docs \
     177        file copy ${worksrcpath}/build/docs \
    235178                ${destroot}${prefix}/share/doc/${name}
    236                
    237         # Install the jk2 connector for apache2
    238         if { [variant_isset apache2] && [variant_isset jk2] } {
    239                 xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \
    240                         ${destroot}${prefix}/apache2/conf
    241                        
    242                 xinstall -m 644 ${jk2path}/../build/jk2/apache2/mod_jk2.so \
    243                         ${destroot}${prefix}/apache2/modules
    244                        
    245                 xinstall -m 644 ${jk2path}/../build/jk2/apache2/libjkjni.so \
    246                         ${target}/server/lib
    247                        
    248                 xinstall -m 644 ${jk2path}/../conf/jk2.properties \
    249                         ${target}/conf
    250                 xinstall -m 644 ${jk2path}/../conf/workers2.properties.minimal \
    251                         ${destroot}/${prefix}/apache2/conf/workers2.properties
    252                
    253                 reinplace s|@@PREFIX@@|${prefix}|g \
    254                         ${target}/conf/jk2.properties
    255         }
    256179}
    257180
    258181
    259182post-install {
    260         if { [variant_isset apache2] && [variant_isset jk2] } {
    261                 ui_msg "
    262 Example files ${prefix}/apache2/conf/workers2.properties and
    263 ${prefix}/${home}/conf/jk2.properties have been installed to illustrate
    264 use of the jk2 connector between apache2 and tomcat over a unix domain socket.
    265 You will want to configure the uri mappings in workers2.properties
    266 or using JkUriSet in httpd.conf.
    267 
    268 Be sure to add the following line to your httpd.conf:
    269 
    270         LoadModule jk2_module modules/mod_jk2.so
    271 "
    272         }
    273        
    274         ui_msg "
    275 The script ${prefix}/${home}/tomcatctl has been installed to facilitate
    276 start and stop of tomcat using the jsvc utility, which allows you to
    277 start tomcat as a true daemon process. Once it has acquired its TCP socket,
    278 jsvc will drop its root privileges and run as user ${tomcatuser}.
    279 "
     183        ui_msg "#"
     184        ui_msg "# Configuration files in ${prefix}/${home}/conf have been"
     185        ui_msg "# installed with a .sample extension so that they won't be replaced by a"
     186        ui_msg "# port update. Each will be copied to its proper location during the"
     187        ui_msg "# first startup of tomcat by catalina.sh or tomcatctl if you don't"
     188        ui_msg "# do this yourself first. If this _is_ an update, you might do a diff to"
     189        ui_msg "# verify that you're not missing anything in the newer .sample versions"
     190        ui_msg "# of these files."
     191        ui_msg "#"
     192        ui_msg "# The script ${prefix}/${home}/bin/tomcatctl has been installed to"
     193        ui_msg "# facilitate start and stop of tomcat using the jsvc utility, which allows you to"
     194        ui_msg "# start tomcat as a true daemon process. Once it has acquired its TCP socket,"
     195        ui_msg "# jsvc will drop its root privileges and run as user ${tomcatuser}."
     196        ui_msg "#"
    280197}
Note: See TracChangeset for help on using the changeset viewer.