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.

123 lines
3.5 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. y="`echo $bzfile | cut -f$cmpfield -d/`"
  49. for x ; do
  50. [ $checkthis = 1 ] && checkthis=0
  51. [ "$y" = $x ] && checkthis=2
  52. done
  53. if [ $checkthis = 0 ] ; then
  54. : echo "Skip: $bzfile" ; continue
  55. fi
  56. if [[ "$bzfile" = *.bz2 ]] || [[ "$bzfile" = *.tbz2 ]] ; then
  57. echo -n "$bzfile (bzip2): " >&2
  58. cksum="`bunzip2 < $bzfile | cksum | cut -f1 -d' '`"
  59. else
  60. echo -n "$gzfile (raw): " >&2
  61. cksum="`cksum "$gzfile" | cut -f1 -d' '`"
  62. fi
  63. echo $cksum >&2
  64. rep="`echo $bzfile | cut -f2 -d/`"
  65. if [ -d package/$rep ] ; then
  66. xfile="`echo $gzfile | cut -f4- -d/`"
  67. pkgdir="package/`echo $gzfile | cut -f2,3 -d/`"
  68. descfile="$pkgdir/`echo $gzfile | cut -f3 -d/`.desc"
  69. if [ -f $descfile ] ; then
  70. sedscript="s,\[D\] *00* *$xfile,[D] $cksum $xfile,"
  71. sed "$sedscript" < $descfile > /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 [ -d target/$rep ] ; then
  86. descfile="target/$rep/download.txt"
  87. else
  88. descfile="scripts/miscdown.txt"
  89. fi
  90. xfile="`echo $gzfile | cut -f3- -d/`"
  91. if [ -f $descfile ] ; then
  92. sedscript="s,^00* *$xfile,$cksum $xfile,"
  93. sed "$sedscript" < $descfile > /tmp/$$
  94. if cmp -s ./$descfile /tmp/$$ ; then
  95. echo "!!! SED script didn't change anything:" >&2
  96. echo "!!! $sedscript" >&2
  97. else
  98. { echo "diff -u -U 0 ./$descfile /tmp/$$"
  99. diff -u -U 0 ./$descfile /tmp/$$ ; }
  100. fi
  101. rm -f /tmp/$$
  102. else
  103. echo "!!! No Desc File for $gzfile" >&2
  104. echo "!!! (My guess was $descfile)" >&2
  105. fi
  106. else
  107. echo "!!! No Desc File for $gzfile" >&2
  108. echo "!!! (I didn't have any possible guesses)" >&2
  109. fi
  110. fi
  111. done