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.

102 lines
3.0 KiB

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