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.

122 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. tempdesc=`mktemp`
  43. temppatch=`mktemp`
  44. ./scripts/Download -list-cksums | grep '^00* ' | \
  45. while read cksum gzfile ; do
  46. bzfile="`echo "$gzfile" | sed 's,\.\(t\?\)\(gz\|Z\)$,.\1bz2,'`"
  47. if [ -f "$bzfile" ]
  48. then
  49. checkthis=1
  50. xfile="`basename $gzfile`"
  51. descfile="`grep $xfile package/*/*/*.desc target/*/download.txt | sed 's,:.*,,'`"
  52. rep="`echo $descfile | cut -f2 -d/`"
  53. pkg="`echo $descfile | cut -f3 -d/`"
  54. for x ; do
  55. [ $checkthis = 1 ] && checkthis=0
  56. [ "$pkg" = $x ] && checkthis=2
  57. [ "$descfile" = $x ] && checkthis=2
  58. done
  59. if [ $checkthis = 0 ] ; then
  60. : echo "Skip: $bzfile" ; continue
  61. fi
  62. if [[ "$bzfile" = *.bz2 ]] || [[ "$bzfile" = *.tbz2 ]] ; then
  63. echo -n "$bzfile (bzip2): " >&2
  64. cksum="`bunzip2 < $bzfile | cksum | cut -f1 -d' '`"
  65. else
  66. echo -n "$gzfile (raw): " >&2
  67. cksum="`cksum "$gzfile" | cut -f1 -d' '`"
  68. fi
  69. echo $cksum >&2
  70. if [ -d package/$rep ] ; then
  71. if [ -f $descfile ] ; then
  72. if [ ! -s $tempdesc ] ; then
  73. cat $descfile > $tempdesc
  74. fi
  75. sedscript="s,\[D\] *00* *$xfile,[D] $cksum $xfile,"
  76. sed "$sedscript" -i $tempdesc
  77. if cmp -s ./$descfile $tempdesc ; then
  78. echo "!!! SED script didn't change anything:" >&2
  79. echo "!!! $sedscript" >&2
  80. else
  81. diff -u -U 0 ./$descfile $tempdesc >$temppatch
  82. fi
  83. else
  84. echo "!!! No Desc File for $gzfile" >&2
  85. echo "!!! (My guess was $descfile)" >&2
  86. fi
  87. elif [ -d target/$rep -o "$rep" = misc ] ; then
  88. if [ -f $descfile ] ; then
  89. if [ ! -s $tempdesc ] ; then
  90. cat $descfile > $tempdesc
  91. fi
  92. sedscript="s,^00* *$xfile,$cksum $xfile,"
  93. sed "$sedscript" -i $tempdesc
  94. if cmp -s ./$descfile $tempdesc ; then
  95. echo "!!! SED script didn't change anything:" >&2
  96. echo "!!! $sedscript" >&2
  97. else
  98. diff -u -U 0 ./$descfile $tempdesc > $temppatch
  99. fi
  100. else
  101. echo "!!! No Desc File for $gzfile" >&2
  102. echo "!!! (My guess was $descfile)" >&2
  103. fi
  104. else
  105. echo "!!! No Desc File for $gzfile" >&2
  106. echo "!!! (I didn't have any possible guesses)" >&2
  107. fi
  108. fi
  109. done
  110. [ -f $temppatch ] && cat $temppatch
  111. rm -f $temppatch $tempdesc