files-checker.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Morris Jobke <hey@morrisjobke.de>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. $expectedFiles = [
  22. '.',
  23. '..',
  24. '.babelrc',
  25. '.codecov.yml',
  26. '.drone.yml',
  27. '.git',
  28. '.gitattributes',
  29. '.github',
  30. '.gitignore',
  31. '.gitmodules',
  32. '.htaccess',
  33. '.idea',
  34. '.jshintrc',
  35. '.mailmap',
  36. '.scrutinizer.yml',
  37. '.tag',
  38. '.tx',
  39. '.user.ini',
  40. '3rdparty',
  41. 'apps',
  42. 'AUTHORS',
  43. 'autotest-checkers.sh',
  44. 'autotest-external.sh',
  45. 'autotest-js.sh',
  46. 'autotest.sh',
  47. 'build',
  48. 'CHANGELOG.md',
  49. 'CODE_OF_CONDUCT.md',
  50. 'composer.json',
  51. 'config',
  52. 'console.php',
  53. 'contribute',
  54. 'COPYING',
  55. 'COPYING-README',
  56. 'core',
  57. 'cron.php',
  58. 'index.html',
  59. 'index.php',
  60. 'lib',
  61. 'Makefile',
  62. 'occ',
  63. 'ocs',
  64. 'ocs-provider',
  65. 'ocm-provider',
  66. 'package.json',
  67. 'package-lock.json',
  68. 'public.php',
  69. 'README.md',
  70. 'remote.php',
  71. 'resources',
  72. 'robots.txt',
  73. 'settings',
  74. 'status.php',
  75. 'tests',
  76. 'themes',
  77. 'version.php',
  78. 'webpack.common.js',
  79. 'webpack.dev.js',
  80. 'webpack.prod.js',
  81. ];
  82. $actualFiles = [];
  83. $files = new \DirectoryIterator(__DIR__ . '/..');
  84. foreach ($files as $file) {
  85. $actualFiles[] = $file->getFilename();
  86. }
  87. $additionalFiles = array_diff($actualFiles, $expectedFiles);
  88. $missingFiles = array_diff($expectedFiles, $actualFiles);
  89. $failed = false;
  90. if (count($additionalFiles) > 0) {
  91. echo sprintf('ERROR: There were %d additional files:', count($additionalFiles)) . PHP_EOL;
  92. echo implode(PHP_EOL, $additionalFiles) . PHP_EOL;
  93. $failed = true;
  94. }
  95. if (count($missingFiles) > 0) {
  96. echo sprintf('ERROR: There were %d missing files:', count($missingFiles)) . PHP_EOL;
  97. echo implode(PHP_EOL, $missingFiles) . PHP_EOL;
  98. $failed = true;
  99. }
  100. if ($failed) {
  101. echo 'ERROR: Please remove or add those files again or inform the release team about those now files to be included or excluded from the release tar ball.' . PHP_EOL;
  102. exit(1);
  103. }
  104. echo 'OK: all expected files are present and no additional files are there.' . PHP_EOL;
  105. exit(0);