* added python-wheel (0.42.0) - The official binary distribution format for Python
[t2sde.git] / scripts / Check-PkgVersion
blob42af6360a073666c60a4c312e443234c62fa2c79
1 #!/usr/bin/env bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Check-PkgVersion
5 # Copyright (C) 2004 - 2023 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7 #
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 if [ "$1" = "-repository" ]; then
16 shift; for y; do
17 for x in package/$y/*; do $0 ${x##*/}; done
18 done
19 exit 0
22 if [ "$1" != "${1#-}" -o $# -eq 0 ]; then
23 echo "Usage: $0 <package-names>"
24 echo "or $0 -repository <repository-names>"
25 exit 1
28 curl_options='--disable-epsv'
30 # Set proxy information
31 if [ -f download/Proxy ]; then
32 proxy="$(< 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
41 if [ -f download/Proxy-auth ]; then
42 proxyauth="$(< 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
54 mkdir -p checkver
56 for package; do
57 for pdir in package/*/$package; do :; done
58 if [ -x $pdir/check-version ]; then
59 sh $pdir/check-version
60 elif [ -f $pdir/$package.desc ]; then
61 x="`egrep '^\[D\] ' $pdir/$package.desc | head -n 1 | tr -s ' '`"
62 if [ -z "$x" ]; then
63 echo "No [D] for package $package found!"
64 else
65 echo "Testing package $package ..."
67 pattern="`echo $x | cut -f3 -d' '`"
68 url="`echo $x | cut -f4 -d' '`" url="${url#-}"
70 if [ "${url:0:1}" == "!" ]; then
71 pattern="${url##*/}"
72 url="${url%/*}"
75 url="`echo ${url#!} | sed -e 's,http://dl.sourceforge.net/sourceforge/,http://prdownloads.sourceforge.net/,'`"
76 pattern="`echo $pattern | \
77 sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
78 -e 's,$,[0-9],' -e 's,^,^,'`"
80 delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz|tbz)$ ^[^0-9]+'
81 delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
82 delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
84 if egrep -q '^\[CV-URL\] ' $pdir/$package.desc; then
85 url="`egrep '^\[CV-URL\] ' \
86 $pdir/$package.desc | head -n 1 | \
87 tr -s ' ' | cut -f2 -d' '`"
90 if egrep -q '^\[CV-PAT\]' $pdir/$package.desc; then
91 pattern="`egrep '^\[CV-PAT\]' \
92 $pdir/$package.desc | head -n 1 | \
93 cut -s -f2- -d' '`"
96 if egrep -q '^\[CV-DEL\]' $pdir/$package.desc; then
97 delpattern="`egrep '^\[CV-DEL\]' \
98 $pdir/$package.desc | head -n 1 | \
99 cut -s -f2- -d' ' | tr -s ' '`"
102 echo -e "\n** `echo $x | cut -f3 -d' '`\n"
103 echo "package='$package' pattern='$pattern'"
104 echo -e "url='$url'\ndelpattern='$delpattern'"
105 echo
107 curl $curl_options -s "$url" | \
108 tee checkver/debug.1 | \
109 tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
110 tee checkver/debug.2 | \
111 perl -e "while (<>) { chomp;
112 \$fn=\$_; next unless /$pattern/;
113 foreach \$x (qw/$delpattern/) { s/\$x//g; }
114 print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
115 tee checkver/debug.3 | \
116 perl -we '
117 use strict;
119 my ($a, $b);
120 my %x;
122 while (<>) {
123 next unless /(\S+)\s+(\S+)/;
124 $a=$1; $_=$1; $b=$2;
125 s/(\d+)/sprintf("%020d", $1)/eg;
126 # print "$_:$a:$b\n";
127 if (not defined $x{$_}) {
128 $x{$_}="$a\t$b";
129 } else {
130 $x{$_}.=" $b";
134 foreach (reverse sort keys %x) {
135 print "$x{$_}\n";
136 }' | tee checkver/$package.new | \
137 while read line; do
138 if [ ! -f checkver/$package.txt ] ||
139 ! grep -qx "$line" checkver/$package.txt
140 then
141 echo " * $line" | expand -t20
142 else
143 echo " $line" | expand -t20
145 done
147 } > checkver/$package.msg
149 if ! [ -s checkver/$package.new ]; then
150 echo "Got no list for package $package!" \
151 >> checkver/$package.msg
152 cat checkver/$package.msg; echo
153 else
154 if grep -q '^ \* ' checkver/$package.msg
155 then cat checkver/$package.msg; echo
156 else rm checkver/$package.msg; fi
159 if [ -f checkver/$package.msg ]; then
160 echo >> checkver/$package.msg
163 else
164 echo "ERROR: Package $package not found!"
166 done