47
47
There are always exceptions. Just ask me.
49
Introducing Dh_Lib.pm:
52
Dh_Lib.pm is the library used by all debhelper programs to parse their
52
Dh_Lib is the library used by all debhelper programs to parse their
53
53
arguments and set some useful variables. It's not mandatory that your
54
54
program use Dh_Lib.pm, but it will make it a lot easier to keep it in sync
55
55
with the rest of debhelper if it does, so this is highly encouraged.
57
(There used to be a version of Dh_lib.pm that was a library of functions for
58
shell scripts. If you want to write a debhelper command that is a shell
59
script, I can dig up that old library for you. Only the perl one is
60
supported now, though.)
62
Use Dh_Lib.pm like this:
64
59
use Debian::Debhelper::Dh_Lib
67
The BEGIN block is there to make perl look for the module in all the right
70
62
The init() function causes Dh_lib to parse the command line and do some other
71
63
initialization tasks.
77
69
-a, and -p. To help you make this work right, Dh_Lib.pm handles argument
78
70
processing. Just call init().
72
You can add support for additional options to your command by passing an
73
options hash to init(). The hash is then passed on the Getopt::Long to
74
parse the command line options. For example, to add a --foo option, which
77
init(options => { foo => \$dh{FOO} });
80
79
After argument processing, some global variables are used to hold the
81
80
results; programs can use them later. These variables are elements of the
99
98
-X EXCLUDE exclude a something from processing (you
100
99
decide what this means for your program)
101
100
(This is an array)
102
EXCLUDE_FIND same as DH_EXCLUDE, except all items are put
101
-X EXCLUDE_FIND same as EXCLUDE, except all items are put
103
102
into a string in a way that they will make
104
103
find find them. (Use ! in front to negate
105
104
that, of course) Note that this should
106
105
only be used inside complex_doit(), not in
109
include conffiles. It's -x for obscure
111
107
-d D_FLAG you decide what this means to your program
112
-r R_FLAG you decide what this means to your program
113
-k K_FLAG you decide what this means to your program
108
-k K_FLAG used to turn on keeping of something
114
109
-P TMPDIR package build directory (implies only one
115
110
package is being acted on)
116
111
-u U_PARAMS will be set to a string, that is typically
117
112
parameters your program passes on to some
118
113
other program. (This is an array)
119
-m M_PARAMS will be set to a string, you decide what it
120
means to your program
121
-l L_PARAMS will be set to a string, you decide what it
122
means to your program
123
114
-V V_FLAG will be set to a string, you decide what it
124
115
means to your program
125
116
-V V_FLAG_SET will be 1 if -V was specified, even if no
129
120
those processed here), will apply to all
130
121
binary packages the program acts on, not just
132
--init-script INIT_SCRIPT will be set to a string, which specifies an
133
init script name (probably only
134
dh_installinit will ever use this)
135
--sourcedir SOURCEDIR will be set to a string (probably only
136
dh_movefiles will ever use this)
137
--destdir DESTDIR will be set to a string (probably only
138
dh_builddeb will ever use this)
139
--filename FILENAME will be set to a string
140
--flavor FLAVOR will be set to a string (probably only
141
dh_installemacsen will ever use this)
142
--number PRIORITY will be set to a number (deprecated)
123
--sourcedir SOURCEDIR will be set to a string
124
--destdir DESTDIR will be set to a string
143
125
--priority PRIORITY will be set to a number
126
--mainpackage MAINPACKAGE controls which package is treated as the
127
main package to act on
144
128
--name NAME a name to use for installed files, instead of
146
130
--error-handler ERROR_HANDLER a function to call on error
147
--language LANGUAGE specify what language a file is in
148
--add-udeb SHLIBS_UDEB used by dh_makeshlibs
150
132
Any additional command line parameters that do not start with "-" will be
151
133
ignored, and you can access them later just as you normally would.
153
If you need a new command line option, just ask me, and I will add it.
155
135
Global variables:
263
243
Prevent logging the program's successful finish to
264
244
debian/*debhelper.log
245
load_log($package, $hashref)
246
Loads the log file for the given package and returns a list of
248
(Passing a hashref also causes it to populate the hash.)
249
write_log($cmd, $package ...)
250
Writes the log files for the specified package(s), adding
256
The dh(1) command has a --with <addon> parameter that ca be used to load
257
a sequence addon named Debian::Debhelper::Sequence::<addon>.
258
These addons can add/remove commands to the dh command sequences, by calling
259
some functions from Dh_Lib:
261
insert_before($existing_command, $new_command)
262
Insert $new_command in sequences before $existing_command
264
insert_after($existing_command, $new_command)
265
Insert $new_command in sequences after $existing_command
267
remove_command($existing_command)
268
Remove $existing_command from the list of commands to run.
266
270
-- Joey Hess <joeyh@debian.org>