summaryrefslogtreecommitdiffstats
path: root/Makefile.PL
blob: 27a9e989eff8c466c52cbd1df642722bb042a84f (plain)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#!/usr/bin/perl
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.

use 5.10.1;
use strict;
use warnings;

use File::Basename;
use File::Spec;

BEGIN {
  require lib;
  my $dir = File::Spec->rel2abs(dirname(__FILE__));
  lib->import(
    $dir,
    File::Spec->catdir($dir, 'lib'),
    File::Spec->catdir($dir, qw(local lib perl5))
  );
}

use ExtUtils::MakeMaker 7.22;
use File::Basename;
use File::Spec;
use English qw(-no_match_vars $OSNAME);

BEGIN {
  if ($ENV{BZ_SILENT_MAKEFILE}) {
    open STDOUT, '>>', File::Spec->devnull
      or die "redirecting STDOUT to /dev/null failed: $!";
    open STDERR, '>>', File::Spec->devnull
      or die "redirecting STDERR to /dev/null failed: $!";
  }
}

# PREREQ_PM
my %requires = (
  'Algorithm::BloomFilter'              => '0.02',
  'CGI'                                 => '4.31',
  'CGI::Compile'                        => 0,
  'CGI::Emulate::PSGI'                  => 0,
  'CPAN::Meta::Prereqs'                 => '2.132830',
  'CPAN::Meta::Requirements'            => '2.121',
  'Class::XSAccessor'                   => '1.18',
  'DBI'                                 => '1.614',
  'DBIx::Connector'                     => 0,
  'Data::Password::passwdqc'            => '0.08',
  'Date::Format'                        => '2.23',
  'DateTime'                            => '0.75',
  'DateTime::TimeZone'                  => '2.11',
  'Devel::NYTProf'                      => '6.04',
  'Digest::SHA'                         => '5.47',
  'Email::MIME'                         => '1.904',
  'Email::Send'                         => '1.911',
  'FFI::Platypus'                       => 0,
  'File::Slurp'                         => '9999.13',
  'File::Slurper'                       => '0.012',
  'Future'                              => '0.34',
  'HTML::Escape'                        => '1.10',
  'IPC::System::Simple'                 => 0,
  'IO::Async'                           => '0.71',
  'JSON::MaybeXS'                       => '1.003008',
  'JSON::XS'                            => '2.01',
  'LWP::Protocol::https'                => '6.07',
  'LWP::UserAgent'                      => '6.26',
  'List::MoreUtils'                     => '0.418',
  'Log::Dispatch'                       => '2.67',
  'Log::Log4perl'                       => '1.49',
  'Math::Random::ISAAC'                 => '1.0.1',
  'Module::Metadata'                    => '1.000033',
  'Module::Runtime'                     => '0.014',
  'Mojolicious'                         => '8.02',
  'MojoX::Log::Log4perl::Tiny'          => '0.01',
  'Mojo::JWT'                           => '0.07',
  'Mojolicious::Plugin::OAuth2::Server' => '0.42',
  'Moo'                                 => '2.002004',
  'MooX::StrictConstructor'             => '0.008',
  'Mozilla::CA'                         => '20160104',
  'Package::Stash'                      => '0.37',
  'Parse::CPAN::Meta'                   => '1.44',
  'Role::Tiny'                          => '2.000003',
  'Scope::Guard'                        => '0.21',
  'Sereal'                              => '4.004',
  'Taint::Util'                         => '0.08',
  'Template'                            => '2.24',
  'Text::CSV_XS'                        => '1.26',
  'Throwable'                           => '0.200013',
  'Sub::Quote'                          => '2.005000',
  'Type::Tiny'                          => '1.004002',
  'URI'                                 => '1.55',
  'URI::Escape::XS'                     => '0.14',
  'version'                             => '0.87',
  'EV'                                  => '4.0',
);

my %build_requires = ('ExtUtils::MakeMaker' => '7.22',);
my %test_requires = (
  'Capture::Tiny'                   => 0,
  'DBD::SQLite'                     => '1.29',
  'Perl::Critic::Freenode'          => 0,
  'Perl::Tidy'                      => '20180220',
  'Pod::Coverage'                   => 0,
  'Test::More'                      => 0,
  'Test::Perl::Critic::Progressive' => 0,
  'Test::Selenium::Firefox'         => 0,
  'Test::WWW::Selenium'             => 0,
);
my %recommends = (Safe => '2.30',);

# Windows requires some additional modules.
if ($OSNAME eq 'MSWin32') {
  $requires{'Win32'}                            = '0.35';
  $requires{'Win32::API'}                       = '0.55';
  $requires{'DateTime::TimeZone::Local::Win32'} = '1.64';
}

if ($OSNAME eq 'linux' && -f '/etc/debian_version') {
  my @extra = qw(
    Test::Pod::Coverage
    Pod::Coverage::TrustPod
    Test::CPAN::Meta
    Test::Pod
  );
  $requires{$_} = 0 for @extra;
}

