line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Probe::GnuWin32; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
243332
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
85
|
|
5
|
2
|
|
|
2
|
|
1025
|
use Alien::Build::Plugin; |
|
2
|
|
|
|
|
6271
|
|
|
2
|
|
|
|
|
21
|
|
6
|
2
|
|
|
2
|
|
276
|
use Module::Load (); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
56
|
|
7
|
2
|
|
|
2
|
|
16
|
use File::Spec; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
65
|
|
8
|
2
|
|
|
2
|
|
16
|
use Carp (); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
61
|
|
9
|
2
|
|
|
2
|
|
1549
|
use Capture::Tiny qw( capture ); |
|
2
|
|
|
|
|
88494
|
|
|
2
|
|
|
|
|
263
|
|
10
|
2
|
|
|
2
|
|
34
|
use List::Util (); |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
2672
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Probe for GnuWin32 packages using the Windows registry |
13
|
|
|
|
|
|
|
our $VERSION = '0.59'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has native_only => 0; |
17
|
|
|
|
|
|
|
has registery_key_regex => undef; |
18
|
|
|
|
|
|
|
has registry_key_regex => undef; |
19
|
|
|
|
|
|
|
has exe_name => undef; |
20
|
|
|
|
|
|
|
has exe_match => undef; |
21
|
|
|
|
|
|
|
has exe_version => undef; |
22
|
|
|
|
|
|
|
has exe_args => ['--version']; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _short ($) |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
0
|
|
0
|
|
0
|
$_[0] =~ /\s+/ ? Win32::GetShortPathName( $_[0] ) : $_[0]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new |
30
|
|
|
|
|
|
|
{ |
31
|
3
|
|
|
3
|
1
|
13352
|
my $class = shift; |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
30
|
my $self = $class->SUPER::new(@_); |
34
|
|
|
|
|
|
|
|
35
|
3
|
100
|
|
|
|
204
|
if($self->registery_key_regex) |
36
|
|
|
|
|
|
|
{ |
37
|
1
|
|
|
|
|
869
|
require Alien::Build; |
38
|
1
|
|
|
|
|
47280
|
Alien::Build->log("warning: you are using a typo'd property, 'registery_key_regex', please use 'registry_key_regex' instead"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
100
|
100
|
|
|
117
|
$self->registry_key_regex || $self->registry_key_regex($self->registery_key_regex) || Carp::croak "register_key_regex is required"; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
42
|
$self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub init |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
|
my($self, $meta) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# we may decide to take this module out of core. |
51
|
0
|
|
|
|
|
|
$meta->add_requires( 'configure' => 'Alien::Build::Plugin::Probe::GnuWin32' => 0 ); |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if($^O eq 'MSWin32') |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
$meta->register_hook( |
56
|
|
|
|
|
|
|
probe => sub { |
57
|
0
|
|
|
0
|
|
|
my($build) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my @paths = ([]); |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if(eval { Module::Load::load "Win32API::Registry"; 1 }) |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
|
my @uninstall_key_names = qw( |
64
|
|
|
|
|
|
|
software\microsoft\windows\currentversion\uninstall |
65
|
|
|
|
|
|
|
); |
66
|
0
|
0
|
|
|
|
|
unshift @uninstall_key_names, qw( software\wow6432node\microsoft\windows\currentversion\uninstall ) |
67
|
|
|
|
|
|
|
unless $self->native_only; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
foreach my $uninstall_key_name (@uninstall_key_names) |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
|
|
|
my $uninstall_key; |
72
|
0
|
0
|
|
|
|
|
Win32API::Registry::RegOpenKeyEx( |
73
|
|
|
|
|
|
|
Win32API::Registry::HKEY_LOCAL_MACHINE(), |
74
|
|
|
|
|
|
|
$uninstall_key_name, |
75
|
|
|
|
|
|
|
0, |
76
|
|
|
|
|
|
|
Win32API::Registry::KEY_READ(), |
77
|
|
|
|
|
|
|
$uninstall_key ) || next; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $pos = 0; |
80
|
0
|
|
|
|
|
|
my($subkey, $class, $time) = ('','',''); |
81
|
0
|
|
|
|
|
|
my($namSiz, $clsSiz) = (1024,1024); |
82
|
0
|
|
|
|
|
|
while(Win32API::Registry::RegEnumKeyEx( $uninstall_key, $pos++, $subkey, $namSiz, [], $class, $clsSiz, $time)) |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
0
|
|
|
|
|
next unless $subkey =~ $self->registery_key_regex; |
85
|
0
|
|
|
|
|
|
my $flex_key; |
86
|
0
|
0
|
|
|
|
|
Win32API::Registry::RegOpenKeyEx( |
87
|
|
|
|
|
|
|
$uninstall_key, |
88
|
|
|
|
|
|
|
$subkey, |
89
|
|
|
|
|
|
|
0, |
90
|
|
|
|
|
|
|
Win32API::Registry::KEY_READ(), |
91
|
|
|
|
|
|
|
$flex_key ) || next; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $data; |
94
|
0
|
0
|
|
|
|
|
if(Win32API::Registry::RegQueryValueEx($flex_key, "InstallLocation", [], Win32API::Registry::REG_SZ(), $data, [] )) |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
|
|
|
push @paths, [File::Spec->catdir(_short $data, "bin")]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if(Win32API::Registry::RegQueryValueEx($flex_key, "Inno Setup: App Path", [], Win32API::Registry::REG_SZ(), $data, [] )) |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
|
|
|
push @paths, [File::Spec->catdir(_short $data, "bin")]; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
Win32API::Registry::RegCloseKey( $flex_key ); |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
|
Win32API::Registry::RegCloseKey($uninstall_key); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
push @paths, map { [_short $ENV{$_}, qw( GnuWin32 bin )] } grep { defined $ENV{$_} } qw[ ProgramFiles ProgramFiles(x86) ]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
push @paths, ['C:\\GnuWin32\\bin']; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$build->log("try system paths:"); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
foreach my $path (map { File::Spec->catdir(@$_) } @paths) |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
{ |
118
|
0
|
0
|
|
|
|
|
$build->log(" - @{[ $path eq '' ? 'PATH' : $path ]}"); |
|
0
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
foreach my $exe_name ($self->exe_name, $self->exe_name . '.exe') |
120
|
|
|
|
|
|
|
{ |
121
|
0
|
|
|
|
|
|
my $exe = File::Spec->catfile($path, $exe_name); |
122
|
0
|
0
|
0
|
|
|
|
next unless $path eq '' || -f $exe; |
123
|
0
|
|
|
|
|
|
my @cmd = ($exe, @{ $self->exe_args }); |
|
0
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my($out, $err) = capture { |
125
|
0
|
|
|
|
|
|
system @cmd; |
126
|
0
|
|
|
|
|
|
}; |
127
|
0
|
0
|
|
|
|
|
if($self->exe_match) |
128
|
|
|
|
|
|
|
{ |
129
|
0
|
0
|
|
|
|
|
next unless $out =~ $self->exe_match; |
130
|
|
|
|
|
|
|
} |
131
|
0
|
0
|
0
|
|
|
|
if($self->exe_version && $out =~ $self->exe_version) |
132
|
|
|
|
|
|
|
{ |
133
|
0
|
|
|
|
|
|
$build->runtime_prop->{version} = $1; |
134
|
|
|
|
|
|
|
} |
135
|
0
|
0
|
|
|
|
|
$build->runtime_prop->{system_bin_dir} = File::Spec->catfile($path) unless $path eq ''; |
136
|
0
|
|
|
|
|
|
return 'system'; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
'share'; |
141
|
|
|
|
|
|
|
} |
142
|
0
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$self; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |