summaryrefslogtreecommitdiffstats
path: root/src/api-support/update-from-tarballs.sh
blob: e91c7090361c4af021c8bfff7681e998fcafdab8 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash -
# libguestfs
# Copyright (C) 2010 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

if [ ! -f BUGS ]; then
    echo "You should run this script from the top source directory."
    exit 1
fi

set -e

cd src/api-support

tmpdir=$(mktemp -d)

website=$HOME/d/redhat/websites/libguestfs
tarballs="$website/download/1.*-*/libguestfs-*.tar.gz"

for t in $tarballs; do
    # libguestfs-x.y.z
    p=$(basename $t .tar.gz)
    # x.y.z
    v=$(echo $p | sed 's/^libguestfs-//')

    if [ $v != "1.2.0" -a $v != "1.3.0" -a ! -f $v ]; then
        rm -rf "$tmpdir/*"
        tar -C "$tmpdir" \
            -zxf $t $p/src/*.c 2>/dev/null ||:

        f="$tmpdir/$p/src/guestfs-actions.c"
        if [ ! -f "$f" ]; then
            f="$tmpdir/$p/src/actions.c"
            if [ ! -f "$f" ]; then
                f="$tmpdir/$p/src/actions-0.c"
                if [ ! -f "$f" ]; then
                    echo "$t does not contain actions file"
                    exit 1
                fi
            fi
        fi

        grep -Eoh 'guestfs_[a-z0-9][_A-Za-z0-9]+' \
                "$f" $tmpdir/$p/src/*.c |
            sort -u |
            grep -v '_ret$' |
            grep -v '_args$' |
            grep -v '_len$' |
            grep -v '_val$' |
            grep -v '_cb$' |
            grep -v '^guestfs_int_' |
            grep -v '^guestfs_set_$' |
            grep -v '^guestfs_free_' |
            grep -v '^guestfs_test0' |
            grep -v '^guestfs_str$' |
            grep -v '^guestfs_internal_test' |
            grep -v '^guestfs_message_direction$' |
            grep -v '^guestfs_message_error$' |
            grep -v '^guestfs_message_header$' |
            grep -v '^guestfs_message_status$' > $v
    fi
done

rm -rf "$tmpdir"

# GNU ls sorts properly by version with the -v option and backwards by
# version with -vr.
rev_versions=$(ls -vr [01]*)
latest=$(ls -v [01]* | tail -1)

exec 5>added

# Get all the symbols from the latest version.
# We are implicitly assuming that symbols are not removed.  ABI
# guarantee should prevent that from happening.
symbols=$(<$latest)

previous=$latest
for v in $rev_versions; do
    next_symbols=
    for sym in $symbols; do
        # If symbol is missing from the file, that indicates it
        # was added in the previous file we checked ($previous).
        if ! egrep -sq \\b$sym\\b $v; then
            echo $sym $previous >&5
        else
            next_symbols="$next_symbols $sym"
        fi
    done
    symbols="$next_symbols"
    previous=$v
done

# Any remaining were added in the very first version.
for sym in $symbols; do
    echo $sym $previous >&5
done

# Close and sort the output by symbol name.
exec 5>&-
sort -o added added