fix_license 3.5 KB

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