Add install_dev script
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 03:45:11 +0000 (20:45 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 23 Dec 2009 04:14:52 +0000 (21:14 -0700)
.gitignore
framework/bin/install_dev [new file with mode: 0755]
framework/bin/install_dev.conf.dist [new file with mode: 0644]
horde/lib/core.php

index 2b10cdf..9cb8638 100644 (file)
@@ -9,6 +9,7 @@
 *.orig
 *.rej
 
-horde/lib/core.local.php
 horde/libs/
 horde/static/*.*
+
+framework/bin/*.conf
diff --git a/framework/bin/install_dev b/framework/bin/install_dev
new file mode 100755 (executable)
index 0000000..4b2c7aa
--- /dev/null
@@ -0,0 +1,108 @@
+#!/usr/bin/env php
+<?php
+/**
+ * Script to install a horde installation in a web-accessible directory,
+ * while allowing changes made to the repository source to also be reflected
+ * in the local installation.
+ *
+ * Requires the file 'install_dev.conf' to live in the same directory as
+ * this script.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ */
+
+require_once './install_dev.conf';
+
+$horde_git = rtrim(ltrim($horde_git), '/ ');
+$horde_hatchery = rtrim(ltrim($horde_hatchery), '/ ');
+$web_dir = rtrim(ltrim($web_dir), '/ ');
+
+if ($debug) {
+    print "DELETING old web directory " . $web_dir . "\n";
+}
+$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($web_dir), RecursiveIteratorIterator::CHILD_FIRST);
+while ($it->valid()) {
+    if (!$it->isDot()) {
+        if ($it->isLink()) {
+            if ($debug) {
+                print "DELETING LINK: " . $it->key() . "\n";
+            }
+            unlink($it->key());
+        } elseif ($it->isDir()) {
+            if ($debug) {
+                print "DELETING DIR: " . $it->key() . "\n";
+            }
+            rmdir($it->key());
+        } elseif ($it->isFile()) {
+            if ($debug) {
+                print "DELETING FILE: " . $it->key() . "\n";
+            }
+            unlink($it->key());
+        }
+    }
+    $it->next();
+}
+
+if (!empty($git)) {
+    if ($debug) {
+        print "\nUPDATING repositories\n";
+    }
+    system('cd ' . $horde_git . ';' . $git);
+    system('cd ' . $horde_hatchery . ';' . $git);
+}
+
+if ($debug) {
+    print "\nLINKING horde\n";
+}
+$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($horde_git . '/horde'), RecursiveIteratorIterator::SELF_FIRST);
+while ($it->valid()) {
+    if (!$it->isDot()) {
+        if ($it->isDir()) {
+            if ($debug) {
+                print "CREATING DIR: " . $web_dir . '/' . $it->getSubPathName() . "\n";
+            }
+            mkdir($web_dir . '/' . $it->getSubPathName());
+        } else {
+            if ($debug) {
+                print "LINKING FILE: " . $web_dir . "/" . $it->getSubPathName() . "\n";
+            }
+            symlink($it->key(), $web_dir . '/' . $it->getSubPathName());
+        }
+    }
+    $it->next();
+}
+
+if (!empty($static_group)) {
+    if ($debug) {
+        print "\nCHGRP/CHMOD static directory\n";
+    }
+    chgrp($web_dir . '/static', $static_group);
+    chmod($web_dir . '/static', $static_mode);
+}
+
+if ($debug) {
+    print "\nLINKING framework\n";
+}
+file_put_contents($web_dir . '/config/horde.local.php', "<?php ini_set('include_path', dirname(__FILE__) . '/../libs' . PATH_SEPARATOR . ini_get('include_path'));");
+mkdir($web_dir . '/libs');
+system('./install_framework --src ' . $horde_git . '/framework --dest ' . $web_dir . '/libs');
+system('./install_framework --src ' . $horde_hatchery . '/framework --dest ' . $web_dir . '/libs');
+
+if ($debug) {
+    print "\nLINKING applications to web directory " . $web_dir . "\n";
+}
+foreach ($apps as $app) {
+    if (file_exists($horde_git . '/' . $app)) {
+        if ($debug) {
+            print "LINKING " . $app . " (horde-git)\n";
+        }
+        symlink($horde_git . '/' . $app, $web_dir . '/' . $app);
+        file_put_contents($horde_git . '/' . $app . '/config/horde.local.php', '<?php define(\'HORDE_BASE\', \'' . $web_dir . '\');');
+    } elseif (file_exists($horde_hatchery . '/' . $app)) {
+        if ($debug) {
+            print "LINKING " . $app . " (horde-hatchery)\n";
+        }
+        symlink($horde_hatchery . '/' . $app, $web_dir . '/' . $app);
+        file_put_contents($horde_hatchery . '/' . $app . '/config/horde.local.php', '<?php define(\'HORDE_BASE\', \'' . $web_dir . '\');');
+    }
+}
diff --git a/framework/bin/install_dev.conf.dist b/framework/bin/install_dev.conf.dist
new file mode 100644 (file)
index 0000000..72d2320
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+// Debug output
+$debug = false;
+
+// Do git update before building web directory? If this is non-false, runs
+// this command in each repository
+// $git = 'git fetch && ( git rebase -v origin || ( git stash && ( git rebase -v origin || echo "WARNING: Run \'git stash pop\' manually!" ) && git stash pop ) )';
+$git = false;
+
+// The list of apps to create symlinks for
+$apps = array();
+
+// The location of the horde-git repository
+$horde_git = '';
+
+// The location of the horde-hatchery repository
+$horde_hatchery = '';
+
+// The web-accessible base directory for horde
+$web_dir = '';
+
+// The group name/mode to use for the '/horde/static' directory
+$static_group = '';
+$static_mode = 0775;
index 4fd7b28..9c421f4 100644 (file)
@@ -26,24 +26,17 @@ if (ini_get('register_globals')) {
     }
 }
 
-/* Local overrides for library paths, ini variables, etc. This is a transition
- * file, to make it easy for developers to maintain customizations as we move
- * to Horde 4.
- *
- * For example, if the Horde Framework packages are not installed in PHP's
- * global include_path, you can add an ini_set() call in this file to set up the
- * correct include_path.
- *
- * Example:
- *   ini_set('include_path', dirname(__FILE__) . PATH_SEPARATOR . ini_get('include_path'));
- */
 $horde_dir = dirname(__FILE__);
 if (!defined('HORDE_BASE')) {
     define('HORDE_BASE', $horde_dir . '/..');
 }
 
-if (file_exists($horde_dir . '/core.local.php')) {
-    include $horde_dir . '/core.local.php';
+/* Define any local include_path alterations in horde/config/horde.local.php.
+ * Example:
+ *   ini_set('include_path', dirname(__FILE__) . PATH_SEPARATOR . ini_get('include_path'));
+ */
+if (file_exists($horde_dir . '/../config/horde.local.php')) {
+    include $horde_dir . '/../config/horde.local.php';
 }
 
 /* PEAR base class. */