#!/bin/bash
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/scripts/Check-PkgVersion
|
|
# ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
|
|
if [ "$1" = "-repository" ] ; then
|
|
shift ; for y ; do
|
|
for x in package/$y/* ; do $0 ${x##*/} ; done
|
|
done
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$1" != "${1#-}" -o $# -eq 0 ] ; then
|
|
echo "Usage: $0 <package-names>"
|
|
echo "or $0 -repository <repository-names>"
|
|
echo
|
|
echo " Search for new source files for the given packages or repositories. Output"
|
|
echo " will be written to *.msg files in checkver/. Old *.msg files will"
|
|
echo " automatically be removed on every run."
|
|
echo
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p checkver
|
|
|
|
for package ; do
|
|
for pdir in package/*/$package ; do : ; done
|
|
if [ -x $pdir/check-version ] ; then
|
|
sh $pdir/check-version
|
|
elif [ -f $pdir/$package.desc ] ; then
|
|
x="`egrep '^\[D\] ' $pdir/$package.desc | head -n 1 | tr -s ' '`"
|
|
if [ -z "$x" ] ; then
|
|
echo "No [D] for package $package found!"
|
|
else
|
|
echo "Testing package $package ..."
|
|
{
|
|
pattern="`echo $x | cut -f3 -d' ' | \
|
|
sed -e 's,+,\\\\+,g' -e 's,[0-9].*$,,' \
|
|
-e 's,$,[0-9],' -e 's,^,^,'`"
|
|
url="`echo $x | cut -f4 -d' '`"
|
|
case "$url" in
|
|
!*) url="`echo "$url" | sed -e 's,^!,,' \
|
|
-e 's,[^/]*$,,'`" ;;
|
|
esac
|
|
delpattern='\.(gz|bz2|Z)$ \.(tar|zip|tgz)$ ^[^0-9]+'
|
|
delpattern="$delpattern"' .*\.(deb|sign?|diff|rpm)$'
|
|
delpattern="$delpattern"' .*\.(dsc|lsm|asc|md5)$'
|
|
|
|
url="$( echo $url | sed -e 's,http://dl.sourceforge.net/sourceforge/,http://prdownloads.sourceforge.net/,' )"
|
|
|
|
if egrep -q '^\[CV-URL\] ' $pdir/$package.desc ; then
|
|
url="`egrep '^\[CV-URL\] ' \
|
|
$pdir/$package.desc | head -n 1 | \
|
|
tr -s ' ' | cut -f2 -d' '`"
|
|
fi
|
|
|
|
if egrep -q '^\[CV-PAT\]' $pdir/$package.desc ; then
|
|
pattern="`egrep '^\[CV-PAT\]' \
|
|
$pdir/$package.desc | head -n 1 | \
|
|
cut -s -f2- -d' '`"
|
|
fi
|
|
|
|
if egrep -q '^\[CV-DEL\]' $pdir/$package.desc ; then
|
|
delpattern="`egrep '^\[CV-DEL\]' \
|
|
$pdir/$package.desc | head -n 1 | \
|
|
cut -s -f2- -d' ' | tr -s ' '`"
|
|
fi
|
|
|
|
echo -e "\n** `echo $x | cut -f3 -d' '`\n"
|
|
echo "package='$package' pattern='$pattern'"
|
|
echo -e "url='$url'\ndelpattern='$delpattern'"
|
|
echo
|
|
|
|
curl --disable-epsv -s "$url" | \
|
|
tee checkver/debug.1 | \
|
|
tr "\r\t\"'<>= /" '\n\n\n\n\n\n\n\n\n' | \
|
|
tee checkver/debug.2 | \
|
|
perl -e "while (<>) { chomp;
|
|
\$fn=\$_; next unless /$pattern/;
|
|
foreach \$x (qw/$delpattern/) { s/\$x//g; }
|
|
print \"\$_\t\$fn\\n\" if \$_ ne ''; }" | \
|
|
tee checkver/debug.3 | \
|
|
perl -we '
|
|
use strict;
|
|
|
|
my ($a, $b);
|
|
my %x;
|
|
|
|
while (<>) {
|
|
next unless /(\S+)\s+(\S+)/;
|
|
$a=$1; $_=$1; $b=$2;
|
|
s/(\d+)/sprintf("%020d", $1)/eg;
|
|
# print "$_:$a:$b\n";
|
|
if (not defined $x{$_}) {
|
|
$x{$_}="$a\t$b";
|
|
} else {
|
|
$x{$_}.=" $b";
|
|
}
|
|
}
|
|
|
|
foreach (reverse sort keys %x) {
|
|
print "$x{$_}\n";
|
|
}' | tee checkver/$package.new | \
|
|
while read line ; do
|
|
if [ ! -f checkver/$package.txt ] ||
|
|
! grep -qx "$line" checkver/$package.txt
|
|
then
|
|
echo " * $line" | expand -t20
|
|
else
|
|
echo " $line" | expand -t20
|
|
fi
|
|
done
|
|
|
|
} > checkver/$package.msg
|
|
|
|
if ! [ -s checkver/$package.new ] ; then
|
|
echo "Got no list for package $package!" \
|
|
>> checkver/$package.msg
|
|
cat checkver/$package.msg ; echo
|
|
else
|
|
if grep -q '^ \* ' checkver/$package.msg
|
|
then cat checkver/$package.msg ; echo
|
|
else rm checkver/$package.msg ; fi
|
|
fi
|
|
|
|
if [ -f checkver/$package.msg ] ; then
|
|
echo >> checkver/$package.msg
|
|
fi
|
|
fi
|
|
else
|
|
echo "ERROR: Package $package not found!"
|
|
fi
|
|
done
|