6 protected $deps = array(
7 'pear.php.net/VersionControl_Git' => 'VersionControl_Git',
8 'pear.twig-project.org/Twig' => 'Twig_Autoloader',
9 'pear.php.net/Date_HumanDiff' => 'Date_HumanDiff',
10 'pear.php.net/HTTP_Request2' => 'HTTP_Request2',
11 'pear.php.net/Pager' => 'Pager',
12 'pear.php.net/Services_Libravatar' => 'Services_Libravatar',
15 protected $writableDirs;
18 public function __construct()
20 $cfg = $GLOBALS['phorkie']['cfg'];
21 $this->writableDirs = array(
22 'gitdir' => $cfg['gitdir'],
23 'workdir' => $cfg['workdir'],
27 public static function run()
36 public function checkDeps()
38 foreach ($this->deps as $package => $class) {
39 if (!class_exists($class, true)) {
40 $this->fail('PEAR package not installed: ' . $package);
45 public function checkDirs()
47 foreach ($this->writableDirs as $name => $dir) {
49 $this->fail($name . ' directory does not exist at ' . $dir);
51 if (!is_writable($dir)) {
52 $this->fail($name . ' directory is not writable at ' . $dir);
57 public function checkGit()
59 $line = exec('git --version', $lines, $retval);
61 $this->fail('Running git executable failed.');
63 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
64 $this->fail('git version output format unexpected: ' . $line);
66 if (version_compare($matches[1], '1.7.5') < 0) {
68 'git version needs to be at least 1.7.5, got: ' . $matches[1]
73 public function checkDatabase()
75 $dbs = new Database_Setup_Elasticsearch();
79 public function fail($msg)
81 throw new Exception($msg);