2010-03-28 06:50:09 +00:00
|
|
|
#!/bin/sh
|
2010-06-20 16:41:23 +00:00
|
|
|
|
2010-03-28 06:50:09 +00:00
|
|
|
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
|
|
|
|
;;
|
2010-07-08 11:27:28 +00:00
|
|
|
-y|--yes)
|
|
|
|
shift
|
|
|
|
YES=1
|
|
|
|
;;
|
2010-03-28 06:50:09 +00:00
|
|
|
*)
|
2010-07-28 18:30:44 +00:00
|
|
|
FILE=$1
|
|
|
|
shift
|
2010-03-28 06:50:09 +00:00
|
|
|
;;
|
|
|
|
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
|
2010-07-28 18:30:44 +00:00
|
|
|
orlist=$(echo $pkg|grep "|" || true)
|
|
|
|
while [ -n "$orlist" ]; do
|
|
|
|
ORPKG=`echo $pkg|cut -d'|' -f2|sed -e 's/^ //'`
|
|
|
|
ALTERNATE="$ALTERNATE $ORPKG"
|
|
|
|
orlist=$(echo $orlist | sed -e "s/.*$ORPKG//;s/^ *//;s/ *$//")
|
|
|
|
ALTERNATE=$(echo $ALTERNATE|sed -e 's/^ *//;s/ *$//')
|
|
|
|
pkg=$(echo $pkg|sed -e "s/|//;s/$ORPKG//;s/^ *//;s/ *$//")
|
|
|
|
done
|
2010-03-28 06:50:09 +00:00
|
|
|
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
|
2010-06-20 16:41:23 +00:00
|
|
|
set +e
|
2010-03-28 06:50:09 +00:00
|
|
|
CHECK=`dpkg --compare-versions $POLICY "$VERCMP" $VERLIMIT ; echo $?`
|
2010-06-20 16:41:23 +00:00
|
|
|
set -e
|
2010-03-28 06:50:09 +00:00
|
|
|
fi
|
2010-07-28 18:30:44 +00:00
|
|
|
if [ -z "$CHECK" ]; then
|
|
|
|
VERLIMIT=
|
|
|
|
VERCMP=
|
|
|
|
name=$(echo $ALTERNATE|sed -e 's/^ //'|cut -d' ' -f1)
|
|
|
|
if [ -n `echo $ALTERNATE|grep '('` ]; then
|
|
|
|
VERLIMIT=`echo $ALTERNATE|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
|
|
|
|
set +e
|
|
|
|
CHECK=`dpkg --compare-versions $POLICY "$VERCMP" $VERLIMIT ; echo $?`
|
|
|
|
set -e
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2010-03-28 06:50:09 +00:00
|
|
|
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
|
2010-07-08 11:27:28 +00:00
|
|
|
if [ -n "$YES" ]; then
|
|
|
|
CMD="$CMD -y $name"
|
|
|
|
fi
|
2010-03-28 06:50:09 +00:00
|
|
|
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
|
2010-07-28 18:30:44 +00:00
|
|
|
elif [ -n "$CMD" ]; then
|
|
|
|
echo apt-get install ${CMD}
|
2010-03-28 06:50:09 +00:00
|
|
|
fi
|