Exemplo n.º 1
0
function run_import_users($task, $args)
{
    if (!isset($args[0])) {
        pake_echo_error('usage: pake i "users.yml"');
        return false;
    }
    pake_echo_comment("Reading file. It can take awhile…");
    $str = file_get_contents($args[0]);
    $data = pakeYaml::loadString($str);
    pake_echo_comment("Starting import…");
    $len = count($data);
    for ($i = 0; $i < $len; $i++) {
        $row = $data[$i];
        if (_create_user($row['login'], $row['password'], $row['data'])) {
            pake_echo_action('user+', "({$i} of {$len}) " . $row['login']);
        } else {
            pake_echo_comment('already exists: ' . "({$i} of {$len}) " . $row['login']);
        }
    }
}
Exemplo n.º 2
0
 public static function run__clean_build($task, $args, $long_args)
 {
     $dir = dirname(pakeApp::get_instance()->getPakefilePath());
     $cfg_file = $dir . '/' . __CLASS__ . '.yaml';
     if (file_exists('Makefile')) {
         pake_sh('make distclean');
     }
     if (file_exists('configure')) {
         if (isset($long_args['with-phpize'])) {
             $phpize = $long_args['with-phpize'];
         } elseif (file_exists($cfg_file)) {
             $cfg_data = pakeYaml::loadFile($cfg_file);
             $phpize = $cfg_data['phpize'];
         } else {
             $phpize = pake_which('phpize');
         }
         if (!file_exists($phpize)) {
             throw new pakeException('"' . $phpize . '" is not available');
         }
         pake_sh(escapeshellarg($phpize) . ' --clean');
     }
 }
Exemplo n.º 3
0
 public static function run_app($task, $args)
 {
     if (isset($args[0])) {
         $config_file = $args[0];
     } else {
         $config_file = getcwd() . '/config.yaml';
     }
     pake_echo_comment('Loading configuration…');
     if (!file_exists($config_file)) {
         throw new \pakeException("Configuration file is not found: " . $config_file);
     }
     $config = \pakeYaml::loadFile($config_file);
     $runner = new Runner();
     foreach ($config['servers'] as $server) {
         if (!class_exists($server['app']['class'])) {
             require dirname($config_file) . '/' . $server['app']['file'];
             pake_echo_action('load class', $server['app']['class']);
         }
         $runner->addServer($server['app']['class'], $server['app']['middlewares'], $server['protocol'], $server['socket'], $server['min-children'], $server['max-children']);
         pake_echo_action('register', $server['app']['class'] . ' server via ' . $server['protocol'] . ' at ' . $server['socket'] . '. (' . $server['min-children'] . '-' . $server['max-children'] . ' children)');
     }
     pake_echo_comment('Starting server…');
     $runner->go();
 }
Exemplo n.º 4
0
function getSettings()
{
    static $settings = array();
    if (!empty($settings)) {
        return $settings;
    }
    $cfgFileName = file_exists('buildConfig.local.yml') ? 'buildConfig.local.yml' : 'buildConfig.yml';
    return $settings = pakeYaml::loadFile($cfgFileName);
}
Exemplo n.º 5
0
function run_obs($task)
{
    run_release($task);
    $_root = dirname(__FILE__);
    $options = pakeYaml::loadFile($_root . '/options.yaml');
    $version = $options['version'];
    $target = $_root . '/target';
    pake_sh(escapeshellarg(pake_which('gunzip')) . ' ' . escapeshellarg($target . '/pake-' . $version . '.tgz'));
    pake_sh(escapeshellarg(pake_which('tar')) . ' -r -f ' . escapeshellarg($target . '/pake-' . $version . '.tar') . ' -C ' . escapeshellarg($_root) . ' debian');
    pake_sh(escapeshellarg(pake_which('gzip')) . ' ' . escapeshellarg($target . '/pake-' . $version . '.tar'));
}
Exemplo n.º 6
0
 /**
  * Builds dependent extensions
  *
  * @todo add locking support
  */
 static function run_build_dependencies($task = null, $args = array(), $cliopts = array())
 {
     $opts = self::getOpts(@$args[0], @$args[1], $cliopts);
     $current = $opts['extension']['name'];
     foreach ($opts['dependencies']['extensions'] as $ext => $source) {
         // avoid loops
         if ($ext != $current) {
             // create a temporary config file to drive the init task
             // this could be done better in memory...
             foreach ($source as $type => $def) {
                 break;
             }
             $tempconf = array('extension' => array('name' => $ext), 'version' => array('major' => 0, 'minor' => 0, 'release' => 0), $type => $def);
             $tempconffile = self::getOptionsDir() . "/options-tmp_{$ext}.yaml";
             pakeYaml::emitfile($tempconf, $tempconffile);
             // download remote extension
             // nb: we can not run the init task here via invoke() because of already_invoked status,
             // so we use execute(). NB: this is fine as long as init has no prerequisites
             $task = pakeTask::get('init');
             $task->execute(array("tmp_{$ext}"), array_merge($cliopts, array('skip-init' => false, 'skip-init-fetch' => false, 'skip-init-clean' => true)));
             // copy config file from ext dir to current config dir
             if (is_file(self::getBuildDir($opts) . "/{$ext}/pake/options-{$ext}.yaml")) {
                 pake_copy(self::getBuildDir($opts) . "/{$ext}/pake/options-{$ext}.yaml", self::getOptionsDir() . "/options-{$ext}.yaml");
             } else {
                 throw new pakeException("Missing pake/options.yaml extension in dependent extension {$ext}");
             }
             // finish the init-task
             $task->execute(array("tmp_{$ext}"), array_merge($cliopts, array('skip-init' => false, 'skip-init-fetch' => true, 'skip-init-clean' => false)));
             pake_remove($tempconffile, '');
             // and build it. Here again we cannot use 'invoke', but we know 'build' has prerequisites
             // so we execute them one by one
             $task = pakeTask::get('build');
             foreach ($task->get_prerequisites() as $pretask) {
                 $pretask = pakeTask::get($pretask);
                 $pretask->execute(array($ext), array_merge($opts, array('skip-init' => true)));
             }
             $task->execute(array($ext), array_merge($opts, array('skip-init' => true)));
         }
     }
 }
Exemplo n.º 7
0
function run_release($task)
{
    $_root = dirname(__FILE__);
    $options = pakeYaml::loadFile($_root . '/options.yaml');
    $version = $options['version'];
    pakeSimpletestTask::call_simpletest($task);
    if ($task->is_verbose()) {
        pake_echo_comment('releasing pake version "' . $version . '"');
    }
    run_create_pear_package();
}