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',
12 protected $writableDirs;
15 public function __construct()
17 $cfg = $GLOBALS['phorkie']['cfg'];
18 $this->writableDirs = array(
19 'gitdir' => $cfg['gitdir'],
20 'workdir' => $cfg['workdir'],
24 public static function run()
32 public function checkDeps()
34 foreach ($this->deps as $package => $class) {
35 if (!class_exists($class, true)) {
36 $this->fail('PEAR package not installed: ' . $package);
41 public function checkDirs()
43 foreach ($this->writableDirs as $name => $dir) {
45 $this->fail($name . ' directory does not exist at ' . $dir);
47 if (!is_writable($dir)) {
48 $this->fail($name . ' directory is not writable at ' . $dir);
53 public function checkGit()
55 $line = exec('git --version', $lines, $retval);
57 $this->fail('Running git executable failed.');
59 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
60 $this->fail('git version output format unexpected: ' . $line);
62 if (version_compare($matches[1], '1.7.5') < 0) {
64 'git version needs to be at least 1.7.5, got: ' . $matches[1]
69 public function fail($msg)
71 throw new Exception($msg);