diff --git a/check-symbols b/check-symbols index c0a0a03..bcb8b7f 100755 --- a/check-symbols +++ b/check-symbols @@ -29,21 +29,55 @@ # * nm (from binutils) 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) DEBLINE="" DEBUG=False -if [[ -z $1 ]]; then - echo "Missing argument: source package name." - exit 1 +usage() { + prog=$(basename $0) + cat <<EOF +Usage: $prog [options] source-package [DEBDIR] + +Get a diff of the exported symbols of all .so files in every binary package of +package the source package. The source package will be found in DEBDIR, defaulting to /var/cache/pbuilder/result. + +Options: + -h, --help show this help message and exit +EOF + exit $1 +} + +PACKAGE="" +DEBDIR="/var/cache/pbuilder/result" +POSITION=0 +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + usage 0 + ;; + -*) + usage 1 + ;; + *) + if [ $POSITION -eq 0 ]; then + PACKAGE="$1" + elif [ $POSITION -eq 1 ]; then + DEBDIR="$1" + else + echo "Too many arguments." >&2 + usage 1 + fi + POSITION=$(($POSITION+1)) + esac + shift +done + +if [ $POSITION -eq 0 ]; then + echo "Missing argument: source package name." >&2 + usage 1 fi -if [[ -z $2 ]]; then - DEBDIR="/var/cache/pbuilder/result" -else - DEBDIR="$2" -fi +VERSION=$(apt-cache madison "$PACKAGE" | grep -- "$DISTRO"'/.*Sources$' | awk '{print $3}') +PACKAGES=$(apt-cache showsrc "$PACKAGE" | grep-dctrl -s Binary -F Version "$VERSION" | sed 's/Binary\:\ //g;s/\,//g' | sort -u) if [ `id -u` != "0" ] then @@ -67,7 +101,7 @@ do done if [[ -z $DEBLINE ]]; then - echo "Package doesn't exist: $1." + echo "Package doesn't exist: $PACKAGE." exit 1 fi diff --git a/debian/changelog b/debian/changelog index 84e3eab..06349d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,7 +3,8 @@ ubuntu-dev-tools (0.142) UNRELEASED; urgency=low * mk-sbuild: Support kmod, when checking for overlayfs availability. * pbuilder-dist: improve bash_completion for *.dsc files. Thanks Maarten Bezemer. (Closes: #670924, LP: #770529) - * submittodebian, check-mir: Use optparse to display --help (LP: #988009) + * submittodebian, check-mir, check-symbols: Do enough argument parsing to + handle --help (LP: #988009) -- Stefano Rivera <stefanor@debian.org> Wed, 25 Apr 2012 17:38:58 +0200 diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index 3d0c32a..e3af9ba 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -25,7 +25,6 @@ from ubuntutools import subprocess from ubuntutools.test import unittest BLACKLIST = { - 'check-symbols': 'No Help', 'grep-merges': 'No Help', 'pbuilder-dist-simple': 'No Help', 'setup-packaging-environment': 'Throws Error',