diff --git a/.gitignore b/.gitignore index 67cac47..ff6c051 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ vendor *.deb src/*.tgz + +tags diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..37191d5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: php +php: + - 5.6 + - 5.5 + - 5.4 + - 5.3 + +install: + - composer install + +script: vendor/bin/phpunit tests diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ba61e8c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# 0.0.13 + +## BC Breaks + + * The packager will throws a RuntimeException if the output folder already + exists and it is not empty. + +# 0.0.10 + +## BC Breaks + +## Deprecations + + * Method `mount` will be replaced by method `addMount` in the future + +# 0.0.4 + +## BC Breaks + +* Build will returns the dpkg command instead print it to the user +* Removed internal autoloader -> use composer as a default + diff --git a/README.md b/README.md index 4d0c0c7..1a88d82 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ # Debian packager (PHP) + * Develop: [![Build Status](https://travis-ci.org/wdalmut/php-deb-packager.svg?branch=develop)](https://travis-ci.org/wdalmut/php-deb-packager) + * Master : [![Build Status](https://travis-ci.org/wdalmut/php-deb-packager.svg?branch=master)](https://travis-ci.org/wdalmut/php-deb-packager) + A simple debian packager for PHP applications +Get composer: + +``` +curl -sS http://getcomposer.org/installer | php +``` + +Install dependencies and autoloader + +``` +php composer.phar install +``` + +Use it: + ```php mount("/path/to/docs", "/usr/share/docs"); //Creates folders using mount points $packager->run(); -//Creates the Debian package -$packager->build(); +//Get the Debian package command +echo $packager->build(); ``` + +**Create the Package** + +``` +$(php pack.php) +``` + ## Pre-Post scripts Optianally you can add script for different hooks @@ -45,14 +69,14 @@ Optianally you can add script for different hooks * Run pre package remove * post-remove * Run post package remove - + Adding scripts ```php $packager->setPreInstallScript(__DIR__ . '/my-pre-install-script.sh'); $packager->setPostInstallScript(__DIR__ . '/my-post-install-script.sh'); $packager->setPreRemoveScript(__DIR__ . '/my-pre-remove-script.sh'); -$packager->setPreRemoveScript(__DIR__ . '/my-post-remove-script.sh'); +$packager->setPostRemoveScript(__DIR__ . '/my-post-remove-script.sh'); ``` See a script example @@ -67,4 +91,8 @@ echo "Goodbye Cruel World" exit 0 ``` - + +## Use Yaml files instead the library directly + +Just take a look to [wdalmut/php-deb-describe](https://github.com/wdalmut/php-deb-describe) + diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..43b2961 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.13 diff --git a/composer.json b/composer.json index 008e4e5..2a85ed5 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,8 @@ { "name": "wdalmut/php-deb-packager", "description": "A simple debian packager for PHP applications", - "version":"0.0.3", "type":"library", - "keywords":["deb","packager","ubuntu","php-deb"], - "time":"2012-07-31", + "keywords":["deb","packager","ubuntu","php-deb", "debian"], "license":"MIT", "authors": [ { @@ -20,15 +18,13 @@ "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4", + "mikey179/vfsStream": "1.4.*" + }, "autoload": { "psr-0": { - "wdm": "src/" + "wdm": ["src/", "tests/"] } - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/wdalmut/php-deb-packager" - } - ] + } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..101f0e2 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1015 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "452e33232d90b29107daa9bb4740b3ea", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "mikey179/vfsStream", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/mikey179/vfsStream.git", + "reference": "61b12172292cf539685507aa65b076c1530e83c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/61b12172292cf539685507aa65b076c1530e83c1", + "reference": "61b12172292cf539685507aa65b076c1530e83c1", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "org\\bovigo\\vfs\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "homepage": "http://vfs.bovigo.org/", + "time": "2014-09-14 10:18:53" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-04-27 22:15:08" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.17", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3", + "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-05-25 05:11:59" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", + "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2015-04-02 05:19:05" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "eab81d02569310739373308137284e0158424330" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", + "reference": "eab81d02569310739373308137284e0158424330", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-04-08 04:46:07" + }, + { + "name": "phpunit/phpunit", + "version": "4.6.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", + "reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.6.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-05-25 05:18:18" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", + "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-04-02 05:36:41" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", + "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-02-22 15:13:53" + }, + { + "name": "sebastian/environment", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-02-24 06:35:25" + }, + { + "name": "symfony/yaml", + "version": "v2.6.7", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-05-02 15:18:45" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.3" + }, + "platform-dev": [] +} diff --git a/src/example.php b/example.php similarity index 85% rename from src/example.php rename to example.php index 00cd7e6..add21b4 100644 --- a/src/example.php +++ b/example.php @@ -1,6 +1,6 @@ mount(__DIR__ . "/../../diff", "/my-differ"); //Creates folders using mount points $packager->run(); -//Creates the Debian package -$packager->build(); \ No newline at end of file +//Get the Debian package command +echo $packager->build(); diff --git a/src/package.xml b/src/package.xml deleted file mode 100644 index ba88263..0000000 --- a/src/package.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - Corley_Deb_Packager - pear.corley.it - Corley DEB packager. - - This library provides mechanisms for generate valid .deb files useful - for software distribution for GNU/Linux Debian based systems. - - - Walter Dal Mut - wdalmut - walter.dalmut at corley.it - yes - - - Gabriele Mittica - gmittica - gabriele.mittica at corley.it - yes - - 2012-06-04 - - - 0.0.2 - 0.0.2 - - - alpha - alpha - - MIT - In this release the first proposal. - - - - - - - - - - - - - - - - - - 5.3.3 - - - 1.4.0 - - - - - \ No newline at end of file diff --git a/src/wdm/debian/Autoloader.php b/src/wdm/debian/Autoloader.php deleted file mode 100644 index 8b0d270..0000000 --- a/src/wdm/debian/Autoloader.php +++ /dev/null @@ -1,4 +0,0 @@ -_control; + } + /** * Pre install script * @@ -97,7 +79,15 @@ class Packager $this->_postRM = $path; } + /** + * @deprecated See addMount instead + */ public function mount($sourcePath, $destinationPath) + { + return $this->addMount($sourcePath, $destinationPath); + } + + public function addMount($sourcePath, $destinationPath) { $this->_mountPoints[$sourcePath] = $destinationPath; return $this; @@ -109,48 +99,54 @@ class Packager return $this; } + public function getOutputPath() + { + return $this->_outputPath; + } + public function run() { - if (file_exists($this->_outputPath)) { - $iterator = new \DirectoryIterator($this->_outputPath); + if (file_exists($this->getOutputPath())) { + $iterator = new \DirectoryIterator($this->getOutputPath()); foreach ($iterator as $path) { - if ($path != '.' || $path != '..') { - echo "OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!" . PHP_EOL; - exit(); + if ($path != '.' && $path != '..') { + throw new RuntimeException("OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!"); } } } - mkdir($this->_outputPath, 0777); - - foreach ($this->_mountPoints as $path => $dest) { - $this->_pathToPath($path, $this->_outputPath . DIRECTORY_SEPARATOR . $dest); + if (!file_exists($this->getOutputPath())) { + mkdir($this->getOutputPath(), 0777); } - mkdir($this->_outputPath . "/DEBIAN", 0777); + foreach ($this->_mountPoints as $path => $dest) { + $this->_pathToPath($path, $this->getOutputPath() . DIRECTORY_SEPARATOR . $dest); + } - file_put_contents($this->_outputPath . "/DEBIAN/control", (string)$this->_control); + mkdir($this->getOutputPath() . "/DEBIAN", 0777); + + file_put_contents($this->getOutputPath() . "/DEBIAN/control", (string)$this->_control); if ($this->_preInst) { - $dest = $this->_outputPath . "/DEBIAN/preinst"; + $dest = $this->getOutputPath() . "/DEBIAN/preinst"; $this->_copy($this->_preInst, $dest); chmod($dest, 0755); } if ($this->_postInst) { - $dest = $this->_outputPath . "/DEBIAN/postinst"; + $dest = $this->getOutputPath() . "/DEBIAN/postinst"; $this->_copy($this->_postInst, $dest); chmod($dest, 0755); } if ($this->_preRM) { - $dest = $this->_outputPath . "/DEBIAN/prerm"; + $dest = $this->getOutputPath() . "/DEBIAN/prerm"; $this->_copy($this->_preRM, $dest); chmod($dest, 0755); } if ($this->_postRM) { - $dest = $this->_outputPath . "/DEBIAN/postrm"; + $dest = $this->getOutputPath() . "/DEBIAN/postrm"; $this->_copy($this->_postRM, $dest); chmod($dest, 0755); } @@ -183,17 +179,32 @@ class Packager if (!file_exists($destFolder)) { mkdir($destFolder, 0777, true); } - copy($source, $dest); + if (is_link($source)) { + symlink(readlink($source), $dest); + return; // don't set perms on symlink targets + } else { + if (!copy($source, $dest)) { + echo "Error: failed to copy: $source -> $dest \m"; + return; + } + } + if (fileperms($source) != fileperms($dest)) { + chmod($dest, fileperms($source)); + } } public function build($debPackageName = false) { if (!$debPackageName) { - $debPackageName = basename($this->_outputPath . ".deb"); + $control = $this->getControl(); + $name = $control['Package']; + $version = $control['Version']; + $arch = $control['Architecture']; + $debPackageName = "{$name}_{$version}_{$arch}.deb"; } - $command = "dpkg -b {$this->_outputPath} {$debPackageName}" . PHP_EOL; + $command = "dpkg -b {$this->getOutputPath()} {$debPackageName}"; - echo $command; + return $command; } } diff --git a/src/wdm/debian/control/StandardFile.php b/src/wdm/debian/control/StandardFile.php index 71dcf8c..1817c98 100644 --- a/src/wdm/debian/control/StandardFile.php +++ b/src/wdm/debian/control/StandardFile.php @@ -1,12 +1,12 @@ - '', + 'Package' => false, 'Version' => '0.1', "Section" => "web", "Priority" => "optional", "Architecture" => "all", "Essential" => "no", - "Depends" => "", - "Pre-Depends" => "", - "Recommends" => "", - "Suggests" => "", + "Depends" => false, + "Pre-Depends" => false, + "Recommends" => false, + "Suggests" => false, "Installed-Size" => 1024, - "Maintainer" => "name [email]", - "Conflicts" => "", - "Replaces" => "", + "Maintainer" => "name ", + "Conflicts" => false, + "Replaces" => false, "Provides" => "your-company", "Description" => "Your description" ); - + public function setPackageName($name) { return $this->_setProperty("Package", $name); } - + public function setVersion($version) { return $this->_setProperty("Version", $version); } - + public function setSection($section) { return $this->_setProperty("Section", $section); } - + public function setPriority($priority) { - return $this->_setProperty($this["Priority"], $priority); + return $this->_setProperty("Priority", $priority); } - + public function setArchitecture($arch) { return $this->_setProperty("Architecture", $arch); } - + public function setEssential($essential) { return $this->_setProperty("Essential", $essential); } - + public function setDepends($depends) { return $this->_setProperty("Depends", $this->_transformList($depends)); } - + public function setPreDepends($depends) { return $this->_setProperty("Pre-Depends", $this->_transformList($depends)); } - public function setRecommends($depends) - { - return $this->_setProperty("Reccommends", $depends); + public function setRecommends($depends) + { + return $this->_setProperty("Recommends", $this->_transformList($depends)); } - + public function setSuggests($depends) { return $this->_setProperty("Suggests", $this->_transformList($depends)); } - + public function setInstalledSize($size) { return $this->_setProperty("Installed-Size", $size); } - + public function setMaintainer($maintainer, $email = false) { $email = ($email) ? $email : "---"; - return $this->_setProperty("Maintainer", $maintainer . "[{$email}]"); + return $this->_setProperty("Maintainer", "{$maintainer} <{$email}>"); } - + public function setConflicts($conflicts) { return $this->_setProperty("Conflicts", $this->_transformList($conflicts)); } - + public function setReplaces($replaces) { - return $this->_setProperty("Conflicts", $this->_transformList($replaces)); + return $this->_setProperty("Replaces", $this->_transformList($replaces)); } - + public function setProvides($provides) { - return $this->_setProperty("Provides", $provides); + return $this->_setProperty("Provides", $this->_transformList($provides)); } - + public function setDescription($description) { return $this->_setProperty("Description", $description); } - + private function _transformList($depends) { - if (is_array($depends)) { - $depends = implode(", ", $depends); - } else { - $depends = $depends; + if (is_array($depends)) { + $depends = implode(", ", $depends); + } else { + $depends = $depends; } - + return $depends; } - + private function _setProperty($key, $value) { $this[$key] = $value; return $this; } - - public function offsetExists ($offset) { - return array_key_exists($offset, $this->_keys); - } - public function offsetGet ($offset) { + public function offsetExists($offset) + { + return array_key_exists($offset, $this->_keys); + } + + public function offsetGet($offset) + { if ($this->offsetExists($offset)) { return $this->_keys[$offset]; } else { return null; - } - } - - public function offsetSet ($offset, $value) { - if (!$this->offsetExists($offset)) { - throw new \Exception("Invalid property for this control file."); } - $this->_keys[$offset] = $value; - } + } - public function offsetUnset ($offset) { + public function offsetSet($offset, $value) + { + if (!$this->offsetExists($offset)) { + throw new \InvalidArgumentException("Invalid property '{$offset}' for this control file."); + } + $this->_keys[$offset] = $value; + } + + public function offsetUnset($offset) + { if ($this->offsetExists($offset)) { unset($this->_keys[$offset]); - } + } } - + /** * Control file string representation. - * + * * @return string The control file */ public function __toString() { $control = ''; foreach ($this->_keys as $key => $value) { - $control .= "{$key}: {$value}" . PHP_EOL; + if ($value) { + $control .= "{$key}: {$value}" . PHP_EOL; + } } - + return $control; } -} \ No newline at end of file +} diff --git a/tests/wdm/debian/PackagerTest.php b/tests/wdm/debian/PackagerTest.php new file mode 100644 index 0000000..6490775 --- /dev/null +++ b/tests/wdm/debian/PackagerTest.php @@ -0,0 +1,105 @@ +object = new Packager(); + } + + public function testRetrieveTheBuildCommand() + { + $this->object->setOutputPath("/tmp"); + + $this->assertEquals("dpkg -b /tmp my.deb", $this->object->build("my.deb")); + } + + public function testRetriveControlFile() + { + $control = new control\StandardFile(); + $this->object->setControl($control); + + $this->assertSame($control, $this->object->getControl()); + } + + /** + * @expectedException RuntimeException + * @expectedExceptionMessage OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately! + */ + public function testOutputFolderIsNotEmpty() + { + $root = vfsStream::setup('root'); + + mkdir(vfsStream::url('root/tmp')); + file_put_contents(vfsStream::url('root/tmp/ciao.txt'), "ciao"); + + $this->object->setOutputPath(vfsStream::url('root/tmp')); + + $control = new control\StandardFile(); + $this->object->setControl($control); + + $this->object->run(); + } + + public function testOutputFolderExistsButIsEmpty() + { + $root = vfsStream::setup('root'); + + mkdir(vfsStream::url('root/tmp')); + + $this->object->setOutputPath(vfsStream::url('root/tmp')); + + $control = new control\StandardFile(); + $this->object->setControl($control); + + $this->object->run(); + $command = $this->object->build(); + + $control = $this->object->getControl(); + $name = $control['Package']; + $version = $control['Version']; + $arch = $control['Architecture']; + $debPackageName = "{$name}_{$version}_{$arch}.deb"; + + $this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command); + } + + public function testCreateDebWhenOutputFolderIsMissing() + { + $root = vfsStream::setup('root'); + + $this->object->setOutputPath(vfsStream::url('root/tmp')); + + $control = new control\StandardFile(); + $this->object->setControl($control); + + $this->object->run(); + $command = $this->object->build(); + + $control = $this->object->getControl(); + $name = $control['Package']; + $version = $control['Version']; + $arch = $control['Architecture']; + $debPackageName = "{$name}_{$version}_{$arch}.deb"; + + $this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command); + } + + public function testCreateDebPackageWithAnotherName() + { + $root = vfsStream::setup('root'); + + $this->object->setOutputPath(vfsStream::url('root/tmp')); + + $control = new control\StandardFile(); + $this->object->setControl($control); + + $this->object->run(); + $command = $this->object->build("myname.deb"); + + $this->assertEquals("dpkg -b vfs://root/tmp myname.deb", $command); + } +} diff --git a/tests/wdm/debian/control/StandardFileTest.php b/tests/wdm/debian/control/StandardFileTest.php new file mode 100644 index 0000000..a26ff32 --- /dev/null +++ b/tests/wdm/debian/control/StandardFileTest.php @@ -0,0 +1,73 @@ +object = new StandardFile(); + } + + public function testMinimumFile() + { + $conf = (string)$this->object; + + $expected = << +Provides: your-company +Description: Your description + +OEF; + $this->assertEquals($expected, $conf); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid property 'MyPersonalSection' for this control file. + */ + public function testFilterMissingOrInvalidProperties() + { + $this->object["MyPersonalSection"] = "Test"; + } + + public function testOverwriteConfiguration() + { + $this->object["Version"] = "1.0.1"; + $this->object["Section"] = "Software"; + $this->object["Priority"] = "security"; + $this->object["Architecture"] = "x86"; + $this->object["Essential"] = "yes"; + $this->object["Installed-Size"] = "2048"; + $this->object["Maintainer"] = "Walter Dal Mut "; + $this->object["Provides"] = "Corley SRL"; + $this->object["Description"] = "My Desc"; + $this->object["Depends"] = "php5-cli"; + $this->object["Recommends"] = "php5-curl"; + + $conf = (string)$this->object; + + $expected = << +Provides: Corley SRL +Description: My Desc + +OEF; + $this->assertEquals($expected, $conf); + } +}