Re: pecl4win patches

From: Date: Sun, 03 Jun 2007 22:00:28 +0000
Subject: Re: pecl4win patches
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-30041@lists.php.net to get a copy of this message
Here's my first attempt at a revision of the build process used by pecl4win: - the pecl sources and version numbers are gotten off the pecl website (transport layer can be easily switched if the server is the same); once a version is downloaded it is never again, unless deleted; the download script can operate on a given extension/version or globally on everything in the db - the build script is modified to build the same pecl extension for all php versions. It is untested, since I do not have (yet) a working win32 build env (missing msdev at the moment) The one question I have facing right now is: is the pversion column in the ext table used at all? If not, it could be converted to hold the pecl extension version. If it is used, I would have to add a new column to the ext table. Any way, most db queries would have to be rewritten. Any indication on the best approach would be preciated, before I start on it... Bye Gaetano
--- mk4.php    Fri Feb 02 01:52:26 2007
+++ mk42.php    Sun Jun 03 23:43:49 2007
@@ -4,16 +4,21 @@ require dirname(__FILE__) . '/conf.php'; +//$base="/php4build"; +$base="C:/htdocs/pecl4win_cvs/pecl4win/lib"; + if (!strlen($argv[1])) { $branch = "4_3"; } else { $branch = $argv[1]; } -if (!strlen($argv[2])) { +if (!strlen(@$argv[2])) { $pecl_ext = "*"; } else { - $pecl_ext = $argv[2]; + $pecl_ext = $argv; + array_shift($pecl_ext); + array_shift($pecl_ext); } if (!isset($conf[$branch])) { @@ -30,15 +35,17 @@ putenv('LIB=' . $lib); if ($pecl_ext != "*") { - $dsps = array($c['pecl_dir'] . "/ext/{$pecl_ext}/{$pecl_ext}.dsp"); + $dsps = array(); + foreach($pecl_ext as $pecl_ext2)
+    $dsps[] = $base . "/exts/{$pecl_ext2}/{$pecl_ext2}.dsp";
} else { - $dsps = glob($c['pecl_dir'] . "/ext/{$pecl_ext}/{$pecl_ext}.dsp"); + $dsps = glob($base . "/exts/{$pecl_ext}/{$pecl_ext}.dsp"); } $fail = ""; foreach ($dsps as $dsp) { - print "Trying $dsp..."; + print "Trying $dsp...\n"; $dir = dirname($dsp); chdir($dir); system("rm -rf $dir/Release_TS"); @@ -49,10 +56,10 @@ if ($res || ((!$content = @file_get_contents($c['pecl_dir'] . "/Release_TS/$fname")) && (!$content = @file_get_contents("$dir/Release_TS/$fname")) )) {
    print "$dir/Release_TS/$fname";
-    print "FAILED";
+    print " FAILED";
    $fail .= "\n\nFailed building $dsp\n" . implode("\n", $out);
} else {
-    print "SUCCESS uploading $fname ";
+    print " SUCCESS uploading $fname ";
    $downloads = 0;
    if (($res = $DB->query(safe_sql_str("select downloads from ext where fname=!s and branch=!s and pversion=!s", $fname, $branch, $c['version'])))
@@ -60,7 +67,7 @@
      $downloads = (int)$row['downloads'];
      $DB->query(safe_sql_str("delete from ext where fname=!s and branch=!s and pversion=!s", $fname, $branch, $c['version']));
    }
-     +
    $res = $DB->query(safe_sql_str("insert into ext(fname, branch, pversion, clog, md5hash, filesize, updated, content, downloads) values (!s, !s, !s, !s, !s, !i, !t, !b, !i)", $fname, $branch, $c['version'], implode("\n", $out), md5($content), strlen($content), time(), $content, $downloads));
    if ($res) {
--- buildall.sh    Fri Mar 16 00:36:21 2007
+++ buildall2.sh    Sun Jun 03 22:59:01 2007
@@ -1,11 +1,18 @@ #!/bin/bash # $Id: buildall.sh,v 1.9 2007/03/15 22:36:21 edink Exp $ +### +### base idea: +### + get new revisions from pecl (ie those not yet downloaded) +### + for every version of php: build it + . /etc/vcenv.sh 6 cvsopt="-z3 -q" -base="/php4build" -php="$base/bin/php -c $base/bin/php.ini" +###base="/php4build" +base="C:/htdocs/pecl4win_cvs/pecl4win/lib" +###php="$base/bin/php -c $base/bin/php.ini" +php="C:/php5/php -c C:/php5/php.ini" if [ -f $base/lock.pecl ]; then
    echo Builder locked
@@ -14,44 +21,54 @@ touch $base/lock.pecl +echo $php $base/bin/fetch.php all $base/exts +exit 0 + +# get new revisions from pecl (ie those not yet downloaded) +cd $base/exts +extlist=$php $base/bin/fetch.php all $base/exts + + # Make php 4.3 and 4.4 -cd $base/pecl_4_3/ext -cvs $cvsopt upd -dP +###cd $base/pecl_4_3/ext +###cvs $cvsopt upd -dP # Compiler crashes on ingres module, delete it -rm -rf ingres -$php $base/bin/mk4.php 4_3 -$php $base/bin/mk4.php 4_4 +###rm -rf ingres +$php $base/bin/mk42.php 4_3 $ext_list + +$php $base/bin/clean_ext2.php $ext_list +$php $base/bin/mk42.php 4_4 # Make php 5.0 -cd $base/pecl_5_0 -cvs $cvsopt upd -dP +###cd $base/pecl_5_0 +###cvs $cvsopt upd -dP # Relic from the past no one wants to delete from cvs -rm -rf pdo_ids -$php $base/bin/clean_ext.php 5_0 -$php $base/bin/mk5.php 5_0 +###rm -rf pdo_ids +$php $base/bin/clean_ext2.php $ext_list +$php $base/bin/mk52.php 5_0 # Make php 5.1 -cd $base/pecl_5_0 -cvs $cvsopt upd -dP +###cd $base/pecl_5_0 +###cvs $cvsopt upd -dP # Relic from the past no one wants to delete from cvs -rm -rf pdo_ids -$php $base/bin/clean_ext.php 5_1 -$php $base/bin/mk5.php 5_1 +###rm -rf pdo_ids +$php $base/bin/clean_ext2.php 5_1 +$php $base/bin/mk52.php 5_1 # Make php 5.2 -cd $base/pecl_5_2 -cvs $cvsopt upd -dP +###cd $base/pecl_5_2 +###cvs $cvsopt upd -dP # Relic from the past no one wants to delete from cvs -rm -rf pdo_ids -$php $base/bin/clean_ext.php 5_2 -$php $base/bin/mk5.php 5_2 +###rm -rf pdo_ids +$php $base/bin/clean_ext2.php 5_2 +$php $base/bin/mk52.php 5_2 # Make php 6.0 -cd $base/pecl_6_0 -cvs $cvsopt upd -dP +###cd $base/pecl_6_0 +###cvs $cvsopt upd -dP # Relic from the past no one wants to delete from cvs -rm -rf pdo_ids -$php $base/bin/clean_ext.php 6_0 -$php $base/bin/mk5.php 6_0 +###rm -rf pdo_ids +$php $base/bin/clean_ext2.php 6_0 +$php $base/bin/mk52.php 6_0 rm -f $base/lock.pecl New file: fetch.php <?php /** * Given a pecl extension name and a target dir, downloads all versions from pecl * and unpacks them as subdirectories. Optionally gets a single given version * ('last' accepted to get latest version, and 'all' to get all extensions). * Does not download extensions/versions that exist already locally as directory. * * @author Gaetano Giunta * @version $Id: $ * @copyright (C) G. Giunta 2007 * @license code licensed under the BSD License */ if ($argc < 3) { die ('Usage: fetch.php extension target_dir [version]'); } $ext = $argv[1]; $dir = $argv[2]; $ver = $argc >= 4 ? $argv[3] : null; //ini_set('display_errors', false); /** * Given a pecl extension name, returns an array of existing versions (or false) * @todo fetch more info, such as release date, alpha/beta/stable state, etc... ? */ function get_versions($ext) { $file = file_get_contents('http://pecl.php.net/package/'.$ext.'/'); //$file = file_get_contents('c:/htdocs/pecl4win_cvs/pecl4win/lib/bin/hash.htm'); if (preg_match_all('|href="/package/'.$ext.'/([^"]*)|i', $file, $matches)) {
       return ($matches[1]);
} else
       return false;
} /// dowloads a given version of a given extension (in tgz format). 'last' ok as version name function get_ext($ext, $ver) { if ($ver == 'last') {
       return file_get_contents('http://pecl.php.net/get/'.$ext);
} else {
       return file_get_contents('http://pecl.php.net/get/'.$ext.'-'.$ver.'.tgz');
} } if ($ext == '*' or $ext == 'all') { require dirname(__FILE__) . '/conf.php'; $res = $DB->query('select distinct fname from ext'); $exts = array(); while ($row = $DB->fetchRow($res)) {
       $file = new stdClass;
       $DB->loadFromDbRow($file, $res, $row);
       $exts[] = substr($file->fname, 4, -4);
} } else { $exts = array($ext); } foreach($exts as $ext) { if ($ver) {
       $vers = array($ver);
} else {
       $vers = get_versions($ext);
       if ($vers == null)
       {
           //echo "ERROR: could not fetch version list for extension $ext\n";
           $vers = array();
       }
} foreach($vers as $version) {
       $filename = $ext.'-'.$version;
       // do not download again if it exists
       if (is_dir($dir.'/'.$filename))
       {
           continue;
       }
       $file = get_ext($ext, $version);
       if ($file != '')
       {
           /// @todo use php zip functions to degzip the file?
           file_put_contents($dir.'/'.$filename.'.tgz', $file);
           system("gunzip $filename.tgz && tar -xvf $filename.tar && rm $filename.tar");
           echo "$filename ";
       }
       else
       {
           //echo "ERROR: could not fetch version $version of extension $ext\n";
       }
} } ?>

« previous php.internals (#30041) next »