├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── VERSION ├── composer.json ├── composer.lock ├── example.php ├── src └── wdm │ └── debian │ ├── Packager.php │ └── control │ └── StandardFile.php └── tests └── wdm └── debian ├── PackagerTest.php └── control └── StandardFileTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .buildpath 3 | .settings 4 | 5 | vendor 6 | *.phar 7 | *.deb 8 | 9 | src/*.tgz 10 | 11 | tags 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.6 4 | - 5.5 5 | - 5.4 6 | - 5.3 7 | 8 | install: 9 | - composer install 10 | 11 | script: vendor/bin/phpunit tests 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.0.13 2 | 3 | ## BC Breaks 4 | 5 | * The packager will throws a RuntimeException if the output folder already 6 | exists and it is not empty. 7 | 8 | # 0.0.10 9 | 10 | ## BC Breaks 11 | 12 | ## Deprecations 13 | 14 | * Method `mount` will be replaced by method `addMount` in the future 15 | 16 | # 0.0.4 17 | 18 | ## BC Breaks 19 | 20 | * Build will returns the dpkg command instead print it to the user 21 | * Removed internal autoloader -> use composer as a default 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Debian packager (PHP) 2 | 3 | * Develop: [![Build Status](https://travis-ci.org/wdalmut/php-deb-packager.svg?branch=develop)](https://travis-ci.org/wdalmut/php-deb-packager) 4 | * Master : [![Build Status](https://travis-ci.org/wdalmut/php-deb-packager.svg?branch=master)](https://travis-ci.org/wdalmut/php-deb-packager) 5 | 6 | A simple debian packager for PHP applications 7 | 8 | Get composer: 9 | 10 | ``` 11 | curl -sS http://getcomposer.org/installer | php 12 | ``` 13 | 14 | Install dependencies and autoloader 15 | 16 | ``` 17 | php composer.phar install 18 | ``` 19 | 20 | Use it: 21 | 22 | ```php 23 | setPackageName("my-package-name") 30 | ->setVersion("0.1.1") 31 | ->setDepends(array("php5", "php5-cli", "php5-xsl")) 32 | ->setInstalledSize(4096) 33 | ->setMaintainer("Walter Dal Mut", "walter.dalmut@corley.it") 34 | ->setProvides("my-package-name") 35 | ->setDescription("My software description"); 36 | ; 37 | 38 | $packager = new \wdm\debian\Packager(); 39 | 40 | $packager->setOutputPath("/path/to/out"); 41 | $packager->setControl($control); 42 | 43 | $packager->mount("/path/to/source-conf", "/etc/my-sw"); 44 | $packager->mount("/path/to/exec", "/usr/bin/my-sw"); 45 | $packager->mount("/path/to/docs", "/usr/share/docs"); 46 | 47 | //Creates folders using mount points 48 | $packager->run(); 49 | 50 | //Get the Debian package command 51 | echo $packager->build(); 52 | ``` 53 | 54 | **Create the Package** 55 | 56 | ``` 57 | $(php pack.php) 58 | ``` 59 | 60 | ## Pre-Post scripts 61 | 62 | Optianally you can add script for different hooks 63 | 64 | * pre-install 65 | * Run pre install 66 | * post-install 67 | * Run post install 68 | * pre-remove 69 | * Run pre package remove 70 | * post-remove 71 | * Run post package remove 72 | 73 | Adding scripts 74 | 75 | ```php 76 | $packager->setPreInstallScript(__DIR__ . '/my-pre-install-script.sh'); 77 | $packager->setPostInstallScript(__DIR__ . '/my-post-install-script.sh'); 78 | $packager->setPreRemoveScript(__DIR__ . '/my-pre-remove-script.sh'); 79 | $packager->setPostRemoveScript(__DIR__ . '/my-post-remove-script.sh'); 80 | ``` 81 | 82 | See a script example 83 | 84 | ```shell 85 | #!/bin/sh 86 | #postinst script for upcloo 87 | 88 | set -e 89 | 90 | echo "Goodbye Cruel World" 91 | 92 | exit 0 93 | ``` 94 | 95 | ## Use Yaml files instead the library directly 96 | 97 | Just take a look to [wdalmut/php-deb-describe](https://github.com/wdalmut/php-deb-describe) 98 | 99 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.0.13 2 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wdalmut/php-deb-packager", 3 | "description": "A simple debian packager for PHP applications", 4 | "type":"library", 5 | "keywords":["deb","packager","ubuntu","php-deb", "debian"], 6 | "license":"MIT", 7 | "authors": [ 8 | { 9 | "name":"Walter Dal Mut", 10 | "email":"walter.dalmut@gmail.com", 11 | "homepage":"http://walterdalmut.com", 12 | "role":"Developer" 13 | } 14 | ], 15 | "support": { 16 | "email":"walter.dalmut@gmail.com" 17 | }, 18 | "require": { 19 | "php": ">=5.3.3" 20 | }, 21 | "require-dev": { 22 | "phpunit/phpunit": "~4", 23 | "mikey179/vfsstream": "1.4.*" 24 | }, 25 | "autoload": { 26 | "psr-0": { 27 | "wdm": ["src/", "tests/"] 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "452e33232d90b29107daa9bb4740b3ea", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "doctrine/instantiator", 12 | "version": "1.0.4", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/doctrine/instantiator.git", 16 | "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", 21 | "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": ">=5.3,<8.0-DEV" 26 | }, 27 | "require-dev": { 28 | "athletic/athletic": "~0.1.8", 29 | "ext-pdo": "*", 30 | "ext-phar": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "squizlabs/php_codesniffer": "2.0.*@ALPHA" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "1.0.x-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "psr-0": { 42 | "Doctrine\\Instantiator\\": "src" 43 | } 44 | }, 45 | "notification-url": "https://packagist.org/downloads/", 46 | "license": [ 47 | "MIT" 48 | ], 49 | "authors": [ 50 | { 51 | "name": "Marco Pivetta", 52 | "email": "ocramius@gmail.com", 53 | "homepage": "http://ocramius.github.com/" 54 | } 55 | ], 56 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 57 | "homepage": "https://github.com/doctrine/instantiator", 58 | "keywords": [ 59 | "constructor", 60 | "instantiate" 61 | ], 62 | "time": "2014-10-13 12:58:55" 63 | }, 64 | { 65 | "name": "mikey179/vfsStream", 66 | "version": "v1.4.0", 67 | "source": { 68 | "type": "git", 69 | "url": "https://github.com/mikey179/vfsStream.git", 70 | "reference": "61b12172292cf539685507aa65b076c1530e83c1" 71 | }, 72 | "dist": { 73 | "type": "zip", 74 | "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/61b12172292cf539685507aa65b076c1530e83c1", 75 | "reference": "61b12172292cf539685507aa65b076c1530e83c1", 76 | "shasum": "" 77 | }, 78 | "require": { 79 | "php": ">=5.3.0" 80 | }, 81 | "require-dev": { 82 | "phpunit/phpunit": "~4.2" 83 | }, 84 | "type": "library", 85 | "extra": { 86 | "branch-alias": { 87 | "dev-master": "1.4.x-dev" 88 | } 89 | }, 90 | "autoload": { 91 | "psr-0": { 92 | "org\\bovigo\\vfs\\": "src/main/php" 93 | } 94 | }, 95 | "notification-url": "https://packagist.org/downloads/", 96 | "license": [ 97 | "BSD" 98 | ], 99 | "homepage": "http://vfs.bovigo.org/", 100 | "time": "2014-09-14 10:18:53" 101 | }, 102 | { 103 | "name": "phpdocumentor/reflection-docblock", 104 | "version": "2.0.4", 105 | "source": { 106 | "type": "git", 107 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 108 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" 109 | }, 110 | "dist": { 111 | "type": "zip", 112 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", 113 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", 114 | "shasum": "" 115 | }, 116 | "require": { 117 | "php": ">=5.3.3" 118 | }, 119 | "require-dev": { 120 | "phpunit/phpunit": "~4.0" 121 | }, 122 | "suggest": { 123 | "dflydev/markdown": "~1.0", 124 | "erusev/parsedown": "~1.0" 125 | }, 126 | "type": "library", 127 | "extra": { 128 | "branch-alias": { 129 | "dev-master": "2.0.x-dev" 130 | } 131 | }, 132 | "autoload": { 133 | "psr-0": { 134 | "phpDocumentor": [ 135 | "src/" 136 | ] 137 | } 138 | }, 139 | "notification-url": "https://packagist.org/downloads/", 140 | "license": [ 141 | "MIT" 142 | ], 143 | "authors": [ 144 | { 145 | "name": "Mike van Riel", 146 | "email": "mike.vanriel@naenius.com" 147 | } 148 | ], 149 | "time": "2015-02-03 12:10:50" 150 | }, 151 | { 152 | "name": "phpspec/prophecy", 153 | "version": "v1.4.1", 154 | "source": { 155 | "type": "git", 156 | "url": "https://github.com/phpspec/prophecy.git", 157 | "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373" 158 | }, 159 | "dist": { 160 | "type": "zip", 161 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", 162 | "reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373", 163 | "shasum": "" 164 | }, 165 | "require": { 166 | "doctrine/instantiator": "^1.0.2", 167 | "phpdocumentor/reflection-docblock": "~2.0", 168 | "sebastian/comparator": "~1.1" 169 | }, 170 | "require-dev": { 171 | "phpspec/phpspec": "~2.0" 172 | }, 173 | "type": "library", 174 | "extra": { 175 | "branch-alias": { 176 | "dev-master": "1.4.x-dev" 177 | } 178 | }, 179 | "autoload": { 180 | "psr-0": { 181 | "Prophecy\\": "src/" 182 | } 183 | }, 184 | "notification-url": "https://packagist.org/downloads/", 185 | "license": [ 186 | "MIT" 187 | ], 188 | "authors": [ 189 | { 190 | "name": "Konstantin Kudryashov", 191 | "email": "ever.zet@gmail.com", 192 | "homepage": "http://everzet.com" 193 | }, 194 | { 195 | "name": "Marcello Duarte", 196 | "email": "marcello.duarte@gmail.com" 197 | } 198 | ], 199 | "description": "Highly opinionated mocking framework for PHP 5.3+", 200 | "homepage": "https://github.com/phpspec/prophecy", 201 | "keywords": [ 202 | "Double", 203 | "Dummy", 204 | "fake", 205 | "mock", 206 | "spy", 207 | "stub" 208 | ], 209 | "time": "2015-04-27 22:15:08" 210 | }, 211 | { 212 | "name": "phpunit/php-code-coverage", 213 | "version": "2.0.17", 214 | "source": { 215 | "type": "git", 216 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 217 | "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3" 218 | }, 219 | "dist": { 220 | "type": "zip", 221 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3", 222 | "reference": "c4e8e7725e351184a76544634855b8a9c405a6e3", 223 | "shasum": "" 224 | }, 225 | "require": { 226 | "php": ">=5.3.3", 227 | "phpunit/php-file-iterator": "~1.3", 228 | "phpunit/php-text-template": "~1.2", 229 | "phpunit/php-token-stream": "~1.3", 230 | "sebastian/environment": "~1.0", 231 | "sebastian/version": "~1.0" 232 | }, 233 | "require-dev": { 234 | "ext-xdebug": ">=2.1.4", 235 | "phpunit/phpunit": "~4" 236 | }, 237 | "suggest": { 238 | "ext-dom": "*", 239 | "ext-xdebug": ">=2.2.1", 240 | "ext-xmlwriter": "*" 241 | }, 242 | "type": "library", 243 | "extra": { 244 | "branch-alias": { 245 | "dev-master": "2.0.x-dev" 246 | } 247 | }, 248 | "autoload": { 249 | "classmap": [ 250 | "src/" 251 | ] 252 | }, 253 | "notification-url": "https://packagist.org/downloads/", 254 | "license": [ 255 | "BSD-3-Clause" 256 | ], 257 | "authors": [ 258 | { 259 | "name": "Sebastian Bergmann", 260 | "email": "sb@sebastian-bergmann.de", 261 | "role": "lead" 262 | } 263 | ], 264 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 265 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 266 | "keywords": [ 267 | "coverage", 268 | "testing", 269 | "xunit" 270 | ], 271 | "time": "2015-05-25 05:11:59" 272 | }, 273 | { 274 | "name": "phpunit/php-file-iterator", 275 | "version": "1.4.0", 276 | "source": { 277 | "type": "git", 278 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 279 | "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb" 280 | }, 281 | "dist": { 282 | "type": "zip", 283 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a923bb15680d0089e2316f7a4af8f437046e96bb", 284 | "reference": "a923bb15680d0089e2316f7a4af8f437046e96bb", 285 | "shasum": "" 286 | }, 287 | "require": { 288 | "php": ">=5.3.3" 289 | }, 290 | "type": "library", 291 | "extra": { 292 | "branch-alias": { 293 | "dev-master": "1.4.x-dev" 294 | } 295 | }, 296 | "autoload": { 297 | "classmap": [ 298 | "src/" 299 | ] 300 | }, 301 | "notification-url": "https://packagist.org/downloads/", 302 | "license": [ 303 | "BSD-3-Clause" 304 | ], 305 | "authors": [ 306 | { 307 | "name": "Sebastian Bergmann", 308 | "email": "sb@sebastian-bergmann.de", 309 | "role": "lead" 310 | } 311 | ], 312 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 313 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 314 | "keywords": [ 315 | "filesystem", 316 | "iterator" 317 | ], 318 | "time": "2015-04-02 05:19:05" 319 | }, 320 | { 321 | "name": "phpunit/php-text-template", 322 | "version": "1.2.0", 323 | "source": { 324 | "type": "git", 325 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 326 | "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" 327 | }, 328 | "dist": { 329 | "type": "zip", 330 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", 331 | "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", 332 | "shasum": "" 333 | }, 334 | "require": { 335 | "php": ">=5.3.3" 336 | }, 337 | "type": "library", 338 | "autoload": { 339 | "classmap": [ 340 | "Text/" 341 | ] 342 | }, 343 | "notification-url": "https://packagist.org/downloads/", 344 | "include-path": [ 345 | "" 346 | ], 347 | "license": [ 348 | "BSD-3-Clause" 349 | ], 350 | "authors": [ 351 | { 352 | "name": "Sebastian Bergmann", 353 | "email": "sb@sebastian-bergmann.de", 354 | "role": "lead" 355 | } 356 | ], 357 | "description": "Simple template engine.", 358 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 359 | "keywords": [ 360 | "template" 361 | ], 362 | "time": "2014-01-30 17:20:04" 363 | }, 364 | { 365 | "name": "phpunit/php-timer", 366 | "version": "1.0.5", 367 | "source": { 368 | "type": "git", 369 | "url": "https://github.com/sebastianbergmann/php-timer.git", 370 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" 371 | }, 372 | "dist": { 373 | "type": "zip", 374 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 375 | "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", 376 | "shasum": "" 377 | }, 378 | "require": { 379 | "php": ">=5.3.3" 380 | }, 381 | "type": "library", 382 | "autoload": { 383 | "classmap": [ 384 | "PHP/" 385 | ] 386 | }, 387 | "notification-url": "https://packagist.org/downloads/", 388 | "include-path": [ 389 | "" 390 | ], 391 | "license": [ 392 | "BSD-3-Clause" 393 | ], 394 | "authors": [ 395 | { 396 | "name": "Sebastian Bergmann", 397 | "email": "sb@sebastian-bergmann.de", 398 | "role": "lead" 399 | } 400 | ], 401 | "description": "Utility class for timing", 402 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 403 | "keywords": [ 404 | "timer" 405 | ], 406 | "time": "2013-08-02 07:42:54" 407 | }, 408 | { 409 | "name": "phpunit/php-token-stream", 410 | "version": "1.4.1", 411 | "source": { 412 | "type": "git", 413 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 414 | "reference": "eab81d02569310739373308137284e0158424330" 415 | }, 416 | "dist": { 417 | "type": "zip", 418 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/eab81d02569310739373308137284e0158424330", 419 | "reference": "eab81d02569310739373308137284e0158424330", 420 | "shasum": "" 421 | }, 422 | "require": { 423 | "ext-tokenizer": "*", 424 | "php": ">=5.3.3" 425 | }, 426 | "require-dev": { 427 | "phpunit/phpunit": "~4.2" 428 | }, 429 | "type": "library", 430 | "extra": { 431 | "branch-alias": { 432 | "dev-master": "1.4-dev" 433 | } 434 | }, 435 | "autoload": { 436 | "classmap": [ 437 | "src/" 438 | ] 439 | }, 440 | "notification-url": "https://packagist.org/downloads/", 441 | "license": [ 442 | "BSD-3-Clause" 443 | ], 444 | "authors": [ 445 | { 446 | "name": "Sebastian Bergmann", 447 | "email": "sebastian@phpunit.de" 448 | } 449 | ], 450 | "description": "Wrapper around PHP's tokenizer extension.", 451 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 452 | "keywords": [ 453 | "tokenizer" 454 | ], 455 | "time": "2015-04-08 04:46:07" 456 | }, 457 | { 458 | "name": "phpunit/phpunit", 459 | "version": "4.6.7", 460 | "source": { 461 | "type": "git", 462 | "url": "https://github.com/sebastianbergmann/phpunit.git", 463 | "reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25" 464 | }, 465 | "dist": { 466 | "type": "zip", 467 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", 468 | "reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25", 469 | "shasum": "" 470 | }, 471 | "require": { 472 | "ext-dom": "*", 473 | "ext-json": "*", 474 | "ext-pcre": "*", 475 | "ext-reflection": "*", 476 | "ext-spl": "*", 477 | "php": ">=5.3.3", 478 | "phpspec/prophecy": "~1.3,>=1.3.1", 479 | "phpunit/php-code-coverage": "~2.0,>=2.0.11", 480 | "phpunit/php-file-iterator": "~1.4", 481 | "phpunit/php-text-template": "~1.2", 482 | "phpunit/php-timer": "~1.0", 483 | "phpunit/phpunit-mock-objects": "~2.3", 484 | "sebastian/comparator": "~1.1", 485 | "sebastian/diff": "~1.2", 486 | "sebastian/environment": "~1.2", 487 | "sebastian/exporter": "~1.2", 488 | "sebastian/global-state": "~1.0", 489 | "sebastian/version": "~1.0", 490 | "symfony/yaml": "~2.1|~3.0" 491 | }, 492 | "suggest": { 493 | "phpunit/php-invoker": "~1.1" 494 | }, 495 | "bin": [ 496 | "phpunit" 497 | ], 498 | "type": "library", 499 | "extra": { 500 | "branch-alias": { 501 | "dev-master": "4.6.x-dev" 502 | } 503 | }, 504 | "autoload": { 505 | "classmap": [ 506 | "src/" 507 | ] 508 | }, 509 | "notification-url": "https://packagist.org/downloads/", 510 | "license": [ 511 | "BSD-3-Clause" 512 | ], 513 | "authors": [ 514 | { 515 | "name": "Sebastian Bergmann", 516 | "email": "sebastian@phpunit.de", 517 | "role": "lead" 518 | } 519 | ], 520 | "description": "The PHP Unit Testing framework.", 521 | "homepage": "https://phpunit.de/", 522 | "keywords": [ 523 | "phpunit", 524 | "testing", 525 | "xunit" 526 | ], 527 | "time": "2015-05-25 05:18:18" 528 | }, 529 | { 530 | "name": "phpunit/phpunit-mock-objects", 531 | "version": "2.3.1", 532 | "source": { 533 | "type": "git", 534 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 535 | "reference": "74ffb87f527f24616f72460e54b595f508dccb5c" 536 | }, 537 | "dist": { 538 | "type": "zip", 539 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/74ffb87f527f24616f72460e54b595f508dccb5c", 540 | "reference": "74ffb87f527f24616f72460e54b595f508dccb5c", 541 | "shasum": "" 542 | }, 543 | "require": { 544 | "doctrine/instantiator": "~1.0,>=1.0.2", 545 | "php": ">=5.3.3", 546 | "phpunit/php-text-template": "~1.2" 547 | }, 548 | "require-dev": { 549 | "phpunit/phpunit": "~4.4" 550 | }, 551 | "suggest": { 552 | "ext-soap": "*" 553 | }, 554 | "type": "library", 555 | "extra": { 556 | "branch-alias": { 557 | "dev-master": "2.3.x-dev" 558 | } 559 | }, 560 | "autoload": { 561 | "classmap": [ 562 | "src/" 563 | ] 564 | }, 565 | "notification-url": "https://packagist.org/downloads/", 566 | "license": [ 567 | "BSD-3-Clause" 568 | ], 569 | "authors": [ 570 | { 571 | "name": "Sebastian Bergmann", 572 | "email": "sb@sebastian-bergmann.de", 573 | "role": "lead" 574 | } 575 | ], 576 | "description": "Mock Object library for PHPUnit", 577 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 578 | "keywords": [ 579 | "mock", 580 | "xunit" 581 | ], 582 | "time": "2015-04-02 05:36:41" 583 | }, 584 | { 585 | "name": "sebastian/comparator", 586 | "version": "1.1.1", 587 | "source": { 588 | "type": "git", 589 | "url": "https://github.com/sebastianbergmann/comparator.git", 590 | "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" 591 | }, 592 | "dist": { 593 | "type": "zip", 594 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", 595 | "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", 596 | "shasum": "" 597 | }, 598 | "require": { 599 | "php": ">=5.3.3", 600 | "sebastian/diff": "~1.2", 601 | "sebastian/exporter": "~1.2" 602 | }, 603 | "require-dev": { 604 | "phpunit/phpunit": "~4.4" 605 | }, 606 | "type": "library", 607 | "extra": { 608 | "branch-alias": { 609 | "dev-master": "1.1.x-dev" 610 | } 611 | }, 612 | "autoload": { 613 | "classmap": [ 614 | "src/" 615 | ] 616 | }, 617 | "notification-url": "https://packagist.org/downloads/", 618 | "license": [ 619 | "BSD-3-Clause" 620 | ], 621 | "authors": [ 622 | { 623 | "name": "Jeff Welch", 624 | "email": "whatthejeff@gmail.com" 625 | }, 626 | { 627 | "name": "Volker Dusch", 628 | "email": "github@wallbash.com" 629 | }, 630 | { 631 | "name": "Bernhard Schussek", 632 | "email": "bschussek@2bepublished.at" 633 | }, 634 | { 635 | "name": "Sebastian Bergmann", 636 | "email": "sebastian@phpunit.de" 637 | } 638 | ], 639 | "description": "Provides the functionality to compare PHP values for equality", 640 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 641 | "keywords": [ 642 | "comparator", 643 | "compare", 644 | "equality" 645 | ], 646 | "time": "2015-01-29 16:28:08" 647 | }, 648 | { 649 | "name": "sebastian/diff", 650 | "version": "1.3.0", 651 | "source": { 652 | "type": "git", 653 | "url": "https://github.com/sebastianbergmann/diff.git", 654 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" 655 | }, 656 | "dist": { 657 | "type": "zip", 658 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", 659 | "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", 660 | "shasum": "" 661 | }, 662 | "require": { 663 | "php": ">=5.3.3" 664 | }, 665 | "require-dev": { 666 | "phpunit/phpunit": "~4.2" 667 | }, 668 | "type": "library", 669 | "extra": { 670 | "branch-alias": { 671 | "dev-master": "1.3-dev" 672 | } 673 | }, 674 | "autoload": { 675 | "classmap": [ 676 | "src/" 677 | ] 678 | }, 679 | "notification-url": "https://packagist.org/downloads/", 680 | "license": [ 681 | "BSD-3-Clause" 682 | ], 683 | "authors": [ 684 | { 685 | "name": "Kore Nordmann", 686 | "email": "mail@kore-nordmann.de" 687 | }, 688 | { 689 | "name": "Sebastian Bergmann", 690 | "email": "sebastian@phpunit.de" 691 | } 692 | ], 693 | "description": "Diff implementation", 694 | "homepage": "http://www.github.com/sebastianbergmann/diff", 695 | "keywords": [ 696 | "diff" 697 | ], 698 | "time": "2015-02-22 15:13:53" 699 | }, 700 | { 701 | "name": "sebastian/environment", 702 | "version": "1.2.2", 703 | "source": { 704 | "type": "git", 705 | "url": "https://github.com/sebastianbergmann/environment.git", 706 | "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" 707 | }, 708 | "dist": { 709 | "type": "zip", 710 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", 711 | "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", 712 | "shasum": "" 713 | }, 714 | "require": { 715 | "php": ">=5.3.3" 716 | }, 717 | "require-dev": { 718 | "phpunit/phpunit": "~4.4" 719 | }, 720 | "type": "library", 721 | "extra": { 722 | "branch-alias": { 723 | "dev-master": "1.3.x-dev" 724 | } 725 | }, 726 | "autoload": { 727 | "classmap": [ 728 | "src/" 729 | ] 730 | }, 731 | "notification-url": "https://packagist.org/downloads/", 732 | "license": [ 733 | "BSD-3-Clause" 734 | ], 735 | "authors": [ 736 | { 737 | "name": "Sebastian Bergmann", 738 | "email": "sebastian@phpunit.de" 739 | } 740 | ], 741 | "description": "Provides functionality to handle HHVM/PHP environments", 742 | "homepage": "http://www.github.com/sebastianbergmann/environment", 743 | "keywords": [ 744 | "Xdebug", 745 | "environment", 746 | "hhvm" 747 | ], 748 | "time": "2015-01-01 10:01:08" 749 | }, 750 | { 751 | "name": "sebastian/exporter", 752 | "version": "1.2.0", 753 | "source": { 754 | "type": "git", 755 | "url": "https://github.com/sebastianbergmann/exporter.git", 756 | "reference": "84839970d05254c73cde183a721c7af13aede943" 757 | }, 758 | "dist": { 759 | "type": "zip", 760 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", 761 | "reference": "84839970d05254c73cde183a721c7af13aede943", 762 | "shasum": "" 763 | }, 764 | "require": { 765 | "php": ">=5.3.3", 766 | "sebastian/recursion-context": "~1.0" 767 | }, 768 | "require-dev": { 769 | "phpunit/phpunit": "~4.4" 770 | }, 771 | "type": "library", 772 | "extra": { 773 | "branch-alias": { 774 | "dev-master": "1.2.x-dev" 775 | } 776 | }, 777 | "autoload": { 778 | "classmap": [ 779 | "src/" 780 | ] 781 | }, 782 | "notification-url": "https://packagist.org/downloads/", 783 | "license": [ 784 | "BSD-3-Clause" 785 | ], 786 | "authors": [ 787 | { 788 | "name": "Jeff Welch", 789 | "email": "whatthejeff@gmail.com" 790 | }, 791 | { 792 | "name": "Volker Dusch", 793 | "email": "github@wallbash.com" 794 | }, 795 | { 796 | "name": "Bernhard Schussek", 797 | "email": "bschussek@2bepublished.at" 798 | }, 799 | { 800 | "name": "Sebastian Bergmann", 801 | "email": "sebastian@phpunit.de" 802 | }, 803 | { 804 | "name": "Adam Harvey", 805 | "email": "aharvey@php.net" 806 | } 807 | ], 808 | "description": "Provides the functionality to export PHP variables for visualization", 809 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 810 | "keywords": [ 811 | "export", 812 | "exporter" 813 | ], 814 | "time": "2015-01-27 07:23:06" 815 | }, 816 | { 817 | "name": "sebastian/global-state", 818 | "version": "1.0.0", 819 | "source": { 820 | "type": "git", 821 | "url": "https://github.com/sebastianbergmann/global-state.git", 822 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" 823 | }, 824 | "dist": { 825 | "type": "zip", 826 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 827 | "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", 828 | "shasum": "" 829 | }, 830 | "require": { 831 | "php": ">=5.3.3" 832 | }, 833 | "require-dev": { 834 | "phpunit/phpunit": "~4.2" 835 | }, 836 | "suggest": { 837 | "ext-uopz": "*" 838 | }, 839 | "type": "library", 840 | "extra": { 841 | "branch-alias": { 842 | "dev-master": "1.0-dev" 843 | } 844 | }, 845 | "autoload": { 846 | "classmap": [ 847 | "src/" 848 | ] 849 | }, 850 | "notification-url": "https://packagist.org/downloads/", 851 | "license": [ 852 | "BSD-3-Clause" 853 | ], 854 | "authors": [ 855 | { 856 | "name": "Sebastian Bergmann", 857 | "email": "sebastian@phpunit.de" 858 | } 859 | ], 860 | "description": "Snapshotting of global state", 861 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 862 | "keywords": [ 863 | "global state" 864 | ], 865 | "time": "2014-10-06 09:23:50" 866 | }, 867 | { 868 | "name": "sebastian/recursion-context", 869 | "version": "1.0.0", 870 | "source": { 871 | "type": "git", 872 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 873 | "reference": "3989662bbb30a29d20d9faa04a846af79b276252" 874 | }, 875 | "dist": { 876 | "type": "zip", 877 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", 878 | "reference": "3989662bbb30a29d20d9faa04a846af79b276252", 879 | "shasum": "" 880 | }, 881 | "require": { 882 | "php": ">=5.3.3" 883 | }, 884 | "require-dev": { 885 | "phpunit/phpunit": "~4.4" 886 | }, 887 | "type": "library", 888 | "extra": { 889 | "branch-alias": { 890 | "dev-master": "1.0.x-dev" 891 | } 892 | }, 893 | "autoload": { 894 | "classmap": [ 895 | "src/" 896 | ] 897 | }, 898 | "notification-url": "https://packagist.org/downloads/", 899 | "license": [ 900 | "BSD-3-Clause" 901 | ], 902 | "authors": [ 903 | { 904 | "name": "Jeff Welch", 905 | "email": "whatthejeff@gmail.com" 906 | }, 907 | { 908 | "name": "Sebastian Bergmann", 909 | "email": "sebastian@phpunit.de" 910 | }, 911 | { 912 | "name": "Adam Harvey", 913 | "email": "aharvey@php.net" 914 | } 915 | ], 916 | "description": "Provides functionality to recursively process PHP variables", 917 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 918 | "time": "2015-01-24 09:48:32" 919 | }, 920 | { 921 | "name": "sebastian/version", 922 | "version": "1.0.5", 923 | "source": { 924 | "type": "git", 925 | "url": "https://github.com/sebastianbergmann/version.git", 926 | "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4" 927 | }, 928 | "dist": { 929 | "type": "zip", 930 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", 931 | "reference": "ab931d46cd0d3204a91e1b9a40c4bc13032b58e4", 932 | "shasum": "" 933 | }, 934 | "type": "library", 935 | "autoload": { 936 | "classmap": [ 937 | "src/" 938 | ] 939 | }, 940 | "notification-url": "https://packagist.org/downloads/", 941 | "license": [ 942 | "BSD-3-Clause" 943 | ], 944 | "authors": [ 945 | { 946 | "name": "Sebastian Bergmann", 947 | "email": "sebastian@phpunit.de", 948 | "role": "lead" 949 | } 950 | ], 951 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 952 | "homepage": "https://github.com/sebastianbergmann/version", 953 | "time": "2015-02-24 06:35:25" 954 | }, 955 | { 956 | "name": "symfony/yaml", 957 | "version": "v2.6.7", 958 | "target-dir": "Symfony/Component/Yaml", 959 | "source": { 960 | "type": "git", 961 | "url": "https://github.com/symfony/Yaml.git", 962 | "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2" 963 | }, 964 | "dist": { 965 | "type": "zip", 966 | "url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2", 967 | "reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2", 968 | "shasum": "" 969 | }, 970 | "require": { 971 | "php": ">=5.3.3" 972 | }, 973 | "require-dev": { 974 | "symfony/phpunit-bridge": "~2.7" 975 | }, 976 | "type": "library", 977 | "extra": { 978 | "branch-alias": { 979 | "dev-master": "2.6-dev" 980 | } 981 | }, 982 | "autoload": { 983 | "psr-0": { 984 | "Symfony\\Component\\Yaml\\": "" 985 | } 986 | }, 987 | "notification-url": "https://packagist.org/downloads/", 988 | "license": [ 989 | "MIT" 990 | ], 991 | "authors": [ 992 | { 993 | "name": "Fabien Potencier", 994 | "email": "fabien@symfony.com" 995 | }, 996 | { 997 | "name": "Symfony Community", 998 | "homepage": "https://symfony.com/contributors" 999 | } 1000 | ], 1001 | "description": "Symfony Yaml Component", 1002 | "homepage": "https://symfony.com", 1003 | "time": "2015-05-02 15:18:45" 1004 | } 1005 | ], 1006 | "aliases": [], 1007 | "minimum-stability": "stable", 1008 | "stability-flags": [], 1009 | "prefer-stable": false, 1010 | "prefer-lowest": false, 1011 | "platform": { 1012 | "php": ">=5.3.3" 1013 | }, 1014 | "platform-dev": [] 1015 | } 1016 | -------------------------------------------------------------------------------- /example.php: -------------------------------------------------------------------------------- 1 | setPackageName("my-package-name") 8 | ->setVersion("0.1.1") 9 | ->setDepends(array("php5", "php5-cli", "php5-xsl")) 10 | ->setInstalledSize(4096) 11 | ->setMaintainer("Walter Dal Mut", "walter.dalmut@corley.it") 12 | ->setProvides("my-package-name") 13 | ->setDescription("My software description"); 14 | ; 15 | 16 | $packager = new \wdm\debian\Packager(); 17 | 18 | $packager->setOutputPath(__DIR__ . "/out"); 19 | $packager->setControl($control); 20 | 21 | $packager->mount(__DIR__ . "/../../diff", "/my-differ"); 22 | 23 | //Creates folders using mount points 24 | $packager->run(); 25 | 26 | //Get the Debian package command 27 | echo $packager->build(); 28 | -------------------------------------------------------------------------------- /src/wdm/debian/Packager.php: -------------------------------------------------------------------------------- 1 | _control = $control; 29 | return $this; 30 | } 31 | 32 | /** 33 | * Return the actual control file 34 | * 35 | * @return StandardFile 36 | */ 37 | public function getControl() 38 | { 39 | return $this->_control; 40 | } 41 | 42 | /** 43 | * Pre install script 44 | * 45 | * @param string $path The absolute path of your pre-install script 46 | */ 47 | public function setPreInstallScript($path) 48 | { 49 | $this->_preInst = $path; 50 | } 51 | 52 | /** 53 | * Post install script 54 | * 55 | * @param string $path The absolute path of your post-install script 56 | */ 57 | public function setPostInstallScript($path) 58 | { 59 | $this->_postInst = $path; 60 | } 61 | 62 | /** 63 | * Pre remove script 64 | * 65 | * @param string $path The absolute path of your pre-remove script 66 | */ 67 | public function setPreRemoveScript($path) 68 | { 69 | $this->_preRM = $path; 70 | } 71 | 72 | /** 73 | * Post remove script 74 | * 75 | * @param string $path The absolute path of your post-remove script 76 | */ 77 | public function setPostRemoveScript($path) 78 | { 79 | $this->_postRM = $path; 80 | } 81 | 82 | /** 83 | * @deprecated See addMount instead 84 | */ 85 | public function mount($sourcePath, $destinationPath) 86 | { 87 | return $this->addMount($sourcePath, $destinationPath); 88 | } 89 | 90 | public function addMount($sourcePath, $destinationPath) 91 | { 92 | $this->_mountPoints[$sourcePath] = $destinationPath; 93 | return $this; 94 | } 95 | 96 | public function setOutputPath($path) 97 | { 98 | $this->_outputPath = $path; 99 | return $this; 100 | } 101 | 102 | public function getOutputPath() 103 | { 104 | return $this->_outputPath; 105 | } 106 | 107 | public function run() 108 | { 109 | if (file_exists($this->getOutputPath())) { 110 | $iterator = new \DirectoryIterator($this->getOutputPath()); 111 | foreach ($iterator as $path) { 112 | if ($path != '.' && $path != '..') { 113 | throw new RuntimeException("OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!"); 114 | } 115 | } 116 | } 117 | 118 | if (!file_exists($this->getOutputPath())) { 119 | mkdir($this->getOutputPath(), 0777); 120 | } 121 | 122 | foreach ($this->_mountPoints as $path => $dest) { 123 | $this->_pathToPath($path, $this->getOutputPath() . DIRECTORY_SEPARATOR . $dest); 124 | } 125 | 126 | mkdir($this->getOutputPath() . "/DEBIAN", 0777); 127 | 128 | file_put_contents($this->getOutputPath() . "/DEBIAN/control", (string)$this->_control); 129 | 130 | if ($this->_preInst) { 131 | $dest = $this->getOutputPath() . "/DEBIAN/preinst"; 132 | $this->_copy($this->_preInst, $dest); 133 | chmod($dest, 0755); 134 | } 135 | 136 | if ($this->_postInst) { 137 | $dest = $this->getOutputPath() . "/DEBIAN/postinst"; 138 | $this->_copy($this->_postInst, $dest); 139 | chmod($dest, 0755); 140 | } 141 | 142 | if ($this->_preRM) { 143 | $dest = $this->getOutputPath() . "/DEBIAN/prerm"; 144 | $this->_copy($this->_preRM, $dest); 145 | chmod($dest, 0755); 146 | } 147 | 148 | if ($this->_postRM) { 149 | $dest = $this->getOutputPath() . "/DEBIAN/postrm"; 150 | $this->_copy($this->_postRM, $dest); 151 | chmod($dest, 0755); 152 | } 153 | 154 | return $this; 155 | } 156 | 157 | private function _pathToPath($path, $dest) 158 | { 159 | if (is_dir($path)) { 160 | $iterator = new \DirectoryIterator($path); 161 | foreach ($iterator as $element) { 162 | if ($element != '.' && $element != '..') { 163 | $fullPath = $path . DIRECTORY_SEPARATOR . $element; 164 | if (is_dir($fullPath)) { 165 | $this->_pathToPath($fullPath, $dest . DIRECTORY_SEPARATOR . $element); 166 | } else { 167 | $this->_copy($fullPath, $dest . DIRECTORY_SEPARATOR . $element); 168 | } 169 | } 170 | } 171 | } else if (is_file($path)) { 172 | $this->_copy($path, $dest); 173 | } 174 | } 175 | 176 | private function _copy($source, $dest) 177 | { 178 | $destFolder = dirname($dest); 179 | if (!file_exists($destFolder)) { 180 | mkdir($destFolder, 0777, true); 181 | } 182 | if (is_link($source)) { 183 | symlink(readlink($source), $dest); 184 | return; // don't set perms on symlink targets 185 | } else { 186 | if (!copy($source, $dest)) { 187 | echo "Error: failed to copy: $source -> $dest \m"; 188 | return; 189 | } 190 | } 191 | if (fileperms($source) != fileperms($dest)) { 192 | chmod($dest, fileperms($source)); 193 | } 194 | } 195 | 196 | public function build($debPackageName = false) 197 | { 198 | if (!$debPackageName) { 199 | $control = $this->getControl(); 200 | $name = $control['Package']; 201 | $version = $control['Version']; 202 | $arch = $control['Architecture']; 203 | $debPackageName = "{$name}_{$version}_{$arch}.deb"; 204 | } 205 | 206 | $command = "dpkg -b {$this->getOutputPath()} {$debPackageName}"; 207 | 208 | return $command; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /src/wdm/debian/control/StandardFile.php: -------------------------------------------------------------------------------- 1 | false, 37 | 'Version' => '0.1', 38 | "Section" => "web", 39 | "Priority" => "optional", 40 | "Architecture" => "all", 41 | "Essential" => "no", 42 | "Depends" => false, 43 | "Pre-Depends" => false, 44 | "Recommends" => false, 45 | "Suggests" => false, 46 | "Installed-Size" => 1024, 47 | "Maintainer" => "name ", 48 | "Conflicts" => false, 49 | "Replaces" => false, 50 | "Provides" => "your-company", 51 | "Description" => "Your description" 52 | ); 53 | 54 | public function setPackageName($name) 55 | { 56 | return $this->_setProperty("Package", $name); 57 | } 58 | 59 | public function setVersion($version) 60 | { 61 | return $this->_setProperty("Version", $version); 62 | } 63 | 64 | public function setSection($section) 65 | { 66 | return $this->_setProperty("Section", $section); 67 | } 68 | 69 | public function setPriority($priority) 70 | { 71 | return $this->_setProperty("Priority", $priority); 72 | } 73 | 74 | public function setArchitecture($arch) 75 | { 76 | return $this->_setProperty("Architecture", $arch); 77 | } 78 | 79 | public function setEssential($essential) 80 | { 81 | return $this->_setProperty("Essential", $essential); 82 | } 83 | 84 | public function setDepends($depends) 85 | { 86 | return $this->_setProperty("Depends", $this->_transformList($depends)); 87 | } 88 | 89 | public function setPreDepends($depends) 90 | { 91 | return $this->_setProperty("Pre-Depends", $this->_transformList($depends)); 92 | } 93 | 94 | public function setRecommends($depends) 95 | { 96 | return $this->_setProperty("Recommends", $this->_transformList($depends)); 97 | } 98 | 99 | public function setSuggests($depends) 100 | { 101 | return $this->_setProperty("Suggests", $this->_transformList($depends)); 102 | } 103 | 104 | public function setInstalledSize($size) 105 | { 106 | return $this->_setProperty("Installed-Size", $size); 107 | } 108 | 109 | public function setMaintainer($maintainer, $email = false) 110 | { 111 | $email = ($email) ? $email : "---"; 112 | return $this->_setProperty("Maintainer", "{$maintainer} <{$email}>"); 113 | } 114 | 115 | public function setConflicts($conflicts) 116 | { 117 | return $this->_setProperty("Conflicts", $this->_transformList($conflicts)); 118 | } 119 | 120 | public function setReplaces($replaces) 121 | { 122 | return $this->_setProperty("Replaces", $this->_transformList($replaces)); 123 | } 124 | 125 | public function setProvides($provides) 126 | { 127 | return $this->_setProperty("Provides", $this->_transformList($provides)); 128 | } 129 | 130 | public function setDescription($description) 131 | { 132 | return $this->_setProperty("Description", $description); 133 | } 134 | 135 | private function _transformList($depends) 136 | { 137 | if (is_array($depends)) { 138 | $depends = implode(", ", $depends); 139 | } else { 140 | $depends = $depends; 141 | } 142 | 143 | return $depends; 144 | } 145 | 146 | private function _setProperty($key, $value) 147 | { 148 | $this[$key] = $value; 149 | return $this; 150 | } 151 | 152 | public function offsetExists($offset) 153 | { 154 | return array_key_exists($offset, $this->_keys); 155 | } 156 | 157 | public function offsetGet($offset) 158 | { 159 | if ($this->offsetExists($offset)) { 160 | return $this->_keys[$offset]; 161 | } else { 162 | return null; 163 | } 164 | } 165 | 166 | public function offsetSet($offset, $value) 167 | { 168 | if (!$this->offsetExists($offset)) { 169 | throw new \InvalidArgumentException("Invalid property '{$offset}' for this control file."); 170 | } 171 | $this->_keys[$offset] = $value; 172 | } 173 | 174 | public function offsetUnset($offset) 175 | { 176 | if ($this->offsetExists($offset)) { 177 | unset($this->_keys[$offset]); 178 | } 179 | } 180 | 181 | /** 182 | * Control file string representation. 183 | * 184 | * @return string The control file 185 | */ 186 | public function __toString() 187 | { 188 | $control = ''; 189 | foreach ($this->_keys as $key => $value) { 190 | if ($value) { 191 | $control .= "{$key}: {$value}" . PHP_EOL; 192 | } 193 | } 194 | 195 | return $control; 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /tests/wdm/debian/PackagerTest.php: -------------------------------------------------------------------------------- 1 | object = new Packager(); 11 | } 12 | 13 | public function testRetrieveTheBuildCommand() 14 | { 15 | $this->object->setOutputPath("/tmp"); 16 | 17 | $this->assertEquals("dpkg -b /tmp my.deb", $this->object->build("my.deb")); 18 | } 19 | 20 | public function testRetriveControlFile() 21 | { 22 | $control = new control\StandardFile(); 23 | $this->object->setControl($control); 24 | 25 | $this->assertSame($control, $this->object->getControl()); 26 | } 27 | 28 | /** 29 | * @expectedException RuntimeException 30 | * @expectedExceptionMessage OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately! 31 | */ 32 | public function testOutputFolderIsNotEmpty() 33 | { 34 | $root = vfsStream::setup('root'); 35 | 36 | mkdir(vfsStream::url('root/tmp')); 37 | file_put_contents(vfsStream::url('root/tmp/ciao.txt'), "ciao"); 38 | 39 | $this->object->setOutputPath(vfsStream::url('root/tmp')); 40 | 41 | $control = new control\StandardFile(); 42 | $this->object->setControl($control); 43 | 44 | $this->object->run(); 45 | } 46 | 47 | public function testOutputFolderExistsButIsEmpty() 48 | { 49 | $root = vfsStream::setup('root'); 50 | 51 | mkdir(vfsStream::url('root/tmp')); 52 | 53 | $this->object->setOutputPath(vfsStream::url('root/tmp')); 54 | 55 | $control = new control\StandardFile(); 56 | $this->object->setControl($control); 57 | 58 | $this->object->run(); 59 | $command = $this->object->build(); 60 | 61 | $control = $this->object->getControl(); 62 | $name = $control['Package']; 63 | $version = $control['Version']; 64 | $arch = $control['Architecture']; 65 | $debPackageName = "{$name}_{$version}_{$arch}.deb"; 66 | 67 | $this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command); 68 | } 69 | 70 | public function testCreateDebWhenOutputFolderIsMissing() 71 | { 72 | $root = vfsStream::setup('root'); 73 | 74 | $this->object->setOutputPath(vfsStream::url('root/tmp')); 75 | 76 | $control = new control\StandardFile(); 77 | $this->object->setControl($control); 78 | 79 | $this->object->run(); 80 | $command = $this->object->build(); 81 | 82 | $control = $this->object->getControl(); 83 | $name = $control['Package']; 84 | $version = $control['Version']; 85 | $arch = $control['Architecture']; 86 | $debPackageName = "{$name}_{$version}_{$arch}.deb"; 87 | 88 | $this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $command); 89 | } 90 | 91 | public function testCreateDebPackageWithAnotherName() 92 | { 93 | $root = vfsStream::setup('root'); 94 | 95 | $this->object->setOutputPath(vfsStream::url('root/tmp')); 96 | 97 | $control = new control\StandardFile(); 98 | $this->object->setControl($control); 99 | 100 | $this->object->run(); 101 | $command = $this->object->build("myname.deb"); 102 | 103 | $this->assertEquals("dpkg -b vfs://root/tmp myname.deb", $command); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /tests/wdm/debian/control/StandardFileTest.php: -------------------------------------------------------------------------------- 1 | object = new StandardFile(); 11 | } 12 | 13 | public function testMinimumFile() 14 | { 15 | $conf = (string)$this->object; 16 | 17 | $expected = << 25 | Provides: your-company 26 | Description: Your description 27 | 28 | OEF; 29 | $this->assertEquals($expected, $conf); 30 | } 31 | 32 | /** 33 | * @expectedException InvalidArgumentException 34 | * @expectedExceptionMessage Invalid property 'MyPersonalSection' for this control file. 35 | */ 36 | public function testFilterMissingOrInvalidProperties() 37 | { 38 | $this->object["MyPersonalSection"] = "Test"; 39 | } 40 | 41 | public function testOverwriteConfiguration() 42 | { 43 | $this->object["Version"] = "1.0.1"; 44 | $this->object["Section"] = "Software"; 45 | $this->object["Priority"] = "security"; 46 | $this->object["Architecture"] = "x86"; 47 | $this->object["Essential"] = "yes"; 48 | $this->object["Installed-Size"] = "2048"; 49 | $this->object["Maintainer"] = "Walter Dal Mut "; 50 | $this->object["Provides"] = "Corley SRL"; 51 | $this->object["Description"] = "My Desc"; 52 | $this->object["Depends"] = "php5-cli"; 53 | $this->object["Recommends"] = "php5-curl"; 54 | 55 | $conf = (string)$this->object; 56 | 57 | $expected = << 67 | Provides: Corley SRL 68 | Description: My Desc 69 | 70 | OEF; 71 | $this->assertEquals($expected, $conf); 72 | } 73 | } 74 | --------------------------------------------------------------------------------