File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/pkgtools.zip
Back
PK i�Zམ�� � phppearchannel/source.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phppearchannel; /** * This class parses channel.xml * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Source { /** * channel.xml file path * * @var string */ protected $_path = NULL; /** * SimpleXML * * @var SimpleXMLElement */ protected $_xml = NULL; /** * Constructor * * @param string $filename */ function __construct($dir_name) { // Find channel.xml $dir_name = realpath($dir_name); foreach (Array('channel.xml') as $try) { if (is_file("$dir_name/$try")) { $this->_path = "$dir_name/$try"; } } if (is_null($this->_path)) { throw new \InvalidArgumentException('channel.xml not found'); } // Parse XML $use_errors = libxml_use_internal_errors(true); $this->_xml = simplexml_load_file($this->_path); /* foreach (libxml_get_errors() as $error) { var_dump($error); } // */ libxml_clear_errors(); libxml_use_internal_errors($use_errors); if ($this->_xml === FALSE) { throw new \InvalidArgumentException('Error parsing channel.xml'); } } /** * Raw properties getter * * @param string $property */ function __get($property) { switch($property) { case 'name': case 'summary': case 'suggestedalias': return $this->_xml->{$property}; default: throw new \InvalidArgumentException("Unknown property: '$property'"); } } } PK i�ZR�H` ` phppearchannel/command.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phppearchannel; /** * All PEAR channel related commands * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Command extends \Pkgtools\Base\Command { /** * Print the channel name */ public function runName() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->name; } /** * Print the channel summary */ public function runSummary() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->summary; } /** * Print the channel alias */ public function runSuggestedalias() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->suggestedalias; } /** * Print substvars (Debian substitution variables) */ public function runSubstvars() { $p = new Source($this->getProperty('_sourcedirectory')); // Print substvars echo 'phppear:channel-name=' . $p->name . "\n"; echo 'phppear:channel-summary=' . $p->summary . "\n"; echo 'phppear:channel-alias=' . $p->suggestedalias . "\n"; $description = 'This is the PEAR channel registry entry for ' . $p->suggestedalias . '.' . "\n"; $description .= "\n"; $description .= 'PEAR is a framework and distribution system for reusable PHP components. '; $description .= 'A PEAR channel is a website that provides package for download and a few extra meta-information for files.'; $description = \Pkgtools\Base\Utils::substvar($description); echo 'phppear:channel-common-description=' . $description . "\n"; } } PK i�Zǿ�}b4 b4 phpcomposer/source.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phpcomposer; use \Pkgtools\Base\Logger; /** * This class parses composer.json * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Source { /** * composer.json file path * * @var string */ protected $_path = NULL; /** * Decoded composer.json * * @var mixed */ protected $_json = NULL; /** * Constructor * * @param string $filename */ function __construct($dir_name) { // Find composer.json $dir_name = realpath($dir_name); if (is_file("$dir_name/composer.json")) { $this->_path = "$dir_name/composer.json"; } if (is_null($this->_path)) { throw new \InvalidArgumentException('composer.json not found'); } // Load file $data = file_get_contents($this->_path); if ($data === false) { throw new \InvalidArgumentException("Unable to open composer.json ($this->_path)"); } // Parse JSON if (!function_exists('json_decode')) { throw new \InvalidArgumentException('JSON extension is not installed or not loaded'); } $this->_json = json_decode($data, true); if ($this->_json === NULL) { switch (json_last_error()) { case JSON_ERROR_NONE: $json_error = 'No errors'; break; case JSON_ERROR_DEPTH: $json_error = 'Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: $json_error = 'Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: $json_error = 'Unexpected control character found'; break; case JSON_ERROR_SYNTAX: $json_error = 'Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: $json_error = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: $json_error = 'Unknown error'; break; } if (function_exists('json_last_error_msg')) { $json_error_msg = json_last_error_msg(); } else { $json_error_msg = ''; } throw new \InvalidArgumentException("Error parsing composer.json: $json_error ($json_error_msg)"); } } /** * Raw properties getter */ function __get($property) { switch($property) { case 'name': case 'description': return $this->_json[$property]; default: throw new \InvalidArgumentException("Unknown property: '$property'"); } } /** * Does the package has a file with role "script" */ function hasPhpScript() { return !empty($this->_json['bin']); } /** * Dependencies */ function getDependencies() { $result = new \Pkgtools\Base\Dependencies(); $levels = Array( 'require', 'require-dev', 'recommend', 'suggest', 'conflict', 'provide', 'replace', ); if ($this->hasPhpScript()) { $dep = new \Pkgtools\Base\Dependency('require', '', 'php-cli'); $result[] = $dep; } else { $dep = new \Pkgtools\Base\Dependency('require', '', 'php'); $result[] = $dep; } foreach ($levels as $level) { if (!empty($this->_json[$level])) { foreach($this->_json[$level] as $project_package => $versions) { Logger::debug('Parsing dependency %s:%s (%s) from file "%s".', $level, $project_package, $versions, $this->_path); if (strpos($project_package, '/') !== FALSE) { list($project, $package) = explode('/', $project_package, 2); } else { $project = ''; $package = $project_package; } $dep = new \Pkgtools\Base\Dependency($level, $project, $package); if (strpos($versions, '|') !== FALSE) { Logger::warning('OR-ed versions are not supported %s:%s (%s) in file "%s".', $level, $project_package, $versions, $this->_path); } else { try { $operator_regexp = '(==?|!=|<>|>=?|<=?|~|\^)'; // $1 $versions = preg_replace("/([^,])\s+$operator_regexp/", '\1,\2', $versions); foreach(explode(',', $versions) as $version) { // Construct regexp $version_regexp = 'v?([0-9.*]*|self\.version|dev-\w+)'; // $2 $stability_regexp = '(-dev|-patch\d*|-alpha\d*|-beta\d*|-RC\d*)?'; // $3 $stabilityflag_regexp = '((?i)@dev|@alpha|@beta|@RC|@stable)?'; // $4 $inlinealias_regexp = '(?:\s+as\s+(\S+))?'; // $5 if (preg_match("/^\s*$operator_regexp?\s*$version_regexp$stability_regexp\s*$stabilityflag_regexp$inlinealias_regexp\s*$/", $version, $operator_matches)) { $operator = $operator_matches[1]; $base_version = $operator_matches[2]; if (!empty($operator_matches[3])) { switch($operator_matches[3][1]) { case 'd': // dev case 'p': // patch $version = $base_version . '~~' . substr($operator_matches[3], 1); break; default: $version = $base_version . '~' . substr($operator_matches[3], 1); } } else { $version = $base_version; } if (substr($version, 0, 4) == 'dev-') { Logger::info('Branch alias mapped to "*" %s:%s (%s) in file "%s".', $level, $project_package, $versions, $this->_path); $version = '*'; } } else { throw new \InvalidArgumentException("Unable to parse version '$version' with dependency $project_package ($versions)"); } if (($operator == '') || ($operator == '=') || ($operator == '==')) { if (($version == '*') || ($version == '')) { // no version constraints } elseif (substr($version, -1) == '*') { // x.y.* -> (>= x.y), (<< x.y+1~~) $version_components = explode('.', $version); array_pop($version_components); // Pop '*' $last_version_component = array_pop($version_components); $dep->minVersion = implode('.', array_merge($version_components, Array($last_version_component))); $dep->maxVersion = implode('.', array_merge($version_components, Array($last_version_component + 1))) . '~~'; } else { $dep->minVersion = $version; $dep->maxVersion = $version; $dep->excludeMaxVersion = false; } } elseif (($operator == '!=') || ($operator == '<>')) { // We turn this into a conflict $dep2 = clone($dep); $dep2->level = 'conflict'; $dep->minVersion = $version; $dep->maxVersion = $version; $dep->excludeMaxVersion = false; $result[] = $dep2; } elseif (($operator == '>') || ($operator == '>=')) { $dep->minVersion = $version; $dep->excludeMinVersion = $operator == '>'; } elseif ($operator == '<') { $dep->maxVersion = $base_version.'~~'; $dep->excludeMaxVersion = true; } elseif ($operator == '<=') { $dep->maxVersion = $version; $dep->excludeMaxVersion = false; } elseif ($operator == '~') { // ~x.y.z -> (>= x.y.z), (<< x.y+1~~) $version_components = explode('.', $version); if (count($version_components) > 1) { array_pop($version_components); $last_version_component = array_pop($version_components); } else { $last_version_component = array_pop($version_components); } $dep->minVersion = $version; $dep->maxVersion = implode('.', array_merge($version_components, Array($last_version_component + 1))) . '~~'; } elseif ($operator == '^') { // ^x.y.z -> (>= x.y.z), (<< x+1~~) if x >= 1 // ^x.y.z -> (>= x.y.z), (<< x.y+1~~) if x == 0 $version_components = explode('.', $version); $prefix_components = Array(); $significant_version_component = array_shift($version_components); if ($significant_version_component == '0') { array_unshift($prefix_components, $significant_version_component); $significant_version_component = array_shift($version_components); } $dep->minVersion = $version; $dep->maxVersion = implode('.', array_merge( $prefix_components, Array($significant_version_component + 1))). '~~'; } else { throw new \InvalidArgumentException("Unable to parse version operator '$operator' with dependency $project_package ($versions)"); } } } catch(\Exception $e) { // suggest can have free text in place of version constraints if ($dep->level != 'suggest') { throw new \Exception($e->getMessage(). " with dependency $project_package ($versions)", $e->getCode(), $e); } } } $result[] = $dep; } } } return $result; } } PK i�Z�^?� � phpcomposer/command.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phpcomposer; /** * All Composer related commands * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Command extends \Pkgtools\Base\Command { /** * Print the package name */ public function runName() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->name; } /** * Print the package description */ public function runDescription() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->description; } /** * Print dependencies */ public function runDependencies() { $p = new Source($this->getProperty('_sourcedirectory')); print $p->getDependencies(); } /** * Print substvars (Debian substitution variables) */ public function runSubstvars() { $p = new Source($this->getProperty('_sourcedirectory')); // Print substvars echo "phpcomposer:name=" . $p->name."\n"; $description = \Pkgtools\Base\Utils::substvar($p->description); if ($description[strlen($description)-1] == '.') { $description = substr($description, 0, -1); } echo 'phpcomposer:description=' . $description."\n"; $dependencies = $p->getDependencies()->asDeb(); foreach ($dependencies as $level => $deps) { echo "phpcomposer:Debian-$level=" . implode(', ', $deps)."\n"; } } } PK i�Z�Pb� � base/overrides.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; use \Pkgtools\Base\Logger; /** * This class provide package name overrides * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Overrides { /** * Overrides map * An array of \Pkgtools\Base\Override, or NULL if uninitialized * * @var Array|NULL */ private static $_overrides = NULL; /** * Constructor * * As this class should not be instanciated, this fails */ final public function __construct() { throw new \LogicException(__class__.' could not be instanciated'); } /** * Load overrides from files * * @param bool $force If true, reload even if already loaded */ static public function load($force = FALSE) { // Already loaded if (!is_null(self::$_overrides) && !$force) { return; } self::$_overrides = Array(); self::loadFiles(); // Builtin extensions $builtin_extensions = Array( // Statically compiled extensions 'calendar', 'core', 'ctype', 'date', 'dba', 'ereg', 'exif', 'fileinfo', 'filter', 'ftp', 'gettext', 'hash', 'iconv', 'libxml', 'openssl', 'pcntl', 'pcre', 'phar', 'posix', 'reflection', 'session', 'shmop', 'sockets', 'spl', 'standard', 'sysvmsg', 'sysvsem', 'sysvshm', 'tokenizer', 'xmlreader', 'xmlwriter', 'zlib', // Dynamically compiled extensions 'pdo', // Extensions provided or no longer builtin //'mhash', 'json', ); foreach ($builtin_extensions as $builtin_extension) { self::$_overrides[] = new Override('pear-pecl.php.net', $builtin_extension, 'builtin', ''); } } /** * Load overrides from one file * * @param string $overrides_file File path */ static private function loadFile($overrides_file) { if (file_exists($overrides_file)) { $fh = fopen($overrides_file, 'r'); if ($fh === false) { throw new \LogicException("Unable to open '$overrides_file'"); } while (($line = fgets($fh)) !== false) { $fields = preg_split("/[\s]+/", $line); if (count($fields) < 3) { Logger::warning('Ignoring line, too short: "%s" in file "%s".', $line, $overrides_file); continue; } $constraint = isset($fields[3]) ? $fields[3] : ''; self::$_overrides[] = new Override('pear-'.$fields[0], $fields[1], $fields[2], $constraint); } if (!feof($fh)) { throw new \LogicException("Unable to read '$overrides_file'"); } fclose($fh); } } /** * Load overrides from one file * * @param string $overrides_file File path */ static private function loadFiles() { self::loadFile('debian/pkg-php-tools-overrides'); // /usr/share/pkg-php-tools/overrides $overrides_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/pkg-php-tools/overrides'; if (is_dir($overrides_dir)) { if ($dh = opendir($overrides_dir)) { while (($file = readdir($dh)) !== false) { if (($file == '.') || ($file == '..')) { continue; } self::loadFile($overrides_dir.'/'.$file); } closedir($dh); } else { throw new \LogicException("Unable to open '$overrides_dir'"); } } } /** * Apply an override * Return: * - NULL if no override found * - a Dependency object * * @param Dependency $dependency * @return Dependency|NULL */ static function override($dependency) { self::load(); foreach(self::$_overrides as $override) { $overriden = $override->override($dependency); if (!is_null($overriden)) { //printLog("Overriding: $dependency -> $overriden"); return $overriden; } } return NULL; } } PK i�Z˄�q� � base/override.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; /** * This class represent one package name override * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Override { /** * Project * * @var string */ private $_project; /** * Package name * * @var string */ private $_package; /** * Override * * @var string */ private $_override; /** * Override constraint * * @var string */ private $_constraint; /** * Constructor * * As this class should not be instanciated, this fails */ final public function __construct($project, $package, $override, $constraint) { if ($project === 'pear-extension') { $project = 'pear-pecl.php.net'; } $this->_project = $project; $this->_package = $package; $this->_override = $override; $this->_constraint = $constraint; } /** * Apply an override * Return: * - NULL if no override found * - a Dependency object * * @param Dependency $dependency * @return Dependency|NULL */ function override($dependency) { if (preg_match('/(^|^pear-|\.)'.$dependency->project.'($|\.)/i', $this->_project) && strcasecmp(str_replace('_', '-', $dependency->package), str_replace('_', '-', $this->_package))==0 ) { if ($this->_constraint === 'none') { $min = NULL; $max = NULL; } else { // Inherit the dependency $min = $dependency->minVersion; $max = $dependency->maxVersion; } $dep = new Dependency($dependency->level, '__override__', $this->_override, $min, $max, $dependency); $dep->excludeMinVersion = $dependency->excludeMinVersion; $dep->excludeMaxVersion = $dependency->excludeMaxVersion; return $dep; } return NULL; } } PK i�Z�| F� � base/logger.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; /** * This class provide logging facility. * It is loosely inspired by python's logging * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Logger { /** * Logging levels */ const CRITICAL = 50; const ERROR = 40; const WARNING = 30; const INFO = 20; const DEBUG = 10; const NOTSET = 0; /** * Current log level */ private static $_level = self::WARNING; /** * Constructor * * As this class should not be instanciated, this fails */ final public function __construct() { throw new \LogicException(__class__.' could not be instanciated'); } /** * Set log level * * @param int $level */ final public static function setLevel($level) { self::$_level = (int) $level; } /** * Get log level */ final public static function getEffectiveLevel() { return self::$_level; } /** * Log a message * * @param int $level * @param string $message * @param string $args ... */ final public static function log($level, $message) { if ($level >= self::$_level) { $args = func_get_args(); array_shift($args); // $level if ($handle = fopen("php://stderr", "a")) { fwrite($handle, call_user_func_array('sprintf', $args) . "\n"); fclose($handle); } } } /** * Logs a message with level DEBUG * * @param string $message * @param string $args ... */ final public static function debug($message) { $args = func_get_args(); array_unshift($args, self::DEBUG); call_user_func_array('self::log', $args); } /** * Logs a message with level INFO * * @param string $message * @param string $args ... */ final public static function info($message) { $args = func_get_args(); array_unshift($args, self::INFO); call_user_func_array('self::log', $args); } /** * Logs a message with level WARNING * * @param string $message * @param string $args ... */ final public static function warning($message) { $args = func_get_args(); array_unshift($args, self::WARNING); call_user_func_array('self::log', $args); } /** * Logs a message with level ERROR * * @param string $message * @param string $args ... */ final public static function error($message) { $args = func_get_args(); array_unshift($args, self::ERROR); call_user_func_array('self::log', $args); } /** * Logs a message with level CRITICAL * * @param string $message * @param string $args ... */ final public static function critical($message) { $args = func_get_args(); array_unshift($args, self::CRITICAL); call_user_func_array('self::log', $args); } } PK i�Zt�$� � base/dependencies.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; use \Pkgtools\Base\Logger; /** * This class represents a list of dependencies * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Dependencies extends \ArrayObject { /** * Get dependencies in Debian format */ function asDeb() { $result = Array(); foreach ($this as $dep) { // Try to override $overriden = Overrides::override($dep); if (is_null($overriden)) { $overriden = $dep; } else { Logger::info('Override: %s -> %s.', $dep, $overriden); } $debDependency = $overriden->debDependency(); Logger::debug('Debian name: %s -> %s:%s.', $dep, $overriden->level, $debDependency); // Dependendency may have been NULLified if (!is_null($debDependency)) { $result[$overriden->level][] = $debDependency; } } return $result; } /** * Get dependencies in readable format */ function __toString() { $result = ''; foreach ($this as $dep) { $result .= $dep . "\n"; } return $result; } } PK i�Z�b"G1 G1 base/dependency.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; /** * This class represents a dependency * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Dependency { /** * Dependency level * One of: * - require * - require-dev * - recommend * - suggest * - conflict * - provide * - replace * * @var string */ private $_level = NULL; /** * Package project * (Composer terminology) * Use an empty string for platform packages * * @var string */ private $_project = NULL; /** * Package name * * @var string */ private $_package = NULL; /** * Minimum version * * @var string */ private $_minVersion = NULL; /** * Exclude minimum version * If true : $vers > $minVersion * If false: $vers >= $minVersion * * @var bool */ private $_excludeMinVersion = false; /** * Maximum version * * @var string */ private $_maxVersion = NULL; /** * Exclude maximum version * If true : $vers < $maxVersion * If false: $vers <= $maxVersion * * @var bool */ private $_excludeMaxVersion = true; /** * Original (before override) dependency * * @var Dependency|NULL */ private $_original = true; /** * Constructor * * @param string $level * @param string $project * @param string $package * @param string $minVersion * @param string $maxVersion * @param Dependency $original Original (before override) dependency */ final public function __construct($level, $project, $package, $minVersion = NULL, $maxVersion = NULL, $original = NULL) { $this->level = $level; $this->project = $project; $this->package = $package; $this->minVersion = $minVersion; $this->maxVersion = $maxVersion; $this->original = $original; } /** * As string */ final public function __toString() { $min = false; if ($this->minVersion) { if ($this->excludeMinVersion) { $min = '> '.$this->minVersion; } else { $min = '>= '.$this->minVersion; } } $max = false; if ($this->maxVersion) { if ($this->excludeMaxVersion) { $max = '< '.$this->maxVersion; } else { $max = '<= '.$this->maxVersion; } } if ($min && $max) { $version = " ($min, $max)"; } elseif ($min) { $version = " ($min)"; } elseif ($max) { $version = " ($max)"; } else { $version = ''; } return sprintf("%s:%s/%s%s", $this->level, $this->project, $this->package, $version); } /** * Raw properties getter * * @param string $property */ function __get($property) { switch($property) { case 'level': case 'project': case 'package': case 'minVersion': case 'excludeMinVersion': case 'maxVersion': case 'excludeMaxVersion': case 'original': return $this->{"_$property"}; default: throw new \InvalidArgumentException("Unknown property: '$property'"); } } /** * Raw properties setter * * @param string $property * @param mixed $value */ function __set($property, $value) { switch($property) { case 'level': if (!in_array($value, Array('require', 'require-dev', 'recommend', 'suggest', 'conflict', 'provide', 'replace'))) { throw new \InvalidArgumentException("Unknown dependency level: '$value'"); } break; case 'project': if (!preg_match('/^[a-zA-Z0-9_.-]*$/', $value)) { throw new \InvalidArgumentException("Malformed dependency $property: '$value'"); } // Prevent misuse if ($value == 'pear-extension') { throw new \InvalidArgumentException("Invalid dependency project: $value"); } break; case 'package': if (!preg_match('/^[a-zA-Z0-9_.-]+$/', $value)) { throw new \InvalidArgumentException("Malformed dependency $property: '$value'"); } // Canonalize PECL extension if (substr($value, 0, 4) == 'ext-') { $this->_project = 'pear-pecl.php.net'; $this->_package = substr($value, 4); return; } break; case 'minVersion': case 'maxVersion': if (!is_null($value) && ($value !== 'self.version') && !preg_match('/^[0-9][a-zA-Z0-9_.~-]*$/', $value)) { throw new \InvalidArgumentException("Malformed dependency $property: '$value'"); } break; case 'excludeMinVersion': case 'excludeMaxVersion': if (!is_bool($value)) { throw new \InvalidArgumentException("Malformed dependency $property: '$value'"); } break; case 'original': if (!is_null($value) && !($value instanceof Dependency)) { throw new \InvalidArgumentException("Malformed dependency $property: '$value'"); } break; default: throw new \InvalidArgumentException("Unknown property: '$property'"); } $this->{"_$property"} = $value; } /** * Debian package name */ function debName() { $prefix = 'php'; $project = $this->project; $package = strtolower($this->package); // Builtin or none overrides if (($project == '__override__') && (in_array($package, Array('builtin', 'none')))) { return NULL; } // Generic overrides if ($project == '__override__') { return $package; } // PHP if (($project == '') && ($package == 'php')) { return 'php-common'; } if (($project == '') && ($package == 'php-cli')) { return 'php-cli'; } // lib-* if (($project == '') && substr($package, 0, 4) == 'lib-') { $lib = substr($package, 4); switch($lib) { case 'curl': return 'libcurl3'; case 'iconv': // static lib return NULL; case 'icu': return 'libicu52'; case 'libxml': return 'libxml2'; case 'openssl': return 'libssl1.0.0'; case 'pcre': return 'libpcre3'; // FIXME: epoch=1 case 'uuid': // static lib return NULL; case 'xsl': return 'libxslt1.1'; default: Logger::info('Unknown dependency: "%s".', $package); return NULL; } } // PEAR package if (substr($project, 0, 5) == 'pear-') { $channel_url = substr($project, 5); if ($channel_url === 'pecl.php.net') { $prefix = 'php'; } // Split channel url by dots $channel_components = explode(".", $channel_url); // Split package name by underscores $package_components = explode('_', $package); // Drop last part of url (TLD): $tld = array_pop($channel_components); if (($tld === 'net') && (end($channel_components) === 'sourceforge')) { // consider sourceforge.net as a TLD array_pop($channel_components); } // Drop first part of url if equal to pear, pecl or www if (isset($channel_components[0]) && in_array($channel_components[0], Array('pear', 'pecl', 'www'))) { array_shift($channel_components); } // Drop first part of url if equal to php if (isset($channel_components[0]) && ($channel_components[0] == 'php')) { array_shift($channel_components); } // Drop first part of package if equal to last part of url if (end($channel_components) == $package_components[0]) { array_shift($package_components); } // PEAR: Build the debian name from remaining components $all_components = array_merge(Array($prefix), $channel_components, $package_components); return preg_replace('/[^a-zA-Z0-9.-]/', '-', implode('-', $all_components)); } // Return package name if package name begins with project name if (strpos($package, $project) === 0) { return "$prefix-$package"; } // Split project name by hyphen $project_components = explode('-', $project); // Split package name by hyphen $package_components = explode('-', $package); // Drop first part of package if equal to last part of url if (end($project_components) == $package_components[0]) { array_shift($package_components); } // Composer: Build the debian name from remaining components $all_components = array_merge(Array($prefix), $project_components, $package_components); return preg_replace('/[^a-zA-Z0-9.-]/', '-', implode('-', $all_components)); } /** * Debian version */ static function toDebVersion($version) { if ($version == 'self.version') { return '${binary:Version}'; } return $version; } /** * Dependency as deb format */ function debDependency() { $name = $this->debName(); if (is_null($name)) { return NULL; } if ($name == 'php-common') { return $name; } if (!$this->minVersion && !$this->maxVersion) { return $name; } if ($this->minVersion == $this->maxVersion) { return $name.' (= '.$this::toDebVersion($this->minVersion).')'; } $min = false; if ($this->minVersion) { if ($this->excludeMinVersion) { $min = $name.' (>> '.$this::toDebVersion($this->minVersion).')'; } else { $min = $name.' (>= '.$this::toDebVersion($this->minVersion).')'; } } $max = false; if ($this->maxVersion) { if ($this->excludeMaxVersion) { $max = $name.' (<< '.$this::toDebVersion($this->maxVersion).')'; } else { $max = $name.' (<= '.$this::toDebVersion($this->maxVersion).')'; } } if ($min && $max) { return "$min, $max"; } if ($min) { return $min; } if ($max) { return $max; } } } PK i�Z]Q��� � base/utils.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; /** * This class provide various utils * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Utils { /** * Constructor * * As this class should not be instanciated, this fails */ final public function __construct() { throw new \LogicException(__class__.' could not be instanciated'); } /** * Format string to substvar format: * - Replace tabs and drop excessive spaces * - Drop starting spaces * - Indent bullets * - Wrap to 80 chars * - Convert new lines to ${Newline} * - Split paragraphs * * @param bool $force If true, reload even if already loaded */ static public function substvar($input) { // Replace tabs and drop excessive spaces $tmp = preg_replace('/\h+/', ' ', $input); // Drop starting spaces $tmp = preg_replace('/^ /m', '', $tmp); // Indent bullets $tmp = preg_replace('/^\*/m', ' *', $tmp); // Wrap to 80 chars $tmp = wordwrap($tmp, 78); // Convert new lines to ${Newline} $tmp = str_replace("\n", '${Newline}', $tmp); return $tmp; } } PK i�Zd��X�) �) base/command.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Base; use \Pkgtools\Base\Logger; /** * This class parses command-line * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ abstract class Command { /** * Parent command * * @var BaseCommand */ private $_parentCommand; /** * Sub-command * * @var BaseCommand */ private $_subCommand = NULL; /** * Options * * @var Array */ private $_options = Array(); /** * Available actions * * @var Array */ public $ACTIONS = array( 'store', // Not implemented: 'store_const', 'store_true', 'store_false', // Not implemented: 'append', // Not implemented: 'append_const', 'count', 'callback', 'help', // Not implemented: 'version', ); /** * Constructor * * @param BaseCommand $parentCommand */ final public function __construct($parentCommand = NULL) { $this->_parentCommand = $parentCommand; $this->addOptions(); } /** * Add an option to the parser * * @param string $opt1 * @param string ... * @param Array $attributes */ final public function addOption() { $opts = func_get_args(); if (count($opts) < 2) { throw new \InvalidArgumentException('addOption() used with unsufficient argument'); } $attributes = array_pop($opts); if (empty($attributes['action'])) { $attributes['action'] = 'store'; } elseif (!in_array($attributes['action'], $this->ACTIONS)) { throw new \InvalidArgumentException(sprintf("invalid action: '%s'", $attributes['action'])); } if (!array_key_exists('dest', $attributes)) { if (substr($opts[0], 0, 2) == '--') { $attributes['dest'] = '_'.substr($opts[0], 2); } elseif ($opts[0][0] == '-') { $attributes['dest'] = '_'.substr($opts[0], 1); } else { throw new \InvalidArgumentException('Option should begin with a dash'); } } foreach ($opts as $opt) { $this->_options[$opt] = $attributes; } } /** * Parse arguments and run */ final public function parseArgs($args = NULL) { if (is_null($args)) { $args = $_SERVER['argv']; // Remove script name array_shift($args); } while ($arg = array_shift($args)) { if (array_key_exists($arg, $this->_options)) { switch ($this->_options[$arg]['action']) { case 'store': $this->{$this->_options[$arg]['dest']} = array_shift($args); continue 2; case 'store_true': $this->{$this->_options[$arg]['dest']} = true; continue 2; case 'store_false': $this->{$this->_options[$arg]['dest']} = false; continue 2; case 'count': $this->{$this->_options[$arg]['dest']}++; continue 2; case 'callback': call_user_func_array($this->_options[$arg]['callback'], Array( $this->_options[$arg], $arg, NULL, // value $this, Array(), // $args Array(), // $kwargs )); continue 2; case 'help': return $this->help(); default: throw new \InvalidArgumentException(sprintf("invalid action: '%s'", $this->_options[$arg]['action'])); } } if (strlen($arg) && ($arg[0] == '-')) { throw new \InvalidArgumentException("Unknown option $arg"); } $class = preg_replace('/Command$/', ucfirst($arg).'\\Command', get_class($this)); // Try to load \Pkgtools\...\$Arg\Command class try { if (class_exists($class)) { $this->_subCommand = new $class($this); return $this->_subCommand->parseArgs($args); } } catch (\LogicException $e) { // spl_autoload thrown an LogicException // "Class $class could not be loaded" if ($e->getTrace()[0]['function'] != 'spl_autoload') { throw $e; } } // Try to use $this->run$Arg() if (method_exists($this, 'run'.ucfirst($arg))) { Logger::debug('Launching %s::%s().', get_class($this), 'run'.ucfirst($arg)); return call_user_func_array(Array($this, 'run'.ucfirst($arg)), $args); } throw new \InvalidArgumentException("Unknown sub-command $arg"); } // Try to use $this->run() if (method_exists($this, 'run')) { Logger::debug('Launching %s::%s().', get_class($this), 'run'); return call_user_func(Array($this, 'run')); } throw new \InvalidArgumentException("Missing sub-command name"); } /** * Recursively get option value */ final public function getProperty($name) { if (property_exists($this,$name)) { return $this->{$name}; } if (!is_null($this->_parentCommand)) { return $this->_parentCommand->getProperty($name); } throw new \InvalidArgumentException("Unknown property: '$name'"); } /** * Split doc comment body and attributes */ static final protected function parseDocComment($str) { $comments = preg_replace('@^/\*\*(.*)\*/$@s', '\1', $str); $comments = preg_replace('@^\s*\*@m', '', $comments); $comments = explode("\n", $comments); $comments = array_map('trim', $comments); $ret = Array(); $ret['body'] = ''; foreach($comments as $comment) { if (preg_match('/@([a-z]+)\s+(.*)/', $comment, $matches)) { $ret[$matches[1]][] = $matches[2]; } else { $ret['body'].= $comment."\n"; } } $ret['body'] = trim($ret['body']); return $ret; } /** * Print command help */ final public function help() { echo "Usage:\n"; echo ' '.str_replace('command', 'COMMAND', strtolower(strtr(\get_class($this), '\\', ' ')))."\n"; echo "\n"; echo "Options:\n"; foreach($this->_options as $k => $opt) { echo " $k:"; if (isset($opt['help'])) { echo ' '.$opt['help']; } echo "\n"; } echo "\n"; echo "Commands:\n"; $rc = new \ReflectionClass($this); foreach($rc->getMethods() as $method) { if (substr($method->name, 0, 3) != 'run') { continue; } $command = strtolower(substr($method->name, 3)); $comment = $this::parseDocComment($method->getDocComment()); echo " $command: ".$comment['body']."\n"; } // Commands from external files if ($classFile = $rc->getFileName()) { $classFileInfo = new \SplFileInfo($classFile); $directoryIterator = $classFileInfo->getPathInfo('\\DirectoryIterator'); $comments = Array(); foreach ($directoryIterator as $fileInfo) { if ($fileInfo->isDot() || !$fileInfo->isDir() || ($fileInfo->getFilename() === 'base')) { continue; } $class = preg_replace('/Command$/', ucfirst($fileInfo->getFilename()).'\\Command', get_class($this)); // Try to load \Pkgtools\...\$Filename\Command class try { if (class_exists($class)) { $rc = new \ReflectionClass($class); $comment = $rc->getDocComment(); $comment = $this::parseDocComment($rc->getDocComment()); $comments[] = ' '.$fileInfo->getFilename().': '.$comment['body']."\n"; } } catch (\LogicException $e) { // spl_autoload thrown an LogicException // "Class $class could not be loaded" if ($e->getTrace()[0]['function'] != 'spl_autoload') { throw $e; } } } sort($comments); // Make output deterministic echo implode($comments); } } // ********************************************************************** // Overridables methods // ********************************************************************** /** * Add command options */ public function addOptions() { $this->addOption('--help', '-h', Array('action' => 'help', 'help' => 'print help')); } /** * Without arguments: print help */ public function run() { $this->help(); } } PK i�Z�����1 �1 phppear/source.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phppear; /** * This class parses package.xml * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Source { /** * package.xml file path * * @var string */ protected $_path = NULL; /** * SimpleXML * * @var SimpleXMLElement */ protected $_xml = NULL; /** * package.xml version * * @var string */ protected $_version = NULL; /** * Constructor * * @param string $filename */ function __construct($dir_name) { // Find package.xml $dir_name = realpath($dir_name); foreach (Array('package2.xml', 'package.xml') as $try) { if (is_file("$dir_name/$try")) { $this->_path = "$dir_name/$try"; break; } } if (is_null($this->_path)) { throw new \InvalidArgumentException('package.xml not found'); } // Parse XML $use_errors = libxml_use_internal_errors(true); $this->_xml = simplexml_load_file($this->_path); /* foreach (libxml_get_errors() as $error) { var_dump($error); } // */ libxml_clear_errors(); libxml_use_internal_errors($use_errors); if ($this->_xml === FALSE) { throw new \InvalidArgumentException('Error parsing package.xml'); } if ($this->_xml->getName() !== 'package') { throw new \InvalidArgumentException('Invalid package.xml: root is not <package>'); } $attributes = $this->_xml->attributes(); if (empty($attributes['version']) || !in_array($attributes['version'], Array('1.0','2.0', '2.1'))) { throw new \InvalidArgumentException('Invalid package.xml: incorrect or unsupported version '.$attributes['version']); } $this->_version = $attributes['version']; } /** * Raw properties getter * * @param string $property */ function __get($property) { switch($property) { case 'name': case 'summary': case 'description': return (string) $this->_xml->{$property}; case 'channel': if ($this->_version == '1.0') { return 'pear.php.net'; } else { return (string) $this->_xml->{$property}; } default: throw new \InvalidArgumentException("Unknown property: '$property'"); } } /** * Get maintainers */ function getMaintainers() { $ret = Array(); if ($this->_version == '1.0') { foreach($this->_xml->maintainers as $maintainer) { $ret[] = Array( 'user' => (string) $maintainer->user, 'name' => (string) $maintainer->name, 'email' => (string) $maintainer->email, 'role' => (string) $maintainer->role, ); } } else { foreach(Array('lead', 'developer', 'contributor', 'helper') as $role) { foreach($this->_xml->{$role} as $maintainer) { $ret[] = Array( 'user' => (string) $maintainer->user, 'name' => (string) $maintainer->name, 'email' => (string) $maintainer->email, 'role' => (string) $role, 'active' => (string) $maintainer->active, ); } } } return $ret; } /** * Get current date */ function getDate() { if ($this->_version == '1.0') { return (string) $this->_xml->release->date; } else { return (string) $this->_xml->date; } } /** * Get current version * * @param string $key release|api */ function getVersion($key = 'release') { if ($this->_version == '1.0') { return (string) $this->_xml->release->version; } else { return (string) $this->_xml->version->{$key}; } } /** * Get current stability * * @param string $key release|api */ function getStability($key = 'release') { if ($this->_version == '1.0') { return (string) $this->_xml->release->state; } else { return (string) $this->_xml->stability->{$key}; } } /** * Get current license */ function getLicense() { if ($this->_version == '1.0') { return trim((string) $this->_xml->release->license); } else { return trim((string) $this->_xml->license); } } /** * Get current notes */ function getNotes() { if ($this->_version == '1.0') { return trim((string) $this->_xml->release->notes); } else { return trim((string) $this->_xml->notes); } } /** * Get package type * * @return string php|extsrc|extbin|zendextsrc|zendextbin|bundle */ function getPackageType() { if ($this->_version == '1.0') { return 'php'; } $types = Array( 'phprelease' => 'php', 'extsrcrelease' => 'extsrc', 'extbinrelease' => 'extbin', 'zendextsrcrelease' => 'zendextsrc', 'zendextbinrelease' => 'zendextbin', 'bundle' => 'bundle' ); foreach($types as $tag => $type) { if($this->_xml->{$tag}) { return $type; } } throw new \InvalidArgumentException('Unable to get package type'); } /** * Does the package has a file with role "script" */ function hasPhpScript() { if ($this->_version == '1.0') { $scripts = $this->_xml->xpath('//file[@role="script"]'); } else { $this->_xml->registerXPathNamespace('p', 'http://pear.php.net/dtd/package-2.0'); $scripts = $this->_xml->xpath('//p:file[@role="script"]'); } return !empty($scripts); } /** * Canonic version. ie: * x.ya1 -> x.y~a1 */ static public function canonicVersion($version) { if (preg_match('/^(.*\d)(alpha\d*|a\d*|beta\d*|b\d*|rc\d*)$/i', $version, $matches)) { return $matches[1] . '~' . $matches[2]; } else { return $version; } } /** * Dependencies */ function getDependencies() { $result = new \Pkgtools\Base\Dependencies(); if ($this->_version == '1.0') { // FIXME package.xm v1.0 getDependencies() return $result; } if ($this->hasPhpScript()) { $dep = new \Pkgtools\Base\Dependency('require', '', 'php-cli'); $result[] = $dep; } $deps0 = $this->_xml->dependencies; foreach ($deps0->children() as $native_level => $deps1) { switch($native_level) { case 'required': $level = 'require'; break; case 'optional': $level = 'recommend'; break; case 'group': $level = 'suggest'; break; default: throw new \InvalidArgumentException("Unknown PEAR dependency level: '$native_level'"); } foreach ($deps1->children() as $native_type => $deps2) { switch($native_type) { case 'pearinstaller': // ignore continue(2); case 'php': $project = ''; $name = 'php'; break; case 'package': case 'subpackage': $project = 'pear-'.$deps2->channel; $name = (string) $deps2->name; break; case 'extension': $project = ''; $name = 'ext-'.$deps2->name; break; case 'os': // We ignore OS dependencies continue 2; default: throw new \InvalidArgumentException("Unknown PEAR dependency type '$native_type'"); } $dep = new \Pkgtools\Base\Dependency($level, $project, $name); if ($deps2->conflicts) { $dep->level = 'conflict'; } if ($deps2->min) { $dep->minVersion = self::canonicVersion((string) $deps2->min); } if (!empty($deps2->min) && ((string) $deps2->min == (string) $deps2->exclude)) { $dep->excludeMinVersion = true; } if ($deps2->max) { $dep->maxVersion = self::canonicVersion((string) $deps2->max); } $dep->excludeMaxVersion = false; if ((string) $deps2->max == (string) $deps2->exclude) { $dep->excludeMaxVersion = true; } $result[] = $dep; } } if ($this->_xml->extsrcrelease) { $phpapi = rtrim('phpapi-'.`/usr/bin/php-config --phpapi`); $dep = new \Pkgtools\Base\Dependency('require', '__override__', $phpapi); $result[] = $dep; } return $result; } /** * Changelog */ function getChangelog() { $ret = "Version ".$this->getVersion()." - ".$this->getDate()." (".$this->getStability().")\n"; $ret .= "----------------------------------------\n"; $ret .= "Notes:\n"; $ret .= " ".str_replace("\n", "\n ", wordwrap(preg_replace('/\s+/', ' ', $this->getNotes())))."\n\n"; if ($this->_version == '1.0') { $releases = $this->_xml->xpath('p:changelog/p:release'); foreach($releases as $release) { $ret .= "Version ".$release->version." - ".$release->date." (".$release->state.")\n"; $ret .= "----------------------------------------\n"; $ret .= "Notes:\n"; $ret .= " ".str_replace("\n", "\n ", wordwrap(preg_replace('/\s+/', " ", trim($release->notes))))."\n\n"; } } else { $this->_xml->registerXPathNamespace('p', 'http://pear.php.net/dtd/package-2.0'); $releases = $this->_xml->xpath('p:changelog/p:release'); $releases = array_reverse($releases); foreach($releases as $release) { $ret .= "Version ".$release->version->release." - ".$release->date." (".$release->stability->release.")\n"; $ret .= "----------------------------------------\n"; $ret .= "Notes:\n"; $ret .= " ".str_replace("\n", "\n ", wordwrap(preg_replace('/\s+/', ' ', trim($release->notes))))."\n\n"; } } return $ret; } /** * Convert to a dependency */ function asDependency($level = 'require') { $dep = new \Pkgtools\Base\Dependency($level, 'pear-'.$this->channel, $this->name); return $dep; } } PK i�Z�[\� � phppear/command.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools\Phppear; /** * All PEAR and PECL related commands * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Command extends \Pkgtools\Base\Command { /** * Print the package name */ public function runName() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->name; } /** * Print Debian package name * * @param string $channel PEAR channel. * @param string $name PEAR package name. */ public function runDebianname($channel = NULL, $name = NULL) { if (($channel === NULL) && ($name === NULL)) { $p = new Source($this->getProperty('_sourcedirectory')); $dep = $p->asDependency(); } elseif (($channel === NULL) || ($name === NULL)) { throw new \InvalidArgumentException('Please specify both channel and name arguments, or none'); } else { $dep = new \Pkgtools\Base\Dependency('require', 'pear-'.$channel, $name); } $overriden = \Pkgtools\Base\Overrides::override($dep); if ($overriden === NULL) { echo $dep->debName(); } else { echo $overriden->debName(); } } /** * Print the package channel */ public function runChannel() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->channel; } /** * Print the package summary */ public function runSummary() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->summary; } /** * Print the package description */ public function runDescription() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->description; } /** * Print the package maintainers list */ public function runMaintainers() { $p = new Source($this->getProperty('_sourcedirectory')); $maints = $p->getMaintainers(); // only keep leads and developers $maints = array_filter($maints, function($a) { return $a['role'] == 'lead' or $a['role'] == 'developer'; }); // format $maints = array_map(function($a) { return $a['name'].' <'.$a['email'].'>'; }, $maints); echo implode(", ", $maints); } /** * Print the package release date */ public function runDate() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->getDate(); } /** * Print the package version */ public function runVersion() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->getVersion('release'); } /** * Print Debian package version * * @param string $version Input version. */ public function runDebianversion($version = NULL) { if ($version === NULL) { $p = new Source($this->getProperty('_sourcedirectory')); $version = $p->getVersion('release'); } echo \Pkgtools\Phppear\Source::canonicVersion($version); } /** * Print the current license */ public function runLicense() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->getLicense(); } /** * Print the PEAR package type */ public function runPackagetype() { $p = new Source($this->getProperty('_sourcedirectory')); echo $p->getPackageType(); } /** * Print dependencies */ public function runDependencies() { $p = new Source($this->getProperty('_sourcedirectory')); print $p->getDependencies(); } /** * Print substvars (Debian substitution variables) */ public function runSubstvars() { $p = new Source($this->getProperty('_sourcedirectory')); $dependencies = $p->getDependencies()->asDeb(); // Ensure no key is missing $dependencies = array_merge(Array( 'require' => Array(), 'recommend' => Array(), 'suggest' => Array(), 'conflict' => Array() ), $dependencies); // Print substvars echo 'phppear:Debian-Depends=' . implode(', ', $dependencies['require'])."\n"; echo 'phppear:Debian-Recommends=' . implode(', ', $dependencies['recommend'])."\n"; echo 'phppear:Debian-Suggests=' . implode(', ', $dependencies['suggest'])."\n"; echo 'phppear:Debian-Breaks=' . implode(', ', $dependencies['conflict'])."\n"; $summary = $p->summary; if ($summary[strlen($summary)-1] == '.') { $summary = substr($summary, 0, -1); } echo 'phppear:summary=' . $summary."\n"; echo 'phppear:description=' . \Pkgtools\Base\Utils::substvar($p->description)."\n"; echo 'phppear:channel=' . $p->channel."\n"; } /** * Print changelog */ public function runChangelog() { $p = new Source($this->getProperty('_sourcedirectory')); print $p->getChangelog(); } } PK i�Z��Mp� � command.phpnu �[��� <?php /* * Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Pkgtools; use \Pkgtools\Base\Logger; /** * This class parses command-line * * @copyright Copyright (c) 2014 Mathieu Parent <sathieu@debian.org> * @author Mathieu Parent <sathieu@debian.org> * @license Expat http://www.jclark.com/xml/copying.txt */ class Command extends \Pkgtools\Base\Command { /** * Verbosity level * * @var int */ protected $_verbose = 0; /** * Source directory * * @var string */ protected $_sourcedirectory = '.'; /** * Add command options */ public function addOptions() { parent::addOptions(); $this->addOption('--verbose', '-v', Array('action' => 'callback', 'callback' => Array($this, 'increaseVerbosity'), 'help' => 'increase verbosity')); $this->addOption('--sourcedirectory', '-D', Array('help' => 'set source directory')); } /** * Increase verbosity */ public function increaseVerbosity() { Logger::setLevel(Logger::getEffectiveLevel() - 10); } } PK i�Zམ�� � phppearchannel/source.phpnu �[��� PK i�ZR�H` ` � phppearchannel/command.phpnu �[��� PK i�Zǿ�}b4 b4 w phpcomposer/source.phpnu �[��� PK i�Z�^?� � L phpcomposer/command.phpnu �[��� PK i�Z�Pb� � W base/overrides.phpnu �[��� PK i�Z˄�q� � �l base/override.phpnu �[��� PK i�Z�| F� � �y base/logger.phpnu �[��� PK i�Zt�$� � � base/dependencies.phpnu �[��� PK i�Z�b"G1 G1 ؔ base/dependency.phpnu �[��� PK i�Z]Q��� � b� base/utils.phpnu �[��� PK i�Zd��X�) �) 1� base/command.phpnu �[��� PK i�Z�����1 �1 #� phppear/source.phpnu �[��� PK i�Z�[\� � G, phppear/command.phpnu �[��� PK i�Z��Mp� � dE command.phpnu �[��� PK � KN
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings