From ebbabed8bb971d3e17e3188e55310f99429a456f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 10 Jan 2014 15:28:34 +0100 Subject: [PATCH] =?utf8?q?installcheck:=20apt-get=20und=20=C3=A4hnliche=20?= =?utf8?q?commands=20mit=20-i=20generieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- scripts/installation_check.pl | 38 ++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/scripts/installation_check.pl b/scripts/installation_check.pl index 3a69630ba..40e312f1b 100755 --- a/scripts/installation_check.pl +++ b/scripts/installation_check.pl @@ -4,6 +4,7 @@ use strict; use Getopt::Long; use Pod::Usage; use Term::ANSIColor; +use Text::Wrap; our $master_templates; BEGIN { unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). @@ -21,9 +22,10 @@ unless (eval { require Config::Std; 1 }){ Debian: you may install the needed *.deb package with: apt-get install libconfig-std-perl - RPM: There is a rpm package "perl-Config-Std" + Red Hat/Fedora/CentOS: you may install the needed *.rpm package with: + yum install perl-Config-Std - Suse: you may install the needed *.rpm package with: + SUSE: you may install the needed *.rpm package with: zypper install perl-Config-Std +------------------------------------------------------------------------------+ @@ -35,7 +37,7 @@ EOL use SL::InstallationCheck; use SL::LxOfficeConf; - +my @missing_modules; my %check; Getopt::Long::Configure ("bundling"); GetOptions( @@ -48,6 +50,14 @@ GetOptions( "r|required!" => \ $check{r}, "h|help" => sub { pod2usage(-verbose => 2) }, "c|color!" => \ ( my $c = 1 ), + "i|install!" => \ my $apt, +); + +my %install_methods = ( + apt => { key => 'debian', install => 'sudo apt-get install', system => "Debian, Ubuntu" }, + yum => { key => 'fedora', install => 'sudo yum install', system => "RHEL, Fedora, CentOS" }, + zypper => { key => 'suse', install => 'sudo zypper install', system => "SLES, openSUSE" }, + cpan => { key => 'name', install => "sudo cpan", system => "CPAN" }, ); # verbos is default @@ -101,6 +111,20 @@ if ($check{l}) { check_latex(); } +if (@missing_modules && $apt) { + print "\nHere are some sample installation lines, choose one apporpriate for your system:\n\n"; + local $Text::Wrap::separator = " \\\n"; + + for (keys %install_methods) { + my $method = $install_methods{$_}; + if (my @install_candidates = grep $_, map { $_->{$method->{key}} } @missing_modules) { + print "$method->{system}:\n"; + print wrap(" ", " ", $method->{install}, @install_candidates); + print $/; + } + } +} + sub check_latex { my ($res) = check_kpsewhich(); print_result("Looking for LaTeX kpsewhich", $res); @@ -177,6 +201,8 @@ sub check_module { return if $res; + push @missing_modules, $module; + my $needed_text = $role{optional} ? 'It is OPTIONAL for kivitendo but RECOMMENDED for improved functionality.' : $role{required} ? 'It is NEEDED by kivitendo and must be installed.' @@ -326,6 +352,12 @@ Print additional info for missing dependancies (enabled by default) Disable verbosity +=item C<-i, --install> + +Tries to generate installation commands for the most common package managers. +Note that these lists can be slightly off, but it should still save you a lot +of typing. + =back =head1 BUGS, CAVEATS and TODO -- 2.20.1