#!/bin/sh
# very very early state, and badly written script..
# check the md5sum of all config files in /var/lib/pacman/*/files
# and compare it to the md5sum in the packages in /var/cache/pacman/pkg/.
# packages not available are just skipped for now,
# but they should probably be downloaded again instead.
# write unavailable packages to /tmp/pkg_unavailable.log,
# obsolete config files to /tmp/config_unavailable.log
# and wrong md5sums to stdout
backup=0
for file in `find /var/lib/pacman/ -name files`; do
name=`echo "$file" |cut -d'/' -f6`
pkg="/var/cache/pacman/pkg/$name.pkg.tar.gz"
if [ ! -f "$pkg" ]; then
echo "$name" >> /tmp/pkg_unavailable.log
continue
fi
cat $file |
while read line; do
if [ -z "$line" ]; then
continue
elif [ "$backup" == "1" ]; then
config=`echo "$line" | cut -f1`
md5cur=`echo "$line" | cut -f2`
if [ "$config" == "$md5cur" ]; then
echo "$name : $line" >> /tmp/config_unavailable.log
continue
fi
md5ori=`tar xvzfO "$pkg" "$config" 2>/dev/null | md5sum \
| cut -d' ' -f1`
if [ "$md5cur" != "$md5ori" ]; then
echo -n "$name : the md5sum of $config is $md5cur in the database"
echo " and $md5ori in the package"
fi
elif [ "$line" == "%BACKUP%" ]; then
backup=1
continue
fi
done
backup=0
done