diff options
author | David Lawrence <dkl@mozilla.com> | 2015-04-13 19:17:10 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-04-13 19:17:52 +0200 |
commit | ab7e4149471d48fb00bcbbf59ceafdde87782c51 (patch) | |
tree | e9008a640be00ff9e5a1d32dcaf8aa5ef2893ea7 | |
parent | 7b7e0cc4000fa15305a8f76f580b3a2dd22a04ee (diff) | |
download | bugzilla-ab7e4149471d48fb00bcbbf59ceafdde87782c51.tar.gz bugzilla-ab7e4149471d48fb00bcbbf59ceafdde87782c51.tar.xz |
Bug 1152360: backport upstream bug 1143005 that adds a parameter to checksetup.pl for generating cpanfile for dependency resolution
-rw-r--r-- | .htaccess | 2 | ||||
-rw-r--r-- | Bugzilla/Install/Requirements.pm | 44 | ||||
-rw-r--r-- | Build.PL | 61 | ||||
-rw-r--r-- | MANIFEST.SKIP | 53 | ||||
-rwxr-xr-x | checksetup.pl | 18 |
5 files changed, 60 insertions, 118 deletions
@@ -1,5 +1,5 @@ # Don't allow people to retrieve non-cgi executable files or our private data -<FilesMatch (\.pm|\.pl|\.tmpl|\.swf|localconfig.*)$> +<FilesMatch (\.pm|\.pl|\.tmpl|\.swf|localconfig.*|cpanfile)$> deny from all </FilesMatch> <IfModule mod_expires.c> diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index 6bb012230..fe66b581b 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -29,6 +29,7 @@ use version; use Bugzilla::Constants; use Bugzilla::Install::Util qw(vers_cmp install_string bin_loc extension_requirement_packages); +use File::Slurp; use List::Util qw(max); use Safe; use Term::ANSIColor; @@ -48,6 +49,7 @@ our @EXPORT = qw( check_requirements check_graphviz + export_cpanfile have_vers install_command map_files_to_features @@ -790,6 +792,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__ diff --git a/Build.PL b/Build.PL deleted file mode 100644 index 024a56024..000000000 --- a/Build.PL +++ /dev/null @@ -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; diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP deleted file mode 100644 index 69204e63f..000000000 --- a/MANIFEST.SKIP +++ /dev/null @@ -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$ diff --git a/checksetup.pl b/checksetup.pl index 501138c6d..d3b4cc1d7 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -68,13 +68,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]; @@ -280,6 +286,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. |