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.

146 lines
4.3 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) ..." >&2
  34. if [ $1 == -help ] ; then
  35. echo
  36. echo "Usage: ./scripts/Create-CopyPatch [ <directories> ]"
  37. echo
  38. echo " Update copyright notes in files that already contain such a note."
  39. echo " The first and last line of ROCK copyright notes are marked by the"
  40. echo " --- ROCK-COPYRIGHT-NOTE-BEGIN ---"
  41. echo " and"
  42. echo " --- ROCK-COPYRIGHT-NOTE-END ---"
  43. echo " respectively."
  44. echo " Files that contain the line"
  45. echo " --- NO-ROCK-COPYRIGHT-NOTE ---"
  46. echo " are not updated."
  47. echo " If no directories are given, process Documentation, architecture,"
  48. echo " misc, package, scripts and target."
  49. echo
  50. exit
  51. fi
  52. [ $# = 0 ] && set Documentation/. architecture/. misc/. \
  53. package/. scripts/. target/.
  54. bash scripts/xfind.sh $* -type f ! -name "*~" \
  55. ! -name Create-CopyPatch | sed 's,/\./,/,g' | \
  56. while read filename
  57. do
  58. grep -q -- '--- NO-ROCK-COPYRIGHT-NOTE ---' $filename && continue
  59. tag="`grep -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' \
  60. $filename | sed 's,---.*,,' | head -n 1`"
  61. cat $filename > $oldfile
  62. if [ -z "$tag" -a '(' \
  63. "$filename" != "${filename%/*.init}" -o \
  64. "$filename" != "${filename%/*.sh}" ')' ] &&
  65. grep -n '^#!' $filename | grep -q ':1:'
  66. then
  67. sed '1 a\
  68. #
  69. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  70. # --- ROCK-COPYRIGHT-NOTE-END ---' < $filename > $oldfile
  71. tag="# "
  72. fi
  73. if [ -z "$tag" -a '(' \
  74. "" != "$( expr $filename : \
  75. 'package/.*/\(.*\)/\1\.conf' )" -o \
  76. "$filename" != "${filename%/*.diff}" -o \
  77. "$filename" != "${filename%/*.patch}" -o \
  78. "$filename" != "${filename%/*.patch.*}" -o \
  79. "$filename" != "${filename%/parse-config*}" -o \
  80. "$filename" != "${filename%/*config*.in}" -o \
  81. "$filename" != "${filename%/config*.hlp}" ')' ]
  82. then
  83. sed '1 i\
  84. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  85. # --- ROCK-COPYRIGHT-NOTE-END ---\
  86. ' < $filename > $oldfile
  87. tag="# "
  88. fi
  89. if [ -z "$tag" -a '(' \
  90. "$filename" != "${filename%/*.cache}" -o \
  91. "$filename" != "${filename%/*.desc}" ')' ]
  92. then
  93. sed '1 i\
  94. [COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  95. [COPY] --- ROCK-COPYRIGHT-NOTE-END ---
  96. ' < $filename > $oldfile
  97. tag="[COPY] "
  98. fi
  99. if [ "$tag" ] ; then
  100. {
  101. grep -B 100000 -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' $oldfile
  102. if [ "$filename" != "${filename%/*.diff}" -o \
  103. "$filename" != "${filename%/*.patch}" -o \
  104. "$filename" != "${filename%/*.patch.*}" ] ; then
  105. cat $copynotepatch | \
  106. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  107. else
  108. cat $copynote | \
  109. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  110. fi
  111. grep -A 100000 -- '--- ROCK-COPYRIGHT-NOTE-END ---' $oldfile
  112. } > $newfile
  113. if ! cmp -s $oldfile $newfile ; then
  114. echo "Creating patch for $filename." >&2
  115. diff -u ./$filename $newfile |
  116. sed -e "2 s,$newfile,./$filename,"
  117. fi
  118. else
  119. echo "WARNING: No Copyright tags in $filename found!" >&2
  120. fi
  121. done
  122. rm -f $copynote $copynotepatch $newfile