cvs: php4(NEW_UI_API) /pear package-PEAR.xml /pear/PEAR Builder.php Installer.php

From: Date: Sun, 02 Jun 2002 07:52:16 +0000
Subject: cvs: php4(NEW_UI_API) /pear package-PEAR.xml /pear/PEAR Builder.php Installer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4356@lists.php.net to get a copy of this message
ssb Sun Jun 2 03:52:16 2002 EDT Modified files: (Branch: NEW_UI_API) /php4/pear package-PEAR.xml /php4/pear/PEAR Builder.php Installer.php Log: * "pear install" now builds and C extensions # PECL just came out of the closet Index: php4/pear/package-PEAR.xml diff -u php4/pear/package-PEAR.xml:1.12 php4/pear/package-PEAR.xml:1.12.2.1 --- php4/pear/package-PEAR.xml:1.12 Mon May 27 21:22:41 2002 +++ php4/pear/package-PEAR.xml Sun Jun 2 03:52:16 2002 @@ -42,6 +42,7 @@ * new command: "build" * fix: config-set did not work with "set" parameters * disable magic_quotes_runtime +* "install" now builds and installs C extensions </notes> <filelist> <file role="data" name="package.dtd"/> Index: php4/pear/PEAR/Builder.php diff -u php4/pear/PEAR/Builder.php:1.1.2.2 php4/pear/PEAR/Builder.php:1.1.2.3 --- php4/pear/PEAR/Builder.php:1.1.2.2 Sat Jun 1 16:45:46 2002 +++ php4/pear/PEAR/Builder.php Sun Jun 2 03:52:16 2002 @@ -16,7 +16,7 @@ // | Authors: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Builder.php,v 1.1.2.2 2002/06/01 20:45:46 ssb Exp $ +// $Id: Builder.php,v 1.1.2.3 2002/06/02 07:52:16 ssb Exp $ require_once 'PEAR/Common.php'; @@ -68,7 +68,7 @@ * * @return array an array of associative arrays with built files, * format: - * array( array( 'name' => '/path/to/ext.so', + * array( array( 'file' => '/path/to/ext.so', * 'php_api' => YYYYMMDD, * 'zend_mod_api' => YYYYMMDD, * 'zend_ext_api' => YYYYMMDD ), @@ -124,13 +124,13 @@ $build_basedir = "/var/tmp/pear-build-$_ENV[USER]"; $build_dir = "$build_basedir/$info[package]-$info[version]"; $this->log(1, "building in $build_dir"); - if (PEAR::isError($err = System::rm("-rf $build_dir"))) { - return $err; + if (is_dir($build_dir)) { + System::rm("-rf $build_dir"); } if (!System::mkDir("-p $build_dir")) { return $this->raiseError("could not create build dir: $build_dir"); } - + $this->addTempFile($build_dir); if (isset($_ENV['MAKE'])) { $make_command = $_ENV['MAKE']; } else { @@ -199,6 +199,7 @@ if ($what != 'cmdoutput') { return; } + $this->log(3, rtrim($data)); if (preg_match('/You should update your .aclocal.m4/', $data)) { return; } @@ -236,7 +237,7 @@ function _runCommand($command, $callback = null) { $this->log(1, "running: $command"); - $pp = @popen($command, "r"); + $pp = @popen("$command 2>&1", "r"); if (!$pp) { return $this->raiseError("failed to run `$command'"); } Index: php4/pear/PEAR/Installer.php diff -u php4/pear/PEAR/Installer.php:1.64.2.2 php4/pear/PEAR/Installer.php:1.64.2.3 --- php4/pear/PEAR/Installer.php:1.64.2.2 Sat Jun 1 14:39:36 2002 +++ php4/pear/PEAR/Installer.php Sun Jun 2 03:52:16 2002 @@ -17,7 +17,7 @@ // | Tomas V.V.Cox <cox@idecnet.com> | // +----------------------------------------------------------------------+ // -// $Id: Installer.php,v 1.64.2.2 2002/06/01 18:39:36 dickmann Exp $ +// $Id: Installer.php,v 1.64.2.3 2002/06/02 07:52:16 ssb Exp $ require_once 'PEAR/Common.php'; require_once 'PEAR/Registry.php'; @@ -173,10 +173,10 @@ case 'script': $dest_dir = $this->config->get('bin_dir'); break; + case 'src': case 'extsrc': - // don't install test files for now - $this->log(2, "$file: no support for building extensions yet"); - return PEAR_INSTALLER_OK; + $this->source_files++; + return; default: break; } @@ -425,6 +425,9 @@ // info from the package it self we want to access from _installFile $this->pkginfo = &$pkginfo; + // used to determine whether we should build any C code + $this->source_files = 0; + if (empty($options['register-only'])) { if (!is_dir($this->config->get('php_dir'))) { return $this->raiseError("no script destination directory\n", @@ -451,7 +454,6 @@ $this->popExpect(); if (PEAR::isError($res)) { if (empty($options['force'])) { - print "raising error!\n"; return $this->raiseError($res); } else { $this->log(0, "Warning: " . $res->getMessage()); @@ -462,6 +464,33 @@ unset($pkginfo['filelist'][$file]); } } + + if ($this->source_files > 0) { + $this->log(1, "$this->source_files source files, building"); + $bob = &new PEAR_Builder($this->ui); + $bob->debug = $this->debug; + $built = $bob->build($descfile, array(&$this, '_buildCallback')); + if (PEAR::isError($built)) { + return $built; + } + foreach ($built as $ext) { + $bn = basename($ext['file']); + $this->log(2, "installing $bn"); + $dest = $this->config->get('ext_dir') . + DIRECTORY_SEPARATOR . $bn; + $this->log(3, "+ cp $ext[file] ext_dir"); + if (!@copy($ext['file'], $dest)) { + return $this->raiseError("failed to copy $bn to $dest"); + } + $pkginfo['filelist'][$bn] = array( + 'role' => 'ext', + 'installed_as' => $dest, + 'php_api' => $ext['php_api'], + 'zend_mod_api' => $ext['zend_mod_api'], + 'zend_ext_api' => $ext['zend_ext_api'], + ); + } + } } // Register that the package is installed ----------------------- @@ -533,6 +562,33 @@ } if (method_exists($this->ui, '_downloadCallback')) $this->ui->_downloadCallback($msg, $params); + } + + // }}} + // {{{ _buildCallback() + + function _buildCallback($what, $data) + { + switch ($what) { + + } + if (($what == 'cmdoutput' && $this->verbose > 1) || + ($what == 'output' && $this->verbose > 0)) { + $this->ui->outputData(rtrim($data), 'build'); + } + } + function _buildCallback($what, $params = null) + { + switch ($what) { + case 'saveas': + $this->log(1, "downloading $params ..."); + break; + case 'done': + $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes'); + break; + } + if (method_exists($this->ui, '_downloadCallback')) + $this->ui->_downloadCallback($what, $params); } // }}}

« previous php.pear.cvs (#4356) next »