ubuntu-dev-tools/check-symbols

67 lines
1.6 KiB
Plaintext
Raw Normal View History

2007-03-27 16:30:36 +02:00
#!/bin/bash
# Copyright 2006-2007 (C) Daniel Holbach <daniel.holbach@ubuntu.com>
2008-01-17 19:43:26 +01:00
# Modified by Siegfried-A. Gevatter <rainct@ubuntu.com>
# License: GPLv2
#
# This script is used to get a diff of the exported symbols of all .so files in
# every binary package of package $1.
2007-03-27 16:30:36 +02:00
DISTRO=$(lsb_release -c -s)
VERSION=$(apt-cache madison "$1" | grep -- "$DISTRO"'/.*Sources$' | awk '{print $3}')
PACKAGES=$(apt-cache showsrc "$1" | grep-dctrl -s Binary -F Version "$VERSION" | sed 's/Binary\:\ //g;s/\,//g' | sort -u)
2007-03-27 16:30:36 +02:00
DEBLINE=""
DEBUG=False
2007-03-27 16:30:36 +02:00
if [[ -z $1 ]]; then
echo "Missing argument: source package name.";
exit;
2007-03-27 16:30:36 +02:00
fi
if [[ -z $2 ]]; then
DEBDIR="/var/cache/pbuilder/result";
else
DEBDIR="$2";
2007-03-27 16:30:36 +02:00
fi
sudo apt-get install $PACKAGES
for pack in $PACKAGES;
do
for lib in `dpkg -L $pack | grep -E "\.so$" | sort -u`;
do
LIBNAME=$(basename $lib);
nm -D $lib | cut -d' ' -f3 | sort -u > /tmp/$LIBNAME.1;
done;
DEBLINE="$DEBLINE $DEBDIR/$pack*.deb ";
2007-03-27 16:30:36 +02:00
done
if [[ -z $DEBLINE ]]; then
echo "Package doesn't exist: $1."; exit
fi
NOFILE=True
for filename in $DEBLINE; do
if [[ ${filename: -5} != "*.deb" ]]; then
NOFILE=False
[[ $DEBUG != True ]] || echo "Found binary file: $filename"
fi
done
if [[ $NOFILE == True ]]; then
echo "No matching binary files found in «$DEBDIR»."; exit
fi
2007-03-27 16:30:36 +02:00
sudo dpkg -i $DEBLINE;
for pack in $PACKAGES;
do
for lib in `dpkg -L $pack | grep -E "\.so$" | sort -u`;
do
LIBNAME=$(basename $lib);
nm -D $lib | cut -d' ' -f3 | sort -u > /tmp/$LIBNAME.2;
echo "Checking: $lib";
diff -u /tmp/$LIBNAME.{1,2};
rm /tmp/$LIBNAME.{1,2};
done;
done