Add postinstall script to set horde_dir config value.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 31 Aug 2010 16:12:25 +0000 (10:12 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 31 Aug 2010 16:30:15 +0000 (10:30 -0600)
framework/Role/Setconfig.php [new file with mode: 0644]
framework/Role/package.xml

diff --git a/framework/Role/Setconfig.php b/framework/Role/Setconfig.php
new file mode 100644 (file)
index 0000000..29364f6
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * PEAR_Installer_Role_Horde postconfig script.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author    Michael Slusarz <slusarz@horde.org>
+ * @category  Horde
+ * @copyright 2010 The Horde Project (http://www.horde.org/)
+ * @license   http://www.fsf.org/copyleft/gpl.html GPL
+ * @package   Role
+ */
+
+/**
+ * @author    Michael Slusarz <slusarz@horde.org>
+ * @category  Horde
+ * @copyright 2010 The Horde Project (http://www.horde.org/)
+ * @license   http://www.fsf.org/copyleft/gpl.html GPL
+ * @package   Role
+ */
+class Setconfig_postinstall
+{
+    /**
+     * PEAR config object.
+     *
+     * @var PEAR_Config
+     */
+    protected $_config;
+
+    /**
+     * Init postinstall task.
+     *
+     * @param PEAR_Config $config       Config object.
+     * @param PEAR_PackageFile_v2 $pkg  Package object.
+     * @param string $version           Last version installed.
+     *
+     * @returns boolean  Success.
+     */
+    public function init($config, $pkg, $version)
+    {
+        $this->_config = $config;
+
+        return true;
+    }
+
+    /**
+     * Run task after prompt.
+     *
+     * @param array $info   Parameter array.
+     * @param string $name  Postinstall phase.
+     */
+    public function run($info, $phase)
+    {
+        if ($phase !== 'first') {
+            return;
+        }
+
+        if (!$this->_config->set('horde_dir', $info['horde_dir'], 'user', 'pear.horde.org')) {
+            print "Could not save horde_dir configuration value to PEAR config.\n";
+            return;
+        }
+
+        $res = $this->_config->writeConfigFile();
+        if ($res instanceof PEAR_Error) {
+            print 'ERROR: ' . $res->getMessage() . "\n";
+            exit;
+        }
+
+        print "Configuration successfully saved to PEAR config.\n";
+    }
+
+}
index 450a0f5..d04be4f 100644 (file)
@@ -31,6 +31,18 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <dir name="/">
    <file name="Horde.php" role="php" />
    <file name="Horde.xml" role="php" />
+   <file name="Setconfig.php" role="php">
+    <tasks:postinstallscript>
+     <tasks:paramgroup>
+      <tasks:id>first</tasks:id>
+      <tasks:param>
+       <tasks:name>horde_dir</tasks:name>
+       <tasks:prompt>Filesystem location where the Horde application is installed.</tasks:prompt>
+       <tasks:type>string</tasks:type>
+      </tasks:param>
+     </tasks:paramgroup>
+    </tasks:postinstallscript>
+   </file>
   </dir> <!-- / -->
  </contents>
  <dependencies>