]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1143005: Add parameter to checksetup.pl that generates a cpanfile usable by utili...
authorDavid Lawrence <dkl@mozilla.com>
Thu, 2 Apr 2015 14:46:36 +0000 (15:46 +0100)
committerDavid Lawrence <dkl@mozilla.com>
Thu, 2 Apr 2015 14:46:36 +0000 (15:46 +0100)
r=dylan,a=glob

.htaccess
Bugzilla/Install/Requirements.pm
Build.PL [deleted file]
MANIFEST.SKIP [deleted file]
checksetup.pl

index aec901005bb55cc6efe30a8c7ada19b8b838b133..8f40e96c639b027a8a002a66ee55fdd66420961a 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -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
index abe8787430829b8f3d6fb7e507a856d4c2cf6020..101bc2205709cde3dbbac2a666a861ce46a07eac 100644 (file)
@@ -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
diff --git a/Build.PL b/Build.PL
deleted file mode 100644 (file)
index 024a560..0000000
--- 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 (file)
index 69204e6..0000000
+++ /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$
index 908029313c2af5aac52c1f3b93a0ee79d5fe7de5..b1a3628bf576b1de8bfe4410484a1e83a0e91106 100755 (executable)
@@ -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.