Code

Updated update-gosa
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 14:44:52 +0000 (14:44 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 14:44:52 +0000 (14:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8522 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/functions.inc
gosa-core/re-generate-mo-will-move [deleted file]
gosa-core/update-gosa [new file with mode: 0755]

index 48e1db979f941c05703ca3fde1cb812e3cc16af1..d04c19ce91e03b6a8cf2f269311a8a9e6e1f94b8 100644 (file)
@@ -95,7 +95,7 @@ function __autoload($class_name) {
     global $class_mapping, $BASE_DIR;
 
     if ($class_mapping === NULL){
-           echo sprintf(_("Fatal error: no class locations defined - please run '%s' to fix this"), "<b>update-gosa</b>");
+           echo sprintf(_("Fatal error: no class locations defined - please run '%s' to fix this"), "<b>update-gosa rescan-classes</b>");
            exit;
     }
 
diff --git a/gosa-core/re-generate-mo-will-move b/gosa-core/re-generate-mo-will-move
deleted file mode 100755 (executable)
index cf51485..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-#!/usr/bin/php5
-<?php
-
-define ("LOCALE_DIR", "/home/cajus/Projekte/gosa/trunk/gosa-all/gosa/locale");
-define ("PLUGSTATE_DIR", "/tmp/gosa");
-
-function print_usage()
-{
-       ?>
-update-gosa - class cache updated and plugin manager for GOsa
-Usage: update-gosa                        Update the class cache
-
-       update-gosa install-plugin dir     Install the plugin placed in "dir" to
-                                          the GOsa tree.
-
-       update-gosa remove-plugin plugin   Remove the plugin named "plugin" from
-                                          the current configuration.
-
-       update-gosa list-plugins           Lists installed plugins
-
-       update-gosa rescan-i18n            Rebuilds the translations
-
-       update-gosa rescan-classes         Rebuilds the class list
-       
-<?php
-       exit (1);
-}
-
-
-/* Function to include all class_ files starting at a given directory base */
-function get_classes($folder= ".")
-{
-  static $base_dir= "";
-  static $result= array();
-
-  if ($base_dir == ""){
-    $base_dir= getcwd();
-  }
-
-  $currdir=getcwd();
-  if ($folder){
-    chdir("$folder");
-  }
-
-  $dh = opendir(".");
-  while(false !== ($file = readdir($dh))){
-
-    if (preg_match("/.*\.svn.*/", $file) ||
-        preg_match("/.*smarty.*/i",$file) ||
-        preg_match("/.*\.tpl.*/",$file) ||
-        ($file==".") ||($file =="..")){
-      continue;
-    }
-
-    /* Recurse through all "common" directories */
-    if (is_dir($file)){
-      get_classes($file);
-      continue;
-    }
-
-    /* Only take care about .inc and .php files... */
-    if (!(preg_match('/\.php$/', $file) || preg_match('/\.inc$/', $file))){
-      continue;
-    }
-
-    /* Include existing class_ files */
-    $contents= file($file);
-    foreach($contents as $line){
-      $line= chop($line);
-      if (preg_match('/^\s*class\s*\w.*$/', $line)){
-        $class= preg_replace('/^\s*class\s*(\w+).*$/', '\1', $line);
-        $result[$class]= preg_replace("%$base_dir/%", "", "$currdir/$folder/$file");
-      }
-    }
-  }
-
-  closedir($dh);
-  chdir($currdir);
-
-  return ($result);
-}
-
-
-function rescan_classes()
-{
-       $class_mapping= get_classes();
-       $filename= "include/class_location.inc";
-
-       /* Sanity checks */
-       if (!file_exists($filename) || is_writable($filename)) {
-
-           if (!$handle= fopen($filename, 'w')) {
-                echo "Cannot open file \"$filename\" - aborted\n";
-                exit (1);
-           }
-
-       } else {
-           echo "File \"$filename\" is not writable - aborted\n";
-           exit (2);
-       }
-
-       fwrite ($handle, "<?php\n\$class_mapping= array(\n");
-       foreach ($class_mapping as $key => $value){
-         fwrite ($handle, "                \"$key\" => \"$value\",\n");
-       }
-       fwrite ($handle, " );\n?>");
-
-       fclose($handle);
-}
-
-
-function rescan_i18n()
-{
-       $languages= array();
-       $size= strlen(LOCALE_DIR);
-
-       /* Get all available messages.po files, sort them for languages */
-       $dir= new RecursiveDirectoryIterator(LOCALE_DIR);
-       $all= new RecursiveIteratorIterator($dir);
-       foreach ( $all as $element ){
-               if ($element->isFile() && preg_match('/\/LC_MESSAGES\/messages.po$/', $element->getPathname())){
-                       $lang= preg_replace('/^.*\/([^\/]+)\/LC_MESSAGES\/.*$/', '\1', $element);
-                       if (!isset($languages[$lang])){
-                               $languages[$lang]= array();
-                       }
-                       $languages[$lang][]= substr($element->getPathName(), $size+1);
-               }
-       }
-
-       /* For each language, merge the target .mo to the compiled directory. */
-       foreach ($languages as $language => $po_files){
-               if (!is_dir(LOCALE_DIR."/compiled/${language}/LC_MESSAGES")){
-                       if (!mkdir (LOCALE_DIR."/compiled/${language}/LC_MESSAGES", 0755, TRUE)){
-                               echo "Failed to create '".LOCALE_DIR."/compiled/${language}/LC_MESSAGES'- aborted";
-                               exit (3);
-                       }
-               }
-
-               /* Cat all these po files into one single file */
-               system ("(cd ".LOCALE_DIR." && msgcat ".implode(" ", $po_files)." > compiled/${language}/LC_MESSAGES/messages.po)", $val);
-               if ($val != 0){
-                       echo "Merging of message files failed - aborted";
-                       exit (4);
-               }
-               system ("(cd ".LOCALE_DIR."/compiled/${language}/LC_MESSAGES && msgfmt -o messages.mo messages.po && rm messages.po)", $val);
-               if ($val != 0){
-                       echo "Compiling of message files failed - aborted";
-                       exit (5);
-               }
-       }
-}
-
-
-function parse_ini($file)
-{
-       global $description, $provides, $depends;
-
-       $res= "";
-       if (file_exists($file)){
-               $tmp= parse_ini_file($file, TRUE);
-
-               if (isset($tmp['gosa-plugin'])){
-                       $plugin= &$tmp['gosa-plugin'];
-                       if (isset($plugin['name'])&& isset($plugin['description']) && isset($plugin['provides'])){
-                               $res= $plugin['name'];
-                               $provides[$res]= $plugin['provides'];
-                               $description[$res]= $plugin['description'];
-                               if (isset($plugin['depends'])){
-                                       $depends[$res]= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
-                               }
-                       }
-               }
-       }
-
-       return $res;
-}
-
-
-function dependency_check()
-{
-       global $description, $provides, $depends;
-
-       foreach ($depends as $name => $pl_depends){
-               foreach ($pl_depends as $pl){
-                       if (!in_array($pl, $provides)){
-                               echo "! Error: plugin '$name' depends on '$pl' which is not provided by any plugin\n\n";
-                               exit (1);
-                       }
-               }
-       }
-}
-
-
-function load_plugins()
-{
-       $dir= new DirectoryIterator(PLUGSTATE_DIR);
-       foreach ($dir as $entry){
-               if ($dir->isDir() && !preg_match('/^\./', $dir->__toString())){
-                       $file= $dir->getPathName()."/plugin.dsc";
-                       if (!parse_ini($file)){
-                               echo "! Warning: plugin ".$dir->getPathName()." is missing declarations\n";
-                       }
-               }
-       }
-}
-
-
-function list_plugins()
-{
-       global $description;
-       $count= 0;
-
-       /* Load plugin list */
-       load_plugins();
-
-       /* Show plugins */
-       foreach ($description as $name => $dsc){
-               if ($count == 0){
-                       echo "Plugin\t\t| Description\n";
-                       echo "------------------------------------------------------------------------\n";
-               }
-               echo "* $name\t\t| ".$dsc."\n";
-               $count++;
-       }
-
-       /* Yell about non existing plugins... */
-       if ($count == 0){
-               echo "No plugins found...\n\n";
-       } else {
-               # Check for dependencies
-               dependency_check();
-               echo "\n";
-       }
-}
-
-
-function install_plugin($name)
-{
-       global $description, $provides, $depends;
-
-       /* Load plugin list */
-       load_plugins();
-
-       # go to the directory, load dsc file
-       # check if it already there
-       # check if all dependencies are fullfilled
-       # copy plugin
-       # update classlist
-       # update i18n
-
-       #if (isset($)){
-       #}
-}
-
-
-/* Fill global values */
-$description= $provides= $depends= array();
-
-/* Action specified? */
-if ($argc < 2){
-        exit (0);
-}
-switch ($argv[1]){
-        case 'install-plugin':
-                if (isset($argv[2])){
-                       install_plugin($argv[2]);
-               } else {
-                       echo "Usage: update-gosa install-plugin directory\n\n";
-                       exit (1);
-               }
-                break;
-        case 'list-plugins':
-                list_plugins();
-                break;
-        case 'remove-plugin':
-                echo "remove\n";
-                break;
-        case 'rescan-i18n':
-                rescan_i18n();
-                break;
-        case 'rescan-classes':
-                rescan_classes();
-                break;
-        default:
-                echo "Error: Supplied command not known\n\n";
-                print_usage();
-                break;
-}
-
-
-?>
diff --git a/gosa-core/update-gosa b/gosa-core/update-gosa
new file mode 100755 (executable)
index 0000000..a50368d
--- /dev/null
@@ -0,0 +1,292 @@
+#!/usr/bin/php5
+<?php
+
+define ("LOCALE_DIR", "/home/cajus/Projekte/gosa/trunk/gosa-all/gosa/locale");
+define ("PLUGSTATE_DIR", "/tmp/gosa");
+
+function print_usage()
+{
+       ?>
+update-gosa - class cache updated and plugin manager for GOsa
+Usage: update-gosa                        Update the class cache
+
+       update-gosa install-plugin dir     Install the plugin placed in "dir" to
+                                          the GOsa tree.
+
+       update-gosa remove-plugin plugin   Remove the plugin named "plugin" from
+                                          the current configuration.
+
+       update-gosa list-plugins           Lists installed plugins
+
+       update-gosa rescan-i18n            Rebuilds the translations
+
+       update-gosa rescan-classes         Rebuilds the class list
+       
+<?php
+       exit (1);
+}
+
+
+/* Function to include all class_ files starting at a given directory base */
+function get_classes($folder= ".")
+{
+  static $base_dir= "";
+  static $result= array();
+
+  if ($base_dir == ""){
+    $base_dir= getcwd();
+  }
+
+  $currdir=getcwd();
+  if ($folder){
+    chdir("$folder");
+  }
+
+  $dh = opendir(".");
+  while(false !== ($file = readdir($dh))){
+
+    if (preg_match("/.*\.svn.*/", $file) ||
+        preg_match("/.*smarty.*/i",$file) ||
+        preg_match("/.*\.tpl.*/",$file) ||
+        ($file==".") ||($file =="..")){
+      continue;
+    }
+
+    /* Recurse through all "common" directories */
+    if (is_dir($file)){
+      get_classes($file);
+      continue;
+    }
+
+    /* Only take care about .inc and .php files... */
+    if (!(preg_match('/\.php$/', $file) || preg_match('/\.inc$/', $file))){
+      continue;
+    }
+
+    /* Include existing class_ files */
+    $contents= file($file);
+    foreach($contents as $line){
+      $line= chop($line);
+      if (preg_match('/^\s*class\s*\w.*$/', $line)){
+        $class= preg_replace('/^\s*class\s*(\w+).*$/', '\1', $line);
+        $result[$class]= preg_replace("%$base_dir/%", "", "$currdir/$folder/$file");
+      }
+    }
+  }
+
+  closedir($dh);
+  chdir($currdir);
+
+  return ($result);
+}
+
+
+function rescan_classes()
+{
+       $class_mapping= get_classes();
+       $filename= "include/class_location.inc";
+
+       /* Sanity checks */
+       if (!file_exists($filename) || is_writable($filename)) {
+
+           if (!$handle= fopen($filename, 'w')) {
+                echo "Cannot open file \"$filename\" - aborted\n";
+                exit (1);
+           }
+
+       } else {
+           echo "File \"$filename\" is not writable - aborted\n";
+           exit (2);
+       }
+
+       fwrite ($handle, "<?php\n\$class_mapping= array(\n");
+       foreach ($class_mapping as $key => $value){
+         fwrite ($handle, "                \"$key\" => \"$value\",\n");
+       }
+       fwrite ($handle, " );\n?>");
+
+       fclose($handle);
+}
+
+
+function rescan_i18n()
+{
+       $languages= array();
+       $size= strlen(LOCALE_DIR);
+
+       /* Get all available messages.po files, sort them for languages */
+       $dir= new RecursiveDirectoryIterator(LOCALE_DIR);
+       $all= new RecursiveIteratorIterator($dir);
+       foreach ( $all as $element ){
+               if ($element->isFile() && preg_match('/\/LC_MESSAGES\/messages.po$/', $element->getPathname())){
+                       $lang= preg_replace('/^.*\/([^\/]+)\/LC_MESSAGES\/.*$/', '\1', $element);
+                       if (!isset($languages[$lang])){
+                               $languages[$lang]= array();
+                       }
+                       $languages[$lang][]= substr($element->getPathName(), $size+1);
+               }
+       }
+
+       /* For each language, merge the target .mo to the compiled directory. */
+       foreach ($languages as $language => $po_files){
+               if (!is_dir(LOCALE_DIR."/compiled/${language}/LC_MESSAGES")){
+                       if (!mkdir (LOCALE_DIR."/compiled/${language}/LC_MESSAGES", 0755, TRUE)){
+                               echo "Failed to create '".LOCALE_DIR."/compiled/${language}/LC_MESSAGES'- aborted";
+                               exit (3);
+                       }
+               }
+
+               /* Cat all these po files into one single file */
+               system ("(cd ".LOCALE_DIR." && msgcat ".implode(" ", $po_files)." > compiled/${language}/LC_MESSAGES/messages.po)", $val);
+               if ($val != 0){
+                       echo "Merging of message files failed - aborted";
+                       exit (4);
+               }
+               system ("(cd ".LOCALE_DIR."/compiled/${language}/LC_MESSAGES && msgfmt -o messages.mo messages.po && rm messages.po)", $val);
+               if ($val != 0){
+                       echo "Compiling of message files failed - aborted";
+                       exit (5);
+               }
+       }
+}
+
+
+function parse_ini($file)
+{
+       global $description, $provides, $depends;
+
+       $res= "";
+       if (file_exists($file)){
+               $tmp= parse_ini_file($file, TRUE);
+
+               if (isset($tmp['gosa-plugin'])){
+                       $plugin= &$tmp['gosa-plugin'];
+                       if (isset($plugin['name'])&& isset($plugin['description']) && isset($plugin['provides'])){
+                               $res= $plugin['name'];
+                               $provides[$res]= $plugin['provides'];
+                               $description[$res]= $plugin['description'];
+                               if (isset($plugin['depends'])){
+                                       $depends[$res]= explode(',', preg_replace('/\s+/', '', $plugin['depends']));
+                               }
+                       }
+               }
+       }
+
+       return $res;
+}
+
+
+function dependency_check()
+{
+       global $description, $provides, $depends;
+
+       foreach ($depends as $name => $pl_depends){
+               foreach ($pl_depends as $pl){
+                       if (!in_array($pl, $provides)){
+                               echo "! Error: plugin '$name' depends on '$pl' which is not provided by any plugin\n\n";
+                               exit (1);
+                       }
+               }
+       }
+}
+
+
+function load_plugins()
+{
+       $dir= new DirectoryIterator(PLUGSTATE_DIR);
+       foreach ($dir as $entry){
+               if ($dir->isDir() && !preg_match('/^\./', $dir->__toString())){
+                       $file= $dir->getPathName()."/plugin.dsc";
+                       if (!parse_ini($file)){
+                               echo "! Warning: plugin ".$dir->getPathName()." is missing declarations\n";
+                       }
+               }
+       }
+}
+
+
+function list_plugins()
+{
+       global $description;
+       $count= 0;
+
+       /* Load plugin list */
+       load_plugins();
+
+       /* Show plugins */
+       foreach ($description as $name => $dsc){
+               if ($count == 0){
+                       echo "Plugin\t\t| Description\n";
+                       echo "------------------------------------------------------------------------\n";
+               }
+               echo "* $name\t\t| ".$dsc."\n";
+               $count++;
+       }
+
+       /* Yell about non existing plugins... */
+       if ($count == 0){
+               echo "No plugins found...\n\n";
+       } else {
+               # Check for dependencies
+               dependency_check();
+               echo "\n";
+       }
+}
+
+
+function install_plugin($name)
+{
+       global $description, $provides, $depends;
+
+       /* Load plugin list */
+       load_plugins();
+
+       # go to the directory, load dsc file
+       # check if it already there
+       # check if all dependencies are fullfilled
+       # copy plugin
+       # update classlist
+       # update i18n
+
+       #if (isset($)){
+       #}
+}
+
+
+/* Fill global values */
+$description= $provides= $depends= array();
+
+/* Action specified? */
+if ($argc < 2){
+       print_usage();
+        exit (0);
+}
+switch ($argv[1]){
+        case 'install-plugin':
+                if (isset($argv[2])){
+                       install_plugin($argv[2]);
+               } else {
+                       echo "Usage: update-gosa install-plugin directory\n\n";
+                       exit (1);
+               }
+                break;
+        case 'list-plugins':
+                list_plugins();
+                break;
+        case 'remove-plugin':
+                echo "remove\n";
+                break;
+        case 'rescan-i18n':
+                rescan_i18n();
+                break;
+        case 'rescan-classes':
+                rescan_classes();
+                break;
+        default:
+                echo "Error: Supplied command not known\n\n";
+                print_usage();
+                break;
+}
+
+
+?>