Permalink
Browse files

added a PEAR package file

git-svn-id: http://svn.twig-project.org/trunk@23 93ef8e89-cb99-4229-a87c-7fa0fa45744b
  • Loading branch information...
1 parent 0c98ebc commit 5b8fd1c3bd19700da4558874135c59981afff03e fabien committed Oct 12, 2009
Showing with 108 additions and 0 deletions.
  1. +45 −0 bin/create_pear_package.php
  2. +63 −0 package.xml.tpl
@@ -0,0 +1,45 @@
+<?php
+
+require_once dirname(__FILE__).'/../lib/Twig/Autoloader.php';
+Twig_Autoloader::register();
+
+if (!isset($argv[1]))
+{
+ die('You must provide the version (1.0.0)');
+}
+
+if (!isset($argv[2]))
+{
+ die('You must provide the stability (alpha, beta, or stable)');
+}
+
+$context = array(
+ 'date' => date('Y-m-d'),
+ 'time' => date('H:m:00'),
+ 'version' => $argv[1],
+ 'api_version' => $argv[1],
+ 'stability' => $argv[2],
+ 'api_stability' => $argv[2],
+);
+
+$context['files'] = '';
+$path = realpath(dirname(__FILE__).'/../lib/Twig');
+foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
+{
+ if (preg_match('/\.php$/', $file))
+ {
+ $name = str_replace($path.'/', '', $file);
+ $context['files'] .= ' <file install-as="Twig/'.$name.'" name="'.$name.'" role="php" />'."\n";
+ }
+}
+
+$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
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.8.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ 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>Twig</name>
+ <channel>pear.twig-project.org</channel>
+ <summary>Twig is a PHP template engine.</summary>
+ <description>
+ Twig is a template language for PHP, released under the new BSD license
+ (code and documentation).
+
+ Twig uses a syntax similar to the Django and Jinja template languages which
+ inspired the Twig runtime environment.
+ </description>
+ <lead>
+ <name>Fabien Potencier</name>
+ <user>fabpot</user>
+ <email>fabien.potencier@symfony-project.org</email>
+ <active>yes</active>
+ </lead>
+ <lead>
+ <name>Armin Ronacher</name>
+ <user>armin</user>
+ <email>armin.ronacher@active-4.com</email>
+ <active>no</active>
+ </lead>
+ <date>{{ date }}</date>
+ <time>{{ time }}</time>
+ <version>
+ <release>{{ version }}</release>
+ <api>{{ api_version }}</api>
+ </version>
+ <stability>
+ <release>{{ stability }}</release>
+ <api>{{ stability }}</api>
+ </stability>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
+ <notes>-</notes>
+ <contents>
+ <dir name="/">
+ <file name="AUTHORS" role="doc" />
+ <file name="LICENSE" role="doc" />
+ <file name="README.markdown" role="doc" />
+ <dir name="lib">
+ <dir name="Twig">
+{{ files }}
+ </dir>
+ </dir>
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.4</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease />
+</package>

0 comments on commit 5b8fd1c

Please sign in to comment.