22require_once
'PEAR.php';
27define(
'PEAR_COMMON_ERROR_INVALIDPHP', 1);
28define(
'_PEAR_COMMON_PACKAGE_NAME_PREG',
'[A-Za-z][a-zA-Z0-9_]+');
32define(
'_PEAR_COMMON_PACKAGE_VERSION_PREG',
'\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?');
37 ')(-([.0-9a-zA-Z]+))?');
41define(
'_PEAR_CHANNELS_NAME_PREG',
'[A-Za-z][a-zA-Z0-9\.]+');
45define(
'_PEAR_CHANNELS_SERVER_PREG',
'[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*(\/[a-zA-Z0-9\-]+)*');
67$GLOBALS[
'_PEAR_Common_maintainer_roles'] = array(
'lead',
'developer',
'contributor',
'helper');
73$GLOBALS[
'_PEAR_Common_release_states'] = array(
'alpha',
'beta',
'stable',
'snapshot',
'devel');
79$GLOBALS[
'_PEAR_Common_dependency_types'] = array(
'pkg',
'ext',
'php',
'prog',
'ldlib',
'rtlib',
'os',
'websrv',
'sapi');
85$GLOBALS[
'_PEAR_Common_dependency_relations'] = array(
'has',
'eq',
'lt',
'le',
'gt',
'ge',
'not',
'ne');
91$GLOBALS[
'_PEAR_Common_file_roles'] = array(
'php',
'ext',
'test',
'doc',
'data',
'src',
'script');
97$GLOBALS[
'_PEAR_Common_replacement_types'] = array(
'php-const',
'pear-config',
'package-info');
103$GLOBALS[
'_PEAR_Common_provide_types'] = array(
'ext',
'prog',
'class',
'function',
'feature',
'api');
109$GLOBALS[
'_PEAR_Common_script_phases'] = array(
'pre-install',
'post-install',
'pre-uninstall',
'post-uninstall',
'pre-build',
'post-build',
'pre-configure',
'post-configure',
'pre-setup',
'post-setup');
169 parent::__construct();
170 $this->config = &PEAR_Config::singleton();
171 $this->debug = $this->config->get(
'verbose');
183 $tempfiles =&
$GLOBALS[
'_PEAR_Common_tempfiles'];
184 while ($file = array_shift($tempfiles)) {
185 if (@is_dir($file)) {
186 if (!class_exists(
'System')) {
187 require_once
'System.php';
190 System::rm(array(
'-rf', $file));
191 } elseif (file_exists($file)) {
210 if (!class_exists(
'PEAR_Frontend')) {
211 require_once
'PEAR/Frontend.php';
229 $this->
log(2,
"+ create dir $dir");
230 if (!class_exists(
'System')) {
231 require_once
'System.php';
233 return System::mkDir(array(
'-p', $dir));
244 public function log($level, $msg, $append_crlf =
true)
246 if ($this->debug >= $level) {
247 if (!class_exists(
'PEAR_Frontend')) {
248 require_once
'PEAR/Frontend.php';
252 if (is_a(
$ui,
'PEAR_Frontend')) {
253 $ui->log($msg, $append_crlf);
273 $topt = $tmpdir ? array(
'-t', $tmpdir) : array();
274 $topt = array_merge($topt, array(
'-d',
'pear'));
275 if (!class_exists(
'System')) {
276 require_once
'System.php';
279 if (!$tmpdir = System::mktemp($topt)) {
309 static $states = array(
'snapshot',
'devel',
'alpha',
'beta',
'stable');
310 $i = array_search($state, $states);
317 return array_slice($states, $i + 1);
327 return $GLOBALS[
'_PEAR_Common_maintainer_roles'];
337 return $GLOBALS[
'_PEAR_Common_release_states'];
347 return $GLOBALS[
'_PEAR_Common_dependency_types'];
357 return $GLOBALS[
'_PEAR_Common_dependency_relations'];
367 return $GLOBALS[
'_PEAR_Common_file_roles'];
377 return $GLOBALS[
'_PEAR_Common_replacement_types'];
387 return $GLOBALS[
'_PEAR_Common_provide_types'];
397 return $GLOBALS[
'_PEAR_Common_script_phases'];
434 if (file_exists($path) && is_readable($path)) {
438 $ipath = explode(PATH_SEPARATOR, ini_get(
'include_path'));
439 foreach ($ipath as $include) {
440 $test = realpath($include . DIRECTORY_SEPARATOR . $path);
441 if (file_exists($test) && is_readable($test)) {
455 $errs = $pf->getUserinfo();
456 if (is_array($errs)) {
457 foreach ($errs as $error) {
458 $e = $this->raiseError($error[
'message'], $error[
'code'],
null,
null, $error);
528 if (!is_a($pf,
'PEAR_PackageFile_v2')) {
529 $this->pkginfo = $pf->toArray();
535 $arr = $pf->toArray(
true);
536 $arr = array_merge($arr, $arr[
'old']);
537 unset($arr[
'old'], $arr[
'xsdversion'], $arr[
'contents'], $arr[
'compatible'],
538 $arr[
'channel'], $arr[
'uri'], $arr[
'dependencies'], $arr[
'phprelease'],
539 $arr[
'extsrcrelease'], $arr[
'zendextsrcrelease'], $arr[
'extbinrelease'],
540 $arr[
'zendextbinrelease'], $arr[
'bundle'], $arr[
'lead'], $arr[
'developer'],
541 $arr[
'helper'], $arr[
'contributor']);
542 $arr[
'filelist'] = $pf->getFilelist();
543 $this->pkginfo = $arr;
560 if (is_string($info) && file_exists($info)) {
564 $errs = $pf->getUserinfo();
565 if (is_array($errs)) {
566 foreach ($errs as $error) {
567 $e = $this->raiseError($error[
'message'], $error[
'code'],
null,
null, $error);
593 $config = &PEAR_Config::singleton();
595 $pf = &$packagefile->fromArray(
$pkginfo);
596 $gen = &$pf->getDefaultGenerator();
615 $config = &PEAR_Config::singleton();
618 if (strpos($info,
'<?xml') !==
false) {
626 $errs = $pf->getUserinfo();
627 if (is_array($errs)) {
628 foreach ($errs as $error) {
629 if ($error[
'level'] ==
'error') {
630 $errors[] = $error[
'message'];
632 $warnings[] = $error[
'message'];
664 $file = basename($srcinfo[
'source_file']);
666 if (isset($this->_packageName)) {
667 $pn = $this->_packageName;
671 foreach ($srcinfo[
'declared_classes'] as $class) {
672 $key =
"class;$class";
673 if (isset($this->pkginfo[
'provides'][$key])) {
677 $this->pkginfo[
'provides'][$key] =
678 array(
'file'=> $file,
'type' =>
'class',
'name' => $class);
679 if (isset($srcinfo[
'inheritance'][$class])) {
680 $this->pkginfo[
'provides'][$key][
'extends'] =
681 $srcinfo[
'inheritance'][$class];
685 foreach ($srcinfo[
'declared_methods'] as $class => $methods) {
686 foreach ($methods as $method) {
687 $function =
"$class::$method";
688 $key =
"function;$function";
689 if ($method[0] ==
'_' || !strcasecmp($method, $class) ||
690 isset($this->pkginfo[
'provides'][$key])) {
694 $this->pkginfo[
'provides'][$key] =
695 array(
'file'=> $file,
'type' =>
'function',
'name' => $function);
699 foreach ($srcinfo[
'declared_functions'] as $function) {
700 $key =
"function;$function";
701 if ($function[0] ==
'_' || isset($this->pkginfo[
'provides'][$key])) {
705 if (!strstr($function,
'::') && strncasecmp($function, $pn, $pnl)) {
706 $warnings[] =
"in1 " . $file .
": function \"$function\" not prefixed with package name \"$pn\"";
709 $this->pkginfo[
'provides'][$key] =
710 array(
'file'=> $file,
'type' =>
'function',
'name' => $function);
723 if (!class_exists(
'PEAR_PackageFile_v2_Validator')) {
724 require_once
'PEAR/PackageFile/v2/Validator.php';
733 if (!function_exists(
"token_get_all")) {
738 return $this->raiseError($info);
741 if (!is_array($info)) {
746 $used_c = $decl_c = $decl_f = $decl_m = array();
747 foreach ($info[
'filelist'] as $file => $fa) {
749 $used_c = @array_merge($used_c, $tmp[
'used_classes']);
750 $decl_c = @array_merge($decl_c, $tmp[
'declared_classes']);
751 $decl_f = @array_merge($decl_f, $tmp[
'declared_functions']);
752 $decl_m = @array_merge($decl_m, $tmp[
'declared_methods']);
753 $inheri = @array_merge($inheri, $tmp[
'inheritance']);
756 $used_c = array_unique($used_c);
757 $decl_c = array_unique($decl_c);
758 $undecl_c = array_diff($used_c, $decl_c);
760 return array(
'used_classes' => $used_c,
761 'declared_classes' => $decl_c,
762 'declared_methods' => $decl_m,
763 'declared_functions' => $decl_f,
764 'undeclared_classes' => $undecl_c,
765 'inheritance' => $inheri,
824 $url, &
$ui, $save_dir =
'.', $callback =
null, $lastmodified =
null,
825 $accept =
false, $channel =
false
827 if (!class_exists(
'PEAR_Downloader')) {
828 require_once
'PEAR/Downloader.php';
831 $this, $url,
$ui, $save_dir, $callback, $lastmodified,
837require_once
'PEAR/Config.php';
838require_once
'PEAR/PackageFile.php';
const _PEAR_COMMON_CHANNEL_DOWNLOAD_PREG
const _PEAR_CHANNELS_NAME_PREG
const _PEAR_CHANNELS_SERVER_PREG
const PEAR_COMMON_PACKAGE_VERSION_PREG
const PEAR_COMMON_PACKAGE_NAME_PREG
$GLOBALS['_PEAR_Common_tempfiles']
const _PEAR_COMMON_PACKAGE_DOWNLOAD_PREG
const _PEAR_CHANNELS_PACKAGE_PREG
const _PEAR_COMMON_PACKAGE_NAME_PREG
const _PEAR_COMMON_PACKAGE_VERSION_PREG
$GLOBALS['_PEAR_default_error_mode']
const PEAR_VALIDATE_PACKAGING
const PEAR_VALIDATE_NORMAL
static getDependencyTypes()
log($level, $msg, $append_crlf=true)
static getDependencyRelations()
downloadHttp( $url, &$ui, $save_dir='.', $callback=null, $lastmodified=null, $accept=false, $channel=false)
_postProcessValidPackagexml(&$pf)
static betterStates($state, $include=false)
buildProvidesArray($srcinfo)
static getReplacementTypes()
detectDependencies($any, $status_callback=null)
static addTempFile($file)
validPackageVersion($ver)
infoFromDescriptionFile($descfile)
validatePackageInfo($info, &$errors, &$warnings, $dir_prefix='')
static isIncludeable($path)
static getReleaseStates()
static analyzeSourceCode($file)
static _downloadHttp( $object, $url, &$ui, $save_dir='.', $callback=null, $lastmodified=null, $accept=false, $channel=false)
static addTempFile($file)
static & singleton($type=null)
analyzeSourceCode($file, $string=false)
static staticPopErrorHandling()
static staticPushErrorHandling($mode, $options=null)
static isError($data, $code=null)