* updated libxspf (1.2.0 -> 1.2.1)
[t2-trunk.git] / scripts / Check-PkgVersion
blob4b5d2cde9e46671abd6fc33b9d8f8c53ce525e00
1 #!/bin/bash
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 - 2020 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
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 ---
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
25 if [ "$1" != "${1#-}" -o $# -eq 0 ]; then
26 echo "Usage: $0 <package-names>"
27 echo "or $0 -repository <repository-names>"
28 exit 1
31 curl_options='--disable-epsv'
33 # Set proxy information
34 if [ -f download/Proxy ]; then
35 proxy="$(< download/Proxy)"
36 if [ "$proxy" ]; then
37 echo "INFO: Setting proxy to $proxy."
38 curl_options="$curl_options --proxy $proxy"
39 else
40 echo "INFO: No proxy information... removing download/Proxy."
41 rm download/Proxy
44 if [ -f download/Proxy-auth ]; then
45 proxyauth="$(< download/Proxy-auth)"
46 if [ "$proxyauth" ]; then
47 echo "INFO: Setting proxy authentication information."
48 curl_options="$curl_options --proxy-user $proxyauth"
49 else
50 echo "INFO: No proxy-auth information... removing download/Proxy-auth."
51 rm download/Proxy-auth
57 mkdir -p checkver
59 for package; do
60 for pdir in package/*/$package; do :; done
61 if [ -x $pdir/check-version ]; then
62 sh $pdir/check-version
63 elif [ -f $pdir/$package.desc ]; then
64 x="`egrep '^\[D\] ' $pdir/$package.desc | head -n 1 | tr -s ' '`"
65 if [ -z "$x" ]; then
66 echo "No [D] for package $package found!"
67 else
68 echo "Testing package $package ..."
70 pattern="`echo $x | cut -f3 -d' '`"
71 url="`echo $x | cut -f4 -d' '`"; url="${url#-}"
73 if [ "${url:0:1}" == "!" ]; then
74 pattern="${url##*/}"
75 url="${url%/*}"
78 url="$( echo ${url#!} | sed -e 's,http://dl.sourceforge.net/sourceforge/,http://prdownloads.sourceforge.net/,' )"
79 pattern="`echo $pattern | \
80 sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
81 -e 's,$,[0-9],' -e 's,^,^,'`"
83 delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz|tbz)$ ^[^0-9]+'
84 delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
85 delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
87 if egrep -q '^\[CV-URL\] ' $pdir/$package.desc; then
88 url="`egrep '^\[CV-URL\] ' \
89 $pdir/$package.desc | head -n 1 | \
90 tr -s ' ' | cut -f2 -d' '`"
93 if egrep -q '^\[CV-PAT\]' $pdir/$package.desc; then
94 pattern="`egrep '^\[CV-PAT\]' \
95 $pdir/$package.desc | head -n 1 | \
96 cut -s -f2- -d' '`"
99 if egrep -q '^\[CV-DEL\]' $pdir/$package.desc; then
100 delpattern="`egrep '^\[CV-DEL\]' \
101 $pdir/$package.desc | head -n 1 | \
102 cut -s -f2- -d' ' | tr -s ' '`"
105 echo -e "\n** `echo $x | cut -f3 -d' '`\n"
106 echo "package='$package' pattern='$pattern'"
107 echo -e "url='$url'\ndelpattern='$delpattern'"
108 echo
110 curl $curl_options -s "$url" | \
111 tee checkver/debug.1 | \
112 tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
113 tee checkver/debug.2 | \
114 perl -e "while (<>) { chomp;
115 \$fn=\$_; next unless /$pattern/;
116 foreach \$x (qw/$delpattern/) { s/\$x//g; }
117 print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
118 tee checkver/debug.3 | \
119 perl -we '
120 use strict;
122 my ($a, $b);
123 my %x;
125 while (<>) {
126 next unless /(\S+)\s+(\S+)/;
127 $a=$1; $_=$1; $b=$2;
128 s/(\d+)/sprintf("%020d", $1)/eg;
129 # print "$_:$a:$b\n";
130 if (not defined $x{$_}) {
131 $x{$_}="$a\t$b";
132 } else {
133 $x{$_}.=" $b";
137 foreach (reverse sort keys %x) {
138 print "$x{$_}\n";
139 }' | tee checkver/$package.new | \
140 while read line; do
141 if [ ! -f checkver/$package.txt ] ||
142 ! grep -qx "$line" checkver/$package.txt
143 then
144 echo " * $line" | expand -t20
145 else
146 echo " $line" | expand -t20
148 done
150 } > checkver/$package.msg
152 if ! [ -s checkver/$package.new ]; then
153 echo "Got no list for package $package!" \
154 >> checkver/$package.msg
155 cat checkver/$package.msg; echo
156 else
157 if grep -q '^ \* ' checkver/$package.msg
158 then cat checkver/$package.msg; echo
159 else rm checkver/$package.msg; fi
162 if [ -f checkver/$package.msg ]; then
163 echo >> checkver/$package.msg
166 else
167 echo "ERROR: Package $package not found!"
169 done