early: fixed modprobe
[opensde-nopast.git] / scripts / Check-PkgVersion
blob05804c9443eabf0aea5cfecf9879945fcd6603a0
1 #!/bin/bash
3 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
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
11 # More information can be found in the files COPYING and README.
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 ---
19 if [ "$1" = "-repository" ] ; then
20 shift ; for y ; do
21 for x in package/$y/* ; do $0 ${x##*/} ; done
22 done
23 exit 0
26 if [ "$1" != "${1#-}" -o $# -eq 0 ] ; then
27 echo "Usage: $0 <package-names>"
28 echo "or $0 -repository <repository-names>"
29 exit 1
32 curl_options='--disable-epsv'
34 # Set proxy information
35 if [ -f download/Proxy ]; then
36 proxy="`cat download/Proxy`"
37 if [ "$proxy" ]; then
38 echo "INFO: Setting proxy to $proxy."
39 curl_options="$curl_options --proxy $proxy"
40 else
41 echo "INFO: No proxy information... removing download/Proxy."
42 rm download/Proxy
45 if [ -f download/Proxy-auth ]; then
46 proxyauth="`cat download/Proxy-auth`"
47 if [ "$proxyauth" ]; then
48 echo "INFO: Setting proxy authentication information."
49 curl_options="$curl_options --proxy-user $proxyauth"
50 else
51 echo "INFO: No proxy-auth information... removing download/Proxy-auth."
52 rm download/Proxy-auth
58 mkdir -p checkver
60 for package ; do
61 for pdir in package/*/$package ; do : ; done
62 if [ -x $pdir/check-version ] ; then
63 sh $pdir/check-version
64 elif [ -f $pdir/$package.desc ] ; then
65 x="`egrep '^\[D\] ' $pdir/$package.desc | head -n 1 | tr -s ' '`"
66 if [ -z "$x" ] ; then
67 echo "No [D] for package $package found!"
68 else
69 echo "Testing package $package ..."
71 pattern="`echo $x | cut -f3 -d' '`"
72 url="`echo $x | cut -f4 -d' '`"; url="${url#-}"
74 if [ "${url:0:1}" = "!" ]; then
75 pattern="${url##*/}"
76 url="${url%/*}"
79 url="$( echo ${url#!} | sed -e 's,http://dl.sourceforge.net/sourceforge/,http://prdownloads.sourceforge.net/,' )"
80 pattern="`echo $pattern | \
81 sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
82 -e 's,$,[0-9],' -e 's,^,^,'`"
84 delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz|tbz)$ ^[^0-9]+'
85 delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
86 delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
88 if egrep -q '^\[CV-URL\] ' $pdir/$package.desc ; then
89 url="`egrep '^\[CV-URL\] ' \
90 $pdir/$package.desc | head -n 1 | \
91 tr -s ' ' | cut -f2 -d' '`"
94 if egrep -q '^\[CV-PAT\]' $pdir/$package.desc ; then
95 pattern="`egrep '^\[CV-PAT\]' \
96 $pdir/$package.desc | head -n 1 | \
97 cut -s -f2- -d' '`"
100 if egrep -q '^\[CV-DEL\]' $pdir/$package.desc ; then
101 delpattern="`egrep '^\[CV-DEL\]' \
102 $pdir/$package.desc | head -n 1 | \
103 cut -s -f2- -d' ' | tr -s ' '`"
106 echo -e "\n** `echo $x | cut -f3 -d' '`\n"
107 echo "package='$package' pattern='$pattern'"
108 echo -e "url='$url'\ndelpattern='$delpattern'"
109 echo
111 curl $curl_options -s "$url" | \
112 tee checkver/debug.1 | \
113 tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
114 tee checkver/debug.2 | \
115 perl -e "while (<>) { chomp;
116 \$fn=\$_; next unless /$pattern/;
117 foreach \$x (qw/$delpattern/) { s/\$x//g; }
118 print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
119 tee checkver/debug.3 | \
120 perl -we '
121 use strict;
123 my ($a, $b);
124 my %x;
126 while (<>) {
127 next unless /(\S+)\s+(\S+)/;
128 $a=$1; $_=$1; $b=$2;
129 s/(\d+)/sprintf("%020d", $1)/eg;
130 # print "$_:$a:$b\n";
131 if (not defined $x{$_}) {
132 $x{$_}="$a\t$b";
133 } else {
134 $x{$_}.=" $b";
138 foreach (reverse sort keys %x) {
139 print "$x{$_}\n";
140 }' | tee checkver/$package.new | \
141 while read line ; do
142 if [ ! -f checkver/$package.txt ] ||
143 ! grep -qx "$line" checkver/$package.txt
144 then
145 echo " * $line" | expand -t20
146 else
147 echo " $line" | expand -t20
149 done
151 } > checkver/$package.msg
153 if ! [ -s checkver/$package.new ] ; then
154 echo "Got no list for package $package!" \
155 >> checkver/$package.msg
156 cat checkver/$package.msg ; echo
157 else
158 if grep -q '^ \* ' checkver/$package.msg
159 then cat checkver/$package.msg ; echo
160 else rm checkver/$package.msg ; fi
163 if [ -f checkver/$package.msg ] ; then
164 echo >> checkver/$package.msg
167 else
168 echo "ERROR: Package $package not found!"
170 done