[vdr] 06/06: Install a debhelper addon in vdr-dev which supports the plugin packaging

Tobias Grimm tiber-guest at moszumanska.debian.org
Thu Mar 12 22:54:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

tiber-guest pushed a commit to branch master
in repository vdr.

commit 4fcc3a95108fe8348ed83c5a01fd51b0fea285c5
Author: etobi <git at e-tobi.net>
Date:   Thu Mar 12 23:53:16 2015 +0100

    Install a debhelper addon in vdr-dev which supports the plugin packaging
---
 debian/changelog                                   |   1 +
 debian/dh-addon-vdrplugin/dh_vdrplugin_depends     |  64 ++++++++
 debian/dh-addon-vdrplugin/dh_vdrplugin_enable      | 179 +++++++++++++++++++++
 .../dh-addon-vdrplugin/postinst-vdrplugin-enable   |  12 ++
 debian/dh-addon-vdrplugin/postrm-vdrplugin-enable  |  12 ++
 debian/dh-addon-vdrplugin/vdrplugin.pm             |   9 ++
 debian/rules                                       |   4 +
 debian/vdr-dev.install                             |   8 +-
 debian/vdr-dev.manpages                            |   1 +
 debian/vdr-plugin-dvbhddevice.links                |   1 -
 debian/vdr-plugin-dvbhddevice.postinst             |   3 +
 debian/vdr-plugin-dvbsddevice.links                |   1 -
 debian/vdr-plugin-dvbsddevice.postinst             |   3 +
 13 files changed, 295 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c2246a3..b66a0da 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ vdr (2.2.0-1) UNRELEASED; urgency=medium
   * Arguments for vdr are now read from /etc/vdr/conf.d/
   * Plugins must provide a config, which may cointain plugin arguments, in
     /etc/vdr/conf.d/ in order to be loaded
+  * Install a debhelper addon in vdr-dev which supports the plugin packaging
 
  -- Tobias Grimm <etobi at debian.org>  Sat, 07 Mar 2015 13:02:02 +0100
 
