trying to figure out hoe i group os's and stuff
authorpaulr <me@pjr.cc>
Mon, 25 Jul 2011 04:56:49 +0000 (14:56 +1000)
committerpaulr <me@pjr.cc>
Mon, 25 Jul 2011 04:56:49 +0000 (14:56 +1000)
plugins/admin.php
plugins/knownos.php [new file with mode: 0644]
plugins/repo.php

index 8b6c2a9..af5ed85 100644 (file)
@@ -20,7 +20,7 @@ class GLCASAdmin {
                if(isset($_REQUEST["action"])) {
                        switch($_REQUEST["action"]) {
                                case "addrepo":
-                                       GLCASpageBuilder($this,"doAddRepo");
+                                       GLCASpageBuilder($this,"doAddRepoForm");
                                        return;
                                        break;
                                case "scanrepo":
@@ -44,13 +44,37 @@ class GLCASAdmin {
                $this->mainBody($url);
        }
        
-       function doAddRepo($url)
+       function doAddRepoForm($url)
        {
                $myRep = new GLCASRepo($this->config);
                
-               $glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
+               $wasyum = false;
+               if($_REQUEST["repotype"] == "yumbase") {
+                       $glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
+                       $wasyum = true;
+               } else if($_REQUEST["repotype"] == "yummirrorlist") {
+                       $glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"], true);
+                       $wasyum = true;
+               } else if($_REQUEST["repotype"] == "apt") {
+                       $glt = $myRep->getRepoDetailsApt($_REQUEST["repourl"]);
+               }
+               
                
-               echo "<pre>$glt</pre>";
+               if($wasyum) {
+                       $os = $glt["OS"];
+                       $version = $glt["version"];
+                       $arch = $glt["arch"];
+                       echo "<form method=\"post\" action=\"repoaddreal\">";
+                       echo "OS: <input type=\"text\" name=\"OS\" value=\"$os\"><br>";
+                       echo "Version: <input type=\"text\" name=\"version\" value=\"$version\"><br>";
+                       echo "Architecture: <input type=\"text\" name=\"Architecture\" value=\"$arch\"><br>";
+                       echo "Short URL <input type=\"text\" name=\"shorturl\"><br>";
+                       echo "URL Prefix (blank for none) <input type=\"text\" name=\"shorturl\"><br>";
+                       echo "<input type=\"submit\" name=\"Add\" value=\"add\"><br>";
+                       echo "</form>";
+               } else {
+                       // apt is much tricker cause one repo can provide multiple versions, OS's and architectures.
+               }
        }
        
        function mainBody($url)
diff --git a/plugins/knownos.php b/plugins/knownos.php
new file mode 100644 (file)
index 0000000..eda7b96
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+// this class will provide OS knowledge - though how i have no idea yet
+class GLCASKnownOS {
+       
+       function __construct()
+       {
+               $knownOS = getKnownOSList();
+       }
+       
+       function getOSList()
+       {
+       }
+       
+       function getRepoTypeForOS($os)
+       {
+               
+       }
+       
+       function getRepoTypes()
+       {
+               
+       }
+       
+       public $knownOS;
+}
+
+function getKnownOSList()
+{
+       // repo types
+       $kos["repotype"]["yum"] = "Yellowdog Updater Modified";
+       $kos["repotype"]["apt"] = "APT";
+
+       // repo providers
+       $kos["repotype"]["yum"][0] = "baseurl";
+       $kos["repotype"]["yum"][1] = "mirrorlist";
+       $kos["repotype"]["apt"][0] = "baseurl";
+       
+       // OS's
+       $kos["os"]["Fedora"] = "Fedora";
+       $kos["os"]["Debian"] = "Debian";
+       $kos["os"]["RedHat"] = "RedHat Enterprise Linux";
+       $kos["os"]["Ubuntu"] = "Ubuntu";
+       $kos["os"]["CentOS"] = "Community Enterprise OS";
+       
+       // Repo types per os
+       $kos["os"]["Fedora"]["repotype"] = "yum";
+       $kos["os"]["Debian"]["repotype"] = "apt";
+       $kos["os"]["RedHat"]["repotype"] = "yum";
+       $kos["os"]["Ubuntu"]["repotype"] = "apt";
+       $kos["os"]["CentOS"]["repotype"] = "yum";
+       
+       
+       
+       return $kos;
+}
+
+?>
\ No newline at end of file
index c85ff12..fea1c4f 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 $URL_HANDLERS["*"] = "GLCASRepo";
 
+
 class GLCASRepo {
        function __construct($config)
        {
@@ -18,7 +19,7 @@ class GLCASRepo {
                echo "for the repo, i am the repo $url";
        }
        
-       function getRepoDetailsYum($url)
+       function getRepoDetailsYum($url, $ismirrorlist=false)
        {
                $actionurl = $url."/repodata/repomd.xml";
                
@@ -26,9 +27,16 @@ class GLCASRepo {
                
                $ld = file_get_contents($actionurl);
                
+               // so here we try and get what this repository provides (os, version, arch), for yum this
+               // should come straight off the url... i.e. centos/6.0/os/x86_64/ (centos, 6.0, base os, 64bit arch)
+               
                if(!$ld) return false;
                
-               return $ld;
+               $glt["OS"] = "Fedora";
+               $glt["version"] = "15";
+               $glt["arch"] = "x86_64";
+               
+               return $glt;
        }
        
        private $config;