my %optional_features = (
  alien_cmark => {
    description => 'Support GitHub-flavored markdown',
    prereqs     => {runtime => {requires => {'Alien::libcmark_gfm' => '3'},},},
  },
  argon2 => {
    description => 'Support hashing passwords with Argon2',
    prereqs     => {runtime => {requires => {'Crypt::Argon2' => '0.004',},},},
  },
  smtp_auth => {
    description => 'SMTP Authentication',
    prereqs     => {runtime => {requires => {'Authen::SASL' => 0}}},
  },
  detect_charset => {
    description => 'Automatic charset detection for text attachments',
    prereqs =>
      {runtime => {requires => {'Encode::Detect' => 0, Encode => '2.21'}}},
  },
  chart_clicker => {
    description => 'Support nice-looking charts',
    prereqs     => {runtime => {requires => {'Chart::Clicker' => 0}},},
  },
  new_charts => {
    description => 'New Charts',
    prereqs =>
      {runtime => {requires => {'Chart::Lines' => 'v2.4.10', GD => '1.20'}}}
  },
  html_desc => {
    description => 'More HTML in Product/Group Descriptions',
    prereqs     => {
      runtime => {requires => {'HTML::Parser' => '3.67', 'HTML::Scrubber' => 0}}
    }
  },
  markdown => {
    description => 'Markdown syntax support for comments',
    prereqs => {runtime => {requires => {'Text::MultiMarkdown' => '1.000034'}}}
  },
  pg => {
    description => 'Postgres database support',
    prereqs     => {runtime => {requires => {'DBD::Pg' => 'v2.19.3'}}},
  },
  memcached => {
    description => 'Memcached Support',
    prereqs => {runtime => {requires => {'Cache::Memcached::Fast' => '0.17'}}}
  },
  updates => {
    description => 'Automatic Update Notifications',
    prereqs     => {runtime => {requires => {'XML::Twig' => 0}}}
  },
  auth_radius => {
    description => 'RADIUS Authentication',
    prereqs     => {runtime => {requires => {'Authen::Radius' => 0}}}
  },
  documentation => {
    description => 'Documentation',
    prereqs     => {
      runtime =>
        {requires => {'File::Which' => 0, 'File::Copy::Recursive' => 0,}}
    },
  },
  xmlrpc => {
    description => 'XML-RPC Interface',
    prereqs     => {
      runtime => {
        requires => {
          'XMLRPC::Lite' => '0.712',
          'SOAP::Lite'   => '0.712',
          'Test::Taint'  => '1.06'
        }
      }
    }
  },
  auth_ldap => {
    description => 'LDAP Authentication',
    prereqs     => {runtime => {requires => {'Net::LDAP' => 0}}},
  },
  old_charts => {
    description => 'Old Charts',
    prereqs =>
      {runtime => {requires => {GD => '1.20', 'Chart::Lines' => 'v2.4.10'}},},
  },
  moving => {
    description => 'Move Bugs Between Installations',
    prereqs =>
      {runtime => {requires => {'MIME::Parser' => '5.406', 'XML::Twig' => 0}}},
  },
  oracle => {
    description => 'Oracle database support',
    prereqs     => {runtime => {requires => {'DBD::Oracle' => '1.19'}}}
  },
  s3 => {
    description => 'Amazon S3 Attachment Storage',
    prereqs     => {
      runtime => {
        requires => {
          'Class::Accessor::Fast' => 0,
          'XML::Simple'           => 0,
          'URI::Escape'           => 0,
        }
      }
    }
  },
  typesniffer => {
    description => 'Sniff MIME type of attachments',
    prereqs     => {
      runtime =>
        {requires => {'IO::Scalar' => 0, 'File::MimeInfo::Magic' => 0,},},
    },
  },
  sqlite => {
    description => 'SQLite database support',
    prereqs     => {runtime => {requires => {'DBD::SQLite' => '1.29'}}},
  },
  mysql => {
    description => 'MySQL database support',
    prereqs     => {runtime => {requires => {'DBD::mysql' => '4.037'}}}
  },
  jsonrpc => {
    description => 'JSON-RPC Interface',
    prereqs     => {
      runtime =>
        {requires => {'JSON::RPC' => '== 1.01', 'Test::Taint' => '1.06'}}
    }
  },
  graphical_reports => {
    description => 'Graphical Reports',
    prereqs     => {
      runtime => {
        requires => {
          'GD::Text'                    => 0,
          'Template::Plugin::GD::Image' => 0,
          'GD::Graph'                   => 0,
          GD                            => '1.20',
        }
      }
    }
  },
  mfa => {
    description => 'Multi-Factor Authentication',
    prereqs     => {
      runtime => {
        requires =>
          {'Auth::GoogleAuth' => '1.01', 'GD::Barcode::QRcode' => '0',},
      }
    },
  },
  inbound_email => {
    description => 'Inbound Email',
    prereqs     => {
      runtime => {
        requires =>
          {'Email::MIME::Attachment::Stripper' => 0, 'Email::Reply' => 0,}
      }
    },
  },
  patch_viewer => {
    description => 'Patch Viewer',
    prereqs     => {runtime => {requires => {PatchReader => '0.9.6'}}}
  },
  rest => {
    description => 'REST Interface',
    prereqs     => {
      runtime =>
        {requires => {'Test::Taint' => '1.06', 'JSON::RPC' => '==1.01',}}
    }
  },
  linux_pid => {
    description => 'Linux::PID',
    prereqs     => {runtime => {requires => {'Linux::Pid' => 0},},},
  },
  linux_smaps => {
    description => 'Linux::Smaps::Tiny for limiting memory usage',
    prereqs     => {runtime => {requires => {'Linux::Smaps::Tiny' => '0'}}},
  },
  linux_pdeath => {
    description => 'Linux::Pdeathsig for a good parent/child relationships',
    prereqs     => {runtime => {requires => {'Linux::Pdeathsig' => 0},},},
  },
  jobqueue => {
    description => 'Mail Queueing',
    prereqs     => {
      runtime => {requires => {TheSchwartz => '1.10', 'Daemon::Generic' => 0}}
    }
  },
  elasticsearch => {
    description => 'Elasticsearch-powered searches',
    prereqs     => {
      runtime => {
        recommends => {'Term::ProgressBar'     => 0},
        requires   => {'Search::Elasticsearch' => 0},

      },
    },
  },
  sentry => {
    description => 'Sentry Support',
    prereqs     => {
      runtime => {requires => {'Log::Log4perl::Appender::Raven' => '0.006'},},
    },
  },
  datadog => {
    description => 'Data Dog support',
    prereqs => {runtime => {requires => {'DataDog::DogStatsd' => '0.05'},},},
  },
);

