mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.7 KiB

  1. #!/bin/bash
  2. copynote=`mktemp`
  3. copynotepatch=`mktemp`
  4. oldfile=`mktemp`
  5. newfile=`mktemp`
  6. cat << EOT > $copynote
  7. This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  8. Please add additional copyright information _after_ the line containing
  9. the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  10. the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  11. ROCK Linux: rock-src/@@FILENAME@@
  12. ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf
  13. EOT
  14. cp $copynote $copynotepatch
  15. cat << EOT >> $copynote
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2 of the License, or
  19. (at your option) any later version. A copy of the GNU General Public
  20. License can be found at Documentation/COPYING.
  21. Many people helped and are helping developing ROCK Linux. Please
  22. have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  23. file for details.
  24. EOT
  25. cat << EOT >> $copynotepatch
  26. This patch file is dual-licensed. It is available under the license the
  27. patched project is licensed under, as long as it is an OpenSource license
  28. as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  29. of the GNU General Public License as published by the Free Software
  30. Foundation; either version 2 of the License, or (at your option) any later
  31. version.
  32. EOT
  33. echo "Creating copy.patch (this may take a while) ..."
  34. echo -n > copy.patch
  35. [ $# = 0 ] && set Documentation/. architecture/. misc/. \
  36. package/. scripts/. target/.
  37. bash scripts/xfind.sh $* -type f ! -name "*~" \
  38. ! -name Create-CopyPatch | sed 's,/\./,/,g' | \
  39. while read filename
  40. do
  41. grep -q -- '--- NO-ROCK-COPYRIGHT-NOTE ---' $filename && continue
  42. tag="`grep -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' \
  43. $filename | sed 's,---.*,,' | head -1`"
  44. cat $filename > $oldfile
  45. if [ -z "$tag" -a '(' \
  46. "$filename" != "${filename%/*.init}" -o \
  47. "$filename" != "${filename%/*.sh}" ')' ] &&
  48. grep -n '^#!' $filename | grep -q ':1:'
  49. then
  50. sed '1 a\
  51. #
  52. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  53. # --- ROCK-COPYRIGHT-NOTE-END ---' < $filename > $oldfile
  54. tag="# "
  55. fi
  56. if [ -z "$tag" -a '(' \
  57. "" != "$( expr $filename : \
  58. 'package/.*/\(.*\)/\1\.conf' )" -o \
  59. "$filename" != "${filename%/*.diff}" -o \
  60. "$filename" != "${filename%/*.patch}" -o \
  61. "$filename" != "${filename%/*.patch.*}" -o \
  62. "$filename" != "${filename%/parse-config*}" -o \
  63. "$filename" != "${filename%/*config*.in}" -o \
  64. "$filename" != "${filename%/config*.hlp}" ')' ]
  65. then
  66. sed '1 i\
  67. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  68. # --- ROCK-COPYRIGHT-NOTE-END ---\
  69. ' < $filename > $oldfile
  70. tag="# "
  71. fi
  72. if [ -z "$tag" -a '(' \
  73. "$filename" != "${filename%/*.cache}" -o \
  74. "$filename" != "${filename%/*.desc}" ')' ]
  75. then
  76. sed '1 i\
  77. [COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  78. [COPY] --- ROCK-COPYRIGHT-NOTE-END ---
  79. ' < $filename > $oldfile
  80. tag="[COPY] "
  81. fi
  82. if [ "$tag" ] ; then
  83. {
  84. grep -B 100000 -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' $oldfile
  85. if [ "$filename" != "${filename%/*.diff}" -o \
  86. "$filename" != "${filename%/*.patch}" -o \
  87. "$filename" != "${filename%/*.patch.*}" ] ; then
  88. cat $copynotepatch | \
  89. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  90. else
  91. cat $copynote | \
  92. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  93. fi
  94. grep -A 100000 -- '--- ROCK-COPYRIGHT-NOTE-END ---' $oldfile
  95. } > $newfile
  96. if ! cmp -s $oldfile $newfile ; then
  97. echo "Creating patch for $filename."
  98. diff -u ./$filename $newfile |
  99. sed -e "2 s,$newfile,./$filename," >> copy.patch
  100. fi
  101. else
  102. echo "WARNING: No Copyright tags in $filename found!"
  103. fi
  104. done
  105. rm -f $copynote $copynotepatch $newfile