| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
dh_gstscancodecs - enumerate and classify gstreamer codecs |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
use strict; |
| 10 |
use Debian::Debhelper::Dh_Lib; |
| 11 |
use File::Temp; |
| 12 |
|
| 13 |
=head1 SYNOPSIS |
| 14 |
|
| 15 |
dh_gstscancodecs [debhelper options] |
| 16 |
|
| 17 |
=head1 DESCRIPTION |
| 18 |
|
| 19 |
This program is meant to assist in building a package that provides |
| 20 |
codecs, demultiplexers and other media-handling components for |
| 21 |
gstreamer-based applications. |
| 22 |
|
| 23 |
dh_gstscancodecs generates substitution variable for debian/control, |
| 24 |
by scanning libraries /usr/lib/gstreamer-1.0/*.so and |
| 25 |
/usr/lib/$DEB_HOST_MULTIARCH/gstreamer-1.0/*.so. |
| 26 |
|
| 27 |
The generated substitution variables are |
| 28 |
|
| 29 |
=over 4 |
| 30 |
|
| 31 |
=item gstreamer:Version |
| 32 |
|
| 33 |
Should be added to XB-GStreamer-Version |
| 34 |
|
| 35 |
=item gstreamer:Elements |
| 36 |
|
| 37 |
Should be added to XB-GStreamer-Elements |
| 38 |
|
| 39 |
=item gstreamer:Provides |
| 40 |
|
| 41 |
Should be added to Provides |
| 42 |
|
| 43 |
=item gstreamer:URISources |
| 44 |
|
| 45 |
Should be added to XB-GStreamer-URI-Sources |
| 46 |
|
| 47 |
=item gstreamer:URISinks |
| 48 |
|
| 49 |
Should be added to XB-GStreamer-URI-Sinks |
| 50 |
|
| 51 |
=item gstreamer:Encoders |
| 52 |
|
| 53 |
Should be added to XB-GStreamer-Encoders |
| 54 |
|
| 55 |
=item gstreamer:Decoders |
| 56 |
|
| 57 |
Should be added to XB-GStreamer-Decoders |
| 58 |
|
| 59 |
=back |
| 60 |
|
| 61 |
This control fields will be used by the /usr/bin/gstreamer-codec-install |
| 62 |
helper to install required missing GStreamer elements. |
| 63 |
|
| 64 |
=head1 OPTIONS |
| 65 |
|
| 66 |
The standard debhelper options are supported. |
| 67 |
|
| 68 |
=cut |
| 69 |
|
| 70 |
init(); |
| 71 |
|
| 72 |
my $deb_host_multiarch = `dpkg-architecture -qDEB_HOST_MULTIARCH`; |
| 73 |
chop $deb_host_multiarch; |
| 74 |
my $libdir = '/usr/lib/'.$deb_host_multiarch; |
| 75 |
$::pluginlibdirprefix = $libdir.'/gstreamer-'; |
| 76 |
$::pluginlibdirlegacy = '/usr/lib/gstreamer-'; |
| 77 |
|
| 78 |
foreach my $package (@{$dh{DOPACKAGES}}) { |
| 79 |
my $tmp = tmpdir($package); |
| 80 |
|
| 81 |
delsubstvar($package, "gstreamer:Version"); |
| 82 |
delsubstvar($package, "gstreamer:URISinks"); |
| 83 |
delsubstvar($package, "gstreamer:URISources"); |
| 84 |
delsubstvar($package, "gstreamer:Encoders"); |
| 85 |
delsubstvar($package, "gstreamer:Decoders"); |
| 86 |
|
| 87 |
foreach my $sodir (glob "$tmp$::pluginlibdirprefix* $tmp$::pluginlibdirlegacy*") { |
| 88 |
my $gstversion = $sodir; |
| 89 |
$gstversion =~ s/^$tmp$::pluginlibdirprefix//; |
| 90 |
$gstversion =~ s/^$tmp$::pluginlibdirlegacy//; |
| 91 |
verbose_print("# gstreamer version $gstversion"); |
| 92 |
|
| 93 |
my (undef, $tmpfile) = File::Temp::tempfile("/tmp/".basename($0).".XXXX", UNLINK => 1); |
| 94 |
my (undef, $registryfile) = File::Temp::tempfile("/tmp/".basename($0).".XXXX", UNLINK => 1); |
| 95 |
|
| 96 |
my $command="GST_REGISTRY=$registryfile GST_PLUGIN_SYSTEM_PATH= GST_PLUGIN_PATH=$sodir $libdir/gstreamer$gstversion/gstreamer-$gstversion/gst-codec-info-$gstversion " . join(' ', (glob "$sodir/*.so")) . " > $tmpfile"; |
| 97 |
|
| 98 |
system($command); |
| 99 |
if ($?) { |
| 100 |
my $output; |
| 101 |
{ |
| 102 |
local *F; |
| 103 |
open(F, $tmpfile); |
| 104 |
local $/; |
| 105 |
$output = <F>; |
| 106 |
close(F); |
| 107 |
} |
| 108 |
die("gst-codec-info-$gstversion call failed: '".$command."' rc: $? output: $output"); |
| 109 |
} |
| 110 |
|
| 111 |
local *F; |
| 112 |
open(F, $tmpfile); |
| 113 |
my ($variable, $value); |
| 114 |
while(<F>) { |
| 115 |
$variable = $1 if /([a-zA-Z]*:[a-zA-Z]*)=/; |
| 116 |
$value = $2 if /([a-zA-Z]*:[a-zA-Z]*)=(.*)\n/; |
| 117 |
addsubstvar($package, $variable, $value); |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
=head1 SEE ALSO |
| 123 |
|
| 124 |
L<debhelper(1)> |
| 125 |
|
| 126 |
This program is an extension to debhelper. |
| 127 |
|
| 128 |
=head1 AUTHOR |
| 129 |
|
| 130 |
Ian Jackson <[email protected]> |
| 131 |
Sebastian Dröge <[email protected]> |
| 132 |
|
| 133 |
=cut |