for my $file (glob 'extensions/*/Config.pm') {
  my $dir  = dirname($file);
  my $name = basename($dir);

  next if -f File::Spec->catfile($dir, 'disabled');
  require $file;
  my $class = "Bugzilla::Extension::$name";
  if ($class->can('REQUIRED_MODULES')) {
    foreach my $required_module (@{$class->REQUIRED_MODULES()}) {
      $requires{$required_module->{module}} = $required_module->{version};
    }
  }

  if ($class->can('OPTIONAL_MODULES')) {
    my $default_feature = 'extension_' . lc($name) . '_optional';
    foreach my $mod (@{$class->OPTIONAL_MODULES}) {
      my @features = $mod->{feature} ? @{$mod->{feature}} : ($default_feature);
      foreach my $feature (@features) {
        $optional_features{$feature}{prereqs}{runtime}{requires}{$mod->{module}}
          = $mod->{version} // 0;
      }
    }
  }
}

# BMO Customization
my @bmo_features = grep { is_bmo_feature($_) } keys %optional_features;

$optional_features{bmo} = {
  description => 'features that bmo needs',
  prereqs     => {
    runtime => {
      requires => {
        map { %{$optional_features{$_}{prereqs}{runtime}{requires}} }
          @bmo_features
      },
    },
  },
};

WriteMakefile(
  NAME             => 'Bugzilla',
  AUTHOR           => q{Bugzilla Developers <developers@bugzilla.org>},
  VERSION_FROM     => 'Bugzilla.pm',
  ABSTRACT         => 'Bugzilla Bug Tracking System',
  LICENSE          => 'Mozilla_2_0',
  MIN_PERL_VERSION => '5.10.1',
  CONFIGURE_REQUIRES =>
    {'ExtUtils::MakeMaker' => $build_requires{'ExtUtils::MakeMaker'}},
  PREREQ_PM      => {%requires},
  BUILD_REQUIRES => {%build_requires},
  TEST_REQUIRES  => {%test_requires},
  META_MERGE     => {
    'meta-spec' => {
      url     => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
      version => '2'
    },
    dynamic_config => 1,
    prereqs        => {
      build   => {requires => {%build_requires}},
      runtime => {requires => {%requires}, recommends => {%recommends}},
      test    => {requires => {%test_requires}},
    },
    optional_features => \%optional_features,
  },
);

sub MY::postamble {
  return <<"MAKE";
GEN_CPANFILE_ARGS = -D bmo
cpanfile: MYMETA.json
\t\$(PERLRUN) gen-cpanfile.pl \$(GEN_CPANFILE_ARGS)

META.json: Makefile.PL
\tmake distmeta 2>&1 /dev/null; mv */META.json .

META.yml: Makefile.PL
\tmake distmeta 2>&1 /dev/null; mv */META.yml .
MAKE
}

sub is_bmo_feature {
  local $_ = shift;
  return $OSNAME eq 'linux' if /^linux/;
  return !m{
        ^
        (?: pg
          | oracle
          | sqlite
          | auth_ldap
          | auth_radius
          | smtp_auth
          | updates)
        $
    }mxs;
}