Added a tool to check massively if an url is a slackware repository.

when I define a repository group as
http://taper.alienbase.nl/mirrors/alien-kde/{13.37,14.0,14.1,current}/{latest,testing}/{x86,x86_64}/
that is expanded in many repositories, but not all are existent.

kde5 for slackware 13.37
http://taper.alienbase.nl/mirrors/alien-kde/13.37/testing/x86/
does not exists.

$ ./checkrepos.sh http://taper.alienbase.nl/mirrors/alien-kde/{13.37,current}/testing/x86/
Expanded repositories
http://taper.alienbase.nl/mirrors/alien-kde/13.37/testing/x86/
http://taper.alienbase.nl/mirrors/alien-kde/current/testing/x86/

Check repositories

Repository: http://taper.alienbase.nl/mirrors/alien-kde/13.37/testing/x86/
  Host: taper.alienbase.nl
  Check IP:   98.158.153.254
  Check connection: OK
  CHECKSUMS.md5:   not present
Invalid repository

Repository: http://taper.alienbase.nl/mirrors/alien-kde/current/testing/x86/
  Host: taper.alienbase.nl
  Check IP:   98.158.153.254
  Check connection: OK
  CHECKSUMS.md5: OK 212965 bytes ( Wed, 09 Dec 2015 00:40:09 GMT )
  PACKAGES.TXT: OK 203453 bytes ( Wed, 09 Dec 2015 00:39:49 GMT )
  GPG-KEY: Eric Hameleers <alien@slackware.com>
Done

========================================================
url     md5     gpg     pack

http://taper.alienbase.nl/mirrors/alien-kde/current/testing/x86 yes     yes     yes

It helps me to check repositories's sanity
This commit is contained in:
Matteo Rossini 2015-12-13 19:24:06 +01:00
parent 7fbed91d1e
commit c44fe7fed4
3 changed files with 333 additions and 0 deletions

202
src/checkrepos.sh Executable file
View file

