Add a check-deps script to parse the Depends of an individual .deb

git-svn-id: http://emdebian.org/svn/current@6882 563faec7-e20c-0410-992a-a66f704d0ccd
This commit is contained in:
codehelp 2010-03-28 06:50:09 +00:00
parent a50b40c3a5
commit 7ebe5ce7a8
3 changed files with 94 additions and 1 deletions

91
check-deps.sh Executable file
View file

@ -0,0 +1,91 @@
#!/bin/sh
set -e
# Copyright 2010 Neil Williams <codehelp@debian.org>
# Copyright 2010 Philip Hands <phil@hands.com>
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# using the package directly means we don't have to deal
# with multiline Depends
while [ -n "$1" ]; do
case "$1" in
-\?|-h|--help)
shift
echo "-f path to a .deb filename; -i install the packages now."
exit 0
;;
-f|--file)
shift
FILE=$1
shift
;;
-i|--install)
shift
INSTALL=1
;;
*)
echo "Unrecognised option: $1"
exit;
;;
esac
done
if [ ! -f "$FILE" -o ! -r "$FILE" ]; then
echo "Please specify a path to a debian package file with the -f command."
exit 2
fi
DEPS=$(dpkg-deb -f $FILE Depends) || exit 3
IFS=,
CMD=
ERR=
for pkg in $DEPS; do
CHECK=
name=$(echo $pkg|sed -e 's/^ //'|cut -d' ' -f1)
if [ "apt" = "$name" ]; then
continue
fi
if [ -n `echo $pkg|grep '('` ]; then
VERLIMIT=`echo $pkg|cut -d'(' -f2|tr -d ')'|tr -d '\n'|grep -v $name || true`
VERCMP=`echo $VERLIMIT|sed -e 's/\(.*\) \(.*\)/\1/'`
VERLIMIT=`echo $VERLIMIT|sed -e 's/\(.*\) \(.*\)/\2/'`
fi
POLICY=`LC_ALL=C apt-cache policy $name 2>/dev/null|grep Candidate|cut -d':' -f2-3|tr -d ' '`
if [ -n "$POLICY" ]; then
if [ -n "$VERLIMIT" ]; then
CHECK=`dpkg --compare-versions $POLICY "$VERCMP" $VERLIMIT ; echo $?`
fi
else
ERR="$ERR $name "
fi
if [ -z "$CHECK" -o "0" != "$CHECK" ]; then
if [ -n "$VERCMP" ]; then
echo "$name ($VERCMP $VERLIMIT) is NOT available."
ERR="$ERR $name ($VERCMP $VERLIMIT) "
fi
fi
CMD="$CMD $name"
done
if [ -n "$ERR" ]; then
echo Some packages are not available: $ERR
exit 1
fi
if [ -n "$INSTALL" ]; then
eval apt-get install "$CMD"
dpkg -i $FILE
else
echo apt-get install $CMD
fi

3
debian/changelog vendored
View file

@ -6,8 +6,9 @@ emdebian-rootfs (2.0.7) unstable; urgency=low
* Add subroutines to replace functionality from Emdebian::Tools * Add subroutines to replace functionality from Emdebian::Tools
in shell scripts. Drop Emdebian::Tools dependency. (LP: #531143) in shell scripts. Drop Emdebian::Tools dependency. (LP: #531143)
* [INTL:fr] French program output translation (Closes: #575314) * [INTL:fr] French program output translation (Closes: #575314)
* Add a check-deps script to parse the Depends of an individual .deb
-- Neil Williams <codehelp@debian.org> Wed, 24 Mar 2010 21:38:45 +0000 -- Neil Williams <codehelp@debian.org> Sun, 28 Mar 2010 07:45:00 +0100
emdebian-rootfs (2.0.6) unstable; urgency=low emdebian-rootfs (2.0.6) unstable; urgency=low

View file

@ -5,4 +5,5 @@ examples/multistrap-example.conf ./usr/share/doc/multistrap/examples/
examples/sid.conf ./usr/share/multistrap/ examples/sid.conf ./usr/share/multistrap/
examples/squeeze.conf ./usr/share/multistrap/ examples/squeeze.conf ./usr/share/multistrap/
examples/lenny.conf ./usr/share/multistrap/ examples/lenny.conf ./usr/share/multistrap/
check-deps.sh ./usr/share/multistrap/
bash/multistrap ./etc/bash_completion.d/ bash/multistrap ./etc/bash_completion.d/