1 This file documents things you should know to write a new debhelper program.
6 There are lots of debhelper commands. To make the learning curve shallower,
7 I want them all to behave in a standard manner:
9 All debhelper programs have names beginning with "dh_". This is so we don't
10 pollute the name space too much.
12 Debhelper programs should never output anything to standard output except
13 error messages, important warnings, and the actual commands they run that
14 modify files under debian/ and debian/tmp, etc (this last only if they are
15 passed -v, and if you output the commands, you should indent them with 1 tab).
16 This is so we don't have a lot of noise output when all the debhelper commands
17 in a debian/rules are run, so the important stuff is clearly visible.
19 Debhelper programs should accept the options, -v, -i, -a, -p, --no-act, and
20 -P, and any long forms of these options, like --verbose . If necessary, the
21 options may be ignored.
23 If debhelper commands need config files, they should use
24 debian/package.filename as the name of the confile file (replace filename
25 with whatever your command wants), and debian/filename should also be
26 checked for config information for the first binart package in
27 debian/control. Also, debhelper commands should accept the same sort of
28 information that appears in the config files, on their command lines, if
29 possible, and apply that information to the first package thay act on.
31 Debhelper programs should never modify the debian/postinst, debian/prerm,
32 etc scripts, instead, they can add lines to debian/postinst.debhelper, etc.
33 The autoscript() function (see below) is one easy way to do this.
34 dh_installdeb is an exception, it will run after the other commands and
35 merge these modifications into the actual postinst scripts.
37 There are always exceptions. Just ask me.
42 All debhelper programs use the dh_lib library (actually it's a shell script)
43 to parse their arguments and set some useful variables. It's not mandatory
44 that your program use dh_lib, but it will make it a lot easier to keep it in
45 sync with the rest of debhelper if it does, so this is highly encouraged.
47 Typically, you invoke dh_lib like this:
49 PATH=debian:$PATH:/usr/lib/debhelper
52 The path statement is there to make your program look first in debian/ for
53 dh_lib (so users can install a modified version there if necessary), then the
54 rest of the path, then the canoical location of dh_lib, /usr/lib/debhelper.
59 All debhelper programs should respond to certian arguemnts, such as -v, -i,
60 -a, and -p. To help you make this work right, dh_lib handles argumeny
63 As soon as dh_lib loads, it processes any arguments that have been passed to
64 your program. The following variables may be set during this stage; your
65 program can use them later:
67 switch variable description
68 -v DH_VERBOSE should the program verbosely output what it is
70 --no-act DH_NO_ACT should the program not actually do anything?
71 -i,-a,-p DH_DOPACKAGES a space delimited list of the binary packages
73 -i,-p DH_DOINDEP a space delimited list of the binary independant
75 -a,-p DH_DOARCH a space delimited list of the binary dependant
77 -n DH_NOSCRIPTS if set, do not make any modifications to the
78 package's postinst, posrtm, etc scripts.
79 -x DH_EXCLUDE exclude a something from processing (you
80 decide what this means for your program)
81 -d DH_D_FLAG you decide what this means to your program
82 -r DH_R_FLAG you decide what this means to your program
83 -k DH_K_FLAG you decide what this means to your program
84 -P DH_TMPDIR package build directory (implies only one
85 package is being acted on)
86 -u DH_U_PARAMS will be set to a string, that is typically
87 parameters your program passes on to some
89 -m DH_M_PARAMS will be set to a string, you decide what it
91 -V DH_V_FLAG will be set to a string, you decide what it
93 -V DH_V_FLAG_SET will be 1 if -V was specified, even if no
94 parameters were passed along with the -V
95 -A DH_PARAMS_ALL generally means that additional command line
96 parameters passed to the program (other than
97 those processed here), will apply to all
98 binary packages the program acts on, not just
101 Any additional command line parameters that do not start with "-" will be
102 ignored, and you can access them later just as you normally would ($1, $2,
105 If you need a new command line option, just ask me, and I will add it.
110 The following variables are also set, you can use any of them:
112 MAINPACKAGE the name of the first binary package listed in
114 DH_FIRSTPACKAGE the first package we were instructed to act on. This package
115 typically gets special tratment, addiiional arguments
116 specified on the command line may effect it.
121 Dh_lib also contains a number of functions you may find useful.
124 Pass this function a string that is a shell command. It will run the
125 command (unless DH_NO_ACT is set), and if DH_VERBOSE is set, it will
126 also output the command to stdout. You should use this function for
127 almost all commands your program performs that manipulate files in
128 the package build directories.
130 This is the same as doit(), except you can pass more complicated
131 commands to it (ie, commands involving piping redirection)
133 Pass this command a string, and it will echo it if DH_VERBOSE is set.
135 Pass this command a string, it will output it to standard error and
138 Pass this command the name of a binary package, it will return the
139 name of the tmp directory that will be used as this package's
140 package build directory. Typically, this will be "debian/tmp" or
143 Pass this command the name of a binary package, and the base name of a
144 file, and it will return the actual filename to use. This is used
145 for allowing debhelper programs to have configuration files in the
146 debian/ directory, so there can be one config file per binary
147 package. The conversion is that the files are named
148 debian/package.filename, and debian/filename is also allowable for
149 the MAINPACKAGE. If the file does not exist, nothing is returned.
151 Pass this command the name of a binary package, and it will return
152 the name to prefix to files in debian/ for this package. For the
153 MAINPACKAGE, it returns nothing (there is no prefix), for the other
154 packages, it returns "package.".
156 Pass this command the name of a package, it returns 1 if the package
157 is a native debian package.
158 As a side effect, VERSION is set to the version number of the
163 2: filename of snippet
164 3: sed commands to run on the snippet. Ie, s/#PACKAGE#/$PACKAGE/
166 This command automatically adds shell script snippets to a debian
167 maintainer script (like the postinst or prerm).
172 Dh_lib is still evolving.
173 There will probably be a perl version too, in the future.
175 -- Joey Hess <joeyh@master.debian.org>