Ignore:
Timestamp:
Oct 28, 2004, 10:23:47 PM (15 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.

Location:
trunk/dports/java/tomcat5
Files:
2 added
4 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}
  • trunk/dports/java/tomcat5/files/patch-jk2.properties.diff

    r8862 r9016  
    1 --- jakarta-tomcat-connectors/jk/conf/jk2.properties.orig       Tue Oct 19 17:48:44 2004
    2 +++ jakarta-tomcat-connectors/jk/conf/jk2.properties    Tue Oct 19 17:51:52 2004
    3 @@ -24,3 +24,8 @@
     1--- ../jakarta-tomcat-connectors/jk/conf/jk2.properties.orig    Wed Oct 27 16:10:50 2004
     2+++ ../jakarta-tomcat-connectors/jk/conf/jk2.properties Wed Oct 27 16:16:24 2004
     3@@ -24,3 +24,12 @@
    44 # If set to inprocess the mod_jk2 will Register natives itself
    55 # This will enable the starting of the Tomcat from mod_jk2
    66 # apr.jniModeSo=inprocess
    77+
    8 +#################################################
     8+###############################################################
    99+# Configure a local unix domain socket
    10 +apr.nativeSo=@@PREFIX@@/share/java/tomcat5/server/lib/libjkjni.so
     10+#
     11+# This assumes that the jni library we need has been installed
     12+# in the apache2/modules directory.
     13+#
     14+apr.nativeSo=@@PREFIX@@/apache2/modules/libjkjni.so
    1115+channelUnix.file=@@PREFIX@@/share/java/tomcat5/logs/jk2.socket
  • trunk/dports/java/tomcat5/files/patch-setclasspath.sh.diff

    r8862 r9016  
    1 --- jakarta-tomcat-catalina/catalina/src/bin/setclasspath.sh.orig       Sun Oct 10 15:23:36 2004
    2 +++ jakarta-tomcat-catalina/catalina/src/bin/setclasspath.sh    Sun Oct 10 15:25:49 2004
     1--- ../jakarta-tomcat-catalina/catalina/src/bin/setclasspath.sh.orig    Sun Oct 10 15:23:36 2004
     2+++ ../jakarta-tomcat-catalina/catalina/src/bin/setclasspath.sh Sun Oct 10 15:25:49 2004
    33@@ -10,7 +10,7 @@
    44   echo "This environment variable is needed to run this program"
  • trunk/dports/java/tomcat5/files/tomcatctl

    r8922 r9016  
    11#!/bin/sh
    2 
     2#
     3#       tomcatctl
     4#
     5#       Tomcat control script to control tomcat running under jsvc.
     6#
     7#       USAGE: tomcatctl [--jdpa] start|stop|restart|status|info
     8#
     9
     10# To be customized by installer...
    311PREFIX=
    412TOMCAT_USER=
     
    917#JSVC_DEBUG="-debug -verbose"
    1018
    11 usage()
    12 {
    13     cat <<EOT
    14 USAGE: `basename $0` [--jpda] start|stop|restart|info
    15 EOT
    16 }
    17 
    18 # Parse Parameters
    19 USE_JPDA=false
    20 while [[ "$1" == -* ]]; do
    21     case $1 in
    22     --jpda)
    23         USE_JPDA=true
    24         ;;
    25     *)
    26         usage
    27         exit 1
    28         ;;
    29     esac
    30     shift
    31 done
    32 
    33 # Parse action verb
    34 if [ $# -lt 1 ]; then
    35    usage
    36    exit 1
    37 fi
    38 ACTION=$1
    39 shift
    40 
    41 # Calculate CATALINA_HOME
     19# Calculate CATALINA_HOME based on our location
    4220if [ -z "$CATALINA_HOME" ]; then
    4321    # Handle symlinks
     
    6947
    7048# Set variable default values
    71 [ -n "$CATALINA_BASE" ]     || CATALINA_BASE="${CATALINA_HOME}"
    72 [ -n "$CATALINA_TMPDIR" ]   || CATALINA_TMPDIR="${CATALINA_BASE}/temp"
    73 
    74 [ -n "$TOMCAT_PIDNAME" ]    || TOMCAT_PIDNAME="tomcat5.pid"
    75 [ -n "$TOMCAT_PIDFILE" ]    || TOMCAT_PIDFILE="${PREFIX}/var/run/${TOMCAT_PIDNAME}"
    76 [ -n "$TOMCAT_USER" ]       || TOMCAT_USER=tomcat
    77 
    78 [ -n "$JAVA_ENDORSED_DIRS" ]|| JAVA_ENDORSED_DIRS=${CATALINA_BASE}/common/endorsed
    79 
    80 [ -n "$JPDA_TRANSPORT" ]    || JPDA_TRANSPORT=dt_socket
    81 [ -n "$JPDA_ADDRESS" ]      || JPDA_ADDRESS=8000
    82 
    83 if $USE_JPDA && [ -z "$JPDA_OPTS" ]; then
    84     JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n"
    85 fi
     49[ -z "$CATALINA_BASE" ]         && CATALINA_BASE="${CATALINA_HOME}"
     50[ -z "$CATALINA_TMPDIR" ]       && CATALINA_TMPDIR="${CATALINA_BASE}/temp"
     51
     52[ -z "$TOMCAT_PIDNAME" ]        && TOMCAT_PIDNAME="tomcat5.pid"
     53[ -z "$TOMCAT_PIDFILE" ]        && TOMCAT_PIDFILE="${CATALINA_BASE}/logs/${TOMCAT_PIDNAME}"
     54[ -z "$TOMCAT_USER" ]           && TOMCAT_USER=tomcat
     55
     56[ -z "$JAVA_ENDORSED_DIRS" ]    && JAVA_ENDORSED_DIRS=${CATALINA_BASE}/common/endorsed
     57
     58[ -z "$JPDA_TRANSPORT" ]        && JPDA_TRANSPORT=dt_socket
     59[ -z "$JPDA_ADDRESS" ]          && JPDA_ADDRESS=8000
    8660
    8761CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar
     62
     63usage()
     64{
     65    cat <<EOT
     66USAGE: `basename $0` [--jpda] start|stop|restart|status|info
     67EOT
     68}
     69
    8870
    8971check()
     
    9577    if [ -f "$TOMCAT_PIDFILE" ]; then
    9678        PID=`cat $TOMCAT_PIDFILE`
    97         #if [ -n "$PID" ] && kill -0 $PID; then
    98         if [ -n "$PID" ] && ((`ps $PID | $WC -l` > 1)); then
     79        if [ -n "$PID" -a `ps $PID | $WC -l` -gt 1 ]; then
    9980            STATUS="running (pid $PID)"
    10081            RUNNING=$PID
     
    11293start()
    11394{
     95        # Run conf_setup.sh to check and repair the conf directory
     96        if [ -x "$CATALINA_HOME/bin/conf_setup.sh" ]; then
     97                CATALINA_BASE="$CATALINA_BASE" "$CATALINA_HOME/bin/conf_setup.sh"
     98        fi
     99
    114100    echo -n "Starting Tomcat..."
    115101    check
     
    184170
    185171
    186 case $ACTION in
    187 start)
    188     start
    189     ;;
    190    
    191 stop)
    192     stop
    193     ;;
    194    
    195 restart)
    196     stop
    197     start
    198     ;;
    199    
    200 info)
    201     check
    202    
    203     cat <<EOT
    204 
     172# Ensure at least one parameter
     173if [ $# -lt 1 ]; then
     174   usage
     175   exit 1
     176fi
     177
     178# Parameter Handling
     179while [ $# -gt 0 ]; do
     180        case "$1" in
     181        --jpda)
     182                [ -z "$JPDA_OPTS" ] && JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n"
     183                ;;
     184               
     185        start)
     186                start
     187                ;;
     188               
     189        stop)
     190                stop
     191                ;;
     192               
     193        restart)
     194                stop
     195                start
     196                ;;
     197               
     198        status)
     199                check
     200                echo "Tomcat is $STATUS"
     201                ;;
     202               
     203        info)
     204                check
     205                cat <<EOT
     206       
    205207Tomcat is $STATUS
    206208
     
    213215JPDA_OPTS           $JPDA_OPTS
    214216EOT
    215     ;;
    216    
    217 *)
    218     usage
    219     ;;
    220 esac
    221 
    222 
     217                ;;
     218               
     219        *)
     220                echo "$0: unrecognized option '$1'"
     221                usage
     222                exit 1
     223                ;;
     224        esac
     225       
     226        shift
     227done
     228
     229
Note: See TracChangeset for help on using the changeset viewer.