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.

116 lines
3.4 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Create-CkSumPatch
  11. # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. if [ $# = 1 -a "$1" = -misc ] ; then
  25. set x -repository misc ; shift
  26. fi
  27. if [ $# = 1 -a "$1" = -all ] ; then
  28. shift $# ; cmpfield=2
  29. else
  30. if [ "$1" = "-repository" -o "$1" = "-target" ]
  31. then cmpfield=2 ; shift ; else cmpfield=3 ; fi
  32. if [ "$#" -eq 0 -o "${1#-}" != "$1" ] ; then
  33. echo "Usage: $0 <package-names>"
  34. echo "or $0 -repository <respository-names>"
  35. echo "or $0 -target <target-names>"
  36. echo "or $0 -misc"
  37. echo "or $0 -all"
  38. exit 1
  39. fi
  40. fi
  41. echo "Creating cksum.patch ..." >&2
  42. ./scripts/Download -list-cksums | grep '^00* ' | \
  43. while read cksum gzfile ; do
  44. bzfile="`echo "$gzfile" | sed 's,\.\(t\?\)\(gz\|Z\)$,.\1bz2,'`"
  45. if [ -f "$bzfile" ]
  46. then
  47. checkthis=1
  48. xfile="`basename $gzfile`"
  49. descfile="`grep $xfile package/*/*/*.desc target/*/download.txt | sed 's,:.*,,'`"
  50. rep="`echo $descfile | cut -f2 -d/`"
  51. pkg="`echo $descfile | cut -f3 -d/`"
  52. for x ; do
  53. [ $checkthis = 1 ] && checkthis=0
  54. [ "$pkg" = $x ] && checkthis=2
  55. [ "$descfile" = $x ] && checkthis=2
  56. done
  57. if [ $checkthis = 0 ] ; then
  58. : echo "Skip: $bzfile" ; continue
  59. fi
  60. if [[ "$bzfile" = *.bz2 ]] || [[ "$bzfile" = *.tbz2 ]] ; then
  61. echo -n "$bzfile (bzip2): " >&2
  62. cksum="`bunzip2 < $bzfile | cksum | cut -f1 -d' '`"
  63. else
  64. echo -n "$gzfile (raw): " >&2
  65. cksum="`cksum "$gzfile" | cut -f1 -d' '`"
  66. fi
  67. echo $cksum >&2
  68. if [ -d package/$rep ] ; then
  69. if [ -f $descfile ] ; then
  70. sedscript="s,\[D\] *00* *$xfile,[D] $cksum $xfile,"
  71. sed "$sedscript" -i /tmp/$$
  72. if cmp -s ./$descfile /tmp/$$ ; then
  73. echo "!!! SED script didn't change anything:" >&2
  74. echo "!!! $sedscript" >&2
  75. else
  76. { echo "diff -u -U 0 ./$descfile /tmp/$$"
  77. diff -u -U 0 ./$descfile /tmp/$$ ; }
  78. fi
  79. rm -f /tmp/$$
  80. else
  81. echo "!!! No Desc File for $gzfile" >&2
  82. echo "!!! (My guess was $descfile)" >&2
  83. fi
  84. elif [ -d target/$rep -o "$rep" = misc ] ; then
  85. if [ -f $descfile ] ; then
  86. sedscript="s,^00* *$xfile,$cksum $xfile,"
  87. sed "$sedscript" < $descfile > /tmp/$$
  88. if cmp -s ./$descfile /tmp/$$ ; then
  89. echo "!!! SED script didn't change anything:" >&2
  90. echo "!!! $sedscript" >&2
  91. else
  92. { echo "diff -u -U 0 ./$descfile /tmp/$$"
  93. diff -u -U 0 ./$descfile /tmp/$$ ; }
  94. fi
  95. rm -f /tmp/$$
  96. else
  97. echo "!!! No Desc File for $gzfile" >&2
  98. echo "!!! (My guess was $descfile)" >&2
  99. fi
  100. else
  101. echo "!!! No Desc File for $gzfile" >&2
  102. echo "!!! (I didn't have any possible guesses)" >&2
  103. fi
  104. fi
  105. done