#/bin/sh
# This script checks that the lists pf packages in ./pkg_lists/<date> are
# consistent with the specs in ./pkg_lists
# run it like this, on the same day as <date>
# sh consistency_checks 32|64
CWD=$(pwd)
SLACKVERSION="14.2"
SLINTVERSION="14.2"
usage() {
  printf %b "Usage: $0 32|64\n"
  exit
}
if [ $# -ne 1 ]; then usage; fi
if [ $1 -ne 32 ] && [ $1 -ne 64 ]; then usage; fi
SFX=$(echo $1|grep 64)
SLINTREPO=../..
MIRRORSLACKWARE=/storage/slackware${SFX}-$SLACKVERSION
DATESTAMP=`date +%Y%m%d`
TMP=$(mktemp -d)
# Get the current list of packages in the Slackware tree
echo $TMP
echo TMP=$TMP
cd $MIRRORSLACKWARE/slackware$SFX
find -name "*t?z"|sed "s/\(.\)-[^-]*-[^-]*-[^-]*$/\1/;s/^.//"|sort > $TMP/all_slack_packages
nb_slack=$(find -name "*t?z"|sed "s/\(.\)-[^-]*-[^-]*-[^-]*$/\1/;s/^.//"|wc -l)
cd $CWD
echo "Found $nb_slack Slackware packages"
nb_kdei=$(grep "/kdei/" $TMP/all_slack_packages|wc -l)
grep -v "/kdei/" $TMP/all_slack_packages |sort >
echo "Among them $nb_kdei in the KDEI series"
echo "and $((nb_slack - nb_kdei)) in other series."
echo "In pkg_lists/$1/$DATESTAMP/slackware we have $(grep . $CWD/pkg_lists/$1/$DATESTAMP/slackware|wc -l) lines".
