1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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
|