diff --git a/debian/dh-addon-vdrplugin/dh_vdrplugin_depends b/debian/dh-addon-vdrplugin/dh_vdrplugin_depends
new file mode 100755
index 0000000..0ea3bb5
--- /dev/null
+++ b/debian/dh-addon-vdrplugin/dh_vdrplugin_depends
@@ -0,0 +1,64 @@
+#! /usr/bin/perl -w
+
+=head1 NAME
+
+dh_vdrplugin_depends - calculates vdr dependencies
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_vdrplugin_depends> [S<I<debhelper options>>]
+
+=head1 DESCRIPTION
+
+dh_vdrplugin_depends is a debhelper program that is responsible for generating the
+${vdr:Depends} substvars substitution for a vdr plugin package.
+
+Each vdr-plugin is required to have a ${vdr:Depends} substvar listed in its
+Depends line in debian/control. 
+
+=head1 EXAMPLES
+
+dh_vdrplugin_depends is usually called indirectly in a rules file via the dh command.
+
+	%:
+		dh --with vdrplugin $@
+
+It can also be called directly, prior to calling dh_gencontrol.
+
+=head1 CONFORMS TO
+
+Debian policy, version 3.8.1
+
+=cut
+
+init ();
+
+no locale;
+
+open(my $abiversion_file, "</usr/share/vdr-dev/abi-version") or die "Could not read VDR's ABI version dependency";
+my @abiversion = <$abiversion_file>;
+close($abiversion_file);
+
+verbose_print("Setting vdr:Depends=@abiversion");
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+  delsubstvar($package, "vdr:Depends");
+  addsubstvar($package, "vdr:Depends", @abiversion);
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is not a part of debhelper.
+
+=head1 AUTHOR
+
+Tobias Grimm <tobias.grimm at e-tobi.net>
+
+=cut
diff --git a/debian/dh-addon-vdrplugin/dh_vdrplugin_enable b/debian/dh-addon-vdrplugin/dh_vdrplugin_enable
new file mode 100755
index 0000000..527b234
--- /dev/null
+++ b/debian/dh-addon-vdrplugin/dh_vdrplugin_enable
@@ -0,0 +1,179 @@
+#! /usr/bin/perl -w
+
+=head1 NAME
+
+dh_vdrplugin_enable - enables plugin loading in /etc/vdr/conf.d
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+use Scalar::Util qw(looks_like_number);
+
+=head1 SYNOPSIS
+
+B<dh_vdrplugin_enable> [S<I<debhelper options>>]
+
+=head1 DESCRIPTION
+
+dh_vdrplugin_enable is a debhelper program that is responsible for generating
+the symlinks in /etc/vdr/conf.d which vdr parses to load its plugins.
+
+By default all config files a package provides in /etc/vdr/conf.avail will be
+linked to /etc/vdr/conf.d/50-<plugin>.conf. For all plugins in
+/usr/lib/vdr/plugins which do not have an explicit config, a default config file
+will be created with the appropriate symlink in /etc/vdr/conf.d/.
+
+If a debian/<package>.vdrargs file is specified only the config files listed
+there will be installed/symlinked.
+
+=head1 FILES
+
+=over 4
+
+=item debian/I<package>.vdrargs
+
+Lists config files to be installed to /etc/vdr/conf.avail/ and linked to
+/etc/vdr/conf.d/. By default symlinks will be created as 50-<config.conf>.
+You can change the default priority of 50 by adding it after the config
+file separated by whitespace.
+
+If the priority is set to DISABLED, the config file will be installed to
+/etc/vdr/conf.avail/ but not linked to /etc/conf.d/.
+
+=back
+
+=head1 EXAMPLES
+
+dh_vdrplugin is usually called indirectly in a rules file via the dh command.
+
+	%:
+		dh --with vdrplugin $@
+
+It can also be called directly, prior to calling dh_gencontrol.
+
+=head1 CONFORMS TO
+
+Debian policy, version 3.8.1
+
+=cut
+
+init ();
+
+no locale;
+
+sub get_plugins_from_config {
+  my ($config_file) = @_;
+  my @plugins;
+  open(my $conf, '<', $config_file);
+  while(<$conf>) {
+    if ($_ =~ /^\[(.+)\]/) {
+      push(@plugins, $1);
+    }
+  }
+  close($conf);
+  return @plugins;
+}
+
+sub get_plugins_from_lib_dir {
+  my ($package_dir) = @_;
+  return map { $_ =~ /libvdr-(.+?)\./ && $1 } <$package_dir/usr/lib/vdr/plugins/libvdr-*.so.*>;
+}
+
+sub create_default_config {
+  my ($plugin, $package_dir) = @_;
+  my $conf_dir = "$package_dir/etc/vdr/conf.avail";
+  my $conf_file = "$conf_dir/$plugin.conf";
+
+  if (! -e $conf_dir) {
+    doit("install", "-d", $conf_dir);
+  }
+
+  verbose_print("Creating default VDR plugin config '$conf_file'");
+
+  open(my $conf, '>', $conf_file);
+  print $conf "#\n";
+  print $conf "# $plugin VDR plugin arguments\n";
+  print $conf "#\n";
+  print $conf "\n";
+  print $conf "[$plugin]\n";
+  close($conf);
+
+  return $conf_file;
+}
+
+sub load_pkgfile {
+  my ($package) = @_;
+  my %config_files = ();
+  my $pkgfile=pkgfile($package, "vdrargs");
+  if ($pkgfile) {
+    foreach my $config (filedoublearray($pkgfile, ".")) {
+      $config_files{@$config[0]} = @$config[1] // 50;
+    }
+  }
+  return %config_files;
+}
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+  my $package_dir=tmpdir($package);
+  my %config_files = load_pkgfile($package);
+
+  if (%config_files) {
+    #
+    # Install config files defined in pkgfile
+    #
+    for my $source (keys %config_files) {
+      my $target = "$package_dir/etc/vdr/conf.avail/" . basename($source);
+      doit("install", "-p", "-D", "-m644", $source, $target);
+      $config_files{$target} = $config_files{$source};
+      delete $config_files{$source};
+    }
+  }
+  else {
+    #
+    # Add already installed conf files with priority 50
+    #
+    foreach my $config_file (<$package_dir/etc/vdr/conf.avail/*.conf>) {
+      if (!$config_files{$config_file}) {
+        $config_files{$config_file} = 50;
+      }
+    }
+
+    #
+    # Figure out which plugins the conf files are for
+    #
+    my @plugins_with_config = ();
+    for my $config_file (keys %config_files) {
+      push(@plugins_with_config, get_plugins_from_config($config_file));
+    }
+
+    #
+    # Add default config file for plugins without a conf
+    #
+    foreach my $plugin (get_plugins_from_lib_dir($package_dir)) {
+      if (!grep { $_ eq $plugin } @plugins_with_config) {
+        my $new_config = create_default_config($plugin, $package_dir);
+        $config_files{$new_config} = 50;
+      }
+    }
+  }
+  #
+  # Now pass the configs to be symlinked to the postinst/postrm templates
+  #
+  my @enabled_configs = grep { looks_like_number($config_files{$_}) } (keys %config_files);
+  my $configs = join(' ', map { (basename($_), $config_files{$_}) } (@enabled_configs));
+  autoscript($package, "postinst", "postinst-vdrplugin-enable", "s/#PLUGINCONFIGS#/$configs/");
+  autoscript($package, "postrm", "postrm-vdrplugin-enable", "s/#PLUGINCONFIGS#/$configs/");
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is not a part of debhelper.
+
+=head1 AUTHOR
+
+Tobias Grimm <tobias.grimm at e-tobi.net>
+
+=cut
diff --git a/debian/dh-addon-vdrplugin/postinst-vdrplugin-enable b/debian/dh-addon-vdrplugin/postinst-vdrplugin-enable
new file mode 100644
index 0000000..84f8f30
--- /dev/null
+++ b/debian/dh-addon-vdrplugin/postinst-vdrplugin-enable
@@ -0,0 +1,12 @@
+dh_vdrplugin_create_symlinks() {
+  while [ $# -gt 1 ] ; do
+    local config=$1
+    local priority=$2
+    shift 2
+    ln -sr "/etc/vdr/conf.avail/$config" "/etc/vdr/conf.d/$priority-$config"
+  done
+}
+
+if [ "$1" = configure -a -z "$2" ]; then
+  dh_vdrplugin_create_symlinks #PLUGINCONFIGS#
+fi
diff --git a/debian/dh-addon-vdrplugin/postrm-vdrplugin-enable b/debian/dh-addon-vdrplugin/postrm-vdrplugin-enable
new file mode 100644
index 0000000..fdb43fc
--- /dev/null
+++ b/debian/dh-addon-vdrplugin/postrm-vdrplugin-enable
@@ -0,0 +1,12 @@
+dh_vdrplugin_delete_symlinks() {
+  while [ $# -gt 1 ] ; do
+    local config=$1
+    local priority=$2
+    shift 2
+    rm -f "/etc/vdr/conf.d/$priority-$config"
+  done
+}
+
+if [ "$1" = "remove" ] ; then
+  dh_vdrplugin_delete_symlinks #PLUGINCONFIGS#
+fi
diff --git a/debian/dh-addon-vdrplugin/vdrplugin.pm b/debian/dh-addon-vdrplugin/vdrplugin.pm
new file mode 100644
index 0000000..0ad5f6d
--- /dev/null
+++ b/debian/dh-addon-vdrplugin/vdrplugin.pm
@@ -0,0 +1,9 @@
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+insert_after("dh_shlibdeps", "dh_vdrplugin_depends");
+
+insert_after("dh_install", "dh_vdrplugin_enable");
+
+1
diff --git a/debian/rules b/debian/rules
index 0df22a8..132b36a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -16,10 +16,14 @@ MAKE_OPTIONS = PREFIX=$(PREFIX) VIDEODIR=$(VIDEODIR) LIBDIR=$(LIBDIR)
 override_dh_auto_build:
 	dh_auto_build -- $(MAKE_OPTIONS)
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o debian/vdr-shutdown.wrapper debian/vdr-shutdown-wrapper.c
+	for file in $$(ls debian/dh-addon-vdrplugin/dh_*); do \
+		pod2man --section=1 --utf8 $$file $$file.1; \
+	done
 
 override_dh_auto_clean:
 	dh_auto_clean
 	rm -f debian/vdr-shutdown.wrapper
+	rm -f debian/dh-addon-vdrplugin/*.1
 
 override_dh_auto_install:
 	dh_auto_install -- $(MAKE_OPTIONS)
diff --git a/debian/vdr-dev.install b/debian/vdr-dev.install
index f9cb93b..2f3cd56 100644
--- a/debian/vdr-dev.install
+++ b/debian/vdr-dev.install
@@ -5,4 +5,10 @@ debian/debianize-vdrplugin      usr/bin/
 
 debian/plugin-template/         usr/share/vdr-dev/
 debian/dependencies.sh          usr/share/vdr-dev/
-debian/abi-version              usr/share/vdr-dev
\ No newline at end of file
+debian/abi-version              usr/share/vdr-dev/
+
+debian/dh-addon-vdrplugin/vdrplugin.pm               /usr/share/perl5/Debian/Debhelper/Sequence/
+debian/dh-addon-vdrplugin/postinst-vdrplugin-enable  /usr/share/debhelper/autoscripts/
+debian/dh-addon-vdrplugin/postrm-vdrplugin-enable    /usr/share/debhelper/autoscripts/
+debian/dh-addon-vdrplugin/dh_vdrplugin_depends       /usr/bin/
+debian/dh-addon-vdrplugin/dh_vdrplugin_enable        /usr/bin/
diff --git a/debian/vdr-dev.manpages b/debian/vdr-dev.manpages
index 472dc24..b0ecc13 100644
--- a/debian/vdr-dev.manpages
+++ b/debian/vdr-dev.manpages
@@ -1,2 +1,3 @@
 debian/vdr-newplugin.1
 debian/debianize-vdrplugin.1
+debian/dh-addon-vdrplugin/*.1
diff --git a/debian/vdr-plugin-dvbhddevice.links b/debian/vdr-plugin-dvbhddevice.links
deleted file mode 100644
index 61e67ac..0000000
--- a/debian/vdr-plugin-dvbhddevice.links
+++ /dev/null
@@ -1 +0,0 @@
-etc/vdr/conf.avail/dvbhddevice.conf    etc/vdr/conf.d/50-dvbhddevice.conf
diff --git a/debian/vdr-plugin-dvbhddevice.postinst b/debian/vdr-plugin-dvbhddevice.postinst
new file mode 100644
index 0000000..a0776fc
--- /dev/null
+++ b/debian/vdr-plugin-dvbhddevice.postinst
@@ -0,0 +1,3 @@
+if [ "$1" = configure -a -z "$2" ]; then
+  ln -sr "/etc/vdr/conf.avail/dvbhddevice.conf" "/etc/vdr/conf.d/50-dvbhddevice.conf"
+fi
diff --git a/debian/vdr-plugin-dvbsddevice.links b/debian/vdr-plugin-dvbsddevice.links
deleted file mode 100644
index 8b5e618..0000000
--- a/debian/vdr-plugin-dvbsddevice.links
+++ /dev/null
@@ -1 +0,0 @@
-etc/vdr/conf.avail/dvbsddevice.conf    etc/vdr/conf.d/50-dvbsddevice.conf
diff --git a/debian/vdr-plugin-dvbsddevice.postinst b/debian/vdr-plugin-dvbsddevice.postinst
new file mode 100644
index 0000000..e7176e5
--- /dev/null
+++ b/debian/vdr-plugin-dvbsddevice.postinst
@@ -0,0 +1,3 @@
+if [ "$1" = configure -a -z "$2" ]; then
+  ln -sr "/etc/vdr/conf.avail/dvbsddevice.conf" "/etc/vdr/conf.d/50-dvbsddevice.conf"
+fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vdr-dvb/vdr.git



More information about the pkg-vdr-dvb-changes mailing list