Here is the exact script that's used for Ubuntu external dependencies:
Code:
#!/bin/sh
if [ `whoami` != "root" ]; then
if [ -x /usr/bin/gksudo ] && [ ! -z "$DISPLAY" ]; then
ROOT="/usr/bin/gksudo"
elif [ -x /usr/bin/kdesu ] && [ ! -z "$DISPLAY" ]; then
ROOT="/usr/bin/kdesu"
elif [ -x /usr/bin/sudo ]; then
ROOT="/usr/bin/sudo"
fi
else
ROOT=""
fi
if [ -x /usr/bin/aptitude ]; then
# aptitude is nice since it doesn't fail if a non-existant package is hit
# See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503215
$ROOT "aptitude -y install $*"
else
$ROOT "apt-get -y --ignore-missing install $*"
fi
It covers not using gksudo when the DISPLAY is not set (as no X Server is likely running) and the apt commands are in quotes. Found in pts/distro-scripts/install-ubuntu-packages.sh on all releases prior to 2.4 or with 2.4+ is to be found in pts-core/static/distro-scripts/install-ubuntu-packages.sh.