X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FInstallationCheck.pm;h=0d1ab8bd5e13af3be0da995cdfe0ec2cb946b9f4;hb=e0ad5757c7f9551f808b55c114ff8892f09689f4;hp=5f9776816224c61e792eb27b72d23e4939a1732f;hpb=5c695f5dff59f951d17172851a6428bf346b9d66;p=kivitendo-erp.git diff --git a/SL/InstallationCheck.pm b/SL/InstallationCheck.pm index 5f9776816..0d1ab8bd5 100644 --- a/SL/InstallationCheck.pm +++ b/SL/InstallationCheck.pm @@ -51,7 +51,43 @@ sub module_available { my $module = $_[0]; my $version = $_[1] || '' ; - return eval "use $module $version; 1"; + my $got = eval "use $module $version; 1"; + + if ($got) { + return ($got, $module->VERSION); + } else { + return + } +} + +sub check_kpsewhich { + my $exit = system("which kpsewhich > /dev/null"); + + return $exit > 0 ? 0 : 1; +} + +sub template_dirs { + my ($path) = @_; + opendir my $dh, $path || die "can't open $path"; + my @templates = sort grep { !/^\.\.?$/ } readdir $dh; + close $dh; + + return @templates; +} + +sub classes_from_latex { + my ($path, $class) = @_; + eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return; + $path = shell_quote $path; + $class = shell_quote $class; + + open my $pipe, q#egrep -rs '^[\ \t]*# . "$class' $path". q# | sed 's/ //g' | awk -F '{' '{print $2}' | awk -F '}' '{print $1}' |#; + my @cls = <$pipe>; + close $pipe; + + # can't use uniq here + my %class_hash = map { $_ => 1 } map { s/\n//; $_ } split ',', join ',', @cls; + return sort keys %class_hash; } my %conditional_dependencies;