create_pear_package.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. if (!isset($argv[1]))
  3. {
  4. die('You must provide the version (1.0.0)');
  5. }
  6. if (!isset($argv[2]))
  7. {
  8. die('You must provide the stability (alpha, beta, or stable)');
  9. }
  10. $context = array(
  11. 'date' => date('Y-m-d'),
  12. 'time' => date('H:m:00'),
  13. 'version' => $argv[1],
  14. 'api_version' => $argv[1],
  15. 'stability' => $argv[2],
  16. 'api_stability' => $argv[2],
  17. );
  18. $context['files'] = '';
  19. $path = realpath(dirname(__FILE__).'/../lib/Twig');
  20. foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
  21. {
  22. if (preg_match('/\.php$/', $file))
  23. {
  24. $name = str_replace($path.'/', '', $file);
  25. $context['files'] .= ' <file install-as="Twig/'.$name.'" name="'.$name.'" role="php" />'."\n";
  26. }
  27. }
  28. $template = file_get_contents(dirname(__FILE__).'/../package.xml.tpl');
  29. $content = preg_replace_callback('/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/', 'replace_parameters', $template);
  30. file_put_contents(dirname(__FILE__).'/../package.xml', $content);
  31. function replace_parameters($matches)
  32. {
  33. global $context;
  34. return isset($context[$matches[1]]) ? $context[$matches[1]] : null;
  35. }