Ignore:
Timestamp:
Nov 16, 2011, 10:54:37 PM (8 years ago)
Author:
pixilla@…
Message:

group/php5pear-1.0.tcl:

  • Install a temporary pear installer into worksrcpath for each port.
  • This leaves a resident pear command for a later accomplishment.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/_resources/port1.0/group/php5pear-1.0.tcl

    r86867 r87310  
    4444options php5pear.package
    4545options php5pear.channel
    46 options php5pear.bin-pre
    47 options php5pear.bin
    48 options php5pear.bin-post
     46options php5pear.cmd-pre
     47options php5pear.cmd-pear
     48options php5pear.cmd-phar
     49options php5pear.cmd-php
     50options php5pear.cmd-post
    4951options php5pear.cmd
    5052options php5pear.destroot
    51 
    52 proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"}} {
    53     global worksrcpath distname extract.suffix master_sites prefix
    54     global php5pear.bin-pre php5pear.bin php5pear.bin-post php5pear.cmd
    55 
    56     php5pear.package    ${php5pear.package}
    57     php5pear.channel    ${php5pear.channel}
    58     name                pear-${php5pear.package}
    59     version             ${version}
    60     categories          php
    61     distname            ${php5pear.package}-${version}
    62     extract.suffix      .tgz
    63     homepage            http://${php5pear.channel}/package/${php5pear.package}
    64     master_sites        http://${php5pear.channel}/get
    65     livecheck.type      regex
    66     livecheck.url       http://${php5pear.channel}/package/${php5pear.package}/download
    67     livecheck.regex     "http://download.${php5pear.channel}/package/${php5pear.package}-((?!\.tgz).*)${extract.suffix}"
    68 
    69     supported_archs     noarch
    70     use_parallel_build  yes
    71     depends_lib         path:bin/phpize:php5 port:php5-pear
    72 
    73     php5pear.destroot   ${worksrcpath}/packagingroot   
    74     php5pear.bin-pre    TZ=UTC
    75     php5pear.bin        ${prefix}/libexec/php/bin/pear
    76     php5pear.bin-post   -C ${prefix}/libexec/php/etc/pear.conf \
    77                         -c ${prefix}/libexec/php/etc/pear.conf
    78 
    79     extract.mkdir       yes
    80     extract {
    81         copy ${distpath}/${distname}${extract.suffix} ${worksrcpath}
    82     }
    83 
    84     configure {
    85         set fp [open "${prefix}/libexec/php/etc/pear.conf" r]
    86         set ccount [regexp -all "${php5pear.channel}" [read $fp]]
    87         close $fp
    88         if { ! $ccount && "${php5pear.channel}" != "pear.php.net" } {
    89             system "curl -s http://${php5pear.channel}/channel.xml -o ${worksrcpath}/channel.xml"
    90             system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} channel-add ${worksrcpath}/channel.xml"
    91         } else {
    92             system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} channel-update ${php5pear.channel}"
    93         }
    94     }
    95    
    96     build {
    97         system "${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} config-show"
    98         system "cd ${worksrcpath} && ${php5pear.bin-pre} ${php5pear.bin} ${php5pear.bin-post} install --nodeps --offline --ignore-errors --packagingroot=${php5pear.destroot} ${distname}${extract.suffix}"
    99     }
    100    
    101     destroot {
    102         xinstall -d ${destroot}${prefix}/lib/php/pear
    103         foreach path [glob -nocomplain -directory ${php5pear.destroot}${prefix}/libexec/php/pear *] {
    104             copy ${path} ${destroot}${prefix}/lib/php/pear
    105         }
    106         if { [file exists "${destroot}${prefix}/lib/php/pear/generate_package_xml.php"] } {
    107             file rename "${destroot}${prefix}/lib/php/pear/generate_package_xml.php" "${destroot}${prefix}/lib/php/pear/conflict-${php5pear.package}-generate_package_xml.php"
    108         }
    109         if { [file exists "${destroot}${prefix}/lib/php/pear/package.php"] } {
    110             file rename "${destroot}${prefix}/lib/php/pear/package.php" "${destroot}${prefix}/lib/php/pear/conflict-${php5pear.package}-package.php"
    111         }
    112     }
     53options php5pear.sourceroot
     54options php5pear.instpath
     55options php5pear.pearpath
     56options php5pear.installer
     57options php5pear.packagexml
     58
     59proc php5pear.setup {php5pear.package version {php5pear.channel "pear.php.net"} {php5pear.packagexml "package.xml"}} {
     60  global worksrcpath distname extract.suffix master_sites prefix destroot distpath
     61  global php5pear.cmd-pre php5pear.cmd-pear php5pear.cmd-phar php5pear.cmd-php php5pear.cmd-post
     62  global php5pear.cmd php5pear.instpath php5pear.pearpath
     63  global php5pear.installer name php5pear.sourceroot
     64
     65  # The pear name for the package.
     66  php5pear.package    ${php5pear.package}
     67  # The pear channel for the package.
     68  php5pear.channel    ${php5pear.channel}
     69  # The name of the packages xml file used by pear to build the package.
     70  # Note: so far the two knowns names are package.xml and package2.xml.
     71  php5pear.packagexml ${php5pear.packagexml}
     72
     73  name                pear-${php5pear.package}
     74  version             ${version}
     75  categories          php
     76  distname            ${php5pear.package}-${version}
     77  extract.suffix      .tgz
     78  homepage            http://${php5pear.channel}/package/${php5pear.package}
     79  master_sites        http://${php5pear.channel}/get
     80  livecheck.type      regex
     81  livecheck.url       http://${php5pear.channel}/package/${php5pear.package}/download
     82  livecheck.regex     "http://download.${php5pear.channel}/package/${php5pear.package}-((?!\.tgz).*)${extract.suffix}"
     83
     84  dist_subdir         pear
     85  supported_archs     noarch
     86  use_parallel_build  yes
     87  depends_lib         path:bin/phpize:php5 port:php5-pear
     88 
     89  # List of ports that pear-PEAR depends on.
     90  if {
     91    ${name} != "pear-Archive_Tar" &&
     92    ${name} != "pear-Console_Getopt" &&
     93    ${name} != "pear-Structures_Graph" &&
     94    ${name} != "pear-XML_Util" &&
     95    ${name} != "pear-PEAR"
     96  } {
     97    depends_lib-append    port:pear-PEAR
     98  }
     99
     100  # Where the pear installer is installed for each port.
     101  php5pear.installer  ${worksrcpath}/installer
     102  # The base paths for our pear.conf.
     103  php5pear.instpath   ${prefix}/lib/php
     104  php5pear.pearpath   ${php5pear.instpath}/pear
     105  # Where we expand our source files.
     106  php5pear.sourceroot ${worksrcpath}/packagesource   
     107  # Where we instruct pear to install our package.
     108  php5pear.destroot   ${worksrcpath}/packagingroot   
     109
     110  # The pear command we will use.
     111  php5pear.cmd-pear   ${php5pear.installer}/bin/pear
     112  # The phar file that contains our pear installer.
     113  php5pear.cmd-phar   ${prefix}/lib/php/pear/install-pear-nozlib.phar
     114  # The php binary we will use.
     115  php5pear.cmd-php    ${prefix}/bin/php
     116  # Args placed before the php or pear commands.
     117  php5pear.cmd-pre    cd ${php5pear.sourceroot} && TZ=UTC \
     118                      PHP_PEAR_INSTALL_DIR=${php5pear.installer}/pear \
     119                      PHP_PEAR_BIN_DIR=${php5pear.installer}/bin \
     120                      PHP_PEAR_PHP_BIN=${php5pear.cmd-php} \
     121                      PHP_PEAR_CFG_DIR=${php5pear.installer}/pear/cfg \
     122                      PHP_PEAR_DOC_DIR=${php5pear.installer}/pear/docs \
     123                      PHP_PEAR_DATA_DIR=${php5pear.installer}/pear/data \
     124                      PHP_PEAR_WWW_DIR=${php5pear.installer}/pear/www \
     125                      PHP_PEAR_TEST_DIR=${php5pear.installer}/pear/tests \
     126                      PHP_PEAR_SYSCONF_DIR=${php5pear.installer}
     127  # Args placed after php or pear commands.
     128  php5pear.cmd-post   -c ${php5pear.installer}/pear.conf \
     129                      -C ${php5pear.installer}/pear.conf
     130 
     131  extract.mkdir       yes
     132  extract.post_args   "| tar --strip-components 1 -x -f - -C '${php5pear.sourceroot}'"
     133
     134  pre-extract {
     135    xinstall -d ${php5pear.sourceroot}
     136  }
     137
     138  post-extract {
     139    # Get the name of our package xml file.
     140    php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0]
     141    # The "--strip-components 1" causes the lose of our package file so we will extract it now.
     142    system "tar -z -x -v -f '${distpath}/${distname}${extract.suffix}' - -C '${php5pear.sourceroot}' ${php5pear.packagexml}"
     143    # Install the pear command using the phar file.
     144    system "${php5pear.cmd-pre} ${php5pear.cmd-php} ${php5pear.cmd-phar}"
     145  }
     146
     147  post-patch {
     148    # Some ports use a "." baseinstalldir which can cause issues creating pears packagingroot directory.
     149    reinplace "s|baseinstalldir=\"\.\"|baseinstalldir=\"/\"|g" \
     150      ${php5pear.sourceroot}/${php5pear.packagexml}
     151  }
     152
     153  configure {
     154    # Setup pears conf file.
     155    # The order of appears to be important, we get errors if we set php_dir before adding channels
     156    # and the directory is not writable.
     157    xinstall -d "${php5pear.installer}/pear/php"
     158    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set auto_discover 1"
     159    if { "${php5pear.channel}" != "pear.php.net" } {
     160      system "curl -s http://${php5pear.channel}/channel.xml -o ${worksrcpath}/channel.xml"
     161      system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} channel-add ${worksrcpath}/channel.xml"
     162      system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set default_channel ${php5pear.channel}"
     163    }
     164    # Change the install directories to the final destinations
     165    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set php_dir ${php5pear.pearpath}"
     166    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set bin_dir ${php5pear.pearpath}/bin"
     167    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set doc_dir ${php5pear.pearpath}/docs"
     168    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set data_dir ${php5pear.pearpath}/data"
     169    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set www_dir ${php5pear.pearpath}/www"
     170    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-set test_dir ${php5pear.pearpath}/tests"
     171    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} config-show"
     172  }
     173 
     174  build {
     175    # Get the name of our package xml file.
     176    php5pear.packagexml [lindex [exec tar -tzf ${distpath}/${distname}${extract.suffix} | grep package.*\.xml] 0]
     177    # Install our package into our pears packagingroot.
     178    system "${php5pear.cmd-pre} ${php5pear.cmd-pear} ${php5pear.cmd-post} install -n -f -P '${php5pear.destroot}' ${php5pear.packagexml}"
     179  }
     180 
     181  destroot {
     182    copy ${php5pear.destroot}${php5pear.instpath} ${destroot}${prefix}/lib
     183    # Remove all invisible "dot" files.
     184    fs-traverse -ignoreErrors item "${destroot}${php5pear.instpath}" {
     185      if {[string first . [file tail ${item}] 0] == 0} {
     186        # Using system rm because I could not find a way to delete dot files with [file delete].
     187        system "rm -R ${item}"
     188      }
     189    }
     190    if { [file exists "${destroot}${php5pear.pearpath}/generate_package_xml.php"] } {
     191      # Some pear packages contain package creation files so we remove them.
     192      delete "${destroot}${php5pear.pearpath}/generate_package_xml.php"
     193    }
     194    if { [file exists "${destroot}${php5pear.pearpath}/package.php"] } {
     195      # Some pear packages contain package creation files so we remove them.
     196      delete "${destroot}${php5pear.pearpath}/package.php"
     197    }
     198  }
     199 
    113200}
Note: See TracChangeset for help on using the changeset viewer.