Commit: b017d3375422ce0719789227431c3746edac10a2 Author: Anatol Belski <[email protected]> Mon, 21 Oct 2013 10:07:21 +0200 Parents: 4c762385d9578cb0f0681ac38960af192ba9b509 Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=b017d3375422ce0719789227431c3746edac10a2 Log: added LICENSE/COPYING check Changed paths: M client/include/PeclExt.php Diff: diff --git a/client/include/PeclExt.php b/client/include/PeclExt.php index 0ddc2b9..7ac4555 100644 --- a/client/include/PeclExt.php +++ b/client/include/PeclExt.php @@ -27,6 +27,7 @@ class PeclExt protected $configure_data = NULL; protected $non_core_ext_deps = array(); protected $pkg_config = NULL; + protected $lic_fnames = array(); public function __construct($pkg_path, $build) { @@ -71,6 +72,19 @@ class PeclExt $this->pkg_path = $pkg_path; $this->build = $build; + /* setup license filenames */ + $base = array( + "COPYING", + "COPYRIGHT", + "LICENSE", + ); + + $this->lic_fnames = $base; + foreach ($base as $nm) { + $lic_fnames[] = "$nm*"; + $lic_fnames[] = strtolower($nm) . "*"; + $lic_fnames[] = ucfirst(strtolower($nm)) . "*"; + } } public function init($force_name = NULL, $force_version = NULL) @@ -530,25 +544,33 @@ if (!function_exists('rmtools\combinations')) { return $this->buildConfigureLine($config); } - /* No errors here, the license presence should be done by PECL site */ - public function prepareLicenseSimple($source, $target, $suffix = NULL) + public function checkLicense() { - $ret = array(); - $base = array( - "COPYING", - "COPYRIGHT", - "LICENSE", - "README", - ); + $license_found = false; - $names = $base; - foreach ($base as $nm) { - $names[] = "$nm*"; - $names[] = strtolower($nm) . "*"; - $names[] = ucfirst(strtolower($nm)) . "*"; + foreach ($this->lic_fnames as $name) { + $pat = $this->tmp_extract_path . DIRECTORY_SEPARATOR . $name; + + $glob = glob($pat); + + if (is_array($glob) && !empty($glob)) { + $license_found = true; + break; + } } - foreach ($names as $name) { + if (!$license_found) { + throw new \Exception("No LICENSE or COPYING was found in the package '" . $this->name . "'"); + } + + } + + + public function prepareLicenseSimple($source, $target, $suffix = NULL) + { + $ret = array(); + + foreach ($this->lic_fnames as $name) { $pat = $source . DIRECTORY_SEPARATOR . $name; $glob = glob($pat); @@ -575,8 +597,9 @@ if (!function_exists('rmtools\combinations')) { $ret = $this->prepareLicenseSimple($source, $target, $suffix); if (!$ret) { + /* XXX don't do that! */ /* No license file, check package.xml*/ - if ($this->package_xml && isset($this->package_xml->license)) { + /*if ($this->package_xml && isset($this->package_xml->license)) { if (isset($this->package_xml->license[0]["uri"])) { $txt = (string)$this->package_xml->license[0]["uri"]; } else { @@ -588,7 +611,8 @@ if (!function_exists('rmtools\combinations')) { file_put_contents($fl, $txt); $ret[] = $fl; } - } + }*/ + throw new \Exception("No LICENSE or COPYING was found in the package '" . $this->name . "'"); } return $ret; @@ -718,7 +742,6 @@ if (!function_exists('rmtools\combinations')) { } /* care about extension license */ - /* lack of license s not an error for us, this has to be checked on pecl pkg upload */ /* The ext license will be copied based on the info from package.xml, but let these lines stay */ /*$files_to_zip = array_merge( $files_to_zip, @@ -861,6 +884,8 @@ nodoc: throw new \Exception("config.w32 doesn't exist in the tarball"); } + $this->checkLicense(); + if ($this->package_xml) { $min_php_ver = (string)$this->getPackageXmlProperty("dependencies", "required", "php", "min"); $max_php_ver = (string)$this->getPackageXmlProperty("dependencies", "required", "php", "max"); -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
