| 1 |
#!/usr/bin/perl |
| 2 |
# |
| 3 |
# Copyright 2014-2016 Sebastian Ramacher <[email protected]> |
| 4 |
# |
| 5 |
# Permission is hereby granted, free of charge, to any person obtaining |
| 6 |
# a copy of this software and associated documentation files (the |
| 7 |
# "Software"), to deal in the Software without restriction, including |
| 8 |
# without limitation the rights to use, copy, modify, merge, publish, |
| 9 |
# distribute, sub license, and/or sell copies of the Software, and to |
| 10 |
# permit persons to whom the Software is furnished to do so, subject to |
| 11 |
# the following conditions: |
| 12 |
# |
| 13 |
# The above copyright notice and this permission notice (including the |
| 14 |
# next paragraph) shall be included in all copies or substantial portions |
| 15 |
# of the Software. |
| 16 |
# |
| 17 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 18 |
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 20 |
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 21 |
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 |
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 |
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
|
| 25 |
# PROMISE: DH NOOP WITHOUT tmp(usr/lib) |
| 26 |
|
| 27 |
=head1 NAME |
| 28 |
|
| 29 |
dh_libva - helps with packaging VA API drivers |
| 30 |
|
| 31 |
=head1 SYNOPSIS |
| 32 |
|
| 33 |
dh_libva [S<I<debhelper options>>] [B<-X>I<item>] [I<directory>...] |
| 34 |
|
| 35 |
=head1 DESCRIPTION |
| 36 |
|
| 37 |
B<dh_libva> is a debhelper program that generates dependencies for VA API driver |
| 38 |
packages. It scans packages looking for VA API drivers and adds the packages |
| 39 |
providing the necessary ABI for the driver to the B<${misc:Depends}> |
| 40 |
substitution variable. |
| 41 |
|
| 42 |
=head1 OPTIONS |
| 43 |
|
| 44 |
=over 4 |
| 45 |
|
| 46 |
=item B<--substvar=>I<substvar> |
| 47 |
|
| 48 |
Override the substitution variable. |
| 49 |
|
| 50 |
=back |
| 51 |
|
| 52 |
=cut |
| 53 |
|
| 54 |
use strict; |
| 55 |
use warnings; |
| 56 |
use Debian::Debhelper::Dh_Lib; |
| 57 |
use Set::Scalar; |
| 58 |
|
| 59 |
init(options => { |
| 60 |
"substvar=s" => \$dh{SUBSTVAR} |
| 61 |
}); |
| 62 |
|
| 63 |
unless ($dh{SUBSTVAR}) { |
| 64 |
$dh{SUBSTVAR} = "misc:Depends"; |
| 65 |
} |
| 66 |
|
| 67 |
my $triplet = dpkg_architecture_value("DEB_HOST_MULTIARCH"); |
| 68 |
|
| 69 |
foreach my $package (@{$dh{DOPACKAGES}}) { |
| 70 |
# Directory that contains the files included in the package. |
| 71 |
my $pkgpath = tmpdir($package); |
| 72 |
$pkgpath .= "/usr/lib/$triplet/dri"; |
| 73 |
next unless -d $pkgpath; |
| 74 |
|
| 75 |
# ABI versions |
| 76 |
my $abiver = Set::Scalar->new; |
| 77 |
|
| 78 |
# Files to check |
| 79 |
my @filelist = glob($pkgpath . "/*_drv_video.so"); |
| 80 |
foreach my $driver (@filelist) { |
| 81 |
open(my $nm, "-|", "nm", ("-D", $driver)) or |
| 82 |
error("cannot read symbols: $!\n"); |
| 83 |
while (<$nm>) { |
| 84 |
chomp; |
| 85 |
|
| 86 |
my @data = split(' '); |
| 87 |
next unless scalar(@data) == 3; |
| 88 |
|
| 89 |
my $symbol = $data[2]; |
| 90 |
if ($symbol =~ /^__vaDriverInit_(\d+)_(\d+)$/) { |
| 91 |
$abiver->insert("libva-driver-abi-$1.$2"); |
| 92 |
} |
| 93 |
} |
| 94 |
close $nm or error($! ? "cannot close nm pipe: $!\n" : |
| 95 |
"non-zero exit status from nm: $=\n"); |
| 96 |
} |
| 97 |
|
| 98 |
# Add substvar |
| 99 |
addsubstvar($package, $dh{SUBSTVAR}, |
| 100 |
join(' | ', reverse sort $abiver->elements)); |
| 101 |
} |
| 102 |
|
| 103 |
exit 0; |
| 104 |
|
| 105 |
=head1 SEE ALSO |
| 106 |
|
| 107 |
L<debhelper(7)>, L<dh(1)>. |
| 108 |
|
| 109 |
This program is meant to be used together with debhelper. |
| 110 |
|
| 111 |
=head1 AUTHOR |
| 112 |
|
| 113 |
Sebastian Ramacher <[email protected]> |
| 114 |
|
| 115 |
=cut |
| 116 |
|
| 117 |
# vim:ts=2 sw=2 et |