| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
# Copyright (C) 2010 Modestas Vainius <[email protected]> |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/> |
| 17 |
|
| 18 |
=head1 NAME |
| 19 |
|
| 20 |
dh_movelibkdeinit - move libkdeinit4_*.so from public to the private directory |
| 21 |
|
| 22 |
=head1 SYNOPSIS |
| 23 |
|
| 24 |
B<dh_movelibkdeinit> [S<I<debhelper options>>] |
| 25 |
|
| 26 |
=head1 DESCRIPTION |
| 27 |
|
| 28 |
B<dh_movelibkdeinit> is a helper program which moves all installed |
| 29 |
F<usr/lib/libkdeinit4_*.so> kdeinit "shared" executables from the public |
| 30 |
location to the private subdirectory F</usr/lib/kde4/libkdeinit>. |
| 31 |
libkdeinit*.so shared executables are not proper public shared libraries by |
| 32 |
definition and they are built as shared library only for performance purposes. |
| 33 |
|
| 34 |
Please note, however, that in order for the moved executables to work properly, |
| 35 |
the following conditions must be met: |
| 36 |
|
| 37 |
=over 4 |
| 38 |
|
| 39 |
=item * |
| 40 |
|
| 41 |
the package should depend on the kde4libs binary packages built with the |
| 42 |
C<-DLIBKDEINIT_INSTALL_DIR=/usr/lib/kde4/libkdeinit> cmake flag (enabled since |
| 43 |
kde4libs 4:4.4.0). B<dh_movelibkdeinit> will try to confirm this condition and |
| 44 |
it will do nothing if it is not met. |
| 45 |
|
| 46 |
=item * |
| 47 |
|
| 48 |
the source package was built with the C<-DENABLE_LIBKDEINIT_RUNPATH=ON> cmake |
| 49 |
flag. This flag is enabled by default when building using |
| 50 |
the debhelper kde build system as shipped in the 0.6.2 or |
| 51 |
later version of the I<pkg-kde-tools> package. |
| 52 |
|
| 53 |
=back |
| 54 |
|
| 55 |
=head1 OPTIONS |
| 56 |
|
| 57 |
=over 4 |
| 58 |
|
| 59 |
=item B<-X>I<item>, B<--exclude> I<item> |
| 60 |
|
| 61 |
Do not move libkdeinit4_*.so files that contain "item" anywhere in their |
| 62 |
filename. You may use this option multiple times to build up a list of things |
| 63 |
to exclude. |
| 64 |
|
| 65 |
=back |
| 66 |
|
| 67 |
=cut |
| 68 |
|
| 69 |
use strict; |
| 70 |
use warnings; |
| 71 |
|
| 72 |
use Debian::Debhelper::Dh_Lib; |
| 73 |
|
| 74 |
use constant LIBKDEINIT_INSTALL_DIR => '/usr/lib/kde4/libkdeinit'; |
| 75 |
|
| 76 |
init(); |
| 77 |
|
| 78 |
if (@{$dh{DOPACKAGES}} && -f '/usr/bin/kdeinit4' && |
| 79 |
system(sprintf("objdump -p /usr/bin/kdeinit4 2>/dev/null | grep -q 'RUNPATH.*%s'", |
| 80 |
LIBKDEINIT_INSTALL_DIR)) != 0) |
| 81 |
{ |
| 82 |
warning("kdeinit4 does not have a proper RUNPATH set, not moving public libkdeinit4_*.so"); |
| 83 |
exit 0; |
| 84 |
} |
| 85 |
|
| 86 |
foreach my $package (@{$dh{DOPACKAGES}}) { |
| 87 |
my $tmpdir = tmpdir($package); |
| 88 |
if (-d "$tmpdir/usr/lib") { |
| 89 |
my $libkdeinit_dir = $tmpdir . LIBKDEINIT_INSTALL_DIR; |
| 90 |
my @libkdeinit; |
| 91 |
my $exclude = ''; |
| 92 |
if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') { |
| 93 |
$exclude = "! \\( $dh{EXCLUDE_FIND} \\)"; |
| 94 |
} |
| 95 |
open (FIND, "find $tmpdir/usr/lib -maxdepth 1 -type f \\( -name 'libkdeinit4_*.so' \\) $exclude |"); |
| 96 |
while (<FIND>) { |
| 97 |
chop; |
| 98 |
push @libkdeinit, $_; |
| 99 |
} |
| 100 |
close FIND; |
| 101 |
|
| 102 |
for my $libkdeinit (@libkdeinit) { |
| 103 |
my $exename; |
| 104 |
my $exepath; |
| 105 |
if ($libkdeinit =~ m%/libkdeinit4_([^/]*)\.so$%) { |
| 106 |
$exename = $1; |
| 107 |
if (-x "$tmpdir/usr/bin/$exename") { |
| 108 |
$exepath = "$tmpdir/usr/bin/$exename"; |
| 109 |
} else { |
| 110 |
open (FIND, "find $tmpdir -type f -executable -name $exename |"); |
| 111 |
$exepath = <FIND>; |
| 112 |
chop $exepath if $exepath; |
| 113 |
close FIND; |
| 114 |
} |
| 115 |
} |
| 116 |
if ($exepath) { |
| 117 |
if (system(sprintf("objdump -p '%s' 2>/dev/null | grep -q 'RUNPATH.*%s'", |
| 118 |
$exepath, LIBKDEINIT_INSTALL_DIR)) == 0) { |
| 119 |
unless (-d $libkdeinit_dir) { |
| 120 |
doit("mkdir", "-p", $libkdeinit_dir); |
| 121 |
} |
| 122 |
doit("mv", $libkdeinit, $libkdeinit_dir); |
| 123 |
} else { |
| 124 |
warning("unable to validate RUNPATH on the dummy kdeinit executable for $libkdeinit, not moving"); |
| 125 |
} |
| 126 |
} else { |
| 127 |
warning("unable to find a dummy kdeinit executable for $libkdeinit, not moving"); |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
exit 0; |
| 134 |
|
| 135 |
=head1 SEE ALSO |
| 136 |
|
| 137 |
L<debhelper(7)> |
| 138 |
|
| 139 |
=head1 AUTHOR |
| 140 |
|
| 141 |
Modestas Vainius <[email protected]> |
| 142 |
|
| 143 |
=cut |