1 # Library functions for debhelper programs.
3 # Run a command, and display the command to stdout if verbose mode is on.
4 # All commands that modifiy files in debian/$TMP should be ran via this
11 # Echo something if the verbose flag is on.
12 function verbose_echo() {
13 if [ "$DH_VERBOSE" ]; then
18 # Echo an error message and exit.
20 echo `basename $0`": $1" >&2
24 # Pass it a name of a binary package, it returns the name of the tmp dir to
25 # use, for that package, relative to debian/
26 # This is for back-compatability with the debian/tmp tradition.
28 if [ "$1" = "$MAINPACKAGE" ]; then
35 # Pass it a name of a binary package, it returns the name to prefix to files
36 # in debian for this package.
38 if [ "$1" != "$MAINPACKAGE" ]; then
43 # Argument processing and global variable initialization is below.
46 set -- `getopt viap: $*`
64 DH_DOPACKAGES="$DH_DOPACKAGES $2"
75 # Get the package version from the changelog.
76 LINE=`head -1 debian/changelog`
77 VERSION=`expr "$LINE" : '.* (\(.*\))'`
79 # Get the name of the main binary package.
80 MAINPACKAGE=`grep ^Package: debian/control | cut -d " " -f 2 | head -1`
82 # Is this a native Debian package?
83 if ! expr "$VERSION" : '.*-' >/dev/null; then
87 if [ "$DH_DOINDEP" -o "$DH_DOARCH" ]; then
88 # Figure out all the binary packages to be produced, by looking at the
89 # control file. Break it into 2 lists, INDEP_PACKAGES and ARCH_PACKAGES.
91 # First, get the list of all binary packages.
92 PACKAGES=`grep ^Package: debian/control | cut -d " " -f 2 | tr "\n" " "`
93 # Remove trailing space.
94 PACKAGES=`expr "$PACKAGES" : '\(.*\) '`
95 # Loop on the list of architectures. Note that we tac the result to reverse
96 # it, becuase we are going through the list of packages in reverse.
97 for ARCH in `grep ^Architecture: debian/control | tac | cut -d " " -f 2` ; do
98 THISPKG=`expr "$PACKAGES" : '.* \(.*\)'` || true
99 if [ ! "$THISPKG" ]; then
102 PACKAGES=`expr "$PACKAGES" : '\(.*\) .*'` || true
103 if [ ! "$THISPKG" ]; then
104 error "debian/control invalid - too many Architecture lines or too few Package lines"
106 if [ "$ARCH" = "all" ]; then
107 INDEP_PACKAGES="$INDEP_PACKAGES $THISPKG"
109 ARCH_PACKAGES="$ARCH_PACKAGES $THISPKG"
113 if [ "$PACKAGES" ]; then
114 error "debian/control invalid - too many Architecure lines or too few Package lines"
116 if [ "$DH_DOINDEP" ]; then
117 DH_DOPACKAGES="$DH_DOPACKAGES $INDEP_PACKAGES"
119 if [ "$DH_DOARCH" ]; then
120 DH_DOPACKAGES="$DH_DOPACKAGES $ARCH_PACKAGES"
124 # Check if packages to build have been specified, if not, fall back to
125 # the default, doing them all. Note that DH_DOPACKAGES may have a leading
126 # space and be empty otherwise.
127 if [ ! "$DH_DOPACKAGES" -o "$DH_DOPACKAGES" = " " ]; then
128 if [ "$DH_DOINDEP" -o "$DH_DOARCH" ]; then
129 error "I have no package to build."
131 DH_DOPACKAGES=`grep ^Package: debian/control | cut -d " " -f 2`