From: Dylan William Hardison Date: Thu, 5 May 2016 16:18:48 +0000 (-0400) Subject: Bug 1270536 - Provide helper script to run cpanm with sane default arguments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=347b1bae26a784f3260317a8a6dd808e817b7e60;p=thirdparty%2Fbugzilla.git Bug 1270536 - Provide helper script to run cpanm with sane default arguments --- diff --git a/checksetup.pl b/checksetup.pl index 11a70e25ec..1b82d1f5f2 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -48,6 +48,7 @@ init_console(); my %switch; GetOptions(\%switch, 'help|h|?', 'no-templates|t', 'verbose|v|no-silent', + 'cpanm:s', 'make-admin=s', 'reset-password=s', 'version|V', 'no-permissions|p'); @@ -58,9 +59,35 @@ pod2usage({-verbose => 1, -exitval => 1}) if $switch{'help'}; # non-interactive mode. my $answers_file = $ARGV[0]; my $silent = $answers_file && !$switch{'verbose'}; - print(install_string('header', get_version_and_os()) . "\n") unless $silent; exit 0 if $switch{'version'}; + +if (defined $switch{cpanm}) { + my $default = 'all notest -oracle -mysql -pg -mod_perl -old_charts -new_charts -graphical_reports -detect_charset'; + my @features = split(/\s+/, $switch{cpanm} || $default); + my @cpanm_args = ('-l', 'local', '--installdeps'); + while (my $feature = shift @features) { + if ($feature eq 'all') { + push @cpanm_args, '--with-all-features'; + } + elsif ($feature eq 'default') { + unshift @features, split(/\s+/, $default); + } + elsif ($feature eq 'notest') { + push @cpanm_args, '--notest'; + } + elsif ($feature =~ /^-(.+)$/) { + push @cpanm_args, "--without-feature=$1"; + } + else { + push @cpanm_args, "--with-feature=$feature"; + } + } + print "cpanm @cpanm_args \".\"\n" if !$silent; + my $rv = system('cpanm', @cpanm_args, '.'); + exit 1 if $rv != 0; +} + my $meta = load_cpan_meta(); my $requirements = check_cpan_requirements($meta, \@BUGZILLA_INC, !$silent);