delay_flash_on_redirect Magie im Basecontroller.
[kivitendo-erp.git] / SL / InstallationCheck.pm
index 91216a1..0d1ab8b 100644 (file)
@@ -24,6 +24,7 @@ BEGIN {
   { name => "Rose::Object",                        url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-object-perl' },
   { name => "Rose::DB",                            url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-perl' },
   { name => "Rose::DB::Object",                    url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-object-perl' },
+  { name => "String::ShellQuote", version => 1.01, url => "http://search.cpan.org/~rosch/",     debian => 'libstring-shellquote-perl' },
   { name => "Sort::Naturally",                     url => "http://search.cpan.org/~sburke/",    debian => 'libsort-naturally-perl' },
   { name => "Template",        version => '2.18',  url => "http://search.cpan.org/~abw/",       debian => 'libtemplate-perl' },
   { name => "Text::CSV_XS",    version => '0.23',  url => "http://search.cpan.org/~hmbrand/",   debian => 'libtext-csv-xs-perl' },
@@ -50,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;