Add get-build-deps.

This commit is contained in:
Siegfried-Angel Gevatter Pujals (RainCT) 2007-10-27 17:49:10 +02:00
parent 4f7aeb5399
commit 60577d5d53

87
get-build-deps Executable file
View File

@ -0,0 +1,87 @@
#!/bin/bash
# Copyright 2007 (C) Siegfried-A. Gevatter <siggi.gevatter@gmail.com>
# License: GPLv3 or later
#
# If you don't pass it any argument, this script will check if
# there's a control (debian/control) file somewhere in the current
# directory, and if it's so, it'll install the build dependencies
# listed there.
#
# If it gets a single argument, and it's the name of a file, it will
# read it, supposing that each line contains the name of a package,
# and install the build dependencies for all those.
#
# Otherwise, if there is more than one argument, or the given argument
# isn't the name of an existing file, it will suppose that the each
# argument is the name of a package, and install the dependencies for
# all of them.
if [ $# -eq 0 ]
then
#########################################################
# Install the dependencies for the source package the
# user is working on.
if [ -f ../debian/control ]; then
cd ..
elif [ ! -f ./debian/control ]; then
echo "\
Couldn't find the file debian/control. You have to be inside the \
source directory of a Debian package or pass the name of the \
package(s) whose build dependencies you want to install in order \
to use this script."
exit 1
fi
if [ ! -x /usr/lib/pbuilder/pbuilder-satisfydepends ]; then
# The package «pbuilder» isn't installed, but it's required
# to install the build dependencies of a source package.
# Ask the user if he wants to install it automatically.
echo -n "\
This script requires a component that's included in the «pbuilder» \
package, which isn't currently installed, in order to install the \
dependencies required to build the source package in the current \
directory.
Would you like to install pbuilder now? [y/N] "
read install_now
if [ ! $install_now ] || ([ $install_now != 'y' ] && [ $install_now != 'Y' ])
then
# Don't install it. Abort.
exit 1
fi
echo 'Installing package «pbuilder»...'
sudo aptitude install pbuilder
echo; echo
fi
echo "Installing the build dependencies described in «`pwd`/debian/control»..."
sudo /usr/lib/pbuilder/pbuilder-satisfydepends
exit 0
elif [ $# -eq 1 ]
then
#########################################################
# Check if the given argument is a file name, else
# continue after the if.
if [ -f $1 ]
then
packages=''
echo "Installing the build dependencies for the following packages:"
while read line
do
echo $line
packages="$packages $line"
done < $1
echo
sudo apt-get build-dep $packages
exit 0
fi
fi
#########################################################
# All arguments should be package names, install
# their build dependencies.
sudo apt-get build-dep $*