OpenSDE Framework (without history before r20070)
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.

169 lines
4.5 KiB

  1. #!/bin/bash
  2. #
  3. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. #
  6. # T2 SDE: scripts/Check-PkgVersion
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- T2-COPYRIGHT-NOTE-END ---
  17. if [ "$1" = "-repository" ] ; then
  18. shift ; for y ; do
  19. for x in package/$y/* ; do $0 ${x##*/} ; done
  20. done
  21. exit 0
  22. fi
  23. if [ "$1" != "${1#-}" -o $# -eq 0 ] ; then
  24. echo "Usage: $0 <package-names>"
  25. echo "or $0 -repository <repository-names>"
  26. exit 1
  27. fi
  28. curl_options='--disable-epsv'
  29. # Set proxy information
  30. if [ -f download/Proxy ]; then
  31. proxy="`cat download/Proxy`"
  32. if [ "$proxy" ]; then
  33. echo "INFO: Setting proxy to $proxy."
  34. curl_options="$curl_options --proxy $proxy"
  35. else
  36. echo "INFO: No proxy information... removing download/Proxy."
  37. rm download/Proxy
  38. fi
  39. fi
  40. if [ -f download/Proxy-auth ]; then
  41. proxyauth="`cat download/Proxy-auth`"
  42. if [ "$proxyauth" ]; then
  43. echo "INFO: Setting proxy authentication information."
  44. curl_options="$curl_options --proxy-user $proxyauth"
  45. else
  46. echo "INFO: No proxy-auth information... removing download/Proxy-auth."
  47. rm download/Proxy-auth
  48. fi
  49. fi
  50. mkdir -p checkver
  51. for package ; do
  52. for pdir in package/*/$package ; do : ; done
  53. if [ -x $pdir/check-version ] ; then
  54. sh $pdir/check-version
  55. elif [ -f $pdir/$package.desc ] ; then
  56. x="`egrep '^\[D\] ' $pdir/$package.desc | head -n 1 | tr -s ' '`"
  57. if [ -z "$x" ] ; then
  58. echo "No [D] for package $package found!"
  59. else
  60. echo "Testing package $package ..."
  61. {
  62. pattern="`echo $x | cut -f3 -d' '`"
  63. url="`echo $x | cut -f4 -d' '`"; url="${url#-}"
  64. if [ "${url:0:1}" == "!" ]; then
  65. pattern="${url##*/}"
  66. url="${url%/*}"
  67. fi
  68. url="$( echo ${url#!} | sed -e 's,http://dl.sourceforge.net/sourceforge/,http://prdownloads.sourceforge.net/,' )"
  69. pattern="`echo $pattern | \
  70. sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
  71. -e 's,$,[0-9],' -e 's,^,^,'`"
  72. delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz|tbz)$ ^[^0-9]+'
  73. delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
  74. delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
  75. if egrep -q '^\[CV-URL\] ' $pdir/$package.desc ; then
  76. url="`egrep '^\[CV-URL\] ' \
  77. $pdir/$package.desc | head -n 1 | \
  78. tr -s ' ' | cut -f2 -d' '`"
  79. fi
  80. if egrep -q '^\[CV-PAT\]' $pdir/$package.desc ; then
  81. pattern="`egrep '^\[CV-PAT\]' \
  82. $pdir/$package.desc | head -n 1 | \
  83. cut -s -f2- -d' '`"
  84. fi
  85. if egrep -q '^\[CV-DEL\]' $pdir/$package.desc ; then
  86. delpattern="`egrep '^\[CV-DEL\]' \
  87. $pdir/$package.desc | head -n 1 | \
  88. cut -s -f2- -d' ' | tr -s ' '`"
  89. fi
  90. echo -e "\n** `echo $x | cut -f3 -d' '`\n"
  91. echo "package='$package' pattern='$pattern'"
  92. echo -e "url='$url'\ndelpattern='$delpattern'"
  93. echo
  94. curl $curl_options -s "$url" | \
  95. tee checkver/debug.1 | \
  96. tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
  97. tee checkver/debug.2 | \
  98. perl -e "while (<>) { chomp;
  99. \$fn=\$_; next unless /$pattern/;
  100. foreach \$x (qw/$delpattern/) { s/\$x//g; }
  101. print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
  102. tee checkver/debug.3 | \
  103. perl -we '
  104. use strict;
  105. my ($a, $b);
  106. my %x;
  107. while (<>) {
  108. next unless /(\S+)\s+(\S+)/;
  109. $a=$1; $_=$1; $b=$2;
  110. s/(\d+)/sprintf("%020d", $1)/eg;
  111. # print "$_:$a:$b\n";
  112. if (not defined $x{$_}) {
  113. $x{$_}="$a\t$b";
  114. } else {
  115. $x{$_}.=" $b";
  116. }
  117. }
  118. foreach (reverse sort keys %x) {
  119. print "$x{$_}\n";
  120. }' | tee checkver/$package.new | \
  121. while read line ; do
  122. if [ ! -f checkver/$package.txt ] ||
  123. ! grep -qx "$line" checkver/$package.txt
  124. then
  125. echo " * $line" | expand -t20
  126. else
  127. echo " $line" | expand -t20
  128. fi
  129. done
  130. } > checkver/$package.msg
  131. if ! [ -s checkver/$package.new ] ; then
  132. echo "Got no list for package $package!" \
  133. >> checkver/$package.msg
  134. cat checkver/$package.msg ; echo
  135. else
  136. if grep -q '^ \* ' checkver/$package.msg
  137. then cat checkver/$package.msg ; echo
  138. else rm checkver/$package.msg ; fi
  139. fi
  140. if [ -f checkver/$package.msg ] ; then
  141. echo >> checkver/$package.msg
  142. fi
  143. fi
  144. else
  145. echo "ERROR: Package $package not found!"
  146. fi
  147. done