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.

170 lines
4.5 KiB

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