From a29f798a2506ec2b57cd4f7ebbdaf58387e6e490 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 2 Apr 2015 15:46:36 +0100 Subject: 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 --- .htaccess | 2 +- Bugzilla/Install/Requirements.pm | 56 ++++++++++++++++++++++++++++++++++++ Build.PL | 61 ---------------------------------------- MANIFEST.SKIP | 53 ---------------------------------- checksetup.pl | 18 ++++++++++-- 5 files changed, 72 insertions(+), 118 deletions(-) delete mode 100644 Build.PL delete mode 100644 MANIFEST.SKIP diff --git a/.htaccess b/.htaccess index aec901005..8f40e96c6 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ # Don't allow people to retrieve non-cgi executable files or our private data - + Deny from all diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index abe878743..101bc2205 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -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 + + Description: Based on C and C, + the function outputs text useful for writing to a + C. C can be used by utilities + such as C for installing the Perl dependencies + needed by an application. + + Params: None + + Returns: Text output for writing to a C. + =item C Description: Tells you whether or not you have the appropriate 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 => < '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 908029313..b1a3628bf 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -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 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 +and other utilities used to install Perl dependencies. + =item B<--check-modules> Only check for correct module dependencies and quit afterward. -- cgit v1.2.3-24-g4f1b