File: popconent

package info (click to toggle)
debian-reference 2.24
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,088 kB
  • ctags: 35
  • sloc: xml: 70,510; sh: 616; makefile: 352; perl: 221; sed: 3
file content (59 lines) | stat: -rwxr-xr-x 1,595 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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()
{
# Currently 0.014% is 10 vote
if [ $1 = 0 ] || [ $2 = 0 ]; then
  echo 0
  return
fi
point=$((10000*${1}/${2}))
if [ $point -ge 200 ]; then
  echo $((point/100))
elif [ $point -ge 100 ]; then
  echo "$(echo "scale=1; ${point}/100"|bc)"
elif [ $point -ge 20 ]; then
  echo "0$(echo "scale=1; ${point}/100"|bc)"
elif [ $point -gt 0 ]; then
  echo "0$(echo "scale=2; ${point}/100"|bc)"
else
  echo "0.00"
fi
}

submission=$1

while read dummy 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 " \!#\$%()=\-~^|\\/+*,.?;:@\`\"'&><")
    # for regrex package names with '.*' -> case is glob
    case $package in
      linux-tree-2.6.*) entityname=pop-linuxtreecg ;;
    esac
    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 sts=2 ai expandtab: