#! /bin/sh # (C) 2005, Pierre Habouzit # GPL'ed code follows. ##################################################################### # # TODO : # That part may certainly be automatized instead of the user giving # the version as an argument # [ -n "$1" ] || { echo "usage: check-shlibs2 version" echo echo " version the version (with revision) that has been uploaded last" echo " this version is used to perform the symbols analysis" exit 1 } LAST_VERSION=$1 # ##################################################################### dh_testdir || exit 1 eval `dpkg-architecture` NM='nm --dynamic --defined-only --no-sort' SOURCE=`awk '/^Source:/ {print $2}' debian/control` VERSION=`dpkg-parsechangelog | grep -E '^Version:' | cut -f 2 -d ' '` SHLIBS_SVN='svn://svn.debian.org/pkg-kde/branches/kde-3.4.0/shlibs' WHERE=debian/shlibs-check perror() { echo >&2 "$1" } ##################################################################### # # make_symbols_tree foo bar # # make a symbol tree snapshot from the libs in dir $foo # and put it in dir $bar # make_symbols_tree () { SRC=$1 DST=$2 find "$SRC" -name '*.so.[0-9]' | while read lib; do P=`dirname $lib` L=$DST/${P##$SRC/} test -d $L || mkdir -p $L 2>/dev/null $NM $lib | awk '{print $3}' | env LC_COLLATE=C sort >$L/`basename $lib` done } ##################################################################### # # make_old_symbols pkg # # try to get the package pkg_$version_$arch.deb , if it fails, # then we assume it was an arch-indep package, else we extract it # and (try to) build a symbol tree from it. then we clean all up # make_old_symbols () { BASE=$1 LETTER=`echo $SOURCE | cut -b1` PKG=${BASE}_${LAST_VERSION}_${DEB_BUILD_ARCH}.deb URL=http://ftp.debian.org/debian/pool/main/$LETTER/$SOURCE/$PKG TMP=debian/old/$BASE if wget -q $URL; then test -d $TMP || mkdir -p $TMP 2>/dev/null dpkg -x $PKG $TMP make_symbols_tree $TMP $WHERE/$SOURCE.old/$BASE rm -rf $PKG debian/old else perror "E: Couldn't get the package $PKG." exit 1 fi } ##################################################################### # # check_symbols_equal pkg # # test with diff if the symbols trees for the current build # and the last uploaded package are the same # check_symbols_equal () { test -d $WHERE/$SOURCE/$p || return if diff -NrU0 $WHERE/$SOURCE.old/$p $WHERE/$SOURCE/$p; then perror "-- $p has no differences" else perror "** $p has differences" fi } ##################################################################### ##################################################################### rm -rf $WHERE for p in `/usr/lib/cdbs/list-packages arch`; do make_old_symbols $p make_symbols_tree debian/$p $WHERE/$SOURCE/$p check_symbols_equal $p done