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.

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