Bug 1143005: Add parameter to checksetup.pl that generates a cpanfile usable by utilities such as cpanm for installing Perl dependencies
r=dylan,a=glob git-svn-id: svn://10.0.0.236/trunk@265898 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
66c9d06ac7
commit
be99f96a17
@ -1 +1 @@
|
||||
9352
|
||||
9353
|
||||
@ -1 +1 @@
|
||||
1fa1aa54ae725989c6c44f198376e37ba000ca02
|
||||
a29f798a2506ec2b57cd4f7ebbdaf58387e6e490
|
||||
@ -1,5 +1,5 @@
|
||||
# Don't allow people to retrieve non-cgi executable files or our private data
|
||||
<FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*)$>
|
||||
<FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*|cpanfile)$>
|
||||
<IfModule mod_version.c>
|
||||
<IfVersion < 2.4>
|
||||
Deny from all
|
||||
|
||||
@ -20,6 +20,7 @@ use warnings;
|
||||
use Bugzilla::Constants;
|
||||
use Bugzilla::Install::Util qw(install_string bin_loc
|
||||
extension_requirement_packages);
|
||||
use File::Slurp;
|
||||
use List::Util qw(max);
|
||||
use Term::ANSIColor;
|
||||
|
||||
@ -32,6 +33,7 @@ our @EXPORT = qw(
|
||||
check_requirements
|
||||
check_webdotbase
|
||||
check_font_file
|
||||
export_cpanfile
|
||||
have_vers
|
||||
install_command
|
||||
map_files_to_features
|
||||
@ -841,6 +843,48 @@ sub map_files_to_features {
|
||||
return \%files;
|
||||
}
|
||||
|
||||
sub export_cpanfile {
|
||||
my $cpanfile;
|
||||
# Required modules
|
||||
foreach my $module (@{ REQUIRED_MODULES() }) {
|
||||
my $requires = "requires '" . $module->{module} . "'";
|
||||
$requires .= ", '" . $module->{version} . "'" if $module->{version};
|
||||
$requires .= ";\n";
|
||||
$cpanfile .= $requires;
|
||||
}
|
||||
# Recommended modules
|
||||
foreach my $module (@{ OPTIONAL_MODULES() }) {
|
||||
my $recommends = "";
|
||||
if (exists $module->{feature}) {
|
||||
foreach my $feature (@{ $module->{feature} }) {
|
||||
$recommends .= "feature '" . $feature . "', '" . $module->{package} . "' => sub {\n";
|
||||
$recommends .= " recommends '" . $module->{module} . "'";
|
||||
$recommends .= ", '" . $module->{version} . "'" if $module->{version};
|
||||
$recommends .= ";\n};\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$recommends .= "recommends '" . $module->{module} . "'";
|
||||
$recommends .= ", '" . $module->{version} . "'" if $module->{version};
|
||||
$recommends .= ";\n";
|
||||
}
|
||||
$cpanfile .= $recommends;
|
||||
}
|
||||
# Database modules
|
||||
foreach my $db (keys %{ DB_MODULE() }) {
|
||||
next if !exists DB_MODULE->{$db}->{dbd};
|
||||
my $dbd = DB_MODULE->{$db}->{dbd};
|
||||
my $recommends .= "feature '$db', '" . $dbd->{package} . "' => sub {\n";
|
||||
$recommends .= " recommends '" . $dbd->{module} . "'";
|
||||
$recommends .= ", '" . $dbd->{version} . "'" if $dbd->{version};
|
||||
$recommends .= ";\n};\n";
|
||||
$cpanfile .= $recommends;
|
||||
}
|
||||
|
||||
# Write out the cpanfile to the document root
|
||||
write_file(bz_locations()->{'libpath'} . '/cpanfile', \$cpanfile);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
@ -961,6 +1005,18 @@ Params: C<$output> - C<$true> if you want the function to
|
||||
|
||||
Returns: C<1> if the check was successful, C<0> otherwise.
|
||||
|
||||
=item C<export_cpanfile>
|
||||
|
||||
Description: Based on C<REQUIRED_MODULES> and C<OPTIONAL_MODULES>,
|
||||
the function outputs text useful for writing to a
|
||||
C<cpanfile>. C<cpanfile> can be used by utilities
|
||||
such as C<cpanm> for installing the Perl dependencies
|
||||
needed by an application.
|
||||
|
||||
Params: None
|
||||
|
||||
Returns: Text output for writing to a C<cpanfile>.
|
||||
|
||||
=item C<have_vers($module, $output)>
|
||||
|
||||
Description: Tells you whether or not you have the appropriate
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
#!/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 FindBin qw($RealBin);
|
||||
use lib ($RealBin, "$RealBin/lib");
|
||||
|
||||
use Module::Build 0.36_14;
|
||||
|
||||
use Bugzilla::Install::Requirements qw(REQUIRED_MODULES OPTIONAL_MODULES);
|
||||
use Bugzilla::Constants qw(BUGZILLA_VERSION);
|
||||
|
||||
sub requires {
|
||||
my $requirements = REQUIRED_MODULES();
|
||||
my $hrequires = {};
|
||||
foreach my $module (@$requirements) {
|
||||
$hrequires->{$module->{module}} = $module->{version};
|
||||
}
|
||||
return $hrequires;
|
||||
};
|
||||
|
||||
sub build_requires {
|
||||
return requires();
|
||||
}
|
||||
|
||||
sub recommends {
|
||||
my $recommends = OPTIONAL_MODULES();
|
||||
my @blacklist = ('Apache-SizeLimit', 'mod_perl'); # Does not compile properly on Travis
|
||||
my $hrecommends = {};
|
||||
foreach my $module (@$recommends) {
|
||||
next if grep($_ eq $module->{package}, @blacklist);
|
||||
$hrecommends->{$module->{module}} = $module->{version};
|
||||
}
|
||||
return $hrecommends;
|
||||
}
|
||||
|
||||
my $build = Module::Build->new(
|
||||
module_name => 'Bugzilla',
|
||||
dist_abstract => <<END,
|
||||
Bugzilla is a free bug-tracking system that is developed by an active
|
||||
community of volunteers. You can install and use it without having to
|
||||
pay any license fee.
|
||||
END
|
||||
dist_version_from => 'Bugzilla/Constants.pm',
|
||||
dist_version => BUGZILLA_VERSION,
|
||||
requires => requires(),
|
||||
recommends => recommends(),
|
||||
license => 'Mozilla_2_0',
|
||||
create_readme => 0,
|
||||
create_makefile_pl => 0
|
||||
);
|
||||
|
||||
$build->create_build_script;
|
||||
@ -1,53 +0,0 @@
|
||||
# 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.
|
||||
|
||||
#!start included /usr/share/perl5/ExtUtils/MANIFEST.SKIP
|
||||
# Avoid version control files.
|
||||
\B\.git\b
|
||||
\B\.bzr\b
|
||||
\B\.bzrignore\b
|
||||
\B\.gitignore\b
|
||||
\B\.gitrev\b
|
||||
\B\.patch\b
|
||||
|
||||
# Avoid Makemaker generated and utility files.
|
||||
\bMANIFEST\.bak
|
||||
\bMakefile$
|
||||
\bblib/
|
||||
\bMakeMaker-\d
|
||||
\bpm_to_blib\.ts$
|
||||
\bpm_to_blib$
|
||||
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
|
||||
|
||||
# Avoid Module::Build generated and utility files.
|
||||
\bBuild$
|
||||
\b_build/
|
||||
|
||||
# Avoid temp and backup files.
|
||||
~$
|
||||
\.old$
|
||||
\#$
|
||||
\b\.#
|
||||
\.bak$
|
||||
\.swp$
|
||||
|
||||
#!end included /usr/share/perl5/ExtUtils/MANIFEST.SKIP
|
||||
|
||||
# Avoid Module::Build generated and utility files.
|
||||
\bBuild$
|
||||
\bBuild.bat$
|
||||
\b_build
|
||||
\bBuild.COM$
|
||||
\bBUILD.COM$
|
||||
\bbuild.com$
|
||||
|
||||
# Avoid archives of this distribution
|
||||
\bBugzilla-[\d\.\_]+
|
||||
|
||||
# Bugzilla specific avoids
|
||||
\bdata\/\b
|
||||
\blocalconfig$
|
||||
@ -41,13 +41,19 @@ Bugzilla::Install::Util::no_checksetup_from_cgi() if $ENV{'SERVER_SOFTWARE'};
|
||||
init_console();
|
||||
|
||||
my %switch;
|
||||
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
|
||||
'verbose|v|no-silent', 'make-admin=s',
|
||||
'reset-password=s', 'version|V');
|
||||
GetOptions(\%switch, 'help|h|?', 'check-modules', 'cpanfile',
|
||||
'no-templates|t', 'verbose|v|no-silent',
|
||||
'make-admin=s', 'reset-password=s', 'version|V');
|
||||
|
||||
# Print the help message if that switch was selected.
|
||||
pod2usage({-verbose => 1, -exitval => 1}) if $switch{'help'};
|
||||
|
||||
# Export cpanfile and exit
|
||||
if ($switch{cpanfile}) {
|
||||
export_cpanfile();
|
||||
exit;
|
||||
}
|
||||
|
||||
# Read in the "answers" file if it exists, for running in
|
||||
# non-interactive mode.
|
||||
my $answers_file = $ARGV[0];
|
||||
@ -259,6 +265,12 @@ the L</"RUNNING CHECKSETUP NON-INTERACTIVELY"> section.
|
||||
|
||||
Display this help text
|
||||
|
||||
=item B<--cpanfile>
|
||||
|
||||
Outputs a cpanfile in the document root listing the current and optional
|
||||
modules with their respective versions. This file can be used by <cpanm>
|
||||
and other utilities used to install Perl dependencies.
|
||||
|
||||
=item B<--check-modules>
|
||||
|
||||
Only check for correct module dependencies and quit afterward.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user