Skip to content
Browse files

Add PEAR package builder

  • Loading branch information...
1 parent 627128a commit 539dc7c287bf63112f715ec9722548edb6c7011b @rmccue committed Jun 16, 2012
Showing with 78 additions and 12 deletions.
  1. +55 −0 bin/create_pear_package.php
  2. +23 −12 package.xml → package.xml.tpl
View
55 bin/create_pear_package.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * PEAR package builder
+ *
+ * Inspired by Twig's create_pear_package.php.
+ * @link https://raw.github.com/fabpot/Twig/master/bin/create_pear_package.php
+ * @author Twig Team
+ * @license BSD license
+ */
+
+if (!isset($argv[1]) || $argv[1] === '-h' || $argv[1] === '--help') {
+ echo 'usage: php ' . $argv[0] . ' <version> <stability>' . PHP_EOL;
+ echo PHP_EOL;
+ echo ' version:' . PHP_EOL;
+ echo ' Version of the package, in the form of major.minor.bug' . PHP_EOL;
+ echo PHP_EOL;
+ echo ' stability:' . PHP_EOL;
+ echo ' One of alpha, beta, stable' . PHP_EOL;
+ die();
+}
+
+if (!isset($argv[2])) {
+ die('You must provide the stability (alpha, beta, or stable)');
+}
+
+$context = array(
+ 'date' => gmdate('Y-m-d'),
+ 'time' => gmdate('H:m:00'),
+ 'version' => $argv[1],
+ 'api_version' => $argv[1],
+ 'stability' => $argv[2],
+ 'api_stability' => $argv[2],
+);
+
+$context['files'] = '';
+$path = realpath(dirname(__FILE__).'/../library/Requests');
+foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
+ if (preg_match('/\.php$/', $file)) {
+ $name = str_replace($path . DIRECTORY_SEPARATOR, '', $file);
+ $name = str_replace(DIRECTORY_SEPARATOR, '/', $name);
+ $context['files'][] = "\t\t\t\t\t" . '<file install-as="Requests/' . $name . '" name="' . $name . '" role="php" />';
+ }
+}
+
+$context['files'] = implode("\n", $context['files']);
+
+$template = file_get_contents(dirname(__FILE__).'/../package.xml.tpl');
+$content = preg_replace_callback('/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/', 'replace_parameters', $template);
+file_put_contents(dirname(__FILE__).'/../package.xml', $content);
+
+function replace_parameters($matches) {
+ global $context;
+
+ return isset($context[$matches[1]]) ? $context[$matches[1]] : null;
+}
View
35 package.xml → package.xml.tpl
@@ -5,34 +5,45 @@
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
- <name></name>
+ <name>Requests</name>
<channel>pear.ryanmccue.info</channel>
<summary>A HTTP library written in PHP, for human beings.</summary>
<description>
- A HTTP library written in PHP, for human beings.
+ Requests is a HTTP library written in PHP, for human beings. It is
+ roughly based on the API from the excellent Requests Python library.
+ Requests is ISC Licensed (similar to the new BSD license) and has
+ no dependencies.
</description>
<lead>
- <name>Ryan Mccue</name>
+ <name>Ryan McCue</name>
<user>rmccue</user>
- <email>me plus pear at ryanmccue dot info</email>
+ <email>me+pear@ryanmccue dot info</email>
<active>yes</active>
</lead>
- <date>2012-02-08</date>
- <time>14:35:00</time>
+ <date>{{ date }}</date>
+ <time>{{ time }}</time>
<version>
- <release>1.6.0-dev</release>
- <api>1.6.0-dev</api>
+ <release>{{ version }}</release>
+ <api>{{ api_version }}</api>
</version>
<stability>
- <release>devel</release>
- <api>devel</api>
+ <release>{{ stability }}</release>
+ <api>{{ stability }}</api>
</stability>
<license uri="https://github.com/rmccue/Requests/blob/master/LICENSE" filesource="LICENSE">ISC</license>
<notes>-</notes>
<contents>
- <dir name="/">
- <!-- This needs to be updated on release -->
+ <dir name="/">
+ <file name="CHANGELOG.md" role="doc" />
+ <file name="LICENSE" role="doc" />
+ <file name="README.md" role="doc" />
+ <dir name="library">
+ <file install-as="Requests.php" name="Requests.php" role="php" />
+ <dir name="Requests">
+{{ files }}
+ </dir>
</dir>
+ </dir>
</contents>
<dependencies>
<required>

0 comments on commit 539dc7c

Please sign in to comment.
Something went wrong with that request. Please try again.