Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unified package script generator

git-svn-id: http://svn.php.net/repository/pear/packages/Net_Growl/trunk@323451 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit f752969292d8a9ce02fe144abaf023d038de7dce 1 parent 75dbd6a
Laurent Laville authored
Showing with 222 additions and 73 deletions.
  1. +59 −0 package.ini
  2. +163 −73 package.php
View
59 package.ini
@@ -0,0 +1,59 @@
+; Configuration for Net_Growl package
+;
+; SVN: $Id$
+;
+[options]
+baseinstalldir = "/"
+filelistgenerator = file
+simpleoutput = true
+clearcontents = false
+changelogoldtonew = false
+
+ignores[] = package.ini
+ignores[] = *.log
+ignores[] = Thumbs.db
+ignores[] = docs/js/*.js
+ignores[] = docs/styles/*.css
+ignores[] = phpunit.xml
+
+exceptions[] = README.txt, doc
+exceptions[] = build-phing.xml, doc
+exceptions[] = local.win.properties, doc
+
+[package]
+name = Net_Growl
+summary = Send notifications to Growl from PHP on MACOSX and WINDOWS
+desc = "Growl is a MACOSX application that listen to notifications sent by
+applications and displays them on the desktop using different display
+styles. Net_Growl offers the possibility to send notifications to Growl
+from your PHP application through network communication using UDP.
+"
+license = "BSD License, http://www.opensource.org/licenses/bsd-license.php"
+version = 2.5.1
+version.api = 2.5.0
+stability.release = stable
+stability.api = stable
+
+authors[] = "Laurent Laville, farell, pear@laurent-laville.org"
+authors[] = "Bertrand Mansion, mansion, bmansion@mamasam.com, inactive"
+helpers[] = "Brian Dunnington, <brian>, Brian Dunnington@gmail.com"
+contributors[] = "Takeshi Kawamoto, ariela, yuki@transrain.net"
+
+channel = pear.php.net
+notes = "
+QA release
+
+Additions and changes:
+- adds required mbstring extension but missing in package xml file
+- upgrade PEAR installer to version 1.9.4
+
+Bug fixes:
+- none
+"
+
+[require]
+php = 5.2.0
+pearinstaller = 1.9.4
+ext/pcre =
+ext/spl =
+ext/mbstring =
View
236 package.php
@@ -1,83 +1,173 @@
<?php
+/**
+ * Unified package script generator.
+ *
+ * Build PEAR package easily, quickly.
+ * Its own package.ini file looks simple enough to edit and maintain.
+ *
+ * Credits to https://github.com/c9s/Onion
+ *
+ * PHP version 5
+ *
+ * @category Networking
+ * @package Net_Growl
+ * @author Laurent Laville <pear@laurent-laville.org>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version SVN: $Id$
+ * @link http://growl.laurent-laville.org/
+ * @link http://pear.php.net/package/Net_Growl
+ */
+
require_once 'PEAR/PackageFileManager2.php';
+/**
+ * Build list of a category of maintainer
+ *
+ * @param array $authors Maintainers list
+ * @param string $type Maintainer category (lead, helper, contributor)
+ * @param object $pfm Instance of PEAR_PackageFileManager2
+ *
+ * @return void
+ */
+function addMaintainer($authors, $type, $pfm)
+{
+ // author info: {name}, {userid} [, {email} [, {inactive}]]
+ foreach ($authors as $author) {
+ $matches = explode(',', $author);
+ if (count($matches) > 1) {
+ $matches = array_map('trim', $matches);
+ $active = 'yes';
+ if (isset($matches[3])) {
+ $active = ($matches[3] === 'inactive') ? 'no' : $active;
+ }
+ $email = (isset($matches[2])) ? $matches[2] : '';
+ $pfm->addMaintainer($type, $matches[1], $matches[0], $email, $active);
+ }
+ }
+}
+
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'package.ini';
+if (!file_exists($filename)) {
+ echo 'Configuration file "package.ini" does not exist';
+ exit(1);
+}
+
+$ini = parse_ini_file($filename, true);
+
+if ($ini === false) {
+ echo 'Cannot parse configuration file "package.ini"';
+ exit(1);
+}
+
+//print_r($ini); exit();
+
PEAR::setErrorHandling(PEAR_ERROR_DIE);
-$p2 = new PEAR_PackageFileManager2();
-
-$name = 'Net_Growl';
-$summary = 'Send notifications to Growl from PHP on MACOSX and WINDOWS';
-$description = 'Growl is a MACOSX application that listen to notifications sent by
-applications and displays them on the desktop using different display
-styles. Net_Growl offers the possibility to send notifications to Growl
-from your PHP application through network communication using UDP.
-';
-$channel = 'pear.php.net';
-
-$release_state = 'stable';
-$release_version = '2.5.0';
-
-$api_state = 'stable';
-$api_version = '2.5.0';
-$release_notes = "
-Additions and changes:
-- Update Net_Growl::getDefaultGrowlIcon() method to return either
-old or new Growl claw icons to match Mac icon.
-- Use PHPUnit/Autoload.php instead of requiring the files manually.
-- phing build documentation script is now easily reuseable (configuration through an external properties file)
-
-Bug fixes:
-- Require the autoloader in the test files so the class files will be found (Daniel Convissor)
-";
-$license = array('BSD License', 'http://www.opensource.org/licenses/bsd-license.php');
-
-$p2->setOptions(array(
+$pfm = new PEAR_PackageFileManager2();
+
+// files to ignore
+if (isset($ini['options']['ignores'])) {
+ $ignores = (array)$ini['options']['ignores'];
+} else {
+ $ignores = array();
+}
+$ignores[] = basename(__FILE__);
+
+// files mapping exception
+$exceptions = array();
+
+if (isset($ini['options']['exceptions'])) {
+ foreach ($ini['options']['exceptions'] as $exception) {
+ $rule = explode(',', $exception);
+
+ if (count($rule)) {
+ list($file, $role) = array_map('trim', $rule);
+ $exceptions[$file] = $role;
+ }
+ }
+}
+
+$options = array(
'packagedirectory' => dirname(__FILE__),
- 'baseinstalldir' => '/',
- 'filelistgenerator' => 'file',
- 'simpleoutput' => true,
- 'clearcontents' => false,
- 'changelogoldtonew' => false,
- 'ignore' => array(basename(__FILE__),
- '*.tgz', '*.log', '*.html', '*.pdf', '*.chm', '*.zip',
- 'icon.php', 'Thumbs.db', 'docs/js/*.js', 'docs/styles/*.css'
- ),
- 'exceptions' => array('README.txt' => 'doc',
- 'build-phing.xml' => 'doc', 'local.win.properties' => 'doc'
- ),
- ));
-
-$p2->setPackage($name);
-$p2->setChannel($channel);
-$p2->setSummary($summary);
-$p2->setDescription($description);
-
-$p2->setPackageType('php');
-$p2->setReleaseVersion($release_version);
-$p2->setReleaseStability($release_state);
-$p2->setAPIVersion($api_version);
-$p2->setAPIStability($api_state);
-$p2->setNotes($release_notes);
-$p2->setLicense($license[0], $license[1]);
-
-$p2->setPhpDep('5.2.0');
-$p2->setPearinstallerDep('1.5.4');
-
-$p2->addExtensionDep('required', 'pcre');
-$p2->addExtensionDep('required', 'spl');
-
-$p2->addMaintainer('lead', 'farell', 'Laurent Laville', 'pear@laurent-laville.org');
-$p2->addMaintainer('lead', 'mansion', 'Bertrand Mansion', 'bmansion@mamasam.com', 'no');
-$p2->addMaintainer('helper', '<brian>', 'Brian Dunnington', 'Brian Dunnington@gmail.com');
-$p2->addMaintainer('contributor', 'ariela', 'Takeshi Kawamoto', 'yuki@transrain.net');
-
-$p2->addGlobalReplacement('package-info', '@package_version@', 'version');
-
-$p2->generateContents();
+ 'baseinstalldir' => $ini['options']['baseinstalldir'],
+ 'filelistgenerator' => $ini['options']['filelistgenerator'],
+ 'simpleoutput' => $ini['options']['simpleoutput'],
+ 'clearcontents' => $ini['options']['clearcontents'],
+ 'changelogoldtonew' => $ini['options']['changelogoldtonew'],
+ 'ignore' => $ignores,
+ 'exceptions' => $exceptions,
+);
+$pfm->setOptions($options);
+
+$pfm->setPackage($ini['package']['name']);
+$pfm->setChannel($ini['package']['channel']);
+$pfm->setSummary($ini['package']['summary']);
+$pfm->setDescription($ini['package']['desc']);
+
+$pfm->setPackageType('php');
+$pfm->setReleaseVersion($ini['package']['version']);
+$pfm->setReleaseStability($ini['package']['stability.release']);
+$pfm->setAPIVersion($ini['package']['version.api']);
+$pfm->setAPIStability($ini['package']['stability.api']);
+$pfm->setNotes($ini['package']['notes']);
+
+// default license
+$license = array('PHP', false);
+
+if (isset($ini['package']['license'])) {
+ // license info: {license} [, {uri}]
+ $matches = explode(',', $ini['package']['license']);
+ $match = count($matches);
+ if ($match > 0) {
+ $matches = array_map('trim', $matches);
+ if ($match == 1) {
+ // without URI
+ $license = array($matches[0], false);
+ } else {
+ // with URI
+ $license = array($matches[0], $matches[1]);
+ }
+ }
+}
+$pfm->setLicense($license[0], $license[1]);
+
+$pfm->setPhpDep($ini['require']['php']);
+$pfm->setPearinstallerDep($ini['require']['pearinstaller']);
+
+// required dependencies
+if (isset($ini['require'])) {
+ $requires = array_keys($ini['require']);
+
+ foreach ($requires as $dep) {
+ if (preg_match('/ext\/(.*)/', $dep, $matches)) {
+ $pfm->addExtensionDep('required', $matches[1]);
+ }
+ }
+}
+
+// lead
+addMaintainer($ini['package']['authors'], 'lead', $pfm);
+
+// helper
+if (isset($ini['package']['helpers'])) {
+ addMaintainer($ini['package']['helpers'], 'helper', $pfm);
+}
+
+// contributor
+if (isset($ini['package']['contributors'])) {
+ addMaintainer($ini['package']['contributors'], 'contributor', $pfm);
+}
+
+// replaces
+$pfm->addGlobalReplacement('package-info', '@package_version@', 'version');
+
+// generates XML
+$pfm->generateContents();
if (isset($_GET['make'])
- || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
- $p2->writePackageFile();
+ || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')
+) {
+ $pfm->writePackageFile();
} else {
- $p2->debugPackageFile();
+ $pfm->debugPackageFile();
}
Please sign in to comment.
Something went wrong with that request. Please try again.