added a apt repo updater... that doesnt work
[glcas.git] / plugins / admin.php
index b37850a..492ed29 100644 (file)
@@ -116,6 +116,8 @@ class GLCASAdmin {
        {
                $myRep = new GLCASRepo($this->config);
                
+               $kos = getKnownOSList();
+               
                $wasyum = false;
                $wasapt = false;
                if($_REQUEST["repotype"] == "yumbase") {
@@ -141,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>";
@@ -160,15 +162,35 @@ class GLCASAdmin {
                        $version = $glt["versions"];
                        $archs = $glt["arch"];
                        
+                       //echo "<pre>";
+                       //print_r($glt);
+                       //echo "</pre>";
+                       
+                       echo "The joy of apt is that there could be a million distro's under the root of an apt mirror";
+                       echo "if it doesn't list here, but you know its there, its still usable for glcas";
                        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=\"provides\" value=\"Multiple\">";
                        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>";
-                       // 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</td><td><textarea name=\"provides\" rows=\"".$glt["nrepos"]."\" cols=\"100\">$provides</textarea></td></tr>";
+                       
+                       // TODO: deal with block bit
+                       echo "<tr><td>Provides (tick those you wish to BLOCK - not implemented)</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=\"blocked-".$val["name"]."\"> $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\" value=\"3\"> days</td></tr>";
@@ -217,9 +239,26 @@ class GLCASAdmin {
                $init = false;
                if(isset($_REQUEST["initial"])) $init = true;
                
+               $blocklist = null;
+               $bn = 0;
+               foreach($_REQUEST as $key => $val) {
+                       if(preg_match("/^blocked-*/", $key)) {
+                               $blocked = preg_replace("/^blocked-/", "", $key);
+                               //echo "<br>got block for $blocked<br>";
+                               $blocklist[$bn] = "dists\/$blocked.*";
+                               $bn++;
+                       }
+               }
+               
+               //echo "<pre>";
+               //print_r($_REQUEST);
+               //echo "</pre>";
+               
+               //exit(0);
                
+               $repo->addRepo($desc, $OS, $version, $arch, "-", $shorturl, $prefix, $repurl, "APT", $init, $expiretime, $blocklist);
                
-               $repo->addRepo($desc, $OS, $version, $arch, "-", $shorturl, $prefix, $repurl, "APT", $init, $expiretime);
+               // next we need to deal with that "blocked" bit
                
                global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
                header("Location: $BASE_URL/admin/");
@@ -252,6 +291,8 @@ class GLCASAdmin {
        function doUpdateRepo($url)
        {
                $rkey = $_REQUEST["repo"];
+
+               error_log("would update for repo");
                
                $repo = new GLCASRepo($this->config);
                
@@ -319,13 +360,12 @@ class GLCASAdmin {
                //echo "</pre>";
                
                // wrap all this in a table
-               echo "<table><tr><td valign=\"top\">";
+               echo "<table border=\"1\"><tr><td valign=\"top\">";
                // now, add a repo
                echo "<h3>Add A Repo</h3>";
                echo "<form method=\"post\" action=\"?action=reponext\">";
                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</option>";
                        echo "</select><br>";
                echo "URL <input type=\"text\" name=\"repourl\"><br>";
@@ -340,19 +380,37 @@ class GLCASAdmin {
                echo "Hint <select name=\"repohint\">";
                        echo "<option value=\"fedora\">Fedora</option>";
                        echo "<option value=\"centos\">Centos</option>";
-                       echo "<option value=\"ubuntu\">Ubuntu</option>";
                        echo "</select><br>";
                echo "URL <input type=\"text\" name=\"repourl\"><br>";
                echo "<input type=\"submit\" name=\"Scan\" value=\"Scan\"><br>";
                echo "</form>";
                
-               echo "</td></tr></table><hr>";
+               echo "</td><td valign=\"top\">";
+               
+               // now for mirror lists
+               echo "<h3>Via Mirrolist - not implemented</h3>";
+               echo "<form method=\"post\" action=\"?action=mirrorlist\">";
+               echo "Distro <select name=\"mirrordistro\">";
+                       echo "<option value=\"fedora\">Fedora</option>";
+                       echo "<option value=\"centos\">Centos</option>";
+                       echo "</select><br>";
+               echo "Architecture <select name=\"arch\">";
+                       echo "<option value=\"x86_64\">64 bit</option>";
+                       echo "<option value=\"i386\">32 bit</option>";
+                       echo "</select><br>";
+               echo "Version <input type=\"text\" name=\"version\"><br>";
+               echo "Get updates too <input type=\"checkbox\" name=\"getupdates\"><br>";
+               echo "<input type=\"submit\" name=\"Scan\" value=\"Scan\"><br>";
+               echo "</form>";
+               
+               
+               echo "</td></tr></table>";
                
                // repo storage location
                echo "<h3>Storage<h3><br>";
                echo "<form method=\"post\" action=\"?action=setstorage\">";
                $storloc = $this->config->getConfigVar("storagelocation");
-               echo "<input type=\"text\" name=\"storageloc\" value=\"$storloc\" size=\"100\">";
+               echo "<input class=\"storage\" type=\"text\" name=\"storageloc\" value=\"$storloc\" size=\"100\">";
                echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
                echo "</form>";
        }