| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
dh_asterisk - Add dependency on the ABI version of Asterisk |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
use strict; |
| 10 |
use warnings; |
| 11 |
use Debian::Debhelper::Dh_Lib; |
| 12 |
|
| 13 |
=head1 SYNOPSIS |
| 14 |
|
| 15 |
B<dh_asterisk> [S<I<debhelper options>>] |
| 16 |
|
| 17 |
=head1 DESCRIPTION |
| 18 |
|
| 19 |
dh_asterisk is a debhelper program that is responsible for correctly |
| 20 |
setting the dependency on asterisk-abi-I<asterisk-ABI-version> for a package. |
| 21 |
|
| 22 |
When writing a package that builds an Asterisk module and is not built |
| 23 |
with Asterisk itself (and hence depends on the exact binary version), |
| 24 |
add ${asterisk:Depends} to the package's Depends: field in debian control |
| 25 |
and run dh_asterisk. |
| 26 |
|
| 27 |
A debhelper addon is also provided. |
| 28 |
This makes it possible to just use |
| 29 |
|
| 30 |
#!/usr/bin/make -f |
| 31 |
%: |
| 32 |
dh $@ --with asterisk |
| 33 |
|
| 34 |
for F<debian/rules>. |
| 35 |
|
| 36 |
Alternatively, you can just build-depend on B<dh-sequence-asterisk> |
| 37 |
and omit the C<--with asterisk> part. |
| 38 |
|
| 39 |
=cut |
| 40 |
|
| 41 |
init(); |
| 42 |
|
| 43 |
my $BUILD_OPTS_FILE = '/usr/include/asterisk/buildopts.h'; |
| 44 |
|
| 45 |
my ( $fh, $abi ); |
| 46 |
open( $fh, '<', $BUILD_OPTS_FILE ) || do { |
| 47 |
warning("failed to open Asterisk opts file $BUILD_OPTS_FILE: $!"); |
| 48 |
exit 0; |
| 49 |
}; |
| 50 |
while(<$fh>) { |
| 51 |
if (/^#define\s+AST_BUILDOPT_SUM\s+"\K[0-9a-f]+/) { |
| 52 |
$abi = $&; |
| 53 |
last; |
| 54 |
} |
| 55 |
} |
| 56 |
if ($abi) { |
| 57 |
verbose_print("resolved Asterisk ABI: $abi"); |
| 58 |
} |
| 59 |
else { |
| 60 |
warning('failed to resolve Asterisk ABI'); |
| 61 |
exit 0; |
| 62 |
} |
| 63 |
|
| 64 |
foreach my $package (@{$dh{DOPACKAGES}}) { |
| 65 |
addsubstvar($package, "asterisk:Depends", "asterisk-abi-$abi"); |
| 66 |
} |
| 67 |
|
| 68 |
=head1 SEE ALSO |
| 69 |
|
| 70 |
L<debhelper(7)> |
| 71 |
|
| 72 |
This program is part of the Debian Asterisk package. |
| 73 |
|
| 74 |
L<asterisk(8)> |
| 75 |
|
| 76 |
=head1 AUTHOR |
| 77 |
|
| 78 |
Tzafrir Cohen <[email protected]> |
| 79 |
|
| 80 |
Jonas Smedegaard <[email protected]> |
| 81 |
|
| 82 |
=head1 COPYRIGHT AND LICENSE |
| 83 |
|
| 84 |
Copyright 2022, Jonas Smedegaard <[email protected]> |
| 85 |
|
| 86 |
This packaging is free software; |
| 87 |
you can redistribute it and/or modify it |
| 88 |
under the terms of the GNU General Public License |
| 89 |
as published by the Free Software Foundation; |
| 90 |
either version 3, or (at your option) any later version. |