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/Services_Libravatar' => 'Services_Libravatar',
13 protected $writableDirs;
16 public function __construct()
18 $cfg = $GLOBALS['phorkie']['cfg'];
19 $this->writableDirs = array(
20 'gitdir' => $cfg['gitdir'],
21 'workdir' => $cfg['workdir'],
25 public static function run()
34 public function checkDeps()
36 foreach ($this->deps as $package => $class) {
37 if (!class_exists($class, true)) {
38 $this->fail('PEAR package not installed: ' . $package);
43 public function checkDirs()
45 foreach ($this->writableDirs as $name => $dir) {
47 $this->fail($name . ' directory does not exist at ' . $dir);
49 if (!is_writable($dir)) {
50 $this->fail($name . ' directory is not writable at ' . $dir);
55 public function checkGit()
57 $line = exec('git --version', $lines, $retval);
59 $this->fail('Running git executable failed.');
61 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
62 $this->fail('git version output format unexpected: ' . $line);
64 if (version_compare($matches[1], '1.7.5') < 0) {
66 'git version needs to be at least 1.7.5, got: ' . $matches[1]
71 public function checkDatabase()
73 $dbs = new Database_Setup_Elasticsearch();
77 public function fail($msg)
79 throw new Exception($msg);