~jamesodhunt/ubuntu/vivid/upstart/bug-1447756

« back to all changes in this revision

Viewing changes to lib/run_abi_checker.sh.in

  • Committer: James Hunt
  • Date: 2013-05-22 11:11:00 UTC
  • mto: (1182.56.92 upstart)
  • mto: This revision was merged to the branch mainline in revision 1463.
  • Revision ID: james.hunt@ubuntu.com-20130522111100-aeq953ja8qs6ipxn
* Added libupstart library, built from auto-generated
  D-Bus bindings. To avoid ABI breakage, build calls
  abi-compliance-checker(1), if available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
#---------------------------------------------------------------------
 
3
# Script to run abi-compliance-checker to ensure ABI not broken.
 
4
#---------------------------------------------------------------------
 
5
# Copyright (C) 2013 Canonical Ltd.
 
6
#
 
7
# Author: James Hunt <james.hunt@canonical.com>
 
8
#
 
9
# This program is free software: you can redistribute it and/or modify
 
10
# it under the terms of the GNU General Public License as published by
 
11
# the Free Software Foundation, version 3 of the License.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
#---------------------------------------------------------------------
 
22
 
 
23
die()
 
24
{
 
25
    msg="$*"
 
26
    echo "ERROR: $msg" >&2
 
27
    exit 1
 
28
}
 
29
 
 
30
build_dir="@abs_builddir@"
 
31
source_dir="@abs_srcdir@"
 
32
acc="@abi_compliance_checker@"
 
33
acc_descriptor="@abi_build_XML@"
 
34
libupstart_libtool="@libupstart@"
 
35
lib_prefix="${libupstart_libtool%.la}"
 
36
libupstart_lt_version="@libupstart_version@"
 
37
 
 
38
# convert libtool(1) version to dotted form
 
39
dotted_version=$(echo "$libupstart_lt_version"|tr ':' '.')
 
40
 
 
41
libupstart_path="$build_dir/$libupstart_libtool"
 
42
 
 
43
old_abi="$source_dir/abi_dumps/${lib_prefix}/${lib_prefix}_${dotted_version}.abi.tar.gz"
 
44
 
 
45
echo "Checking ABI for $lib_prefix"
 
46
echo
 
47
 
 
48
for file in "$libupstart_path" "$old_abi"
 
49
do
 
50
    [ -f "$file" ] || die "file $file not found"
 
51
done
 
52
 
 
53
# Install the library to a temporary location since we need the
 
54
# full path to the shared library to pass to abi-compliance-checker.
 
55
install_dir=$(mktemp -d --tmpdir="$build_dir")
 
56
[ -z "$install_dir" ] && \
 
57
        die "failed to create temporary install directory"
 
58
 
 
59
libtool --mode=install install \
 
60
    "$libupstart_libtool" "$install_dir" >/dev/null 2>&1
 
61
 
 
62
abi_dump_dir=$(mktemp -d --tmpdir="$build_dir")
 
63
[ -z "$abi_dump_dir" ] && \
 
64
        die "failed to create temporary dump directory"
 
65
 
 
66
abi_dump_path="$abi_dump_dir/${lib_prefix}_${dotted_version}.abi.tar.gz"
 
67
 
 
68
installed_so="$install_dir/$(echo "$lib_prefix"|cut -d\. -f1).so"
 
69
 
 
70
[ -f "$installed_so" ] || die "cannot find $installed_so"
 
71
 
 
72
# generate a descriptor for the newly-built library version
 
73
"$acc" -library "$lib_prefix" -dump "$acc_descriptor" -dump-path "$abi_dump_path"
 
74
 
 
75
new_abi="$abi_dump_dir/${lib_prefix}_${dotted_version}.abi.tar.gz"
 
76
[ -f "$new_abi" ] || die "cannot find $new_abi"
 
77
 
 
78
# run the ABI checker
 
79
"$acc" -library "$lib_prefix" -old "$old_abi" -new "$new_abi"
 
80
 
 
81
# clean up
 
82
libtool --mode=uninstall \
 
83
    rm "$install_dir/$libupstart_libtool" >/dev/null 2>&1
 
84
 
 
85
rm -rf "$abi_dump_dir" "$build_dir/logs" "$install_dir"
 
86
 
 
87
# HTML report generated by $acc
 
88
rm -rf compat_reports/