fix_license 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/php
  2. <?php
  3. define('INSTALLDIR', dirname(__DIR__));
  4. require INSTALLDIR . '/vendor/autoload.php';
  5. use Functional as F;
  6. use App\Util\Functional;
  7. $filenames = glob(INSTALLDIR . '/src/*/*.php');
  8. $files = F\map($filenames, Functional::arity('file_get_contents', 1));
  9. $old_licenses = ['/* {{{ License
  10. * This file is part of GNU social - https://www.gnu.org/software/social
  11. *
  12. * GNU social is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * GNU social is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. ', '// {{{ License
  26. // This file is part of GNU social - https://www.gnu.org/software/soci
  27. //
  28. // GNU social is free software: you can redistribute it and/or modify
  29. // it under the terms of the GNU Affero General Public License as published by
  30. // the Free Software Foundation, either version 3 of the License, or
  31. // (at your option) any later version.
  32. //
  33. // GNU social is distributed in the hope that it will be useful,
  34. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. // GNU Affero General Public License for more details.
  37. //
  38. // You should have received a copy of the GNU Affero General Public License
  39. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  40. // }}}
  41. ', '/*
  42. * This file is part of GNU social - https://www.gnu.org/software/social
  43. *
  44. * GNU social is free software: you can redistribute it and/or modify
  45. * it under the terms of the GNU Affero General Public License as published by
  46. * the Free Software Foundation, either version 3 of the License, or
  47. * (at your option) any later version.
  48. *
  49. * GNU social is distributed in the hope that it will be useful,
  50. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  51. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  52. * GNU Affero General Public License for more details.
  53. *
  54. * You should have received a copy of the GNU Affero General Public License
  55. * along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  56. */'];
  57. $new_license = "// {{{ License
  58. // This file is part of GNU social - https://www.gnu.org/software/social
  59. //
  60. // GNU social is free software: you can redistribute it and/or modify
  61. // it under the terms of the GNU Affero General Public License as published by
  62. // the Free Software Foundation, either version 3 of the License, or
  63. // (at your option) any later version.
  64. //
  65. // GNU social is distributed in the hope that it will be useful,
  66. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  67. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  68. // GNU Affero General Public License for more details.
  69. //
  70. // You should have received a copy of the GNU Affero General Public License
  71. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  72. // }}}
  73. ";
  74. foreach ($old_licenses as $old) {
  75. $files = str_replace("$old", "$new_license", $files);
  76. }
  77. F\map(F\zip($files, $filenames),
  78. function ($arg)
  79. {
  80. list($file, $filename) = $arg;
  81. file_put_contents($filename, $file);
  82. }
  83. );