Exemplo n.º 1
0
 /**
  * @context OpenpearTemplf $ot フィルタ
  */
 protected function __init__()
 {
     $this->add_module(new OpenpearAccountModule());
     $this->vars('pear_domain', OpenpearConfig::pear_domain('openpear.org'));
     $this->vars('pear_alias', OpenpearConfig::pear_alias('openpear'));
     $this->vars('svn_url', OpenpearConfig::svn_url('http://svn.openpear.org'));
     $this->vars('ot', new OpenpearTemplf($this->user()));
     if ($this->is_login()) {
         $unread_messages_count = OpenpearMessage::unread_count($this->user());
         if ($unread_messages_count > 0) {
             $this->vars('unread_messages_count', $unread_messages_count);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 作成後処理
  * - Subversion アカウントの作成
  * - メールの送信
  */
 protected function __after_create__($commit)
 {
     $registered_message = new Template();
     $registered_message->vars('maintainer', $this);
     $message = new OpenpearMessage();
     $message->maintainer_to_id($this->id());
     $message->subject('Welcome to Openpear!');
     $message->description($registered_message->read('messages/registered.txt'));
     $message->type('system');
     $message->save();
     $message = new OpenpearMessage();
     $message->maintainer_to_id($this->id());
     $message->subject('Please join Openpear Group');
     $message->description('Do you already join the Openpear Group? [http://groups.google.com/group/openpear:title=Openpear Group]');
     $message->type('system_notice');
     $message->mail(false);
     $message->save();
 }
Exemplo n.º 3
0
 /**
  * ファイルアップロードからリリース
  * @param string $package_name パッケージ名
  **/
 public function package_release_by_upload($package_name)
 {
     $package = C(OpenpearPackage)->find_get(Q::eq('name', $package_name));
     $package->permission($this->user());
     if ($this->is_post() && $this->is_files('package_file') && $this->verify()) {
         try {
             $package_file = $this->in_files('package_file');
             $package_file->generate(work_path('upload/' . $package_name . '-' . date('YmdHis') . '.tgz'));
             if ($package_xml = simplexml_load_file(sprintf('phar://%s/package.xml', $package_file->fullname()))) {
                 if ($package_xml->name != $package->name()) {
                     throw new OpenpearException(Gettext::trans('incorrect package name'));
                 }
                 if ($package_xml->channel != OpenpearConfig::pear_domain('openpear.org')) {
                     $package_xml->channel = OpenpearConfig::pear_domain('openpear.org');
                     $pd = new PharData($package_file->fullname());
                     $pd->addFromString('package.xml', $package_xml->asXML());
                     unset($pd);
                 }
                 $upload_queue = new stdClass();
                 $upload_queue->package_id = $package->id();
                 $upload_queue->package_file = $package_file->fullname();
                 $upload_queue->maintainer_id = $this->user()->id();
                 $queue = new OpenpearQueue('type=upload_release');
                 $queue->data(serialize($upload_queue));
                 $queue->save();
                 $message = new OpenpearMessage('type=system_notice,mail=false');
                 $message->maintainer_to_id($this->user()->id());
                 $message->subject(trans('リリースキューに追加されました'));
                 $message->description(trans('{1}のリリースを受け付けました。リリースの完了後,メールでお知らせします。', $package->name()));
                 $message->save();
                 $this->redirect_by_map('dashboard');
             }
         } catch (Exception $e) {
             Log::debug($e);
             Exceptions::add($e);
         }
     }
     $this->vars('package', $package);
     $this->vars('package_id', $package->id());
 }
Exemplo n.º 4
0
        $server->addPackage($package_file);
        // これ以降はエラーが起きてもドンマイ
        try {
            $release = new OpenpearRelease();
            $release->package_id($package->id());
            $release->maintainer_id($maintainer->id());
            $release->version($version);
            $release->version_stab($stab);
            $release->notes($xml->f('notes.value()'));
            $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);
        }
        $queue->delete();
    } catch (Exception $e) {
        Log::error($e);
        C($queue)->rollback();
    }
}
Exemplo n.º 5
0
 /**
  * パッケージのビルドとリリースを行う
  * @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);
     }
 }