@ISA=qw(Exporter);
@EXPORT=qw(&init &doit &complex_doit &verbose_print &error &warning &tmpdir
&pkgfile &pkgext &isnative &autoscript &filearray &GetPackages
- &basename &dirname &xargs %dh &compat);
+ &basename &dirname &xargs %dh &compat &addsubstvar &delsubstvar);
my $max_compat=4;
if (defined $ENV{DH_COMPAT}) {
$c=$ENV{DH_COMPAT};
}
+ elsif (-e 'debian/compat') {
+ # Try the file..
+ open (COMPAT_IN, "debian/compat") || die "debian/compat: $!";
+ $c=<COMPAT_IN>;
+ chomp $c;
+ }
if ($c > $max_compat) {
error("Sorry, but $max_compat is the highest compatibility level of debhelper currently supported.");
complex_doit("echo '# End automatically added section' >> $outfile");
}
+# Removes a whole substvar line.
+sub delsubstvar {
+ my $package=shift;
+ my $substvar=shift;
+
+ my $ext=pkgext($package);
+ my $substvarfile="debian/${ext}substvars";
+
+ complex_doit("grep -v '^${substvar}=' $substvarfile > $substvarfile.new || true");
+ doit("mv", "$substvarfile.new","$substvarfile");
+}
+
+# Adds a dependency on some package to the specified
+# substvar in a package's substvar's file.
+sub addsubstvar {
+ my $package=shift;
+ my $substvar=shift;
+ my $deppackage=shift;
+ my $verinfo=shift;
+ my $remove=shift;
+
+ my $ext=pkgext($package);
+ my $substvarfile="debian/${ext}substvars";
+ my $str=$deppackage;
+ $str.=" ($verinfo)" if length $verinfo;
+
+ # Figure out what the line will look like, based on what's there
+ # now, and what we're to add or remove.
+ my $line="";
+ if (-e $substvarfile) {
+ my %items;
+ open(SUBSTVARS_IN, "$substvarfile") || die "read $substvarfile: $!";
+ while (<SUBSTVARS_IN>) {
+ chomp;
+ if (/^\Q$substvar\E=(.*)/) {
+ %items = map { $_ => 1} split(", ", $1);
+
+ last;
+ }
+ }
+ close SUBSTVARS_IN;
+ if (! $remove) {
+ $items{$str}=1;
+ }
+ else {
+ delete $items{$str};
+ }
+ $line=join(", ", keys %items);
+ }
+ elsif (! $remove) {
+ $line=$str;
+ }
+
+ if (length $line) {
+ complex_doit("echo '${substvar}=$line' >> $substvarfile");
+ }
+}
+
# Reads in the specified file, one word at a time, and returns an array of
# the result. If a value is passed in as the second parameter, then glob
# expansion is done in the directory specified by the parameter ("." is
--- /dev/null
+if [ -x "/etc/init.d/#SCRIPT#" ]; then
+ update-rc.d #SCRIPT# #INITPARMS# >/dev/null
+ invoke-rc.d #SCRIPT# start
+fi
--- /dev/null
+if [ -x "/etc/init.d/#SCRIPT#" ]; then
+ update-rc.d #SCRIPT# #INITPARMS# >/dev/null
+ if [ "$1" = "configure" ]; then
+ if [ -z "$2" -o "$2" = "<unknown>" ]; then
+ invoke-rc.d #SCRIPT# start
+ fi
+ fi
+fi
--- /dev/null
+if [ "$1" = "purge" ] ; then
+ update-rc.d #SCRIPT# remove >/dev/null
+fi
--- /dev/null
+if [ -x "/etc/init.d/#SCRIPT#" ]; then
+ invoke-rc.d #SCRIPT# stop
+fi
--- /dev/null
+if [ -x "/etc/init.d/#SCRIPT#" -a "$1" = remove ]; then
+ invoke-rc.d #SCRIPT# stop
+fi
system ($temp) / 256 == 0
or die "Problem with debhelper scripts: $!";
+=head2 Automatic generation of miscellaneous dependencies.
+
+Some debhelper commands may make the generated package need to depend on
+some other packages. For example, if you use L<dh_installdebconf(1)>, you'r
+package will generally need to depend on debconf. Or if you use
+L<dh_installxfonts(1)>, your package will generally need to depend on a
+particular version of xutils. Keeping track of these miscellaneous
+dependencies can be annoying, so debhelper offers a way to automate it.
+All commands of this type, besides documenting what dependencies may be
+needed on their man pages, will automatically generate a substvar called
+${misc:Depends}. If you put that token into your debian/control file, it
+will be expanded to the dependencies debhelper figures you need.
+
+This is entirely independent of the standard ${shlibs:Depends} generated by
+L<dh_makeshlibs(1)>, and the ${perl:Depends} generated by L<dh_perl(1)>.
+You can choose not to use any of these, if debhelper's guesses don't match
+reality.
+
=head2 Package build directories
By default, all debhelper programs assume that the temporary directory used
From time to time, major non-backwards-compatible changes need to be made
to debhelper, to keep it clean and well-designed as needs change and its
author gains more experience. To prevent such major changes from breaking
-existing packages, the DH_COMPAT environment variable was introduced.
-DH_COMPAT may be set to a number, to determine which major revision of
-debhelper should be used. There are currently 3:
+existing packages, the concept of debhelper compatability levels was
+introduced. You tell debhelper which compatability level it should use, and
+it modifies its behavior in various ways.
+
+You tell debhelper what compatability level to use by writing a number to
+debian/compat. For example, to turn on V3 mode:
+
+ % echo 3 > debian/compat
+
+These are the available compatablity levels:
=over 4
=item V1
-Setting DH_COMPAT=1 (or leaving it unset) causes debhelper to act in
-compatibility mode. It will use debian/tmp as the package tree
+This is the original debhelper compatability level, and so it is the default
+one. In this mode, debhelper will use debian/tmp as the package tree
directory for the first binary package listed in the control file, while using
debian/<package> for all other packages listed in the control file.
This mode is deprecated.
=item V2
-Setting DH_COMPAT=2 causes debhelper to consistently use debian/<package>
+In this mode, debhelper will consistently use debian/<package>
as the package tree directory for every package that is built.
=item V3
-This is the reccommended mode of operation.
-Setting DH_COMPAT=3 does everything V2 does, plus:
+This is the reccommended mode of operation. It does everything V2 does,
+plus:
=over 8
=item V4
This mode is still under development, and its behavior may change at any
-time. Currently, setting DH_COMPAT=4 does everything V4 does, plus:
+time. Currently, it does everything V3 does, plus:
=over 8
dh_makeshlibs -V will not include the debian part of the version number in
the generated dependancy line in the shlibs file.
+=item -
+
+dh_installinit uses the new invoke-rc.d program in its generated maintainer
+scripts. (This may later be rolled back into V3).
+
=back
=back
=item DH_COMPAT
-Specifies what compatibility level debhelper should run at. See above.
+Temporarily specifies what compatibility level debhelper should run at,
+overriding any value in debian/compat.
=item DH_NO_ACT
+debhelper (3.4.4) unstable; urgency=low
+
+ * Introduced the debian/compat file. This is the new, preferred way to say
+ what debhelper compatability level your package uses. It has the big
+ advantage of being available to debhelper when you run it at the command
+ line, as well as in debian/rules.
+ * A new v4 feature: dh_installinit, in v4 mode, will use invoke-rc.d.
+ This is in v4 for testing, but I may well roll it back into v3 (and
+ earlier) once woody is released and I don't have to worry about breaking
+ things (and, presumably, once invoke-rc.d enters policy).
+ * Some debhelper commands will now build up a new substvars variable,
+ ${misc:Depends}, based on things they know your package needs to depend
+ on. For example, dh_installinit in v4 mode adds sysvinit (>= 2.80-1) to
+ that dep list, and dh_installxfonts adds a dep on xutils. This variable
+ should make it easier to keep track of what your package needs to depends
+ on, supplimenting the ${shlibs:Depends} and ${perl:Depends} substvars.
+ Hmm, this appears to be based loosely on an idea by Masato Taruishi
+ <taru@debian.org>, filtered through a long period of mulling it over.
+ Closes: #76352
+ * Use the addsubstvar function I wrote for the above in dh_perl too.
+
+ -- Joey Hess <joeyh@debian.org> Sat, 26 Jan 2002 23:30:51 -0500
+
debhelper (3.4.3) unstable; urgency=low
* Improved dh_installxfonts some more:
# be sure to use the new templates from this package.
export DH_AUTOSCRIPTDIR=autoscripts
-# Use most recent compatability level.
-export DH_COMPAT=3
-
# Figure out the `current debhelper version.
VERSION=$(shell expr "`dpkg-parsechangelog 2>/dev/null |grep Version:`" : '.*Version: \(.*\)')
the .debhelper file. The .debhelper files are created by other debhelper
programs, such as L<dh_installmenu(1)>, and are shell script fragments.
-If DH_COMPAT is set to 3 or higher, all files in the etc/ directory in a
+In V3 compatability mode and higher, all files in the etc/ directory in a
package will automatically be flagged as conffiles by this program, so
there is no need to list them manually in package.conffiles.
Files named debian/package.config and debian/package.templates are
installed into the DEBIAN directory in the package build directory.
-Note that if you use debconf, your package probably needs to depend on it.
+Note that if you use debconf, your package probably needs to depend on it
+(it will be added to ${misc:Depends by this program).
=head1 LOCALIZED TEMPLATE FILES
}
}
- if (($config ne ''|| $templates ne '') && ! $dh{NOSCRIPTS}) {
+ if ($config ne '' || $templates ne '') {
+ # I'm going with debconf 0.5 because it was the first
+ # "modern" one.
+ addsubstvar($package, "misc:Depends", "debconf", ">= 0.5");
+ }
+ else {
+ addsubstvar($package, "misc:Depends", "debconf", ">= 0.5", 1); # remove
+ }
+
+ if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) {
autoscript($package,"postrm","postrm-debconf");
}
}
etc/default/package in the package build directory, with "package" replaced
by the package name.
+Historically this program generates postrm and prerm commands that run the
+init scripts by hand. In V4 mode, it uses the invoke-rc.d program instead.
+See L<debhelper(1)> for details about V4 mode. If you decide to use this, you
+should make your package depend on sysvinit (>= 2.80-1) (this dependency is
+added to ${misc:Depends} by this program in V4 mode).
+
=head1 OPTIONS
=over 4
$params="defaults";
}
+ my $substvaradded=0;
if (! $dh{NOSCRIPTS}) {
- # -r on the command line sets R_FLAG. If it's set, there
- # is no restart on upgrade.
+ # In v4 mode, use invoke-rc.d versions of the
+ # autoscripts; prior to that use the old,
+ # manual-invoking versions.
+ my $tailstr="";
+ if (! compat(3)) {
+ $tailstr="-invoke";
+ addsubstvar($package, "misc:Depends", "sysvinit", ">= 2.80-1");
+ $substvaradded=1;
+ }
+ # -r on the command line sets R_FLAG. If it's set,
+ # there is no restart on upgrade.
if ($dh{R_FLAG}) {
- autoscript($package,"postinst", "postinst-init-norestart",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
- autoscript($package,"postrm","postrm-init",
+ autoscript($package,"postinst", "postinst-init-norestart$tailstr",
"s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
- autoscript($package,"prerm","prerm-init-norestart",
+ autoscript($package,"prerm","prerm-init-norestart$tailstr",
"s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
}
else {
- autoscript($package,"postinst","postinst-init",
+ autoscript($package,"postinst","postinst-init$tailstr",
"s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
- autoscript($package,"postrm","postrm-init",
- "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
- autoscript($package,"prerm","prerm-init",
+ autoscript($package,"prerm","prerm-init$tailstr",
"s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
}
+ # This script just removes the links, so it's the
+ # same for all varients.
+ autoscript($package,"postrm","postrm-init",
+ "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+ }
+
+ if (! $substvaradded) {
+ # Remove it, for idemotency's sake.
+ addsubstvar($package, "misc:Depends", "sysvinit", ">= 2.80-1", 1);
}
}
}
build directory.
Your package should should depend on xutils (>= 4.0.3) so that the
-update-fonts-* commands are available.
+update-fonts-* commands are available. (This program adds that dependency to
+${misc:Depends}.)
This programt automatically generates the postinst and postrm commands needed
to register X fonts. See L<dh_installdeb(1)> for an explanation of how this
"s:#CMDS#:".join("\n", map { "\t$_" } @cmds).":;");
autoscript($package, "postrm", "postrm-xfonts",
"s:#CMDS#:".join("\n", @cmds).":;");
+
+ addsubstvar($package, "misc:Depends", "xutils", ">= 4.0.3");
+ }
+ else {
+ # remove
+ addsubstvar($package, "misc:Depends", "xutils", ">= 4.0.3", 1);
}
}
libraries, and generates a shlibs file for the libraries it finds.
It also adds a call to ldconfig in the postinst and postrm scripts (in
-DH_COMPAT=3 mode and above only) to any packages which it finds shared
-libraries in.
+V3 mode and above only) to any packages which it finds shared libraries in.
=head1 OPTIONS
=head1 DESCRIPTION
dh_perl is a debhelper program that is responsible for generating
-the perl:Depends substitutions and adding them to substvars files.
+the ${perl:Depends} substitutions and adding them to substvars files.
The program will look at perl scripts and modules in your package,
and will use this information to generate a dependency.
my $tmp = tmpdir($package);
my $ext = pkgext($package);
- # For idempotency, remove anything this program might have
- # previously added to the substvars file.
- if (-e "debian/${ext}substvars") {
- complex_doit("grep -v ^perl:Depends= debian/${ext}substvars > debian/${ext}substvars.new || true");
- doit("mv", "debian/${ext}substvars.new","debian/${ext}substvars");
- }
-
+ delsubstvar($package, "perl:Depends"); # for idempotency
+
# Check also for alternate locations given on the command line
my @dirs = grep -d, map "$tmp/$_", $vendorlib, $vendorarch, @ARGV;
}, $tmp;
if ($deps) {
- my $perl_depends = $perl;
+ my $version="";
if ($deps & XS_MODULE or $dh{V_FLAG_SET}) {
($version) = `dpkg -s $perl` =~ /^Version:\s*(\S+)/m
unless $version;
- $perl_depends .= " (>= $version)";
+ $version = ">= $version";
}
elsif ($deps & PM_MODULE) {
- $perl_depends .= " (>= $min_version)";
+ $version = ">= $min_version";
}
+
+ # no need to depend on an un-versioned perl-base -- it's
+ # essential
+ addsubstvar($package, "perl:Depends", $perl, $version)
+ unless $perl eq 'perl-base' && ! length($version);
# add perlapi-<ver> for XS modules
- $perl_depends .= ", perlapi-$Config{version}"
+ addsubstvar($package, "perl:Depends", "perlapi-$Config{version}")
if $deps & XS_MODULE;
-
- # don't need to depend on an un-versioned perl-base, it's
- # essential
- unless ($perl_depends eq 'perl-base') {
- complex_doit("echo 'perl:Depends=$perl_depends' >> debian/${ext}substvars");
- }
}
}
Dh_Lib.pm also contains a number of functions you may find useful.
-doit()
+doit(@command)
Pass this function an array that is a
shell command. It will run the command (unless $dh{NO_ACT} is set), and
if $dh{VERBOSE} is set, it will also output the command to stdout. You
should use this function for almost all commands your program performs
that manipulate files in the package build directories.
-complex_doit()
+complex_doit($command)
Pass this function a string that is a shell command, it will run it
similarly to how doit() does. You can pass more complicated commands
to this (ie, commands involving piping redirection), however, you
have to worry about things like escaping shell metacharacters.
-verbose_print()
+verbose_print($message)
Pass this command a string, and it will echo it if $dh{VERBOSE} is set.
-error()
+error($errormsg)
Pass this command a string, it will output it to standard error and
exit.
-warning()
+warning($message)
Pass this command a string, and it will output it to standard error
as a warning message.
-tmpdir()
+tmpdir($dir)
Pass this command the name of a binary package, it will return the
name of the tmp directory that will be used as this package's
package build directory. Typically, this will be "debian/package".
-compat()
+compat($num)
Pass this command a number, and if the current compatibility level
- equals that number, it will return true. Looks at DH_COMPAT to get
- the compatibility level.
-pkgfile()
+ is less than or equal to that number, it will return true.
+ Looks at DH_COMPAT to get the compatibility level.
+pkgfile($package, $basename)
Pass this command the name of a binary package, and the base name of a
file, and it will return the actual filename to use. This is used
for allowing debhelper programs to have configuration files in the
package. The convention is that the files are named
debian/package.filename, and debian/filename is also allowable for
the $dh{MAINPACKAGE}. If the file does not exist, nothing is returned.
-pkgext()
+pkgext($package)
Pass this command the name of a binary package, and it will return
the name to prefix to files in debian/ for this package. For the
$dh{MAINPACKAGE}, it returns nothing (there is no prefix), for the other
packages, it returns "package.".
-isnative()
+isnative($package)
Pass this command the name of a package, it returns 1 if the package
is a native debian package.
As a side effect, $dh{VERSION} is set to the version number of the
package.
-autoscript()
+autoscript($package, $scriptname, $snippetname, $sedcommands)
Pass parameters:
- binary package to be affected
- script to add to
(optional)
This command automatically adds shell script snippets to a debian
maintainer script (like the postinst or prerm).
-dirname()
+dirname($pathname)
Return directory part of pathname.
-basename()
+basename($pathname)
Return base of pathname,
+addsubstvar($package, $substvar, $deppackage, $verinfo, $remove)
+ This function adds a dependency on some package to the specified
+ substvar in a package's substvar's file. It needs all these
+ parameters:
+ - binary package that gets the item
+ - name of the substvar to add the item to
+ - the package that will be depended on
+ - version info for the package (optional) (ie: ">= 1.1")
+ - if this last parameter is passed, the thing that would be added
+ is removed instead. This can be useful to ensure that a debhelper
+ command is idempotent. Note that without this parameter, if you
+ call the function twice with the same values it will only add one
+ item to the substvars file.
+delsubstvar($package, $substvar)
+ This function removes the entire line for the substvar from the
+ package's shlibs file.
-- Joey Hess <joeyh@debian.org>
v4:
-These items are part of v4 already:
-
-* dhmakeshlibs -V omits the debian part of the version number from the
- generated dependancy in the shlibs file
+See debhelper's man page for what's implemented so far.
These items are planned:
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=3
-
build: build-stamp
build-stamp:
dh_testdir
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=3
-
build: build-stamp
build-stamp:
dh_testdir
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=3
-
build: build-stamp
build-stamp:
dh_testdir
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=3
-
# This has to be exported to make some magic below work.
export DH_OPTIONS