@ -0,0 +1,202 @@
#!/bin/bash
unset LANG
if [ -z "$1" ];then
echo "
Usage:
$0 [ -q ] <repository_url>
where repository_url is a full url of a slackware repository
(supported http only)
Or:
$0 [ -q ] <filename>
where filename is the name of a file containing one or more
repositories. It can contain also text. The script extract
urls and check if it is a repository.
-q print non-verbose progress
The repository url can use the syntax '{ ... }' to specify
multiple repository in one row. The script expand it and
check if the expanded repository exists.
Example:
http://slackware.osuosl.org/slackware{,64}-{12.2,14.1,current}/
will be expanded as
http://slackware.osuosl.org/slackware-12.2/
http://slackware.osuosl.org/slackware-14.1/
http://slackware.osuosl.org/slackware-current/
http://slackware.osuosl.org/slackware64-12.2/
http://slackware.osuosl.org/slackware64-14.1/
http://slackware.osuosl.org/slackware64-current/
Next, when the script will validate the repositories, it will
remove slackware64-12.2 that does NOT exists.
You can use this script to expand all repositories in
/usr/doc/slackpkg+-*/repositories.txt
"
exit
fi
V=1
if [ "$1" == "-q" ];then
V=""
shift
fi
if [ -f "$1" ];then
REPOS=$(cat $1|egrep -o 'http://[^ ]*')
else
REPOS=$(echo $*|egrep -o 'http://[^ ]*')
fi
REPOS=$(eval echo $REPOS|sed -e 's/{//g' -e 's/}//g')
[ $V ]&&echo "Expanded repositories"
[ $V ]&&echo $REPOS|sed 's/ /\n/g'
TMP=$(mktemp -d)
cd $TMP
(
echo
echo "Check repositories"
for R in $REPOS;do
[ $V ]&&echo
REPO=${R%/}
echo -n "Repository: $REPO/ "
HOST=$(echo $REPO|cut -f3 -d/)
[ $V ]&&echo -en "\n Host: $HOST\n Check IP: "||echo -n .
if echo $HOST|egrep -q '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$';then
IP=$HOST
else
IP=$(host $HOST 2>/dev/null|grep 'has address'|head -1|awk '{print $NF}')
fi
echo $IP|egrep -q '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
if [ $? -ne 0 ];then
[ $V ]&&echo -e " unable to resolve\nInvalid repository"|grep --color .||echo " Invalid (unable to resolve address)"|grep --color .
continue
fi
[ $V ]&&echo -en " $IP\n Check connection: "||echo -n .
echo |timeout 10 telnet $IP 80 > telnet.out 2>&1
ERR=$?
if grep -q "Escape character is" telnet.out;then
[ $V ]&&echo "OK "||echo -n .
elif grep -q "Connection refused" telnet.out;then
[ $V ]&&echo -e " Connection refused\nInvalid repository"|grep --color .||echo " Invalid (connection refused)"|grep --color .
continue
elif [ $ERR -eq 124 ];then
[ $V ]&&echo -e " Timeout\nInvalid repository"|grep --color .||echo " Invalid (timeout)"|grep --color .
continue
else
[ $V ]&&echo -e " Failed\nInvalid repository"|grep --color .||echo " Invalid (connection failed)"|grep --color .
continue
fi
MD5=no
[ $V ]&&echo -en " CHECKSUMS.md5: "||echo -n .
curl --location --head $REPO/CHECKSUMS.md5 > CHECKSUMS.md5.R 2>/dev/null
ERR=$?
if grep -q "200 OK" CHECKSUMS.md5.R;then
[ $V ]&&echo -n "OK "||echo -n .
if grep -q Content-Length: CHECKSUMS.md5.R;then
[ $V ]&&echo -n "$(grep Content-Length: CHECKSUMS.md5.R|awk '{print $2}'|sed 's/ //') bytes "
fi
if grep -q Last-Modified: CHECKSUMS.md5.R;then
[ $V ]&&echo -n "($(grep Last-Modified: CHECKSUMS.md5.R|cut -f2- -d:|sed 's/ //') ) "
fi
[ $V ]&&echo
MD5=yes
elif grep -q "404 Not Found" CHECKSUMS.md5.R;then
[ $V ]&&echo -e " not present\nInvalid repository"|grep --color .||echo " Invalid (CHECKSUMS.md5 not present)"|grep --color .
continue
else
[ $V ]&&echo -e " unable to retrieve\nInvalid repository"|grep --color .||echo " Invalid (unable to retrieve CHECKSUMS.md5)"|grep --color .
continue
fi
PACK=no
[ $V ]&&echo -en " PACKAGES.TXT: "||echo -n .
curl --location --head $REPO/PACKAGES.TXT > PACKAGES.TXT.R 2>/dev/null
ERR=$?
if grep -q "200 OK" PACKAGES.TXT.R;then
[ $V ]&&echo -n "OK "||echo -n .
if grep -q Content-Length: PACKAGES.TXT.R;then
[ $V ]&&echo -n "$(grep Content-Length: PACKAGES.TXT.R|awk '{print $2}'|sed 's/ //') bytes "
fi
if grep -q Last-Modified: PACKAGES.TXT.R;then
[ $V ]&&echo -n "($(grep Last-Modified: PACKAGES.TXT.R|cut -f2- -d:|sed 's/ //') ) "
fi
[ $V ]&&echo
PACK=yes
elif grep -q "404 Not Found" PACKAGES.TXT.R;then
[ $V ]&&echo -e " not present\nInvalid repository"|grep --color .||echo " Invalid (PACKAGES.TXT not present)"|grep --color .
continue
else
[ $V ]&&echo -e " unable to retrieve\nInvalid repository"|grep --color .||echo " Invalid (unable to retrieve PACKAGES.TXT)"|grep --color .
continue
fi
[ $V ]&&echo -n " GPG-KEY: "||echo -n .
wget -o wget.log --timeout=10 --wait=2 --tries=2 -O GPG-KEY $REPO/GPG-KEY
ERR=$?
if [ $ERR -eq 0 ];then
if [ ! -s GPG-KEY ];then
[ $V ]&&echo "empty"|grep --color .
GPG=bad
elif ! grep -q -- "-----END" GPG-KEY;then
[ $V ]&&echo "invalid"|grep --color .
GPG=bad
else
ID=$(echo $(cat GPG-KEY|grep -m1 ^uid|cut -c4-))
if [ -z "$ID" ];then
[ $V ]&&echo "Unable to get UID"|grep --color .
else
[ $V ]&&echo $ID
fi
GPG=yes
fi
elif grep -q "404 Not Found" wget.log;then
[ $V ]&&echo "not present"|grep --color .
GPG=no
else
[ $V ]&&echo "unable to retrieve"|grep --color .
GPG=no
fi
if [ ! $V ];then
echo -n " OK"
if [ "$GPG" != "yes" ];then
echo -n " ( $GPG gpg )"
fi
echo
else
echo "Done"
fi
echo -e "$REPO\t$MD5\t$GPG\t$PACK" >> repositories.txt
done
echo
echo "========================================================"
) >&2
echo -e "url\tmd5\tgpg\tpack"
echo
cat repositories.txt|sort
cd
#rm -rf $TMP

