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',
13 'zustellzentrum.cweiske.de/MIME_Type_PlainDetect' => 'MIME_Type_PlainDetect',
16 protected $writableDirs;
19 public function __construct()
21 $cfg = $GLOBALS['phorkie']['cfg'];
22 $this->writableDirs = array(
23 'gitdir' => $cfg['gitdir'],
24 'workdir' => $cfg['workdir'],
28 public static function run()
37 public function checkDeps()
39 foreach ($this->deps as $package => $class) {
40 if (!class_exists($class, true)) {
41 $this->fail('PEAR package not installed: ' . $package);
46 public function checkDirs()
48 foreach ($this->writableDirs as $name => $dir) {
50 $this->fail($name . ' directory does not exist at ' . $dir);
52 if (!is_writable($dir)) {
53 $this->fail($name . ' directory is not writable at ' . $dir);
58 public function checkGit()
60 $line = exec('git --version', $lines, $retval);
62 $this->fail('Running git executable failed.');
64 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
65 $this->fail('git version output format unexpected: ' . $line);
67 if (version_compare($matches[1], '1.7.5') < 0) {
69 'git version needs to be at least 1.7.5, got: ' . $matches[1]
74 public function checkDatabase()
76 $dbs = new Database();
77 $dbs->getSetup()->setup();
80 public function fail($msg)
82 throw new Exception($msg);