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()
33 public function checkDeps()
35 foreach ($this->deps as $package => $class) {
36 if (!class_exists($class, true)) {
37 $this->fail('PEAR package not installed: ' . $package);
42 public function checkDirs()
44 foreach ($this->writableDirs as $name => $dir) {
46 $this->fail($name . ' directory does not exist at ' . $dir);
48 if (!is_writable($dir)) {
49 $this->fail($name . ' directory is not writable at ' . $dir);
54 public function checkGit()
56 $line = exec('git --version', $lines, $retval);
58 $this->fail('Running git executable failed.');
60 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
61 $this->fail('git version output format unexpected: ' . $line);
63 if (version_compare($matches[1], '1.7.5') < 0) {
65 'git version needs to be at least 1.7.5, got: ' . $matches[1]
70 public function fail($msg)
72 throw new Exception($msg);