-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalienfile
199 lines (173 loc) · 6.91 KB
/
alienfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
use alienfile;
use Config;
configure { requires 'Alien::Build' => '2.37' };
my $test_program = <<'EOF';
#include <stdio.h>
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
int
main(int argc, char *argv[])
{
xmlDoc *doc = NULL;
/*
* xmlRead should fail, but having this call ensures
* that the we have access to the symbols in -lxml2
* (LIBXML_DOTTED_VERSION below is in the header file)
*/
doc = xmlReadFile("foo.xml", NULL, 0);
printf("xml version = '%s'\n", LIBXML_DOTTED_VERSION);
}
EOF
my @try_flags = (
{ cflags => '', libs => '-lxml2' },
{ cflags => '-I/usr/include/libxml2', libs => '-lxml2' },
{ cflags => '-I/usr/local/include/libxml2', libs => '-lxml2' },
);
plugin 'Probe::Vcpkg' => 'libxml2';
probe [
['xml2-config', '--version' => \'%{.install.my_version}'],
['xml2-config', '--cflags' => \'%{.install.my_cflags}'],
['xml2-config', '--libs' => \'%{.install.my_libs}'],
];
plugin 'PkgConfig' => 'libxml-2.0';
plugin 'Probe::CBuilder' => (
cflags => $_->{cflags},
libs => $_->{libs},
program => $test_program,
version => qr{xml version = '(.*?)'},
) for @try_flags;
plugin 'PkgConfig::MakeStatic' => ();
my %bad_versions = map { $_ => 1 } (
# known bad versions
# may have some extras, and may be incomplete.
# but probably sufficient.
# computed using maint/tags-to-versions.pl and the git repository
# for libxml2.
'2.0.0',
'2.1.0','2.1.1',
'2.2.0','2.2.1','2.2.2','2.2.3','2.2.4','2.2.5','2.2.6','2.2.7','2.2.8',
'2.3.0','2.3.1','2.3.2','2.3.3','2.3.4','2.3.5','2.3.6','2.3.7','2.3.8','2.3.9','2.3.10','2.3.11','2.3.12','2.3.13','2.3.14',
'2.4.0','2.4.1','2.4.2','2.4.3','2.4.4','2.4.5','2.4.6','2.4.7','2.4.8','2.4.9','2.4.10','2.4.11','2.4.12','2.4.13','2.4.14','2.4.15','2.4.16','2.4.17','2.4.18','2.4.19','2.4.20','2.4.21','2.4.22','2.4.23','2.4.24','2.4.25','2.4.26','2.4.27','2.4.28','2.4.29','2.4.30',
'2.5.0','2.5.1','2.5.2','2.5.3','2.5.4','2.5.5','2.5.6','2.5.7','2.5.8','2.5.9','2.5.10','2.5.11',
'2.6.0','2.6.1','2.6.2','2.6.3','2.6.4','2.6.5','2.6.6','2.6.7','2.6.8','2.6.9','2.6.10','2.6.11','2.6.12','2.6.13','2.6.14','2.6.15','2.6.19','2.6.20','2.6.25',
'2.7.0','2.7.1',
'2.9.4',
# The next set have reported CVEs
(map {'2.11.' . $_} (0 .. 9)),
(map {'2.12.' . $_} (0 .. 9)),
(map {'2.13.' . $_} (0 .. 6)),
);
meta->around_hook(
probe => sub {
my $orig = shift;
my $build = shift;
my $install_type = $orig->($build, @_);
# if the system type is install, make sure the version isn't on the
# blacklist.
# Honor $ENV{FORCE} used in the Makefile.PL for XML-LibXML to allow
# versions on the blacklist.
if($install_type eq 'system' && !$ENV{FORCE})
{
# the first is provided by Probe::CBuilder, or pkg-config plugins for AB >= 1.61
# the second is generated by the Probe::CBuilder plugin since forever (or thereabouts)
# the thirds is from this alienfile, (see above with the xml2-config probe).
my $version = $build->hook_prop->{version} ||
$build->install_prop->{plugin_probe_cbuilder_gather}->{version} ||
$build->install_prop->{my_version};
$version =~ s/-.*$//g;
unless(defined $version)
{
print STDERR "Unfortunately, Alien::Libxml2 requires the version from the system libxml2 in\n",
"order to determine if it is acceptible for use, but Alien::Build prior to 1.61\n",
"did not provide this information in the probe step. Alien::Libxml2 can still\n",
"find the system libxml2 on systems with xml2-config in the PATH, or if libxml2\n",
"is available from one of the commonly known locations. If you want to detect\n",
"the system libxml2 with a .pc file via pkg-config, then please upgrade\n",
"Alien::Build to 1.61 or better\n";
return 'share';
}
if($bad_versions{$version})
{
print STDERR "Alien::Libxml2 is designed to work with XML::LibXML.\n\n".
"The installed system version of libxml2 $version is not compatible with XML::LibXML (and probably buggy)!\n\n".
" - don't expect XML::LibXML to build or work correctly with this version of libxml2!\n" .
" - don't report errors with this version of libxml2!\n" .
" - don't send patches for this version of libxml2!\n\n";
if($version eq '2.9.4')
{
print STDERR "XML::LibXML typically attempts to install with this version anyway, so will we.\n";
}
else
{
print STDERR "XML::LibXML typcially refuses to install with this version unless forced, so we will\n";
print STDERR "attempt to download a newer version from the internet. If you prefer you can force\n";
print STDERR "Alien::Libxml2 to install with this possibly buggy version using:\n";
print STDERR "env FORCE=1 perl Makefile.PL\n";
print STDERR "or\n";
print STDERR "env FORCE=1 cpanm Alien::Libxml2\n";
return 'share';
}
}
}
$install_type;
},
);
plugin 'Prefer::BadVersion' => [ keys %bad_versions ];
share {
# out of source build is borked on Windows, so we turn it
# off there. Turn it on elsewhere as it saves a copy.
meta->prop->{out_of_source} = $^O eq 'MSWin32' ? 0 : 1;
plugin 'Download::GitLab' => (
gitlab_host => 'https://gitlab.gnome.org',
gitlab_user => 'GNOME',
gitlab_project => 'libxml2',
type => 'link',
format => 'tar.xz',
version_from => 'tag_name',
convert_version => sub {
my $version = shift;
$version =~ s/^v//;
$version;
},
);
if($^O eq 'MSWin32' && $Config{ccname} eq 'cl')
{
build [
sub { shift->install_prop->{prefix} =~ s/\//\\/g;},
'cd win32',
'cscript configure.js prefix=%{.install.prefix} iconv=no compiler=msvc static=yes',
'nmake -f Makefile.msvc',
'nmake -f Makefile.msvc install',
];
plugin 'Gather::IsolateDynamic';
gather sub {
my($build) = @_;
my $prefix = $build->runtime_prop->{prefix};
$build->runtime_prop->{cflags} = "-I$prefix/include/libxml2";
$build->runtime_prop->{libs} = "-L$prefix/lib libxml2_a.lib";
};
}
else
{
plugin 'Build::Autoconf' => ();
build [
'%{configure} --prefix=%{.install.autoconf_prefix} --without-python --disable-shared --enable-static',
'%{make}',
'%{make} install',
];
plugin 'PkgConfig::MakeStatic' => ();
}
};
sys {
meta->after_hook(
gather_system => sub {
my($build) = @_;
return if defined $build->runtime_prop->{libs};
if($build->install_prop->{my_libs})
{
$build->runtime_prop->{$_} = $build->install_prop->{"my_$_"} for qw( version cflags libs );
}
},
);
};