summaryrefslogtreecommitdiffstats
path: root/debian/dh-addon
diff options
context:
space:
mode:
Diffstat (limited to 'debian/dh-addon')
-rwxr-xr-xdebian/dh-addon/dh_kodiaddon_depends148
-rw-r--r--debian/dh-addon/kodiaddon.pm7
2 files changed, 155 insertions, 0 deletions
diff --git a/debian/dh-addon/dh_kodiaddon_depends b/debian/dh-addon/dh_kodiaddon_depends
new file mode 100755
index 0000000..6e469a1
--- /dev/null
+++ b/debian/dh-addon/dh_kodiaddon_depends
@@ -0,0 +1,148 @@
+#! /usr/bin/perl -w
+
+=head1 NAME
+
+dh_kodiaddon_depends - Provides substvars for Kodi addons
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_kodiaddon_depends> [S<I<debhelper options>>]
+
+=head1 DESCRIPTION
+
+dh_kodiaddon_depends is a debhelper program, that is responsible for setting substvars
+providing the Kodi addon-API dependencies. Kodi provides a virtual package for each API
+which might be used by an addon. The following substvars will be set to a dependency
+clause which can be used directly in the "Depends"-line of the addons debian/control:
+
+${kodi:AUDIODECODERAPI} (ADDON_INSTANCE_VERSION_AUDIODECODER)
+${kodi:AUDIOENCODERAPI} (ADDON_INSTANCE_VERSION_AUDIOENCODER)
+${kodi:AUDIOENGINEAPI} (ADDON_GLOBAL_VERSION_AUDIOENGINE)
+${kodi:FILESYSTEMAPI} (ADDON_GLOBAL_VERSION_FILESYSTEM)
+${kodi:GAMEAPI} (ADDON_INSTANCE_VERSION_GAME)
+${kodi:GENERALAPI} (ADDON_GLOBAL_VERSION_GENERAL)
+${kodi:GUIAPI} (ADDON_GLOBAL_VERSION_GUI)
+${kodi:IMAGEDECODERAPI} (ADDON_INSTANCE_VERSION_IMAGEDECODER)
+${kodi:INPUTSTREAMAPI} (ADDON_INSTANCE_VERSION_INPUTSTREAM)
+${kodi:MAINAPI} (ADDON_GLOBAL_VERSION_MAIN)
+${kodi:NETWORKAPI} (ADDON_GLOBAL_VERSION_NETWORK)
+${kodi:PERIPHERALAPI} (ADDON_INSTANCE_VERSION_PERIPHERAL)
+${kodi:PVRAPI} (ADDON_INSTANCE_VERSION_PVR)
+${kodi:SCREENSAVERAPI} (ADDON_INSTANCE_VERSION_SCREENSAVER)
+${kodi:VFSAPI} (ADDON_INSTANCE_VERSION_VFS)
+${kodi:VIDEOCODECAPI} (ADDON_INSTANCE_VERSION_VIDEOCODEC)
+${kodi:VISUALIZATIONAPI} (ADDON_INSTANCE_VERSION_VISUALIZATION)
+
+=head1 EXAMPLES
+
+dh_kodiaddon_depends is usually called indirectly in a rules file via the dh command.
+
+ %:
+ dh $@ --with kodiaddon
+
+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_api_version {
+ my $headerFileName = $_[0];
+ my $defineName = $_[1];
+ my $apiVersion;
+ my $apiVersionMin;
+ my $apiVersionMax;
+
+ open(HEADERFILE, "<$headerFileName") or die "$!";
+ while (<HEADERFILE>) {
+ if ($_ =~ /^#define $defineName\s+"(.*)"/) {
+ $apiVersion = $1;
+ }
+ if ($_ =~ /^#define ${defineName}_MIN\s+"(.*)"/) {
+ $apiVersionMin = $1;
+ }
+ if ($apiVersion && $apiVersionMin) {
+ last;
+ }
+ }
+ close(HEADERFILE);
+ if ($apiVersion =~ qr/(?:(\d+)\.(\d+)\.(\d+)|(\d+)\.(\d+)|(\d+))?(?:\.\*)?/) {
+ $apiVersionMax = int($2) + 1;
+ $apiVersionMax = "$1.$apiVersionMax.0";
+ }
+ $apiVersion or die "Could not find '$defineName' in $headerFileName";
+ $apiVersionMin or die "Could not find '${defineName}_MIN' in $headerFileName";
+ $apiVersionMax or die "Could not derive maximum API version from '$defineName' in $headerFileName";
+ ($apiVersion, $apiVersionMin, $apiVersionMax)
+}
+
+sub create_substvar {
+ my $substvarName = $_[0];
+ my $substvarValue = $_[1];
+ foreach my $package (@{$dh{DOPACKAGES}}) {
+ delsubstvar($package, $substvarName);
+ addsubstvar($package, $substvarName, $substvarValue);
+ }
+}
+
+my $baseDir = "debian/kodi-addons-dev-common";
+if (! -d "$baseDir/usr/include/kodi") {
+ $baseDir = "debian/tmp";
+ if (! -d "$baseDir/usr/include/kodi") {
+ $baseDir = ""
+ }
+}
+
+my @apis = (
+ ["kodi-api-audiodecoder", "kodi:AUDIODECODERAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_AUDIODECODER"],
+ ["kodi-api-audioencoder", "kodi:AUDIOENCODERAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_AUDIOENCODER"],
+ ["kodi-api-audioengine", "kodi:AUDIOENGINEAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_AUDIOENGINE"],
+ ["kodi-api-filesystem", "kodi:FILESYSTEMAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_FILESYSTEM"],
+ ["kodi-api-game", "kodi:GAMEAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_GAME"],
+ ["kodi-api-general", "kodi:GENERALAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_GENERAL"],
+ ["kodi-api-gui", "kodi:GUIAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_GUI"],
+ ["kodi-api-imagedecoder", "kodi:IMAGEDECODERAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_IMAGEDECODER"],
+ ["kodi-api-inputstream", "kodi:INPUTSTREAMAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_INPUTSTREAM"],
+ ["kodi-api-main", "kodi:MAINAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_MAIN"],
+ ["kodi-api-network", "kodi:NETWORKAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_GLOBAL_VERSION_NETWORK"],
+ ["kodi-api-peripheral", "kodi:PERIPHERALAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_PERIPHERAL"],
+ ["kodi-api-pvr", "kodi:PVRAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_PVR"],
+ ["kodi-api-screensaver", "kodi:SCREENSAVERAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_SCREENSAVER"],
+ ["kodi-api-vfs", "kodi:VFSAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_VFS"],
+ ["kodi-api-videocodec", "kodi:VIDEOCODECAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_VIDEOCODEC"],
+ ["kodi-api-visualization", "kodi:VISUALIZATIONAPI", "$baseDir/usr/include/kodi/versions.h", "ADDON_INSTANCE_VERSION_VISUALIZATION"]
+);
+
+my @provides;
+
+foreach my $api (@apis) {
+ my ($apiName, $apiSubstvar, $apiHeader, $apiDefine) = @$api;
+ my ($apiVersion, $apiVersionMin, $apiVersionMax) = get_api_version($apiHeader, $apiDefine);
+ create_substvar($apiSubstvar, "$apiName (>= $apiVersionMin), $apiName (<< $apiVersionMax)");
+ push @provides, "$apiName (= $apiVersion)";
+}
+
+create_substvar("kodi:APIPROVIDES", join(", ", @provides));
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is not a part of debhelper.
+
+=head1 AUTHOR
+
+Tobias Grimm <tobias.grimm@e-tobi.net>
+
+=cut
diff --git a/debian/dh-addon/kodiaddon.pm b/debian/dh-addon/kodiaddon.pm
new file mode 100644
index 0000000..019793c
--- /dev/null
+++ b/debian/dh-addon/kodiaddon.pm
@@ -0,0 +1,7 @@
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+insert_before("dh_gencontrol", "dh_kodiaddon_depends");
+
+1