Commit: 5d3dcbc959ed49750e3c75ea20d5b6b583b3be6a Author: Anatol Belski <[email protected]> Sun, 1 Sep 2013 16:58:47 +0200 Parents: bc8be5c7abe890872525ad71beba17df4b419a59 Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=5d3dcbc959ed49750e3c75ea20d5b6b583b3be6a Log: fixed usage of package.xml and some more Changed paths: M client/include/PeclExt.php M client/script/pecl.php Diff: diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php index 0fa2b1e..b956c8f 100644 --- a/client/include/PeclExt.php +++ b/client/include/PeclExt.php @@ -16,7 +16,6 @@ class PeclExt protected $zip_cmd = 'c:\php-sdk\bin\zip.exe'; protected $deplister_cmd = 'c:\apps\bin\deplister.exe'; protected $tmp_extract_path = NULL; - protected $tmp_package_xml_path = NULL; protected $ext_dir_in_src_path = NULL; protected $package_xml = NULL; protected $configure_data = NULL; @@ -29,18 +28,29 @@ class PeclExt throw new \Exception("Pecl package should end with .tgz"); } - /* Should open package.xml then and retry, but normally the below should work. */ - $tmp = explode('-', basename($tgz_path, '.tgz')); - $this->name = $tmp[0]; - $this->version = $tmp[1]; + $this->tgz_path = $tgz_path; + $this->build = $build; + + $this->unpack(); + $this->check(); + + /* Setup some stuff */ + if ($this->package_xml) { + $this->name = (string)$this->package_xml->name; + $this->version = (string)$this->package_xml->version->release; + } if (!$this->name || !$this->version) { - /* XXX do unpack here already and get the name/version data */ - throw new \Exception("Couldn't parse extension name or version from the filename"); + /* This is the fallback if there's no package.xml */ + $tmp = explode('-', basename($tgz_path, '.tgz')); + $this->name = !$this->name ?: $tmp[0]; + $this->version = !$this->version ?: $tmp[1]; + + if (!$this->name || !$this->version) { + throw new \Exception("Couldn't parse extension name or version from the filename"); + } } - $this->tgz_path = $tgz_path; - $this->build = $build; } public function getPackageName() @@ -54,9 +64,11 @@ class PeclExt . '-' . $this->build->architecture; } + /* XXX support more compression formats, for now tgz only*/ public function unpack() { - $tmp_path = TMP_DIR . '/' . $this->getPackageName() . '-unpack'; + $tmp_path = tempnam(TMP_DIR, 'unpack'); + unlink($tmp_path); if (!file_exists($tmp_path) && !mkdir($tmp_path)) { throw new \Exception("Couldn't create temporary dir"); } @@ -92,8 +104,8 @@ class PeclExt $this->tmp_extract_path = realpath($tmp_path . '/' . basename($this->tgz_path, '.tgz')); if (file_exists($tmp_path . DIRECTORY_SEPARATOR . 'package.xml')) { - $this->tmp_package_xml_path = $tmp_path . DIRECTORY_SEPARATOR . 'package.xml'; - $this->package_xml = new \SimpleXMLElement($this->tmp_package_xml_path, 0, true); + $package_xml_path = $tmp_path . DIRECTORY_SEPARATOR . 'package.xml'; + $this->package_xml = new \SimpleXMLElement($package_xml_path, 0, true); } $this->tgz_path = NULL; @@ -103,9 +115,6 @@ class PeclExt public function putSourcesIntoBranch() { - if (!$this->tmp_extract_path) { - $this->tmp_extract_path = $this->unpack(); - } $ext_dir = $this->build->getSourceDir() . DIRECTORY_SEPARATOR . 'ext'; $this->ext_dir_in_src_path = $ext_dir . DIRECTORY_SEPARATOR . $this->name; @@ -325,9 +334,6 @@ class PeclExt if ($this->tmp_extract_path) { rmdir_rf(dirname($this->tmp_extract_path)); } - /*if ($this->tmp_package_xml_path) { - unlink($this->tmp_package_xml_path); - }*/ if ($this->ext_dir_in_src_path) { rmdir_rf($this->ext_dir_in_src_path); } @@ -343,28 +349,27 @@ class PeclExt throw new \Exception("config.w32 doesn't exist in the tarball"); } - $min_php_ver = (string)$this->package_xml->dependencies->required->php->min; - $max_php_ver = (string)$this->package_xml->dependencies->required->php->max; - $php_ver = ''; + if ($this->package_xml) { + $min_php_ver = (string)$this->package_xml->dependencies->required->php->min; + $max_php_ver = (string)$this->package_xml->dependencies->required->php->max; + $php_ver = ''; - $ver_hdr = $this->build->getSourceDir() . '/main/php_version.h'; - if(preg_match(',#define PHP_VERSION "(.*)",Sm', file_get_contents($ver_hdr), $m)) { - $php_ver = $m[1]; - } else { - throw new \Exception("Couldn't parse PHP sources for version"); - } + $ver_hdr = $this->build->getSourceDir() . '/main/php_version.h'; + if(preg_match(',#define PHP_VERSION "(.*)",Sm', file_get_contents($ver_hdr), $m)) { + $php_ver = $m[1]; + } else { + throw new \Exception("Couldn't parse PHP sources for version"); + } - if ($min_php_ver && version_compare($php_ver, $min_php_ver) < 0) { - throw new \Exception("At least PHP '$min_php_ver' required, got '$php_ver'"); - } + if ($min_php_ver && version_compare($php_ver, $min_php_ver) < 0) { + throw new \Exception("At least PHP '$min_php_ver' required, got '$php_ver'"); + } - if ($max_php_ver && version_compare($php_ver, $max_php_ver) >= 0) { - throw new \Exception("At most PHP '$max_php_ver' required, got '$php_ver'"); + if ($max_php_ver && version_compare($php_ver, $max_php_ver) >= 0) { + throw new \Exception("At most PHP '$max_php_ver' required, got '$php_ver'"); + } } - //var_dump($php_ver, $min_php_ver, $max_php_ver, $this->package_xml->dependencies);die; - - } } diff --git a/client/script/pecl.php b/client/script/pecl.php index c9c5da4..324ffd3 100644 --- a/client/script/pecl.php +++ b/client/script/pecl.php @@ -50,6 +50,8 @@ $builds = $branch->getBuildList('windows'); /* Each windows configuration from the ini for the given PHP version will be built */ foreach ($builds as $build_name) { + echo "Preparing to build \n"; + $build_src_path = realpath($build_dir_parent . DIRECTORY_SEPARATOR . $branch->config->getBuildSrcSubdir()); $log = rm\exec_single_log('mklink /J ' . $build_src_path . ' ' . $build_src_path); @@ -60,13 +62,19 @@ foreach ($builds as $build_name) { $ext = new rm\PeclExt($ext_tgz, $build); } catch (Exception $e) { echo $e->getMessage() . "\n"; + $build->clean(); + $ext->cleanup(); + rm\rmdir_rf($toupload_dir); + + /* XXX mail the ext dev what the error was, if it's something in the check + phase like missing config.w32, it's interesting for sure. + and no sense to continue as something in ext setup went wrong */ continue; } // looks like php_http-2.0.0beta4-5.3-nts-vc9-x86 $ext_build_name = $ext->getPackageName(); - $toupload_dir = TMP_DIR . '/' . $ext_build_name; if (!is_dir($toupload_dir)) { mkdir($toupload_dir, 0655, true); @@ -76,25 +84,10 @@ foreach ($builds as $build_name) { mkdir($toupload_dir . '/logs', 0655, true); } - echo "Preparing to build '$ext_build_name'\n"; - - try { - $ext->putSourcesIntoBranch(); - - } catch (Exception $e) { - echo $e->getMessage() . "\n"; - $build->clean(); - $ext->cleanup(); - /*rm\rmdir_rf($toupload_dir);*/ - - /* XXX mail the ext dev what the error was, if it's something in the check - phase like missing config.w32, it's interesting for sure. - and no sense to continue as something in ext setup went wrong */ - continue; - } - + echo "Configured for '$ext_build_name'\n"; echo "Running build in <$build_src_path>\n"; try { + $ext->putSourcesIntoBranch(); $build->buildconf(); @@ -142,7 +135,7 @@ foreach ($builds as $build_name) { $build->clean(); $ext->cleanup(); - /*rm\rmdir_rf($toupload_dir);*/ + rm\rmdir_rf($toupload_dir); echo "\n"; } -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