93
src/repositories.lst Normal file
View file

@ -0,0 +1,93 @@
url md5 gpg pack
http://download.salixos.org/i486/13.37 yes yes yes
http://download.salixos.org/i486/14.0 yes yes yes
http://download.salixos.org/i486/14.1 yes yes yes
http://download.salixos.org/x86_64/13.37 yes yes yes
http://download.salixos.org/x86_64/14.0 yes yes yes
http://download.salixos.org/x86_64/14.1 yes yes yes
http://ngc891.blogdns.net/pub/slacke18/slackware-14.1 yes yes yes
http://ngc891.blogdns.net/pub/slacke18/slackware64-14.1 yes yes yes
http://ngc891.blogdns.net/pub/slacke18/slackwarearm-14.1 yes yes yes
http://packages.slackonly.com/pub/packages/14.1-x86 yes yes yes
http://packages.slackonly.com/pub/packages/14.1-x86_64 yes yes yes
http://packages.slackonly.com/pub/packages/current-x86 yes yes yes
http://packages.slackonly.com/pub/packages/current-x86_64 yes yes yes
http://ponce.cc/slackers/repository yes yes yes
http://repository.slacky.eu/slackware-13.37 yes no yes
http://repository.slacky.eu/slackware-14.0 yes yes yes
http://repository.slacky.eu/slackware-14.1 yes yes yes
http://repository.slacky.eu/slackware64-13.37 yes no yes
http://repository.slacky.eu/slackware64-14.0 yes yes yes
http://repository.slacky.eu/slackware64-14.1 yes yes yes
http://rlworkman.net/pkgs/13.37 yes yes yes
http://rlworkman.net/pkgs/14.0 yes yes yes
http://rlworkman.net/pkgs/14.1 yes yes yes
http://rlworkman.net/pkgs/current yes yes yes
http://slackware.org.uk/msb/14.0/1.6/x86 yes yes yes
http://slackware.org.uk/msb/14.0/1.6/x86_64 yes yes yes
http://slackware.org.uk/msb/14.1/1.10/x86 yes yes yes
http://slackware.org.uk/msb/14.1/1.10/x86_64 yes yes yes
http://slackware.org.uk/msb/14.1/1.12/x86 yes yes yes
http://slackware.org.uk/msb/14.1/1.12/x86_64 yes yes yes
http://slackware.org.uk/msb/14.1/1.6/x86 yes yes yes
http://slackware.org.uk/msb/14.1/1.6/x86_64 yes yes yes
http://slackware.org.uk/msb/14.1/1.8/x86 yes yes yes
http://slackware.org.uk/msb/14.1/1.8/x86_64 yes yes yes
http://slackware.org.uk/msb/testing/1.12/x86 yes yes yes
http://slackware.org.uk/msb/testing/1.12/x86_64 yes yes yes
http://slakfinder.org/slackpkg+ yes yes yes
http://studioware.org/files/packages/slackware-13.37 yes yes yes
http://studioware.org/files/packages/slackware-14.0 yes yes yes
http://studioware.org/files/packages/slackware-14.1 yes yes yes
http://studioware.org/files/packages/slackware64-13.37 yes yes yes
http://studioware.org/files/packages/slackware64-14.0 yes yes yes
http://studioware.org/files/packages/slackware64-14.1 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/13.37/latest/x86 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/13.37/latest/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/14.0/latest/x86 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/14.0/latest/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/14.1/latest/x86 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/14.1/latest/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/current/latest/x86 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/current/latest/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/current/testing/x86 yes yes yes
http://taper.alienbase.nl/mirrors/alien-kde/current/testing/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/multilib/13.37 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/multilib/14.0 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/multilib/14.1 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/multilib/current yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/13.37/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/13.37/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/14.0/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/14.0/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/14.1/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/14.1/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/current/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/restricted_sbrepos/current/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/13.37/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/13.37/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/14.0/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/14.0/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/14.1/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/14.1/x86_64 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/current/x86 yes yes yes
http://taper.alienbase.nl/mirrors/people/alien/sbrepos/current/x86_64 yes yes yes
http://www.microlinux.fr/microlinux/desktop-14.1-32bit yes yes yes
http://www.microlinux.fr/microlinux/desktop-14.1-64bit yes yes yes
http://www.microlinux.fr/microlinux/desktop-14.2-32bit yes yes yes
http://www.microlinux.fr/microlinux/desktop-14.2-64bit yes yes yes
http://www.microlinux.fr/microlinux/extras-14.1-32bit yes yes yes
http://www.microlinux.fr/microlinux/extras-14.1-64bit yes yes yes
http://www.microlinux.fr/microlinux/extras-14.2-32bit yes yes yes
http://www.microlinux.fr/microlinux/extras-14.2-64bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.0-32bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.0-64bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.1-32bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.1-64bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.2-32bit yes yes yes
http://www.microlinux.fr/microlinux/server-14.2-64bit yes yes yes
http://www.slackel.gr/repo/i486/current yes yes yes
http://www.slackel.gr/repo/i486/kde5 yes yes yes
http://www.slackel.gr/repo/x86_64/current yes yes yes
http://www.slackel.gr/repo/x86_64/kde5 yes yes yes

