alienfile

filter: Statementstmt 65.3% 17 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 60.0% 3 / 5 Podpod n/a totaltotal 44.4% 20 / 45 CC 7 SCAR 27.0
CC
7
Cov
46%
__ANON__
20.0
__ANON__
20.0
__ANON__
1.2
CRAP 14.8
↑ Summary blib/lib/Alien/libssh/Install/Files.pm »
1 1 ▶use alienfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # Prefer the system libssh if pkg-config can find it.
5 # Falls back to building from the bundled source tarball.
6 #
7 # PkgConfig does probe and gather in one, for both paths: against the system
8 # library on the sys path, and against the libssh.pc the share build installs
9 # into the prefix on the share path. The hand-rolled `probe` plus a `sys`-only
10 # gather covered just the first of those, so a share install finished with no
11 # cflags, no libs and no version -- Alien::libssh->cflags came back empty and
12 # anything compiling against it could not find libssh/libssh.h.
13  
14 # Author release only: force the bundled share build so the shipped offline
15 # fallback is exercised on every `dzil release` (TestRelease), even on a host
16 # that has a system libssh. RELEASE_TESTING marks the author release;
17 # !AUTOMATED_TESTING excludes thorough CPAN smokers, which set BOTH flags --
18 # they must keep probing for their own system libssh, not build share.
19 #
20 # This is the `override` hook (what ALIEN_INSTALL_TYPE drives), NOT a `probe`
21 # hook, on purpose: Alien::Build runs override before the probe hooks and lets
22 # 'share' win outright, whereas a probe returning 'share' only defers to the
23 # next probe -- PkgConfig would then still pick a present system lib, and the
24 # fallback would go untested at release. Registering override replaces
25 # Core::Override's default, so ALIEN_INSTALL_TYPE is re-checked here first to
26 # keep the forced-path runs (share/system) and any user override working.
27 0 ▶meta->register_hook( override => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
28 0 ▶ return $ENV{ALIEN_INSTALL_TYPE} if $ENV{ALIEN_INSTALL_TYPE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"ALIEN_INSTALL_TYPE"} 0 0 0
29 0 ▶ return 'share' if $ENV{RELEASE_TESTING} && !$ENV{AUTOMATED_TESTING};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"RELEASE_TESTING"} and not $ENV{"AUTOMATED_TESTING"} 0 0 0
Condition0%0/3
$ENV{"RELEASE_TESTING"} and not $ENV{"AUTOMATED_TESTING"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"RELEASE_TESTING"} and not $ENV{"AUTOMATED_TESTING"}
$ENV{"RELEASE_TESTING"} not $ENV{"AUTOMATED_TESTING"}
Truth table0%0/3
A and not(B)
A= $ENV{"RELEASE_TESTING"}B= not $ENV{"AUTOMATED_TESTING"}
ABresult
0X0
100
111
30 0 return '';
31 1 });
32  
33 # 0.9.0 is where ssh_session_is_known_server and ssh_session_update_known_hosts
34 # appear, the known-hosts API Net::LibSSH calls. Without a floor any libssh
35 # the probe finds was accepted, and the consumer then failed at link time.
36 # The floor is the probe's only: the share path builds a known version.
37 1 plugin 'PkgConfig' => (
38 pkg_name => 'libssh',
39 minimum_version => '0.9.0',
40 );
41  
42 1 ▶share {
Subroutine __ANON__: called CC=1 SCAR=1.6
43 1 start_url 'file://' . Path::Tiny->cwd->child('share/libssh-0.12.2.tar.xz')->stringify;
44  
45 # start_url alone does nothing: without a fetch hook Alien::Build reaches the
46 # download phase with no way to act on it and dies with "No hooks registered
47 # for fetch", so the advertised fallback never existed on a box without a
48 # system libssh.
49 1 plugin 'Fetch::Local';
50 1 plugin 'Extract' => 'tar.xz';
51 1 plugin 'Build::CMake';
52  
53 # libssh refuses to configure in its own source tree
54 # (cmake/Modules/MacroEnsureOutOfSourceBuild.cmake compares CMAKE_SOURCE_DIR
55 # against CMAKE_BINARY_DIR). Build::CMake builds in the extracted directory
56 # itself unless told otherwise, which is why the source path used to be '..'
57 # -- a directory nothing ever created or changed into.
58 1 meta->prop->{out_of_source} = 1;
59  
60 # One command. A flat list is a sequence of separate commands to
61 # Alien::Build, so the arguments were each exec'd as a program of their own;
62 # and the make steps were absent, leaving a configure that built nothing.
63 # plugin_build_cmake.args carries the generator, PIC, install prefix and
64 # libdir, so only the libssh-specific switches are spelled out here.
65 build [
66 [ '%{cmake}',
67 1 @{ meta->prop->{plugin_build_cmake}->{args} },
68 '-DCMAKE_BUILD_TYPE=Release',
69 # Static, because a share install puts libssh.so where the runtime
70 # linker does not look: the XS test compiled fine against the prefix and
71 # then died on `libssh.so.4: cannot open shared object file`, which is
72 # exactly what Net::LibSSH (also XS) would do at use time.
73 '-DBUILD_SHARED_LIBS=OFF',
74 '-DWITH_EXAMPLES=OFF',
75 '-DWITH_PCAP=OFF',
76 '-DWITH_GSSAPI=OFF',
77 '%{.install.extract}',
78 ],
79 '%{make}',
80 '%{make} install',
81 ];
82  
83 # libssh generates its libssh.pc with a bare `Libs: -L${libdir} -lssh` and no
84 # Libs.private, so a static build hands the consumer a link line that omits
85 # everything libssh itself pulls in: linking with just -lssh compiles and then
86 # dies on `undefined symbol: EVP_PKEY_CTX_new`. libssh is built against
87 # OpenSSL here (WITH_GCRYPT and WITH_MBEDTLS both default off) and with zlib
88 # (WITH_ZLIB defaults on), so those are the two to declare. This hooks after
89 # gather rather than being a plain gather, because PkgConfig registers its
90 # own and would otherwise run last and put the bare .pc line back.
91 0 ▶ after 'gather' => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
92 0 my ($build) = @_;
93 0 for my $key (qw( libs libs_static )) {
94 0 ▶ my $v = $build->runtime_prop->{$key} // '';
Condition0%0/2
$build->runtime_prop->{$key} // ""
l!l
00
MC/DC0%0/1
$build->runtime_prop->{$key} // ""
$build->runtime_prop->{$key}
Truth table0%0/2
A
A= $build->runtime_prop->{$key}
Aresult
11
00
95 0 ▶ next if $v =~ /-lcrypto\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /-lcrypto\b/ 0 0 0
96 0 $build->runtime_prop->{$key} = join ' ', grep { length } $v, '-lcrypto', '-lz';
97 }
98 1 };
99 1 };
↑ Summary blib/lib/Alien/libssh/Install/Files.pm »