Skip to content

Commit

Permalink
Bug 1152360: backport upstream bug 1143005 that adds a parameter to c…
Browse files Browse the repository at this point in the history
…hecksetup.pl for generating cpanfile for dependency resolution
  • Loading branch information
dklawren committed Apr 13, 2015
1 parent 7b7e0cc commit ab7e414
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .htaccess
@@ -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>
Expand Down
44 changes: 44 additions & 0 deletions Bugzilla/Install/Requirements.pm
Expand Up @@ -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;
Expand All @@ -48,6 +49,7 @@ our @EXPORT = qw(
check_requirements
check_graphviz
export_cpanfile
have_vers
install_command
map_files_to_features
Expand Down Expand Up @@ -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__
Expand Down
61 changes: 0 additions & 61 deletions Build.PL

This file was deleted.

53 changes: 0 additions & 53 deletions MANIFEST.SKIP

This file was deleted.

18 changes: 15 additions & 3 deletions checksetup.pl
Expand Up @@ -68,13 +68,19 @@
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];
Expand Down Expand Up @@ -280,6 +286,12 @@ =head1 OPTIONS
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.
Expand Down

0 comments on commit ab7e414

Please sign in to comment.