getting apt up and running
[glcas.git] / plugins / admin.php
index 609047f..13121c3 100644 (file)
@@ -30,6 +30,9 @@ class GLCASAdmin {
                                        GLCASpageBuilder($this,"doRepoNextForm");
                                        return;
                                        break;
+                               case "addrepoapt":
+                                       GLCASpageBuilder($this,"doAddRepoApt");
+                                       return;
                                case "addrepoyum":
                                        GLCASpageBuilder($this,"doAddRepoYum");
                                        return;
@@ -113,6 +116,8 @@ class GLCASAdmin {
        {
                $myRep = new GLCASRepo($this->config);
                
+               $kos = getKnownOSList();
+               
                $wasyum = false;
                $wasapt = false;
                if($_REQUEST["repotype"] == "yumbase") {
@@ -138,7 +143,7 @@ class GLCASAdmin {
                        $extratext = "";
                        $provides = "";
                        if($glt["nrepos"] > 0) {
-                               $kos = getKnownOSList();
+                               
                                foreach($glt["knownrepo"] as $key => $val) {
                                        $reponame = $kos["apt"][$val];
                                        //echo "Fount a repo, $val which is $reponame<br>";
@@ -148,15 +153,45 @@ class GLCASAdmin {
                        } else {
                                //echo "Looks like an apt repo, but I cant find any known distro's<br>";
                        }
+                       //$existing_repos["distros"] = "Ubuntu, Debian";
+                       //$existing_repos["versions"] = "8.04LTS, 9.10, 10.04LTS, 10.10, 11.04, 11.10";
+                       //$existing_repos["arch"] = "x86_64, i386";
+                       
+                       
+                       $distros = $glt["distros"];
+                       $version = $glt["versions"];
+                       $archs = $glt["arch"];
+                       
+                       echo "<pre>";
+                       print_r($glt);
+                       echo "</pre>";
                        
                        echo "<form method=\"post\" action=\"?action=addrepoapt\">";
                        echo "<input type=\"hidden\" name=\"repourl\" value=\"$repourl\">";
+                       echo "<input type=\"hidden\" name=\"distro\" value=\"$distros\">";
+                       echo "<input type=\"hidden\" name=\"arch\" value=\"$archs\">";
                        echo "<table>";
                        echo "<tr><td>Description</td><td><input type=\"text\" name=\"desc\" value=\"APT Repo$extratext\"></td>";
-                       echo "<tr><td>Provides</td><td><textarea name=\"provides\">$provides</text area></td></tr>";
+                       // TODO change this "provides" bit with a bit that allows us to choose which versions
+                       // of ubuntu will be made available from the ones we found
+                       echo "<tr><td>Provides (tick those you wish to BLOCK)</td><td>";
+                       foreach($glt["knownrepo"] as $key => $val) {
+                               $reponame = $kos["apt"][$val["name"]];
+                               $a = "";
+                               $b = "";
+                               if($glt["knownrepo"][$key]["i386"]) $a = "i386";
+                               if($glt["knownrepo"][$key]["amd64"]) $b = "x86_64";
+                               if($a != "" && $b != "") $archs = "$a/$b";
+                               else $archs = "$a$b"; 
+                               echo "<input type=\"checkbox\" name=\"$val\"> $reponame ($archs)<br>";
+                       }
+                       
+                       echo "</td></tr>";
+                       //echo "<tr><td>Provides</td><td><textarea name=\"provides\" rows=\"".$glt["nrepos"]."\" cols=\"100\">$provides</textarea></td></tr>";
                        echo "<tr><td>Short URL</td><td><input type=\"text\" name=\"shorturl\"></td></tr>";
                        echo "<tr><td>URL Prefix (blank for none)</td><td><input type=\"text\" name=\"prefix\"></td></tr>";
-                       echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\"> days</td></tr>";
+                       echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\" value=\"3\"> days</td></tr>";
+                       echo "<tr><td><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
                        echo "</table>";
                        echo "</form>";
                        return true;
@@ -179,12 +214,35 @@ class GLCASAdmin {
                        echo "<tr><td>Short URL</td><td><input type=\"text\" name=\"shorturl\"></td></tr>";
                        echo "<tr><td>URL Prefix (blank for none)</td><td><input type=\"text\" name=\"prefix\"></td></tr>";
                        echo "<tr><td>Do Initial Update (can take a while, but done in background)</td><td><input type=\"checkbox\" name=\"initial\" checked></td></tr>";
-                       echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\"> days</td></tr>";
+                       echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\" value=\"3\"> days</td></tr>";
                        echo "<tr><td><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
                        echo "</table>";
                        echo "</form>";
                }
        }
+
+       function doAddRepoApt($url)
+       {
+               $repo = new GLCASRepo($this->config);
+               
+               $desc = $_REQUEST["desc"];
+               $OS = $_REQUEST["distro"];
+               $version = $_REQUEST["provides"];
+               $arch = $_REQUEST["arch"];
+               $shorturl = $_REQUEST["shorturl"];
+               $prefix = $_REQUEST["prefix"];
+               $repurl = $_REQUEST["repourl"];
+               $expiretime = $REQUEST["expiretime"];
+               $init = false;
+               if(isset($_REQUEST["initial"])) $init = true;
+               
+               
+               
+               $repo->addRepo($desc, $OS, $version, $arch, "-", $shorturl, $prefix, $repurl, "APT", $init, $expiretime);
+               
+               global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+               header("Location: $BASE_URL/admin/");
+       }
        
        function doAddRepoYum($url)
        {
@@ -287,7 +345,7 @@ class GLCASAdmin {
                echo "Type <select name=\"repotype\">";
                        echo "<option value=\"yumbase\">YUM (Base URL)</option>";
                        echo "<option value=\"yummirrorlist\">YUM (Mirror List) - not implemented</option>";
-                       echo "<option value=\"apt\">APT - not implemented</option>";
+                       echo "<option value=\"apt\">APT</option>";
                        echo "</select><br>";
                echo "URL <input type=\"text\" name=\"repourl\"><br>";
                echo "<input type=\"submit\" name=\"Add\" value=\"Add\"><br>";