Code

..
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Oct 2005 07:58:46 +0000 (07:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Oct 2005 07:58:46 +0000 (07:58 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1499 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/pkg.inc [new file with mode: 0644]

diff --git a/plugins/admin/fai/pkg.inc b/plugins/admin/fai/pkg.inc
new file mode 100644 (file)
index 0000000..a8d2bf3
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+function convert_package_list($server, $release, $sections)
+{
+       $result= array();
+       $package= "";
+       
+       foreach ($sections as $section){
+               $fh = fopen("/etc/gosa/fai/$server/$release/$section.in", "r");
+               $fw = fopen("/etc/gosa/fai/$server/$release/$section", "w");
+               
+               while (!feof($fh)){
+                       $buffer= fgets($fh, 256);
+
+                       if (preg_match("/^Package:/", $buffer)){
+                               // Write out result
+                               if ($package != ""){
+                                       fputs($fw, $package."|".
+                                                  $result[$package]["Version"]."|".
+                                                  $result[$package]["Section"]."|".
+                                                  $result[$package]["Description"]."\n");
+                               }
+                               
+                               $package= trim(preg_replace("/^[^:]+:\s+/", "", $buffer));
+                               $result[$package]= array();
+
+                               continue;
+                       }
+
+                       foreach (array("Version", "Description", "Section") as $var){
+                               if (preg_match("/^$var:/", $buffer)){
+                                       $result[$package]["$var"]= trim(preg_replace("/^[^:]+:\s+/", "", $buffer));
+                                       break;
+                               }
+                       }
+
+               }
+               
+               fclose($fw);
+               fclose($fh);
+       }
+
+       return ($result);
+}
+
+convert_package_list("vserver-01", "sarge", array("main"));
+
+?>