1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/bin/sh
# Copyright (C) 2007 Osamu Aoki <osamu@debian.org>
#
# This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of
# the GNU General Public License version 2 or later.
#
set -e
#set -x
calcpercent() {
# now 0.1% as 1 (70 vote or so)
# Currently 0.014% is 10 vote
if [ "$1" = 0 ] || [ "$2" = 0 ] || [ "$#" = 1 ]; then
echo 0
else
echo $((1000 * ${1} / ${2}))
fi
}
submission=$1
while read -r _ package vote old new nofile; do
installed=$((vote + old + new + nofile))
# echo "$package = V:$vote I:$installed"
entityname=pop-$(echo "$package" |
tr "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "abcdefghijklmnopqrstuvwxyzabcdefghij" |
tr -d " \!#\$%()=\-~^|\\/+*,.?;:@\`\"'&><")
if [ $installed -lt 1 ]; then
echo "<!ENTITY $entityname \"I:none\">"
elif [ $((vote * 10)) -gt "$nofile" ]; then
pvote=$(calcpercent "$vote" "$submission")
pinst=$(calcpercent "$installed" "$submission")
echo "<!ENTITY $entityname \"V:$pvote, I:$pinst\">"
else
pinst=$(calcpercent "$installed" "$submission")
echo "<!ENTITY $entityname \"I:$pinst\">"
fi
done
#
#
# vim: set sw=2 ai expandtab:
|