summaryrefslogtreecommitdiffstats
path: root/report-versions.sh
blob: 8dc742ed964863f95a90ad92b13a84d8fefb7a4e (plain)
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
#!/bin/bash
#
#       Sort through the raw results of a scan and list all of
#       packages found and their reported versions
#

if [ "$#" -lt 1 ]
then
        echo "usage: ./report-versions.sh <results-file>"
        exit 1
fi

data="$1"
if [ ! -s "$data" ]
then
        echo "? has to be something to work with"
        exit 1
fi

cat "$data" | (
        declare -i count
        count=0
        while IFS='' read -r line || [ -n "$line" ]
        do
                case "$line" in
                Package:*)
                        [ $count -gt 0 ] && echo $pkg $version
                        count+=1
                        pkg=$(echo $line | sed 's/Package: //')
                        ;;
                Source:*)
                        version=$(echo $line | sed 's/Source: //' | \
                                  sed "s/${pkg}-//")
                        ;;
                esac
        done
)