View file

@ -11,6 +11,42 @@ PKG=$TMP/slackpkg+-$VERSION
OUTPUT=${OUTPUT:-$TMP}
if [ repositories.txt -nt repositories.lst ];then
echo "WARNING: repositories.txt is newer than repositories.lst"
echo " remember to run ./checkrepos.sh repositories.txt > repositories.lst"
sleep 5
fi
INST=$(ls /var/log/packages/slackpkg+-$VERSION-noarch-* 2>/dev/null)
if [ ! -z "$INST" ];then
BINST=$(echo $INST|sed 's/.*-//')
NBUILD=$(echo $BUILD|egrep -o [0-9])
NBINST=$(echo $BINST|egrep -o [0-9])
if [ "$BINST" == "$BUILD" ];then
echo "WARNING: $INST seems to be installed"
echo " remember to change \$VERSION or \$BUILD"
sleep 5
elif [ $NBUILD -le $NBINST ];then
echo "NOTICE: `basename $INST` is installed"
echo " remember to change \$VERSION or \$BUILD"
sleep 5
fi
fi
SPKGPLUS_VERSION=$(grep 'SPKGPLUS_VERSION="'$VERSION'"' slackpkgplus.sh|cut -f2 -d'"')
if [ "$SPKGPLUS_VERSION" != "$VERSION" ];then
echo "WARNING: slackpkg+ version in ChangeLog.txt ($VERSION) does not match with"
echo " slackpkg+ version in slackpkgplus.sh ($SPKGPLUS_VERSION)"
echo " please remember to update both version"
sleep 5
fi
if [ -e ../ChangeLog.txt ];then if ! diff ../ChangeLog.txt ChangeLog.txt;then
echo "WARNING: ChangeLog in src/ and git root does not match; please update both"
sleep 5
fi;fi
rm -rf $PKG
mkdir -p $PKG
@ -26,7 +62,9 @@ cp $CWD/makeinstlog.sh usr/libexec/slackpkg/makeinstlog.sh
cp $CWD/README usr/doc/slackpkg+-$VERSION/
cp $CWD/ChangeLog.txt usr/doc/slackpkg+-$VERSION/
cp $CWD/repositories.txt usr/doc/slackpkg+-$VERSION/
cp $CWD/repositories.lst usr/doc/slackpkg+-$VERSION/
cp $CWD/setupmultilib.sh usr/doc/slackpkg+-$VERSION/
cp $CWD/checkrepos.sh usr/doc/slackpkg+-$VERSION/
cp $CWD/slackpkg+.SlackBuild usr/doc/slackpkg+-$VERSION/
cp $CWD/slackpkgplus.*.sample usr/doc/slackpkg+-$VERSION/
cp $CWD/greylist etc/slackpkg/greylist.new