cvs: peardoc /en/guide/migrating customroles.xml
| From: | Greg Beaver | Date: | Thu, 03 Nov 2005 05:06:54 +0000 |
| Subject: | cvs: peardoc /en/guide/migrating customroles.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7125@lists.php.net to get a copy of this message | ||
cellog Thu Nov 3 00:06:54 2005 EDT
Modified files:
/peardoc/en/guide/migrating customroles.xml
Log:
update docs on custom file roles for PEAR 1.4.3
http://cvs.php.net/diff.php/peardoc/en/guide/migrating/customroles.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/en/guide/migrating/customroles.xml diff -u peardoc/en/guide/migrating/customroles.xml:1.3 peardoc/en/guide/migrating/customroles.xml:1.4 --- peardoc/en/guide/migrating/customroles.xml:1.3 Wed Apr 6 22:21:50 2005 +++ peardoc/en/guide/migrating/customroles.xml Thu Nov 3 00:06:52 2005 @@ -1,15 +1,24 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <chapter id="guide.migrating.customroles"> <chapterinfo> <author> <firstname>Gregory</firstname> <surname>Beaver</surname> </author> - <date>$Date: 2005/04/07 02:21:50 $</date> + <date>$Date: 2005/11/03 05:06:52 $</date> </chapterinfo> <title>Custom File Roles</title> + <warning> + <simpara> + As of PEAR version 1.4.3, the required format for custom file roles has been + changed due to a minor security vulnerability. All custom file roles must + now define a <filename>Role.xml</filename> file in order to properly declare + a custom file role. See the example below for more information. + </simpara> + </warning> + <simpara> One of the programming features that the PEAR installer enforces is the separation of files into separate categories, and the important idea that files of a similar @@ -86,6 +95,7 @@ </notes> <contents> <dir name="/" baseinstalldir="PEAR/Installer/Role"> + <file name="Chiarafoo.xml" role="php"/> <file name="Chiarafoo.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info"/> </file> @@ -94,11 +104,10 @@ <dependencies> <required> <php> - <min>4.2</min> - <max>6.0.0</max> + <min>4.2.0</min> </php> <pearinstaller> - <min>1.4.0a9</min> + <min>1.4.3</min> </pearinstaller> </required> </dependencies> @@ -108,7 +117,35 @@ </programlisting> </para> <para> - The script itself in Chiarafoo.php should be similar to this script: + The XML file Chiarafoo.xml should be similar to this file: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ +<role version="1.0"> + <releasetypes>php</releasetypes> + <installable>1</installable> + <locationconfig>foo_dir</locationconfig> + <honorsbaseinstall>1</honorsbaseinstall> + <unusualbaseinstall /> + <phpfile>1</phpfile> + <executable /> + <phpextension /> + <config_vars> + <foo_dir> + <type>directory</type> + <default><php_dir/><constant>DIRECTORY_SEPARATOR</constant><text>Foo</text></default> + <doc>directory where foo files are installed</doc> + <prompt>PHP foo directory</prompt> + <group>File Locations</group> + </foo_dir> + </config_vars> +</role> + ]]> + </programlisting> + </para> + <para> + The script in Chiarafoo.php is incredibly simple: </para> <para> <programlisting role="php"> @@ -130,7 +167,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 2005 Greg Beaver * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: customroles.xml,v 1.3 2005/04/07 02:21:50 cellog Exp $ + * @version CVS: $Id: customroles.xml,v 1.4 2005/11/03 05:06:52 cellog Exp $ * @link http://pear.chiaraquartet.net/index.php?package=Chiarafoo * @since File available since Release 0.1.0 */ @@ -147,55 +184,15 @@ */ class PEAR_Installer_Role_Chiarafoo extends PEAR_Installer_Role_Common { - var $_setup = - array( - 'releasetypes' => array('php'), - 'installable' => true, - 'locationconfig' => 'foo_dir', - 'honorsbaseinstall' => true, - 'unusualbaseinstall' => false, // required as of PEAR 1.4.0a11 - 'phpfile' => true, - 'executable' => false, - 'phpextension' => false, - ); - function getInfo() - { - return array( - 'releasetypes' => array('php'), - 'installable' => true, - 'locationconfig' => 'foo_dir', - 'honorsbaseinstall' => true, - 'unusualbaseinstall' => false, // required as of PEAR 1.4.0a11 - 'phpfile' => true, - 'executable' => false, - 'phpextension' => false, - ); - } - - function setup(&$installer, $pkg, $atts, $file) - { - } - /** - * This method is called upon instantiating a PEAR_Config object. - * - * This method MUST an array of information for all new configuration - * variables required by the file role. addConfigVar() expects an array of - * configuration information that is identical to what is used internally in PEAR_Config - * @access protected - * @param PEAR_Config + * @param PEAR_Installer + * @param PEAR_PackageFile_v2 + * @param array file attributes + * @param string relative path to file in package.xml */ - function getSupportingConfigVars() + function setup(&$installer, $pkg, $atts, $file) { - return array( - 'foo_dir' => array( - 'type' => 'directory', - 'default' => PEAR_CONFIG_DEFAULT_PHP_DIR . DIRECTORY_SEPARATOR . 'Foo', - 'doc' => 'directory where foo files are installed', - 'prompt' => 'PHP foo directory', - 'group' => 'File Locations', - ), - ); + // do something special with the installer } } ?> @@ -203,60 +200,63 @@ </programlisting> </para> <para> - Both <varname>$_setup</varname> and <function>getInfo</function> are required for all - roles. <function>getSupportingConfigVars</function> is only required if the custom role - needs to process differing configuration roles to do a successful installation. + Since PEAR 1.4.3, nothing else is necessary for a successful implementation of a file + role. </para> <para> - The contents of the <varname>$_setup</varname> and the array returned from - <function>getInfo</function> must contain all of these indices: + The contents of the role's XML file must contain these tags: <itemizedlist> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.releasetypes">releasetypes</link> + <link linkend="guide.migrating.customroles.defining.releasetypes"><releasetypes></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.installable">installable</link> + <link linkend="guide.migrating.customroles.defining.installable"><installable></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.locationconfig">locationconfig</link> + <link linkend="guide.migrating.customroles.defining.locationconfig"><locationconfig></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.honorsbaseinstall">honorsbaseinstall</link> + <link linkend="guide.migrating.customroles.defining.honorsbaseinstall"><honorsbaseinstall></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.unusualbaseinstall">unusualbaseinstall</link> (PEAR 1.4.0a11+) + <link linkend="guide.migrating.customroles.defining.unusualbaseinstall"><unusualbaseinstall></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.phpfile">phpfile</link> + <link linkend="guide.migrating.customroles.defining.phpfile"><phpfile></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.executable">executable</link> + <link linkend="guide.migrating.customroles.defining.executable"><executable></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.phpextension">phpextension</link> + <link linkend="guide.migrating.customroles.defining.phpextension"><phpextension></link> + </para> + </listitem> + <listitem> + <para> + <link linkend="guide.migrating.customroles.defining.config-vars">(optional) <config_vars></link> </para> </listitem> </itemizedlist> </para> <sect2 id="guide.migrating.customroles.defining.releasetypes"> - <title>The 'releasetypes' index</title> + <title>The <releasetypes> tag</title> <para> - This index must be one of: + This tag can only contain one of the following values: </para> <para> <itemizedlist> @@ -278,51 +278,67 @@ </itemizedlist> </para> <para> + In order to specify compatibility with multiple release types, use multiple + <releasetypes> tags as in: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ + <releasetypes>php</releasetypes> + <releasetypes>extsrc</releasetypes> + <releasetypes>extbin</releasetypes> + ]]> + </programlisting> + </para> + <para> releasetypes defines the kind of releases that this role can be used in. For instance, the "src" role is reserved for extsrc packages, and cannot be used in regular PEAR-style php releases. The "data" role can be used in any release, and would - define releasetypes as: + define <releasetypes> as: </para> <para> <programlisting role="php"> <![CDATA[ -array('releasetypes' => array('php', 'extsrc', 'extbin'), // etc.); + <releasetypes>php</releasetypes> + <releasetypes>extsrc</releasetypes> + <releasetypes>extbin</releasetypes> ]]> </programlisting> </para> </sect2> <sect2 id="guide.migrating.customroles.defining.installable"> - <title>The 'installable' index</title> + <title>The <installable> tag</title> <para> - This index must be either &true; or &false; and determines whether files utilizing + This tag must be either <installable>1</installable> or empty + (<installable/>) and determines whether files utilizing this custom role can be installed. Any file that should be installed must set this to - true. Only roles such as the "src" role that is processed and used to create - the files that are eventually installed should set this to &false; + 1. Only roles such as the "src" role that is processed and used to create + the files that are eventually installed should set this to an empty tag. </para> </sect2> <sect2 id="guide.migrating.customroles.defining.locationconfig"> - <title>The 'locationconfig' index</title> + <title>The <locationconfig> tag</title> <para> - This index is used for all installable files to determine which configuration variable + This tag is used for all installable files to determine which configuration variable contains the directory in which the file should be installed. For instance, the php role uses the "php_dir" locationconfig, the data role uses "data_dir". </para> <para> - Our example role, chiarafoo, uses the "foo_dir" configuration variable, and then - through the definition of <function>getSupportingConfigVars</function>, tells the installer - what foo_dir means. Note that once a custom role is installed, the user can config-set/ + Our example role, chiarafoo, uses the "foo_dir" configuration variable, + and then through the definition of <config_vars> tells the installer what + foo_dir means. Note that once a custom role is installed, the user can config-set/ config-get/config-show the variable just like any other configuration variable! </para> <para> - <function>getSupportingConfigVars</function> can define more than one configuration + <config_vars> can define more than one configuration variable, but note that more than 3 variables will trigger an error, disallowing any of them, as a security precaution. </para> </sect2> <sect2 id="guide.migrating.customroles.defining.honorsbaseinstall"> - <title>The 'honorsbaseinstall' index</title> + <title>The <honorsbaseinstall> tag</title> <para> - This index controls whether a role reacts to the "baseinstalldir" attribute + This tag controls whether a role reacts to the "baseinstalldir" attribute of a <file> or <dir> tag. Any role that honors baseinstalldir can potentially allow conflicting files from different packages, and so a check has to be made. A file role that does not honor baseinstalldir is always installed into: @@ -330,37 +346,220 @@ <para> <filename>Packagename/full/path/from/contents/file.ext</filename> </para> + <para> + To specify this value, use + <honorsbaseinstall>1</honorsbaseinstall> + For all other cases, it should be an empty tag (<honorsbaseinstall/>) + </para> </sect2> <sect2 id="guide.migrating.customroles.defining.unusualbaseinstall"> - <title>The 'unusualbaseinstall' index</title> + <title>The <unusualbaseinstall> tag</title> <para> - This index controls whether a role that would normally ignore the + This tag controls whether a role that would normally ignore the "baseinstalldir" attribute of a <file> or <dir> tag would honor it, but still use the <filename>Packagename/baseinstalldir/full/path/from/contents/file.ext</filename> instead of <filename>baseinstalldir/full/path/from/contents/file.ext</filename>. Any role that supports the unusual baseinstalldir type cannot conflict with other files because the - package name is always the parent directory. + package name is always the parent directory. To specify this value, use + <unusualbaseinstall>1</unusualbaseinstall> + For all other cases, it should be an empty tag (<unusualbaseinstall/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.phpfile"> - <title>The 'phpfile' index</title> + <title>The <phpfile> tag</title> <para> - This index should be used for any roles that contain php script files. These files - are analyzed at package time, possibly catching errors before release. + This tag should be set to 1 (<phpfile>1</phpfile>) for any roles that + contain php script files. These files are analyzed at package time, possibly + catching errors before release. For all other cases, it should be an empty tag + (<phpfile/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.executable"> - <title>The 'executable' index</title> + <title>The <executable> tag</title> <para> - This index should be used for roles like the "script" role that should have + This tag should be set to 1 (<executable>1</executable>) for roles + like the "script" role that should have their executable attribute set via <function>chmod</function> on install. + For all other cases, it should be an empty tag (<executable/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.phpextension"> - <title>The 'phpextension' index</title> + <title>The <phpextension> tag</title> <para> - This index should be used for roles like the "ext" role that provide a + This tag should be used for roles like the "ext" role that provide a binary PHP extension. + To specify this value, use + <phpextension>1</phpextension> + For all other cases, it should be an empty tag (<phpextension/>) + </para> + </sect2> + <sect2 id="guide.migrating.customroles.defining.config-vars"> + <title>The optional <config_vars> tag</title> + <para> + This tag is used to define configuration variables that should be added + to the installer by this custom file role. Note that the installer will + not allow a custom file role to create more than 3 configuration variables. + To define configuration variables, create tags with the name of the configuration + variable, and then sub-tags defining information about the configuration variable. + </para> + <para> + These tags are transformed into the PHP array format expected by the PEAR_Config + class using an adapted version of Stephan Schmidt's excellent + <classname>XML_Unserializer</classname> class (from the XML_Serializer package). + As such, it is easiest to understand the XML format by examining existing + configuration variables. + </para> + <para> + <programlisting role="php"> + <![CDATA[ + array( + 'password' => array( + 'type' => 'password', + 'default' => '', + 'doc' => '(maintainers) your PEAR account password', + 'prompt' => 'PEAR password (for maintainers)', + 'group' => 'Maintainers', + ), + // Advanced + 'verbose' => array( + 'type' => 'integer', + 'default' => PEAR_CONFIG_DEFAULT_VERBOSE, + 'doc' => 'verbosity level +0: really quiet +1: somewhat quiet +2: verbose +3: debug', + 'prompt' => 'Debug Log Level', + 'group' => 'Advanced', + ), + 'preferred_state' => array( + 'type' => 'set', + 'default' => PEAR_CONFIG_DEFAULT_PREFERRED_STATE, + 'doc' => 'the installer will prefer releases with this state when installing packages without a version or state specified', + 'valid_set' => array( + 'stable', 'beta', 'alpha', 'devel', 'snapshot'), + 'prompt' => 'Preferred Package State', + 'group' => 'Advanced', + ), + ); + ]]> + </programlisting> + </para> + <para> + These sample configuration values from the actual PEAR_Config class would + translate into this XML: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ +<config_vars> + <password> + <type>password</type> + <default /> + <doc>(maintainers) your PEAR account password'</doc> + <prompt>PEAR password (for maintainers)</prompt> + <group>Maintainers</group> + </password> + <verbose> + <type>integer</type> + <default><constant>PEAR_CONFIG_DEFAULT_VERBOSE</constant></default> + <doc>verbosity level +0: really quiet +1: somewhat quiet +2: verbose +3: debug</doc> + <prompt>Debug Log Level</prompt> + <group>Advanced</group> + </verbose> + <preferred_state> + <type>set</type> + <default><constant>PEAR_CONFIG_DEFAULT_PREFERRED_STATE</constant></default> + <doc>the installer will prefer releases with this state when installing packages without a version or state specified</doc> + <valid_set>stable</valid_set> + <valid_set>beta</valid_set> + <valid_set>alpha</valid_set> + <valid_set>devel</valid_set> + <valid_set>snapshot</valid_set> + <prompt>Preferred Package State</prompt> + <group>Advanced</group> + </preferred_state> +</config_vars> + ]]> + </programlisting> + </para> + <para> + Note that the simple array defining the set converts each value into a + separate <valid_set> tag for the preferred_state configuration variable. + </para> + <para> + The <default> tag's value can accept either a simple string, or + three different kinds of tags: + <itemizedlist> + <listitem> + <para> + <text> - this will be converted into a PHP string + </para> + </listitem> + <listitem> + <para> + <constant> - the contents of this sub-tag will be used to retrieve + the value of a pre-defined PHP constant, or a pre-defined PEAR constant + (as defined in PEAR_Config or PEAR_Common) and substitute the value for + the <constant> tag. + </para> + </listitem> + <listitem> + <para> + any default configuration variable. These include default_channel, + preferred_mirror, remote_config, auto_discover, master_server, + http_proxy, php_dir, ext_dir, doc_dir, bin_dir, data_dir, + test_dir, cache_dir, php_bin, username, password, verbose, + preferred_state, umask, cache_ttl, sig_type, sig_bin, sig_keyid, + and sig_keydir. + </para> + <para> + when used, the configuration variable should simply be an empty tag like + <php_dir/>. The tag will be replaced with the <emphasis>default</emphasis> + value of the configuration variable, <emphasis>not</emphasis> the currently + assigned value. + </para> + </listitem> + </itemizedlist> + </para> + <para> + For instance, this example default value: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ + <default><text0>hi there </text0><constant>PHP_OS</constant><text1> user, your default php_dir is </text1><php_dir/></default> + ]]> + </programlisting> + </para> + <para> + might convert into something like "hi there Linux user, your default php_dir is + /usr/local/lib/php/pear". + </para> + <para> + Our example Chiarafoo role's foo_dir default value: + <programlisting role="xml"> + <![CDATA[ + <default><php_dir/><constant>DIRECTORY_SEPARATOR</constant><text>Foo</text></default> + ]]> + </programlisting> + </para> + <para> + might convert into something like "/usr/local/lib/php/Foo" or + "C:\php5\pear\Foo". + </para> + <para> + Note that in order to use multiple <constant> or <text> tags, + you must append a numbered suffix as in the <text0> <text1> example above. + Only one PEAR configuration variable may be used per default value. + </para> + <para> + Note that if you use <type>integer</type>, no matter what default value + is specified, it will be casted into an integer by PEAR_Config. </para> </sect2> </sect1>
http://cvs.php.net/diff.php/peardoc/en/guide/migrating/customroles.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/en/guide/migrating/customroles.xml diff -u peardoc/en/guide/migrating/customroles.xml:1.3 peardoc/en/guide/migrating/customroles.xml:1.4 --- peardoc/en/guide/migrating/customroles.xml:1.3 Wed Apr 6 22:21:50 2005 +++ peardoc/en/guide/migrating/customroles.xml Thu Nov 3 00:06:52 2005 @@ -1,15 +1,24 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <chapter id="guide.migrating.customroles"> <chapterinfo> <author> <firstname>Gregory</firstname> <surname>Beaver</surname> </author> - <date>$Date: 2005/04/07 02:21:50 $</date> + <date>$Date: 2005/11/03 05:06:52 $</date> </chapterinfo> <title>Custom File Roles</title> + <warning> + <simpara> + As of PEAR version 1.4.3, the required format for custom file roles has been + changed due to a minor security vulnerability. All custom file roles must + now define a <filename>Role.xml</filename> file in order to properly declare + a custom file role. See the example below for more information. + </simpara> + </warning> + <simpara> One of the programming features that the PEAR installer enforces is the separation of files into separate categories, and the important idea that files of a similar @@ -86,6 +95,7 @@ </notes> <contents> <dir name="/" baseinstalldir="PEAR/Installer/Role"> + <file name="Chiarafoo.xml" role="php"/> <file name="Chiarafoo.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info"/> </file> @@ -94,11 +104,10 @@ <dependencies> <required> <php> - <min>4.2</min> - <max>6.0.0</max> + <min>4.2.0</min> </php> <pearinstaller> - <min>1.4.0a9</min> + <min>1.4.3</min> </pearinstaller> </required> </dependencies> @@ -108,7 +117,35 @@ </programlisting> </para> <para> - The script itself in Chiarafoo.php should be similar to this script: + The XML file Chiarafoo.xml should be similar to this file: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ +<role version="1.0"> + <releasetypes>php</releasetypes> + <installable>1</installable> + <locationconfig>foo_dir</locationconfig> + <honorsbaseinstall>1</honorsbaseinstall> + <unusualbaseinstall /> + <phpfile>1</phpfile> + <executable /> + <phpextension /> + <config_vars> + <foo_dir> + <type>directory</type> + <default><php_dir/><constant>DIRECTORY_SEPARATOR</constant><text>Foo</text></default> + <doc>directory where foo files are installed</doc> + <prompt>PHP foo directory</prompt> + <group>File Locations</group> + </foo_dir> + </config_vars> +</role> + ]]> + </programlisting> + </para> + <para> + The script in Chiarafoo.php is incredibly simple: </para> <para> <programlisting role="php"> @@ -130,7 +167,7 @@ * @author Greg Beaver <cellog@php.net> * @copyright 2005 Greg Beaver * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: customroles.xml,v 1.3 2005/04/07 02:21:50 cellog Exp $ + * @version CVS: $Id: customroles.xml,v 1.4 2005/11/03 05:06:52 cellog Exp $ * @link http://pear.chiaraquartet.net/index.php?package=Chiarafoo * @since File available since Release 0.1.0 */ @@ -147,55 +184,15 @@ */ class PEAR_Installer_Role_Chiarafoo extends PEAR_Installer_Role_Common { - var $_setup = - array( - 'releasetypes' => array('php'), - 'installable' => true, - 'locationconfig' => 'foo_dir', - 'honorsbaseinstall' => true, - 'unusualbaseinstall' => false, // required as of PEAR 1.4.0a11 - 'phpfile' => true, - 'executable' => false, - 'phpextension' => false, - ); - function getInfo() - { - return array( - 'releasetypes' => array('php'), - 'installable' => true, - 'locationconfig' => 'foo_dir', - 'honorsbaseinstall' => true, - 'unusualbaseinstall' => false, // required as of PEAR 1.4.0a11 - 'phpfile' => true, - 'executable' => false, - 'phpextension' => false, - ); - } - - function setup(&$installer, $pkg, $atts, $file) - { - } - /** - * This method is called upon instantiating a PEAR_Config object. - * - * This method MUST an array of information for all new configuration - * variables required by the file role. addConfigVar() expects an array of - * configuration information that is identical to what is used internally in PEAR_Config - * @access protected - * @param PEAR_Config + * @param PEAR_Installer + * @param PEAR_PackageFile_v2 + * @param array file attributes + * @param string relative path to file in package.xml */ - function getSupportingConfigVars() + function setup(&$installer, $pkg, $atts, $file) { - return array( - 'foo_dir' => array( - 'type' => 'directory', - 'default' => PEAR_CONFIG_DEFAULT_PHP_DIR . DIRECTORY_SEPARATOR . 'Foo', - 'doc' => 'directory where foo files are installed', - 'prompt' => 'PHP foo directory', - 'group' => 'File Locations', - ), - ); + // do something special with the installer } } ?> @@ -203,60 +200,63 @@ </programlisting> </para> <para> - Both <varname>$_setup</varname> and <function>getInfo</function> are required for all - roles. <function>getSupportingConfigVars</function> is only required if the custom role - needs to process differing configuration roles to do a successful installation. + Since PEAR 1.4.3, nothing else is necessary for a successful implementation of a file + role. </para> <para> - The contents of the <varname>$_setup</varname> and the array returned from - <function>getInfo</function> must contain all of these indices: + The contents of the role's XML file must contain these tags: <itemizedlist> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.releasetypes">releasetypes</link> + <link linkend="guide.migrating.customroles.defining.releasetypes"><releasetypes></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.installable">installable</link> + <link linkend="guide.migrating.customroles.defining.installable"><installable></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.locationconfig">locationconfig</link> + <link linkend="guide.migrating.customroles.defining.locationconfig"><locationconfig></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.honorsbaseinstall">honorsbaseinstall</link> + <link linkend="guide.migrating.customroles.defining.honorsbaseinstall"><honorsbaseinstall></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.unusualbaseinstall">unusualbaseinstall</link> (PEAR 1.4.0a11+) + <link linkend="guide.migrating.customroles.defining.unusualbaseinstall"><unusualbaseinstall></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.phpfile">phpfile</link> + <link linkend="guide.migrating.customroles.defining.phpfile"><phpfile></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.executable">executable</link> + <link linkend="guide.migrating.customroles.defining.executable"><executable></link> </para> </listitem> <listitem> <para> - <link linkend="guide.migrating.customroles.defining.phpextension">phpextension</link> + <link linkend="guide.migrating.customroles.defining.phpextension"><phpextension></link> + </para> + </listitem> + <listitem> + <para> + <link linkend="guide.migrating.customroles.defining.config-vars">(optional) <config_vars></link> </para> </listitem> </itemizedlist> </para> <sect2 id="guide.migrating.customroles.defining.releasetypes"> - <title>The 'releasetypes' index</title> + <title>The <releasetypes> tag</title> <para> - This index must be one of: + This tag can only contain one of the following values: </para> <para> <itemizedlist> @@ -278,51 +278,67 @@ </itemizedlist> </para> <para> + In order to specify compatibility with multiple release types, use multiple + <releasetypes> tags as in: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ + <releasetypes>php</releasetypes> + <releasetypes>extsrc</releasetypes> + <releasetypes>extbin</releasetypes> + ]]> + </programlisting> + </para> + <para> releasetypes defines the kind of releases that this role can be used in. For instance, the "src" role is reserved for extsrc packages, and cannot be used in regular PEAR-style php releases. The "data" role can be used in any release, and would - define releasetypes as: + define <releasetypes> as: </para> <para> <programlisting role="php"> <![CDATA[ -array('releasetypes' => array('php', 'extsrc', 'extbin'), // etc.); + <releasetypes>php</releasetypes> + <releasetypes>extsrc</releasetypes> + <releasetypes>extbin</releasetypes> ]]> </programlisting> </para> </sect2> <sect2 id="guide.migrating.customroles.defining.installable"> - <title>The 'installable' index</title> + <title>The <installable> tag</title> <para> - This index must be either &true; or &false; and determines whether files utilizing + This tag must be either <installable>1</installable> or empty + (<installable/>) and determines whether files utilizing this custom role can be installed. Any file that should be installed must set this to - true. Only roles such as the "src" role that is processed and used to create - the files that are eventually installed should set this to &false; + 1. Only roles such as the "src" role that is processed and used to create + the files that are eventually installed should set this to an empty tag. </para> </sect2> <sect2 id="guide.migrating.customroles.defining.locationconfig"> - <title>The 'locationconfig' index</title> + <title>The <locationconfig> tag</title> <para> - This index is used for all installable files to determine which configuration variable + This tag is used for all installable files to determine which configuration variable contains the directory in which the file should be installed. For instance, the php role uses the "php_dir" locationconfig, the data role uses "data_dir". </para> <para> - Our example role, chiarafoo, uses the "foo_dir" configuration variable, and then - through the definition of <function>getSupportingConfigVars</function>, tells the installer - what foo_dir means. Note that once a custom role is installed, the user can config-set/ + Our example role, chiarafoo, uses the "foo_dir" configuration variable, + and then through the definition of <config_vars> tells the installer what + foo_dir means. Note that once a custom role is installed, the user can config-set/ config-get/config-show the variable just like any other configuration variable! </para> <para> - <function>getSupportingConfigVars</function> can define more than one configuration + <config_vars> can define more than one configuration variable, but note that more than 3 variables will trigger an error, disallowing any of them, as a security precaution. </para> </sect2> <sect2 id="guide.migrating.customroles.defining.honorsbaseinstall"> - <title>The 'honorsbaseinstall' index</title> + <title>The <honorsbaseinstall> tag</title> <para> - This index controls whether a role reacts to the "baseinstalldir" attribute + This tag controls whether a role reacts to the "baseinstalldir" attribute of a <file> or <dir> tag. Any role that honors baseinstalldir can potentially allow conflicting files from different packages, and so a check has to be made. A file role that does not honor baseinstalldir is always installed into: @@ -330,37 +346,220 @@ <para> <filename>Packagename/full/path/from/contents/file.ext</filename> </para> + <para> + To specify this value, use + <honorsbaseinstall>1</honorsbaseinstall> + For all other cases, it should be an empty tag (<honorsbaseinstall/>) + </para> </sect2> <sect2 id="guide.migrating.customroles.defining.unusualbaseinstall"> - <title>The 'unusualbaseinstall' index</title> + <title>The <unusualbaseinstall> tag</title> <para> - This index controls whether a role that would normally ignore the + This tag controls whether a role that would normally ignore the "baseinstalldir" attribute of a <file> or <dir> tag would honor it, but still use the <filename>Packagename/baseinstalldir/full/path/from/contents/file.ext</filename> instead of <filename>baseinstalldir/full/path/from/contents/file.ext</filename>. Any role that supports the unusual baseinstalldir type cannot conflict with other files because the - package name is always the parent directory. + package name is always the parent directory. To specify this value, use + <unusualbaseinstall>1</unusualbaseinstall> + For all other cases, it should be an empty tag (<unusualbaseinstall/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.phpfile"> - <title>The 'phpfile' index</title> + <title>The <phpfile> tag</title> <para> - This index should be used for any roles that contain php script files. These files - are analyzed at package time, possibly catching errors before release. + This tag should be set to 1 (<phpfile>1</phpfile>) for any roles that + contain php script files. These files are analyzed at package time, possibly + catching errors before release. For all other cases, it should be an empty tag + (<phpfile/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.executable"> - <title>The 'executable' index</title> + <title>The <executable> tag</title> <para> - This index should be used for roles like the "script" role that should have + This tag should be set to 1 (<executable>1</executable>) for roles + like the "script" role that should have their executable attribute set via <function>chmod</function> on install. + For all other cases, it should be an empty tag (<executable/>) </para> </sect2> <sect2 id="guide.migrating.customroles.defining.phpextension"> - <title>The 'phpextension' index</title> + <title>The <phpextension> tag</title> <para> - This index should be used for roles like the "ext" role that provide a + This tag should be used for roles like the "ext" role that provide a binary PHP extension. + To specify this value, use + <phpextension>1</phpextension> + For all other cases, it should be an empty tag (<phpextension/>) + </para> + </sect2> + <sect2 id="guide.migrating.customroles.defining.config-vars"> + <title>The optional <config_vars> tag</title> + <para> + This tag is used to define configuration variables that should be added + to the installer by this custom file role. Note that the installer will + not allow a custom file role to create more than 3 configuration variables. + To define configuration variables, create tags with the name of the configuration + variable, and then sub-tags defining information about the configuration variable. + </para> + <para> + These tags are transformed into the PHP array format expected by the PEAR_Config + class using an adapted version of Stephan Schmidt's excellent + <classname>XML_Unserializer</classname> class (from the XML_Serializer package). + As such, it is easiest to understand the XML format by examining existing + configuration variables. + </para> + <para> + <programlisting role="php"> + <![CDATA[ + array( + 'password' => array( + 'type' => 'password', + 'default' => '', + 'doc' => '(maintainers) your PEAR account password', + 'prompt' => 'PEAR password (for maintainers)', + 'group' => 'Maintainers', + ), + // Advanced + 'verbose' => array( + 'type' => 'integer', + 'default' => PEAR_CONFIG_DEFAULT_VERBOSE, + 'doc' => 'verbosity level +0: really quiet +1: somewhat quiet +2: verbose +3: debug', + 'prompt' => 'Debug Log Level', + 'group' => 'Advanced', + ), + 'preferred_state' => array( + 'type' => 'set', + 'default' => PEAR_CONFIG_DEFAULT_PREFERRED_STATE, + 'doc' => 'the installer will prefer releases with this state when installing packages without a version or state specified', + 'valid_set' => array( + 'stable', 'beta', 'alpha', 'devel', 'snapshot'), + 'prompt' => 'Preferred Package State', + 'group' => 'Advanced', + ), + ); + ]]> + </programlisting> + </para> + <para> + These sample configuration values from the actual PEAR_Config class would + translate into this XML: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ +<config_vars> + <password> + <type>password</type> + <default /> + <doc>(maintainers) your PEAR account password'</doc> + <prompt>PEAR password (for maintainers)</prompt> + <group>Maintainers</group> + </password> + <verbose> + <type>integer</type> + <default><constant>PEAR_CONFIG_DEFAULT_VERBOSE</constant></default> + <doc>verbosity level +0: really quiet +1: somewhat quiet +2: verbose +3: debug</doc> + <prompt>Debug Log Level</prompt> + <group>Advanced</group> + </verbose> + <preferred_state> + <type>set</type> + <default><constant>PEAR_CONFIG_DEFAULT_PREFERRED_STATE</constant></default> + <doc>the installer will prefer releases with this state when installing packages without a version or state specified</doc> + <valid_set>stable</valid_set> + <valid_set>beta</valid_set> + <valid_set>alpha</valid_set> + <valid_set>devel</valid_set> + <valid_set>snapshot</valid_set> + <prompt>Preferred Package State</prompt> + <group>Advanced</group> + </preferred_state> +</config_vars> + ]]> + </programlisting> + </para> + <para> + Note that the simple array defining the set converts each value into a + separate <valid_set> tag for the preferred_state configuration variable. + </para> + <para> + The <default> tag's value can accept either a simple string, or + three different kinds of tags: + <itemizedlist> + <listitem> + <para> + <text> - this will be converted into a PHP string + </para> + </listitem> + <listitem> + <para> + <constant> - the contents of this sub-tag will be used to retrieve + the value of a pre-defined PHP constant, or a pre-defined PEAR constant + (as defined in PEAR_Config or PEAR_Common) and substitute the value for + the <constant> tag. + </para> + </listitem> + <listitem> + <para> + any default configuration variable. These include default_channel, + preferred_mirror, remote_config, auto_discover, master_server, + http_proxy, php_dir, ext_dir, doc_dir, bin_dir, data_dir, + test_dir, cache_dir, php_bin, username, password, verbose, + preferred_state, umask, cache_ttl, sig_type, sig_bin, sig_keyid, + and sig_keydir. + </para> + <para> + when used, the configuration variable should simply be an empty tag like + <php_dir/>. The tag will be replaced with the <emphasis>default</emphasis> + value of the configuration variable, <emphasis>not</emphasis> the currently + assigned value. + </para> + </listitem> + </itemizedlist> + </para> + <para> + For instance, this example default value: + </para> + <para> + <programlisting role="xml"> + <![CDATA[ + <default><text0>hi there </text0><constant>PHP_OS</constant><text1> user, your default php_dir is </text1><php_dir/></default> + ]]> + </programlisting> + </para> + <para> + might convert into something like "hi there Linux user, your default php_dir is + /usr/local/lib/php/pear". + </para> + <para> + Our example Chiarafoo role's foo_dir default value: + <programlisting role="xml"> + <![CDATA[ + <default><php_dir/><constant>DIRECTORY_SEPARATOR</constant><text>Foo</text></default> + ]]> + </programlisting> + </para> + <para> + might convert into something like "/usr/local/lib/php/Foo" or + "C:\php5\pear\Foo". + </para> + <para> + Note that in order to use multiple <constant> or <text> tags, + you must append a numbered suffix as in the <text0> <text1> example above. + Only one PEAR configuration variable may be used per default value. + </para> + <para> + Note that if you use <type>integer</type>, no matter what default value + is specified, it will be casted into an integer by PEAR_Config. </para> </sect2> </sect1>