|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php |
| 3 | +namespace de\bisaboard\bisaboard; |
| 4 | +/** |
| 5 | + * Builds be.bastelstu.max.pushNotification |
| 6 | + * |
| 7 | + * @author Tim Düsterhus, edited by Maximilian Mader |
| 8 | + * @copyright 2012-2013 Tim Düsterhus |
| 9 | + * @license BSD 3-Clause License <http://opensource.org/licenses/BSD-3-Clause> |
| 10 | + * @package be.bastelstu.wcf.nodePush |
| 11 | + */ |
| 12 | +$packageXML = file_get_contents('package.xml'); |
| 13 | +preg_match('/<version>(.*?)<\/version>/', $packageXML, $matches); |
| 14 | +echo "Building be.bastelstu.max.pushNotification $matches[1]\n"; |
| 15 | +echo str_repeat("=", strlen("Building be.bastelstu.max.pushNotification $matches[1]"))."\n"; |
| 16 | + |
| 17 | +echo <<<EOT |
| 18 | +Cleaning up |
| 19 | +----------- |
| 20 | +
|
| 21 | +EOT; |
| 22 | + if (file_exists('package.xml.old')) { |
| 23 | + file_put_contents('package.xml', file_get_contents('package.xml.old')); |
| 24 | + unlink('package.xml.old'); |
| 25 | + } |
| 26 | + if (file_exists('file.tar')) unlink('file.tar'); |
| 27 | + if (file_exists('acptemplates.tar')) unlink('acptemplates.tars'); |
| 28 | + if (file_exists('be.bastelstu.max.pushNotification')) unlink('be.bastelstu.max.pushNotification'); |
| 29 | +echo <<<EOT |
| 30 | +
|
| 31 | +Checking PHP for Syntax Errors |
| 32 | +------------------------------ |
| 33 | +
|
| 34 | +EOT; |
| 35 | + chdir('file'); |
| 36 | + $check = null; |
| 37 | + $check = function ($folder) use (&$check) { |
| 38 | + if (is_file($folder)) { |
| 39 | + if (substr($folder, -4) === '.php') { |
| 40 | + passthru('php -l '.escapeshellarg($folder), $code); |
| 41 | + if ($code != 0) exit($code); |
| 42 | + } |
| 43 | + |
| 44 | + return; |
| 45 | + } |
| 46 | + $file = glob($folder.'/*'); |
| 47 | + foreach ($file as $file) { |
| 48 | + $check($file); |
| 49 | + } |
| 50 | + }; |
| 51 | + $check('.'); |
| 52 | +echo <<<EOT |
| 53 | +
|
| 54 | +Building file.tar |
| 55 | +------------------ |
| 56 | +
|
| 57 | +EOT; |
| 58 | + passthru('tar cvf ../file.tar --exclude=.git -- *', $code); |
| 59 | + if ($code != 0) exit($code); |
| 60 | +echo <<<EOT |
| 61 | +
|
| 62 | +Building acptemplates.tar |
| 63 | +------------------------- |
| 64 | +
|
| 65 | +EOT; |
| 66 | + if (is_dir('../acptemplates')) { |
| 67 | + chdir('../acptemplates'); |
| 68 | + passthru('tar cvf ../acptemplates.tar *', $code); |
| 69 | + if ($code != 0) exit($code); |
| 70 | + } |
| 71 | + else { |
| 72 | + echo 'No ACP templates found.'; |
| 73 | + } |
| 74 | + |
| 75 | +echo <<<EOT |
| 76 | +
|
| 77 | +Building be.bastelstu.max.pushNotification |
| 78 | +------------------------------------------ |
| 79 | +
|
| 80 | +EOT; |
| 81 | + chdir('..'); |
| 82 | + file_put_contents('package.xml.old', file_get_contents('package.xml')); |
| 83 | + file_put_contents('package.xml', preg_replace('~<date>\d{4}-\d{2}-\d{2}</date>~', '<date>'.date('Y-m-d').'</date>', file_get_contents('package.xml'))); |
| 84 | + passthru('tar cvf be.bastelstu.max.pushNotification.tar --exclude=*.old --exclude=file --exclude=contrib -- *', $code); |
| 85 | + if (file_exists('package.xml.old')) { |
| 86 | + file_put_contents('package.xml', file_get_contents('package.xml.old')); |
| 87 | + unlink('package.xml.old'); |
| 88 | + } |
| 89 | + if ($code != 0) exit($code); |
| 90 | + |
| 91 | +if (file_exists('file.tar')) unlink('file.tar'); |
| 92 | +if (file_exists('acptemplates.tar')) unlink('acptemplates.tar'); |
0 commit comments