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.

145 lines
4.0 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/Check-PkgVersion
  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" = "-repository" ] ; then
  25. shift ; for y ; do
  26. for x in package/$y/* ; do $0 ${x##*/} ; done
  27. done
  28. exit 0
  29. fi
  30. if [ "$1" != "${1#-}" -o $# -eq 0 ] ; then
  31. echo "Usage: $0 <package-names>"
  32. echo "or $0 -repository <repository-names>"
  33. exit 1
  34. fi
  35. mkdir -p checkver
  36. for package ; do
  37. for pdir in package/*/$package ; do : ; done
  38. if [ -x $pdir/check-version ] ; then
  39. sh $pdir/check-version
  40. elif [ -f $pdir/$package.desc ] ; then
  41. x="`egrep '^\[D\] ' $pdir/$package.desc | head -1 | tr -s ' '`"
  42. if [ -z "$x" ] ; then
  43. echo "No [D] for package $package found!"
  44. else
  45. echo "Testing package $package ..."
  46. {
  47. pattern="`echo $x | cut -f3 -d' ' | \
  48. sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
  49. -e 's,$,[0-9],' -e 's,^,^,'`"
  50. url="`echo $x | cut -f4 -d' '`"
  51. case "$url" in
  52. !*) url="`echo "$url" | sed -e 's,^!,,' \
  53. -e 's,[^/]*$,,'`" ;;
  54. esac
  55. delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz)$ ^[^0-9]+'
  56. delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
  57. delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
  58. if egrep -q '^\[CV-URL\] ' $pdir/$package.desc ; then
  59. url="`egrep '^\[CV-URL\] ' \
  60. $pdir/$package.desc | head -1 | \
  61. tr -s ' ' | cut -f2 -d' '`"
  62. fi
  63. if egrep -q '^\[CV-PAT\]' $pdir/$package.desc ; then
  64. pattern="`egrep '^\[CV-PAT\]' \
  65. $pdir/$package.desc | head -1 | \
  66. cut -s -f2- -d' '`"
  67. fi
  68. if egrep -q '^\[CV-DEL\]' $pdir/$package.desc ; then
  69. delpattern="`egrep '^\[CV-DEL\]' \
  70. $pdir/$package.desc | head -1 | \
  71. cut -s -f2- -d' ' | tr -s ' '`"
  72. fi
  73. echo -e "\n** `echo $x | cut -f3 -d' '`\n"
  74. echo "package='$package' pattern='$pattern'"
  75. echo -e "url='$url'\ndelpattern='$delpattern'"
  76. echo
  77. curl --disable-epsv -s "$url" | \
  78. tee checkver/debug.1 | \
  79. tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
  80. tee checkver/debug.2 | \
  81. perl -e "while (<>) { chomp;
  82. \$fn=\$_; next unless /$pattern/;
  83. foreach \$x (qw/$delpattern/) { s/\$x//g; }
  84. print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
  85. tee checkver/debug.3 | \
  86. perl -we '
  87. use strict;
  88. my ($a, $b);
  89. my %x;
  90. while (<>) {
  91. next unless /(\S+)\s+(\S+)/;
  92. $a=$1; $_=$1; $b=$2;
  93. s/(\d+)/sprintf("%020d", $1)/eg;
  94. # print "$_:$a:$b\n";
  95. if (not defined $x{$_}) {
  96. $x{$_}="$a\t$b";
  97. } else {
  98. $x{$_}.=" $b";
  99. }
  100. }
  101. foreach (reverse sort keys %x) {
  102. print "$x{$_}\n";
  103. }' | tee checkver/$package.new | \
  104. while read line ; do
  105. if [ ! -f checkver/$package.txt ] ||
  106. ! grep -qx "$line" checkver/$package.txt
  107. then
  108. echo " * $line" | expand -t20
  109. else
  110. echo " $line" | expand -t20
  111. fi
  112. done
  113. } > checkver/$package.msg
  114. if ! [ -s checkver/$package.new ] ; then
  115. echo "Got no list for package $package!" \
  116. >> checkver/$package.msg
  117. cat checkver/$package.msg ; echo
  118. else
  119. if grep -q '^ \* ' checkver/$package.msg
  120. then cat checkver/$package.msg ; echo
  121. else rm checkver/$package.msg ; fi
  122. fi
  123. if [ -f checkver/$package.msg ] ; then
  124. echo >> checkver/$package.msg
  125. fi
  126. fi
  127. else
  128. echo "ERROR: Package $package not found!"
  129. fi
  130. done