build: Add ./configure --disable-fuse option.
[libguestfs.git] / src / api-support / update-from-tarballs.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2010 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 if [ ! -f HACKING ]; then
20     echo "You should run this script from the top source directory."
21     exit 1
22 fi
23
24 set -e
25
26 cd src/api-support
27
28 tmpdir=$(mktemp -d)
29
30 website=$HOME/d/redhat/websites/libguestfs
31 tarballs="$website/download/1.*-*/libguestfs-*.tar.gz"
32
33 for t in $tarballs; do
34     # libguestfs-x.y.z
35     p=$(basename $t .tar.gz)
36     # x.y.z
37     v=$(echo $p | sed 's/^libguestfs-//')
38
39     if [ $v != "1.2.0" -a $v != "1.3.0" -a ! -f $v ]; then
40         rm -rf "$tmpdir/*"
41         tar -C "$tmpdir" \
42             -zxf $t $p/src/guestfs-actions.c $p/src/actions.c \
43             $p/src/guestfs.c \
44             2>/dev/null ||:
45
46         f="$tmpdir/$p/src/guestfs-actions.c"
47         if [ ! -f "$f" ]; then
48             f="$tmpdir/$p/src/actions.c"
49             if [ ! -f "$f" ]; then
50                 echo "$t does not contain actions file"
51                 exit 1
52             fi
53         fi
54
55         grep -Eoh 'guestfs_[a-z0-9][_A-Za-z0-9]+' \
56                 "$f" $tmpdir/$p/src/guestfs.c |
57             sort -u |
58             grep -v '_ret$' |
59             grep -v '_args$' |
60             grep -v '^guestfs_free_' |
61             grep -v '^guestfs_test0' |
62             grep -v '^guestfs_message_error$' |
63             grep -v '^guestfs_message_header$' > $v
64     fi
65 done
66
67 rm -rf "$tmpdir"
68
69 # GNU ls sorts properly by version with the -v option and backwards by
70 # version with -vr.
71 rev_versions=$(ls -vr [01]*)
72 latest=$(ls -v [01]* | tail -1)
73
74 exec 5>added
75
76 # Get all the symbols from the latest version.
77 # We are implicitly assuming that symbols are not removed.  ABI
78 # guarantee should prevent that from happening.
79 symbols=$(<$latest)
80
81 previous=$latest
82 for v in $rev_versions; do
83     next_symbols=
84     for sym in $symbols; do
85         # If symbol is missing from the file, that indicates it
86         # was added in the previous file we checked ($previous).
87         if ! grep -sq $sym $v; then
88             echo $sym $previous >&5
89         else
90             next_symbols="$next_symbols $sym"
91         fi
92     done
93     symbols="$next_symbols"
94     previous=$v
95 done
96
97 # Any remaining were added in the very first version.
98 for sym in $symbols; do
99     echo $sym $previous >&5
100 done
101
102 # Close and sort the output by symbol name.
103 exec 5>&-
104 sort -o added added