[debhelper-devel] [debhelper] 01/01: dh_makeshlibs: Use ldconfig trigger instead of maintscripts
Niels Thykier
nthykier at moszumanska.debian.org
Thu Sep 10 20:06:27 UTC 2015
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 9bcb9a4710b17c0631e1ff6a557ccef3a64b64a9
Author: Niels Thykier <niels at thykier.net>
Date: Thu Sep 10 22:06:20 2015 +0200
dh_makeshlibs: Use ldconfig trigger instead of maintscripts
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Dh_Lib.pm | 46 ++++++++++++++++++++++++++++++++++++++++++++++
debian/changelog | 2 ++
dh_installdeb | 29 ++++++++++++++++++++++++++++-
dh_makeshlibs | 13 ++++++++-----
doc/PROGRAMMING | 6 ++++++
5 files changed, 90 insertions(+), 6 deletions(-)
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index d3e2ba0..fd50cb4 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -24,6 +24,7 @@ use vars qw(@EXPORT %dh);
&install_dh_config_file &error_exitcode &package_multiarch
&install_file &install_prog &install_lib &install_dir
&get_source_date_epoch &is_cross_compiling
+ &generated_file &autotrigger
);
my $max_compat=10;
@@ -630,6 +631,51 @@ sub autoscript_sed {
}
}
+# Adds a trigger to the package
+{
+ my %VALID_TRIGGER_TYPES = map { $_ => 1 } qw(
+ interest interest-await interest-noawait
+ activate activate-await activate-noawait
+ );
+
+ sub autotrigger {
+ my ($package, $trigger_type, $trigger_target) = @_;
+ my $triggers_file = generated_file($package, 'triggers');
+ my $ifd;
+ if ( -f $triggers_file ) {
+ open($ifd, '<', $triggers_file)
+ or error("open $triggers_file failed $!");
+ } else {
+ open($ifd, '<', '/dev/null')
+ or error("open /dev/null failed $!");
+ }
+ open(my $ofd, '>', "${triggers_file}.new")
+ or error("open ${triggers_file}.new failed $!");
+ while (my $line = <$ifd>) {
+ next if $line =~ m{\A \Q${triggers_file}\E \s+
+ \Q${trigger_target}\E (?:\s|\Z)
+ }x;
+ print {$ofd} $line;
+ }
+ print {$ofd} '# Triggers added by ' . basename($0) . "\n";
+ print {$ofd} "${trigger_type} ${trigger_target}\n";
+ close($ofd) or error("closing ${triggers_file}.new failed: $!");
+ close($ifd);
+ doit('mv', '-f', "${triggers_file}.new", $triggers_file);
+ }
+}
+
+sub generated_file {
+ my ($package, $filename, $mkdirs) = @_;
+ my $dir = "debian/.debhelper/generated/${package}";
+ my $path = "${dir}/${filename}";
+ $mkdirs //= 1;
+ if ($mkdirs and not -d $dir) {
+ install_dir($dir);
+ }
+ return $path;
+}
+
# Removes a whole substvar line.
sub delsubstvar {
my $package=shift;
diff --git a/debian/changelog b/debian/changelog
index 4ce4e0e..0201d68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -58,6 +58,8 @@ debhelper (9.20150811+unreleased) UNRELEASED; urgency=medium
* dh,Buildsytems: Accept "--no-parallel" to disable
parallel builds. It is effectively the same as using
--max-parallel=1 but may be more intuative to some people.
+ * dh_makeshlibs: Use a noawait trigger to invoke ldconfig
+ rather maintscripts.
[ Paul Tagliamonte ]
* dh_gencontrol: Put debug debs back in the "debug" section.
diff --git a/dh_installdeb b/dh_installdeb
index 5d16921..591669e 100755
--- a/dh_installdeb
+++ b/dh_installdeb
@@ -121,7 +121,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
# Install non-executable files
- my @non_exec_files = (qw{conffiles triggers});
+ my @non_exec_files = (qw{conffiles});
# In compat 10, we let dh_makeshlibs handle "shlibs".
push(@non_exec_files, 'shlibs') if compat(9);
foreach my $file (@non_exec_files) {
@@ -131,6 +131,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
}
+ install_triggers($package, $tmp);
+
# Automatic conffiles registration: If it is in /etc, it is a
# conffile.
if (! compat(2) && -d "$tmp/etc") {
@@ -145,6 +147,31 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
}
+sub install_triggers {
+ my ($package, $tmp) = @_;
+ my $generated = generated_file($package, 'triggers', 0);
+ my @sources = grep { -f $_ } (
+ pkgfile($package, 'triggers'),
+ $generated,
+ );
+ my $target = "$tmp/DEBIAN/triggers";
+ return if not @sources;
+ if (@sources > 1) {
+ my $merged = "${generated}.merged";
+ open(my $ofd, '>', $merged)
+ or error("open ${target} failed: $!");
+ for my $src (@sources) {
+ open(my $ifd, '<', $src)
+ or error("open ${src} failed: $!");
+ print {$ofd} $_ while <$ifd>;
+ close($ifd);
+ }
+ close($ofd) or error("close ${merged} failed: $!");
+ @sources = ($merged);
+ }
+ install_file($sources[0], $target);
+}
+
=head1 SEE ALSO
L<debhelper(7)>
diff --git a/dh_makeshlibs b/dh_makeshlibs
index a0b3253..a5ba10e 100755
--- a/dh_makeshlibs
+++ b/dh_makeshlibs
@@ -81,7 +81,10 @@ be upgraded.
=item B<-n>, B<--noscripts>
-Do not modify F<postinst>/F<postrm> scripts.
+Do not add the "ldconfig" trigger even if it seems like the package
+might need it. The option is called B<--noscripts> for historical
+reasons as B<dh_makeshlibs> would previously generate maintainer
+scripts that called B<ldconfig>.
=item B<-X>I<item>, B<--exclude=>I<item>
@@ -230,10 +233,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
complex_doit("echo '$_' >>$tmp/DEBIAN/shlibs");
}
- # New as of dh_v3.
- if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
- autoscript($package,"postinst","postinst-makeshlibs");
- autoscript($package,"postrm","postrm-makeshlibs");
+ # Historically, --noscripts would disable the creation of
+ # maintscripts for calling ldconfig.
+ if (! $dh{NOSCRIPTS} && $need_ldconfig) {
+ autotrigger($package, 'activate-noawait', 'ldconfig');
}
if ($shlibs_file) {
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 945d192..95c5e54 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -233,6 +233,12 @@ autoscript($package, $scriptname, $snippetname, $sedcommands || $sub)
maintainer script (like the postinst or prerm).
Note that in v6 mode and up, the snippets are added in reverse
order for the removal scripts.
+autotrigger($package, $trigger_type, $trigger_target)
+ This command automatically adds a trigger to the package. The
+ parameters:
+ - binary package to be affected
+ - the type of trigger (e.g. "activate-noawait")
+ - the target (e.g. "ldconfig" or "/usr/share/foo")
dirname($pathname)
Return directory part of pathname.
basename($pathname)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list