Permalink
Browse files

Merge pull request #147 from iarna/new-packaging

New packaging
  • Loading branch information...
2 parents cfef87b + 543c43e commit 9722da69baab2e94112a2ec5e04bd60085e73b96 @aredridel aredridel committed Apr 30, 2012
Showing with 296 additions and 349 deletions.
  1. +1 −0 .gitignore
  2. +27 −7 Makefile
  3. +1 −1 Modyllic/CommandLine.php
  4. +47 −0 base.xml
  5. +137 −0 build-package-xml
  6. +0 −317 package.xml
  7. +64 −11 release-version
  8. +19 −13 test/General_Functional.t
View
@@ -7,3 +7,4 @@ pear.php
*.diff
test.php
PEAR*.tgz
+package.xml
View
@@ -2,22 +2,42 @@ CWD := $(shell pwd)
PHP_INCLUDE_PATH := $(shell echo '<?php echo get_include_path();'|php)
PHP := 'php -d include_path="$(CWD):$(PHP_INCLUDE_PATH)"'
PROVE := prove -r --exec $(PHP)
+PACKAGEXML := base.xml
+BUILDXML := package.xml
+BUILDVAL := $(BUILDXML).validate
default:
-.PHONY: test test-verbose package-validate install uninstall
+.PHONY: test test-verbose package-validate install uninstall clean build-package-xml discover-channel
-install:
- pear channel-discover onlinebuddies.github.com/pear ; pear install package.xml
+clean:
+ rm $BUILDXML $BUILDXML.validate
+
+build-package-xml:
+ php build-package-xml $(PACKAGEXML) $(BUILDXML)
+
+discover-channel:
+ pear channel-discover onlinebuddies.github.com/pear || true
+
+install-build-prereqs: discover-channel
+ pear install OnlineBuddies/PEAR_PackageFileManager_Gitrepoonly
+
+install: build-package-xml discover-channel uninstall
+ pear install $(BUILDXML)
uninstall:
pear uninstall OnlineBuddies/Modyllic
-package-validate:
- @pear package-validate package.xml | egrep -v 'Analyzing|Validation' > pvout ; grep ^Warning: pvout ; if grep ^Error: pvout; then rm pvout; exit 1; else rm pvout; exit 0; fi
+package: build-package-xml
+ pear package $(BUILDXML)
+
+package-validate: build-package-xml
+ pear package-validate $(BUILDXML) | egrep -v 'Analyzing|Validation' > $(BUILDVAL)
+ grep ^Warning: $(BUILDVAL) || true
+ if grep ^Error: $(BUILDVAL); then exit 1; else exit 0; fi
test: package-validate
- $(PROVE) test
+ $(PROVE) tests
test-verbose: package-validate
- $(PROVE) -v test
+ $(PROVE) -v tests
View
@@ -45,7 +45,7 @@ static function display_error( $msg ) {
static function get_args( $arg_spec ) {
global $argv;
if ( in_array("--version",$argv) ) {
- fputs(STDERR,"Modyllic Version: 0.1.8 alpha\n");
+ fputs(STDERR,"Modyllic Version: @VERSION@ @STATE@\n");
exit();
}
$parser = self::get_parser();
View
@@ -0,0 +1,47 @@
+<package packagerversion="1.9.4" 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>Modyllic</name>
+ <channel>onlinebuddies.github.com/pear</channel>
+ <summary>Schema management and DDL diff</summary>
+ <description>Modyllic, PHP SQL Parser and schema management tool</description>
+ <lead>
+ <name>Online Buddies, Inc</name>
+ <user>olb</user>
+ <!-- Possibly not the best email address to use here -->
+ <email>development@online-buddies.com</email>
+ <active>yes</active>
+ </lead>
+ <date>9999-01-01</date>
+ <time>00:00:00</time>
+ <version>
+ <release>0.1.8</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
+ <notes>...</notes>
+ <contents>
+ <dir name="/"/>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+ <package>
+ <name>Console_CommandLine</name>
+ <channel>pear.php.net</channel>
+ <min>1.1.3</min>
+ </package>
+ </required>
+ </dependencies>
+ <phprelease/>
+</package>
View
@@ -0,0 +1,137 @@
+#!/usr/bin/env php
+<?php
+if ( $argc < 3 or $argc > 5 ) {
+ fputs(STDERR, "Form: {$argv[0]} input.xml output.xml [version [state]]\n");
+ fputs(STDERR, "Ex: {$argv[0]} base.xml package.xml 1.0.0 beta\n");
+ exit(1);
+}
+@list($program,$input,$output,$version,$state) = $argv;
+
+// Load a list of all of our tagged releases thus far
+$prev_versions = array();
+foreach (explode("\n",trim(`git for-each-ref --sort='-refname' --format='%(refname:short) %(authordate:short)' refs/tags/v*.*.*`)) as $tag) {
+ list($tag_name,$tag_date) = explode(" ",$tag);
+ $tag_version = substr($tag_name,1);
+ list($tag_major, $tag_minor, $tag_rel) = explode(".",$tag_version);
+ $prev_versions[] = array(
+ "name" => $tag_name,
+ "date" => $tag_date,
+ "version" => $tag_version,
+ "major" => $tag_major,
+ "minor" => $tag_minor,
+ "rel" => $tag_rel,
+ );
+}
+
+// PEAR can't live with strict, so make sure it's off.
+ini_set("error_reporting",E_ALL);
+
+require_once "PEAR/PackageFileManager2.php";
+
+// Load our template package.xml...
+$pfm = new PEAR_PackageFileManager2();
+$res = @$pfm->importOptions( $input );
+if ( $res instanceof PEAR_Error ) {
+ fputs(STDERR, $res->message."\n");
+ exit(1);
+}
+
+// If we weren't given a version...
+if ( ! isset($version) ) {
+ // Then this is an alpha (source build) of the next release...
+ $prev = $prev_versions[0];
+ $rel = $prev['rel'] + 1;
+ $version = "{$prev['major']}.{$prev['minor']}.{$rel}";
+ $state = "alpha";
+ // Just pull in the commit log as the changelog, no need for this to be edited
+ $log = trim(`git log --format='* %s (%aN)' {$prev['name']}.. --ancestry-path --no-merges`);
+ if ( $log == "" ) {
+ $log = trim(`git log --format='* %s (%aN)' {$prev['name']}.. --topo-order --no-merges`);
+ }
+ $res->setNotes( "NOTE: This version was built from source:\n$log" );
+}
+// If we were given a version...
+else {
+ // We get our notes from the CHANGELOG file, which will be created and edited by release-version
+ $res->setNotes( file_get_contents('CHANGELOG') );
+}
+
+// Update our options...
+$options = $res->getOptions();
+$options['clearchangelog'] = false;
+$options['filelistgenerator'] = 'gitRepoOnly'; // This does a `git ls-files` to determine the file list
+$options['baseinstalldir'] = '/';
+$options['packagedirectory'] = '.';
+$options['packagefile'] = $output;
+
+// Types for various extensions and folders
+$options['roles']['md'] = 'doc';
+$options['roles']['t'] = 'test';
+$options['dir_roles']['testlib'] = 'test';
+$options['dir_roles']['tests'] = 'test';
+
+// Don't bundle our build files
+$options['ignore'][] = 'Makefile';
+$options['ignore'][] = 'release-version';
+$options['ignore'][] = 'build-package-xml';
+
+// This includes symlinks, which PHP can't package
+$options['ignore'][] = 'test/test_schema/*';
+
+// Build nice, human readable output without MD5s
+$options['simpleoutput'] = true;
+
+$res->setOptions($options);
+$res->setAPIVersion( $version );
+$res->setReleaseVersion( $version );
+$res->setAPIStability( $state );
+$res->setReleaseStability( $state );
+
+// Add the changelogs for previous releases
+foreach ($prev_versions as $index=>$prev) {
+ $changes = trim(`git show {$prev['name']}:CHANGELOG 2> /dev/null`);
+ if ( $changes == "" ) {
+ $changes = "No changelog for this version.";
+ }
+ $stability = $prev['major'] > 0 ? "stable" : "beta";
+ $res->setChangeLogEntry( $prev['version'], array(
+ "version" => array(
+ "release" => $prev['version'],
+ "api" => $prev['version'],
+ ),
+ "stability" => array(
+ "release" => $stability,
+ "api" => $stability,
+ ),
+ "date" => $prev['date'],
+ "license" => array(
+ "attribs" => array(
+ "uri" => "http://www.opensource.org/licenses/bsd-license.php",
+ ),
+ "_content" => "BSD Style",
+ ),
+ "notes" => $changes,
+ ));
+}
+
+// These propagate the verison info to the commandline utils
+$res->addReplacement( "Modyllic/CommandLine.php", "package-info", "@VERSION@", "version" );
+$res->addReplacement( "Modyllic/CommandLine.php", "package-info", "@STATE@", "state" );
+
+// This actually produces the file list
+$res->generateContents();
+
+// All the docs and scripts should be installed without their folder name...
+foreach ( $res->getFilelist() as $name=>$info ) {
+ if ( preg_match( '{^(?:docs?/|scripts/)(.*)}', $name, $match ) ) {
+ $res->addInstallAs( $name, $match[1] );
+ }
+}
+
+print "Writing $output\n";
+@unlink($output);
+$error = $res->writePackageFile();
+if ( $error instanceof PEAR_Error ) {
+ fputs(STDERR, $error->message."\n");
+ exit(1);
+}
Oops, something went wrong.

0 comments on commit 9722da6

Please sign in to comment.