/** * */ public function visitDocument(PEAR_PackageProjector_Document $doc) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $mssg = preg_replace("/\\s/", " ", substr($this->notes, 0, 50)); $handler->buildMessage(5, "Setting notes... {$mssg}..", true); $doc->setChangelog($this->notes); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting license name... {$this->name}", true); $handler->buildMessage(5, "Setting license uri... {$this->uri}", true); $package->setLicense($this->name, $this->uri); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $mssg = preg_replace("/\\s/", " ", substr($this->summary, 0, 50)); $handler->buildMessage(5, "Setting summary... {$mssg}..", true); $package->setSummary($this->summary); }
public function build() { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); // Create API Document $handler->buildMessage(5, "Update API Document files... ", true); ob_start(); require_once "phpDocumentor/phpDocumentor/Setup.inc.php"; global $argv; $apidoc = $this->_dir . '/' . $this->_release_version; $old_argv = $argv; $argv = array('-p', '-t', $apidoc, '-d', $this->_src_dir); $phpdoc = new phpDocumentor_setup(); $phpdoc->readCommandLineSettings(); $phpdoc->setupConverters(); $phpdoc->createDocs(); $buff = ob_get_contents(); ob_end_clean(); $handler->buildMessage(5, $buff, true); // Create Hatena Document $handler->buildMessage(5, "Update main document file... ", true); $list = glob($this->_dir . "/*"); $links = array(); foreach ($list as $num => $filepath) { if (is_dir($filepath)) { $basename = basename($filepath); $links[] = '<li><a href="' . $basename . '/index.html">' . $basename . '</a></li>' . PHP_EOL; } } rsort($links); $this->pm('apilinks', implode(PHP_EOL, $links)); file_put_contents($this->_dir . 'index.html', $this->tpl()); $argv = $old_argv; }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting API version... {$this->version}", true); $handler->buildMessage(5, "Setting API stability... {$this->stability}", true); $package->setAPIVersion($this->version); $package->setAPIStability($this->stability); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Add install group " . strtolower($this->name) . "...", true); // $postInstall = $package->getPostinstaller(); $params = array(); foreach ($this->params as $num => $param) { $params[] = $param->getArray($postInstall); } $package->addPostInstallGroup($this->name); $postInstall->addParamGroup($this->name, $params, $this->instructions); }
/** * */ public function getArray(PEAR_Task_Postinstallscript_rw $postinstaller) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, " Add " . strtolower($this->name) . "...", true); return $postinstaller->getParam($this->name, $this->prompt, $this->type, $this->default); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting minimum version of PEAR Installer... {$this->min}", true); $package->setPearinstallerDep($this->min); }
/** * */ public function visitDocument(PEAR_PackageProjector_Document $doc) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); // Stylesheet $handler->buildMessage(5, "Setting stylesheet... ", true); $stylesheet = isset($this->projectinfo['docStylesheetFile']) ? $this->projectinfo['docStylesheetFile'] : ''; $doc->setStylesheet($stylesheet); // Toutorial $handler->buildMessage(5, "Setting toutorial... ", true); $toutorial = isset($this->projectinfo['docToutorial']) ? $this->projectinfo['docToutorial'] : ''; $doc->setTutorial($toutorial); // foreach ($this->items as $key => $item) { $doc->accept($item); } // //$doc->accept($this->Roles); //$doc->accept($this->Maintainers); //$doc->accept($this->AttributeManager); //$doc->accept($this->Dependencies); //$doc->accept($this->InstallGroups); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Add role... {$this->extension} => {$this->role}", true); $package->addRole($this->extension, $this->role); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting channel... {$this->channel}", true); $package->setChannel($this->channel); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Add " . strtolower($this->type) . " dependency package ... {$this->channel}/{$this->name}", true); $package->addPackageDepWithChannel($this->type, $this->name, $this->channel, $this->min, $this->max, $this->recommended, $this->exclude, $this->providesextension, $this->nodefault); }
public function ckeckPostInstaller() { // check installer $installer_path = $this->getPackageDirectory() . $this->getSetupFilepath(); $install_name = $this->getPackage() . '_' . self::SETUP_SCRIPT . '_postinstall'; $text = ''; // if (!file_exists($installer_path)) { //create installer $text = PEAR_PackageProjector_ConfigureManeger::getPostInstallerText($install_name, $this->Installgroups); file_put_contents($installer_path, $text); $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "", true); $handler->buildMessage(5, "*** Create Installer File ***", true); $handler->buildMessage(5, "Create File " . $installer_path, true); } else { $text = file_get_contents($installer_path); } // if (preg_match("/\n *class +" . preg_quote($install_name) . "[\\s\\{]/", $text)) { return true; } else { throw new PEAR_Exception("The name of Installer class should be \"{$install_name}\" in {$installer_path}."); return false; } }
/** * */ public static function singleton() { if (is_null(self::$singleton)) { self::$singleton = new self(); } return self::$singleton; }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting base install directory... {$this->dir}", true); $package->setPackageOption('baseinstalldir', $this->dir); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); // $dir = $package->getPackageDirectory(); $fullpath = realpath($dir . '/' . $this->path); // if (true === $this->_getAttr('ignore')) { $handler->buildMessage(5, "Add attribute 'ignore' of [{$this->path}]... yes", true); if (is_dir($fullpath)) { $package->addIgnore($fullpath . DIRECTORY_SEPARATOR . '*'); } else { $package->addIgnore($fullpath); } } // $role = $this->_getAttr('role'); if (!is_null($role)) { $handler->buildMessage(5, "Add attribute 'role' of [{$this->path}]... {$role}", true); if (is_dir($fullpath)) { $package->addDirectoryRole($this->path, $role); } else { $package->addExceptions($this->path, $role); } } // $platform = $this->_getAttr('platform'); if (!is_null($platform)) { $handler->buildMessage(5, "Add attribute 'platform' of [{$this->path}]... {$platform}", true); $package->addPlatformExceptions($this->path, $platform); } // $install = $this->_getAttr('install'); if (!is_null($install)) { $handler->buildMessage(5, "Add attribute 'install' of [{$this->path}]... {$install}", true); $package->addInstallAs($this->path, $install); $package->addInstallExceptions($this->path, '/'); } // $replace = $this->_getAttr('replace'); if (is_array($replace)) { foreach ($replace as $type => $value) { foreach ($value as $from => $to) { $handler->buildMessage(5, "Add attribute 'replace' of [{$this->path}]... {$from} => {$type}::{$to}", true); $package->addReplacement($this->path, $type, $from, $to); } } } }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Add " . strtolower($this->role) . " maintainer... *{$this->handle}* {$this->name}<{$this->email}>", true); $package->addMaintainer($this->role, $this->handle, $this->name, $this->email); }
/** * */ public function visit(PEAR_PackageProjector_Package $package) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting package type... {$this->type}", true); $package->setPackageType($this->type); }
/** * */ private function _buildProject() { // if (!$this->ProjectDirectory->loadSetting($this->ProjectInfo, 0)) { return; } $package = new PEAR_PackageProjector_Package(); $oldcwd = getcwd(); $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); // try { chdir($this->ProjectDirectory->getSrcPath()); /* * Create package2.xml */ $handler->buildMessage(5, "*** Create package2.xml ***", true); // $package->accept($this->ProjectDirectory->getPackageDirectory()); $package->accept($this->ProjectInfo); $package->build(); $handler->buildMessage(5, "", true); /* * Create Tgz */ $handler->buildMessage(5, "*** Create Tgz File ***", true); // chdir($this->ProjectDirectory->getRelasePath()); $pkg = new PEAR_PackageProjector_Packager(); $pkg->setMessageHandler($handler); $pkg->package($this->ProjectDirectory->getPackageFile()); $handler->buildMessage(5, "", true); } catch (Exception $e) { chdir($oldcwd); $handler->buildMessage(5, "\n*** Stop for the exception was generated. ***", true); throw $e; } $handler->buildMessage(5, "*** Finish ***", true); // chdir($oldcwd); // return true; }
/** * パッケージのビルドとリリースを行う * @return void **/ public function build() { $package = C(OpenpearPackage)->find_get(Q::eq('id', $this->package_id)); $maintainer = C(OpenpearMaintainer)->find_get(Q::eq('id', $this->maintainer_id)); $this->init_build_dir(work_path('build/' . $package->name() . '.' . date('YmdHis'))); foreach (array('desc.txt', 'notes.txt', 'summary.txt') as $filename) { File::write($this->build_dir($filename), $package->description()); } if ($package->is_external_repository()) { switch ($package->external_repository_type()) { case 'Git': $cmd = 'git clone'; break; case 'Mercurial': $cmd = 'hg clone'; break; case 'Subversion': $cmd = 'svn export'; break; default: throw new RuntimeException('unknown repository type'); } $command = new Command(sprintf('%s %s %s', $cmd, escapeshellarg($package->external_repository()), escapeshellarg($this->build_dir('tmp')))); } else { // Openpear Repository $revision = is_numeric($this->revision) && $this->revision > 0 ? intval($this->revision) : 'HEAD'; $repository_path = sprintf('%s/%s/trunk', OpenpearConfig::svn_root(), $package->name()); $command = new Command(sprintf('svn export -r %s %s %s', $revision, escapeshellarg($repository_path), escapeshellarg($this->build_dir('tmp')))); } if ($command->end_code()) { throw new RuntimeException($command->stderr()); } $build_path = $this->build_dir(implode('/', array('tmp', $this->build_path))); if (!File::exist($build_path)) { throw new RuntimeException(sprintf('build path is not found: %s', $build_path)); } $mv = new Command(sprintf('mv %s %s', escapeshellarg($build_path), escapeshellarg($this->build_dir('src')))); if ($mv->stderr() || !is_dir($this->build_dir('src'))) { throw new RuntimeException('src dir is not found'); } // ビルドする chdir($this->build_dir()); $project = PEAR_PackageProjector::singleton()->load($this->build_dir()); $project->configure($this->build_dir('build.conf')); $project->make(); // リリースしたファイルはどこ? chdir($this->build_dir('release')); foreach (glob('*.tgz') as $filename) { $package_file = $this->build_dir('release') . '/' . $filename; break; } if (!file_exists($package_file)) { throw new RuntimeException('package file is not exists: ' . $package_file); } // サーバーに追加する $cfg = (include path('channel.config.php')); $server = new PEAR_Server2($cfg); $server->addPackage($package_file); // svn tag $build_conf = parse_ini_string($this->build_conf, true); $svn = new Command(sprintf('svn copy' . ' %s/%s/trunk/%s' . ' %s/%s/tags/%s-%s-%s' . ' -m "%s (%s-%s) (@%s)"' . ' --username openpear', OpenpearConfig::svn_root(), $package->name(), $this->build_path, OpenpearConfig::svn_root(), $package->name(), $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], date('YmdHis'), 'package released', $build_conf['version']['release_ver'], $build_conf['version']['release_stab'], $maintainer->name())); // これ以降はエラーが起きてもドンマイ try { $release = new OpenpearRelease(); $release->package_id($package->id()); $release->maintainer_id($maintainer->id()); $release->version($build_conf['version']['release_ver']); $release->version_stab($build_conf['version']['release_stab']); $release->notes($this->notes); $release->settings($this->build_conf); $release->save(); $package->latest_release_id($release->id()); $package->released_at(time()); $package->save(); $message_template = new Template(); $message_template->vars('t', new Templf()); $message_template->vars('package', $package); $message_template->vars('maintainer', $maintainer); $message = new OpenpearMessage('type=system'); $message->maintainer_to_id($maintainer->id()); $message->subject(trans('{1} package have been released.', $package->name())); $message->description($message_template->read('messages/released.txt')); $message->save(); } catch (Exception $e) { Log::error($e); } }
/** * */ public function visitDocument(PEAR_PackageProjector_Document $doc) { $handler = PEAR_PackageProjector::singleton()->getMessageHandler(); $handler->buildMessage(5, "Setting Document Title... {$this->name}", true); $doc->setTitle($this->name); }