Ticket #37388: Portfile

File Portfile, 4.9 KB (added by chris@…, 11 years ago)

New Portfile

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$
3
4PortSystem 1.0
5
6name                    sonatype-nexus
7version                 2.2-01
8categories              devel
9platforms               darwin
10supported_archs noarch
11license         sonatype
12maintainers             behanna.org:chris
13description             Network-visible Maven repository
14long_description        Sonatype Nexus is an http\[s\]-visible Maven repository, \
15                suitable for use by the Maven build system.  Nexus conforms \
16                to the repository layout used by Maven 2 and Maven 3.
17
18homepage                http://www.sonatype.org/nexus
19master_sites    http://www.sonatype.org/downloads
20checksums               md5     1f904614f5d412c684fe99ad12064000 \
21                                sha1    7c5e1217fdc617ab496707b847b5ce3b237b6ba5 \
22                                rmd160  cd79002bd832c8f29e748a2052cecf3e2213b022
23
24depends_run             path:/usr/bin/java:kaffe
25
26distname        nexus-${version}-bundle
27
28set nexusUser   nexus
29set nexusGroup  ${nexusUser}
30
31add_users       ${nexusUser} group=${nexusGroup}
32
33use_configure   no
34
35#fetch {
36#    puts "exec sh -c (cd ${distpath}; curl -L -O ${master_sites}/${distfiles})"
37#    try {
38#        set results [exec sh -c "(cd ${distpath}; curl -L -O ${master_sites}/${distfiles})"]
39#        set status 0
40#    } catch {CHILDSTATUS results options} {
41#        set status [lindex [dict get $options -errorcode] 2]
42#    } finally {}
43#    puts $results
44#}
45
46build                   {}
47
48extract         {}
49
50destroot            {
51    exec tar zxf ${distpath}/${distfiles} -C ${destroot}${prefix}
52}
53
54set nexusPrefix   ${prefix}/nexus
55set nexusDestroot ${destroot}${nexusPrefix}
56
57#
58# We borrow heavily from the "don't overwrite config files" section in
59# www/privoxy.
60#
61post-destroot {
62    if [file exists ${nexusDestroot}] {
63        file delete ${nexusDestroot}
64    }
65
66    file link -symbolic ${nexusDestroot} nexus-${version}
67
68    # Rename these so local modifications are not removed on uninstall.
69    foreach nexusConf {jetty.xml logback.xml nexus.properties} {
70        if [file exists ${nexusDestroot}/conf/${nexusConf}] {
71            file rename ${nexusDestroot}/conf/${nexusConf} \
72            ${nexusDestroot}/conf/${nexusConf}.new
73        }
74        # backup config files
75        if {[file exists ${nexusPrefix}/conf/${nexusConf}] \
76            && ![file exists ${nexusPrefix}/conf/${nexusConf}.new]} {
77
78            file copy ${nexusPrefix}/conf/${nexusConf} \
79            ${destroot}${nexusPrefix}/conf/${nexusConf}.mp_backup
80        }
81    }
82
83    set startup_script   ${nexusDestroot}/bin/nexus
84    set nexus_properties ${nexusDestroot}/conf/nexus.properties
85
86    #
87    # Put the nexus data directory someplace sensible.
88    #
89    if ![file exists ${destroot}/${prefix}/var/sonatype-work] {
90        file rename ${destroot}/${prefix}/sonatype-work ${destroot}/${prefix}/var/
91    } else {
92        file delete -force ${destroot}/${prefix}/sonatype-work
93    }
94
95    reinplace "s,^nexus-webapp\=.*$,nexus-webapp=${nexusPrefix}/nexus,"    \
96              ${nexus_properties}.new
97
98    reinplace "s,^nexus-work\=.*$,nexus-work=${prefix}/var/sonatype-work," \
99              ${nexus_properties}.new
100
101    reinplace "s,^runtime\=.*$,runtime=${nexusPrefix}/nexus/WEB-INF,"      \
102              ${nexus_properties}.new
103
104    reinplace "s,^#PIDDIR.*$,PIDDIR=${prefix}/var/run," ${startup_script}
105
106    #
107    # Point the startup file to the installation and set the run user.
108    #
109    reinplace "s,^NEXUS_HOME.*$,NEXUS_HOME=${nexusPrefix},"   ${startup_script}
110    reinplace "s,^#RUN_AS_USER.*$,RUN_AS_USER=${nexusUser},"  ${startup_script}
111
112}
113
114post-activate {
115    foreach nexusConf {jetty.xml logback.xml nexus.properties} {
116        if ![file exists ${nexusPrefix}/etc/nexus/${nexusConf}] {
117            # restore config files
118            if [file exists ${nexusPrefix}/conf/${nexusConf}.mp_backup] {
119                file copy ${nexusPrefix}/conf/${nexusConf}.mp_backup \
120                          ${nexusPrefix}/conf/${nexusConf}
121            } else {
122                file copy ${nexusPrefix}/conf/${nexusConf}.new \
123                          ${nexusPrefix}/conf/${nexusConf}
124            }
125        }
126
127        if {[existsuser ${nexusUser}] != 0 && \
128            [existsgroup ${nexusGroup}] != 0} {
129
130            file attributes ${nexusPrefix}/conf/${nexusConf} \
131                -group ${nexusGroup} -owner ${nexusUser}     \
132                -permissions 0664
133        }
134    }
135
136    if {[file exists ${prefix}/var/sonatype-work] && \
137        [existsuser ${nexusUser}] != 0            && \
138        [existsgroup ${nexusGroup}] != 0} {
139
140        file attributes ${prefix}/var/sonatype-work  \
141            -group ${nexusGroup} -owner ${nexusUser} \
142            -permissions 0775
143    }
144}
145
146destroot.violate_mtree  yes
147
148startupitem.create      yes
149startupitem.name        nexus
150startupitem.start       "${prefix}/nexus/bin/nexus start"
151startupitem.stop        "${prefix}/nexus/bin/nexus stop"
152startupitem.restart     "${prefix}/nexus/bin/nexus restart"
153startupitem.pidfile     clean ${prefix}/var/run/nexus.pid