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.

127 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) ..." >&2
  34. [ $# = 0 ] && set Documentation/. architecture/. misc/. \
  35. package/. scripts/. target/.
  36. bash scripts/xfind.sh $* -type f ! -name "*~" \
  37. ! -name Create-CopyPatch | sed 's,/\./,/,g' | \
  38. while read filename
  39. do
  40. grep -q -- '--- NO-ROCK-COPYRIGHT-NOTE ---' $filename && continue
  41. tag="`grep -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' \
  42. $filename | sed 's,---.*,,' | head -n 1`"
  43. cat $filename > $oldfile
  44. if [ -z "$tag" -a '(' \
  45. "$filename" != "${filename%/*.init}" -o \
  46. "$filename" != "${filename%/*.sh}" ')' ] &&
  47. grep -n '^#!' $filename | grep -q ':1:'
  48. then
  49. sed '1 a\
  50. #
  51. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  52. # --- ROCK-COPYRIGHT-NOTE-END ---' < $filename > $oldfile
  53. tag="# "
  54. fi
  55. if [ -z "$tag" -a '(' \
  56. "" != "$( expr $filename : \
  57. 'package/.*/\(.*\)/\1\.conf' )" -o \
  58. "$filename" != "${filename%/*.diff}" -o \
  59. "$filename" != "${filename%/*.patch}" -o \
  60. "$filename" != "${filename%/*.patch.*}" -o \
  61. "$filename" != "${filename%/parse-config*}" -o \
  62. "$filename" != "${filename%/*config*.in}" -o \
  63. "$filename" != "${filename%/config*.hlp}" ')' ]
  64. then
  65. sed '1 i\
  66. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  67. # --- ROCK-COPYRIGHT-NOTE-END ---\
  68. ' < $filename > $oldfile
  69. tag="# "
  70. fi
  71. if [ -z "$tag" -a '(' \
  72. "$filename" != "${filename%/*.cache}" -o \
  73. "$filename" != "${filename%/*.desc}" ')' ]
  74. then
  75. sed '1 i\
  76. [COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN ---\
  77. [COPY] --- ROCK-COPYRIGHT-NOTE-END ---
  78. ' < $filename > $oldfile
  79. tag="[COPY] "
  80. fi
  81. if [ "$tag" ] ; then
  82. {
  83. grep -B 100000 -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' $oldfile
  84. if [ "$filename" != "${filename%/*.diff}" -o \
  85. "$filename" != "${filename%/*.patch}" -o \
  86. "$filename" != "${filename%/*.patch.*}" ] ; then
  87. cat $copynotepatch | \
  88. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  89. else
  90. cat $copynote | \
  91. sed -e "s,@@FILENAME@@,$filename,; s,^,$tag,"
  92. fi
  93. grep -A 100000 -- '--- ROCK-COPYRIGHT-NOTE-END ---' $oldfile
  94. } > $newfile
  95. if ! cmp -s $oldfile $newfile ; then
  96. echo "Creating patch for $filename." >&2
  97. diff -u ./$filename $newfile |
  98. sed -e "2 s,$newfile,./$filename,"
  99. fi
  100. else
  101. echo "WARNING: No Copyright tags in $filename found!" >&2
  102. fi
  103. done
  104. rm -f $copynote $copynotepatch $newfile