source: trunk/dports/_resources/port1.0/group/pear-1.0.tcl @ 102429

Last change on this file since 102429 was 102429, checked in by ryandesign@…, 7 years ago

pear-1.0.tcl: fix "sed: RE error: illegal byte sequence" on Mountain Lion (e.g. in pear-MDB whose package.xml is ISO-8859-1)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.5 KB
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: pear-1.0.tcl 102429 2013-02-02 18:37:12Z ryandesign@macports.org $
3#
4# Copyright (c) 2011-2013 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of The MacPorts Project nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This PortGroup automatically sets up the standard environment for installing
34# a PHP PEAR class.
35#
36# Usage:
37#
38#   PortGroup           pear 1.0
39#   pear.setup      package version channel
40#
41# where package is the name of the PEAR package (e.g. AUTH), version is its
42# version, and channel is the channel hosting the package (default: pear.php.net).
43#
44
45# Args placed before the php or pear commands.
46options pear.env
47default pear.env    {
48    "TZ=UTC \
49    HOME=${pear.installer} \
50    PHP_PEAR_INSTALL_DIR=${pear.installer}/pear \
51    PHP_PEAR_BIN_DIR=${pear.installer}/bin \
52    PHP_PEAR_PHP_BIN=${pear.cmd-php} \
53    PHP_PEAR_CFG_DIR=${pear.installer}/pear/cfg \
54    PHP_PEAR_DOC_DIR=${pear.installer}/pear/docs \
55    PHP_PEAR_DATA_DIR=${pear.installer}/pear/data \
56    PHP_PEAR_WWW_DIR=${pear.installer}/pear/www \
57    PHP_PEAR_TEST_DIR=${pear.installer}/pear/tests \
58    PHP_PEAR_SYSCONF_DIR=${pear.installer}"
59}
60
61# Args placed after php or pear commands.
62options pear.configure.pre_args
63default pear.configure.pre_args   {
64    "-c ${pear.installer}/pear.conf \
65    -C ${pear.installer}/pear.conf"
66}
67
68# Where we instruct pear to install our package.
69options pear.destroot
70default pear.destroot       {${worksrcpath}/packagingroot}
71
72# Where the pear installer is installed for each port.
73options pear.installer
74default pear.installer      {${worksrcpath}/installer}
75
76# Where we expand our source files.
77options pear.sourceroot
78default pear.sourceroot     {${worksrcpath}/packagesource}
79
80# The base paths for our pear.conf.
81options pear.instpath
82default pear.instpath       {${prefix}/lib/php}
83options pear.pearpath
84default pear.pearpath       {${pear.instpath}/pear}
85
86# The pear command we will use.
87options pear.cmd-pear
88default pear.cmd-pear       {${pear.installer}/bin/pear}
89
90# The phar file that contains our pear installer.
91options pear.cmd-phar
92default pear.cmd-phar       {${prefix}/lib/php/pear/install-pear-nozlib.phar}
93
94# The php binary we will use.
95options pear.cmd-php
96default pear.cmd-php        {/usr/bin/php}
97
98# The pear channel for our package.
99options pear.channel
100
101# The name of the package xml file inside the pear package archive.
102options pear.packagexml
103default pear.packagexml     {[lindex [exec tar -tzf ${pear.packagefile} | grep package.*\.xml] 0]}
104
105# Package name.
106options pear.package
107
108# Package file.
109options pear.packagefile
110default pear.packagefile    {"${distpath}/[lindex $distfiles 0]"}
111
112proc pear.setup {package_name package_version {package_channel "pear.php.net"}} {
113    global name extract.suffix version
114    global pear.env pear.cmd-pear pear.destroot pear.sourceroot
115    global pear.channel pear.package pear.packagexml
116
117    # The pear name for the package.
118    pear.package        ${package_name}
119    # The pear channel for the package.
120    pear.channel        ${package_channel}
121
122    name                    pear-${pear.package}
123    version                 ${package_version}
124    categories              php
125    distname                ${pear.package}-${version}
126    extract.suffix          .tgz
127    homepage                http://${pear.channel}/package/${pear.package}
128    master_sites            http://${pear.channel}/get
129    dist_subdir             pear
130    supported_archs         noarch
131    use_parallel_build      yes
132    depends_build           port:pear-install-phar
133
134    # List of ports that pear-PEAR depends on.
135    # Add some pear-PEAR deps to make programmatic creation of pear Portfiles easier.
136    if {
137        ${name} != "pear-Archive_Tar" &&
138        ${name} != "pear-Console_Getopt" &&
139        ${name} != "pear-Structures_Graph" &&
140        ${name} != "pear-XML_Util" &&
141        ${name} != "pear-PEAR"
142    } {
143        depends_lib-append  port:pear-PEAR
144    } elseif {
145        ${name} == "pear-PEAR"
146    } {
147        depends_lib-append  port:pear-Archive_Tar \
148                            port:pear-Console_Getopt \
149                            port:pear-Structures_Graph \
150                            port:pear-XML_Util
151
152    }
153
154    fetch.ignore_sslcert yes
155
156    extract.post_args-append   -C '${pear.sourceroot}' --strip-components 1
157
158    pre-extract {
159        xinstall -d "${pear.sourceroot}"
160    }
161
162    post-extract {
163        # The "--strip-components 1" causes the loss of our package file so we will extract it now.
164        extract.post_args-delete    --strip-components 1
165        extract.post_args-append    ${pear.packagexml}
166        command_exec                extract
167    }
168
169    post-patch {
170        # Some ports use a "." baseinstalldir which can cause issues creating pear's packagingroot directory.
171        reinplace -locale C "s|baseinstalldir=\"\.\"|baseinstalldir=\"/\"|g" \
172            ${pear.sourceroot}/${pear.packagexml}
173    }
174
175    configure.env           ${pear.env}
176    configure.dir           ${pear.sourceroot}
177    configure {
178        # Install the pear command using the phar file.
179        configure.cmd           ${pear.cmd-php}
180        configure.pre_args      ${pear.cmd-phar}
181        command_exec configure
182        configure.cmd           ${pear.cmd-pear}
183        configure.pre_args      -c ${pear.installer}/pear.conf \
184                                -C ${pear.installer}/pear.conf
185        # Set up pear's conf file.
186        # The order appears to be important; we get errors if we set php_dir before adding channels
187        # and the directory is not writable.
188        xinstall -d "${pear.installer}/pear/php"
189        set pear_config [list]
190        lappend pear_config         "config-set auto_discover 1"
191        if { "${pear.channel}" != "pear.php.net" } {
192            lappend pear_config         "channel-discover ${pear.channel}"
193            lappend pear_config         "config-set default_channel ${pear.channel}"
194        }
195        # Change the install directories to the final destinations
196        lappend pear_config         "config-set php_dir ${pear.pearpath}"
197        lappend pear_config         "config-set bin_dir ${pear.pearpath}/bin"
198        lappend pear_config         "config-set cfg_dir ${pear.pearpath}/cfg"
199        lappend pear_config         "config-set doc_dir ${pear.pearpath}/docs"
200        lappend pear_config         "config-set data_dir ${pear.pearpath}/data"
201        lappend pear_config         "config-set www_dir ${pear.pearpath}/www"
202        lappend pear_config         "config-set test_dir ${pear.pearpath}/tests"
203        lappend pear_config         "config-show"
204        foreach pear_args $pear_config {
205            configure.args          "${pear_args}"
206            command_exec configure
207        }
208    }
209
210    build {
211        build.env           ${pear.env}
212        build.dir           ${pear.sourceroot}
213        build.cmd           ${pear.cmd-pear}
214        build.target        install
215        build.args          "-n -f -P '${pear.destroot}' ${pear.packagexml}"
216        command_exec build
217    }
218
219    destroot {
220        copy ${pear.destroot}${pear.instpath} ${destroot}${prefix}/lib
221        # Remove all invisible "dot" files.
222        fs-traverse -ignoreErrors item "${destroot}${pear.instpath}" {
223            if {[string first . [file tail ${item}] 0] == 0} {
224                if {[file tail ${item}] != "." && [file tail ${item}] != ".."} {
225                    puts "Removing dot file ${item}"
226                    delete ${item}
227                }
228            }
229        }
230        if { [file exists "${destroot}${pear.pearpath}/generate_package_xml.php"] } {
231            # Some pear packages contain package creation files so we remove them.
232            delete "${destroot}${pear.pearpath}/generate_package_xml.php"
233        }
234        if { [file exists "${destroot}${pear.pearpath}/package.php"] } {
235            # Some pear packages contain package creation files so we remove them.
236            delete "${destroot}${pear.pearpath}/package.php"
237        }
238    }
239
240    livecheck.type          regex
241    livecheck.url           http://${pear.channel}/package/${pear.package}/download
242    livecheck.regex         http://download.${pear.channel}/package/${pear.package}-(.*?)${extract.suffix}
243}
Note: See TracBrowser for help on using the repository browser.