]> git.donarmstrong.com Git - debhelper.git/blob - dh_lib
r46: Initial revision
[debhelper.git] / dh_lib
1 # Library functions for debhelper programs.
2
3 # Run a command, and display the command to stdout if verbose mode is on.
4 # All commands that edit debian/tmp should be ran via this function.
5 function doit() {
6         verbose_echo "$1"
7         $1
8 }
9
10 # Echo something if the verbose flag is on.
11 function verbose_echo() {
12         if [ "$DH_VERBOSE" ]; then
13                 echo "  $1"
14         fi
15 }
16
17 # Echo an error message and exit.
18 function error() {
19         echo `basename $0`": $1" >&2
20         exit 1
21 }
22
23 # Argument processing and global variable initialization is below.
24
25 # Get the package name and version from the changelog.
26 LINE=`head -1 debian/changelog`
27 PACKAGE=`expr "$LINE" : '\(.*\) (.*)'`
28 VERSION=`expr "$LINE" : '.* (\(.*\))'`
29
30 # Is this a native Debian package?
31 if ! expr "$VERSION" : '.*-' >/dev/null; then
32         NATIVE=1
33 fi
34
35 # Parse command line.
36 set -- `getopt v $*` 
37
38 for i; do
39         case "$i"
40         in
41                 -v)
42                         DH_VERBOSE=1
43                         shift
44                         ;;
45                 --)
46                         shift
47                         break
48                         ;;
49         esac
50 done