getting apt up and running
authorpaulr <me@pjr.cc>
Sat, 6 Aug 2011 12:01:42 +0000 (22:01 +1000)
committerpaulr <me@pjr.cc>
Sat, 6 Aug 2011 12:01:42 +0000 (22:01 +1000)
libglcas/web.php
plugins/admin.php
plugins/knownos.php
plugins/repo.php

index f2182f3..8c415f7 100644 (file)
@@ -140,6 +140,23 @@ function glcas_isRemoteDir($url)
        return false;
 }
 
+function glcas_fileExists($url)
+{
+       $fp = fopen($url, "r");
+       //error_og("did file_get_contents on $url");
+       $retval = false;
+       foreach($http_response_header as $key => $val) {
+               //error_log("got header of $key for $val");
+               if(preg_match("/.*HTTP\/.*200.*/", $val)) {
+                       //echo "is true\n";
+                       
+                       $retval = true;
+               }
+       }
+       fclose($fp);
+       return $retval;
+}
+
 function glcas_startInstaller()
 {
        global $WEB_ROOT_FS, $BASE_URL;
index b37850a..13121c3 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,6 +162,10 @@ class GLCASAdmin {
                        $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\">";
@@ -168,7 +174,20 @@ class GLCASAdmin {
                        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>";
+                       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\" value=\"3\"> days</td></tr>";
index ee1b15a..b6dd89c 100644 (file)
@@ -50,11 +50,12 @@ function getKnownOSList()
        
        
        // ubuntu bit for apt
-       $kos["apt"]["hardy"] = "Hardy Heron (8.04)";
-       $kos["apt"]["hardy-backports"] = "Hardy Heron (8.04) Backports";
-       $kos["apt"]["hardy-proposed"] = "Hardy Heron (8.04) Proposed";
-       $kos["apt"]["hardy-security"] = "Hardy Heron (8.04) Security";
-       $kos["apt"]["hardy-updates"] = "Hardy Heron (8.04) Updates";
+       // TODO uncomment these ones out of testing
+       /*$kos["apt"]["hardy"] = "Hardy Heron (8.04 LTS)";
+       $kos["apt"]["hardy-backports"] = "Hardy Heron (8.04 LTS) Backports";
+       $kos["apt"]["hardy-proposed"] = "Hardy Heron (8.04 LTS) Proposed";
+       $kos["apt"]["hardy-security"] = "Hardy Heron (8.04 LTS) Security";
+       $kos["apt"]["hardy-updates"] = "Hardy Heron (8.04 LTS) Updates";
        $kos["apt"]["karmic"] = "Karmic Koala (9.10)";
        $kos["apt"]["karmic-backports"] = "Karmic Koala (9.10) Backports";
        $kos["apt"]["karmic-proposed"] = "Karmic Koala (9.10) Proposed";
@@ -69,13 +70,13 @@ function getKnownOSList()
        $kos["apt"]["maverick-backports"] = "Maverick Meerkat (10.10) Backports";
        $kos["apt"]["maverick-proposed"] = "Maverick Meerkat (10.10) Proposed";
        $kos["apt"]["maverick-security"] = "Maverick Meerkat (10.10) Security";
-       $kos["apt"]["maverick-updates"] = "Maverick Meerkat (10.10) Updates";
+       $kos["apt"]["maverick-updates"] = "Maverick Meerkat (10.10) Updates";*/
        $kos["apt"]["natty"] = "Natty Narwhal (11.04)";
        $kos["apt"]["natty-backports"] = "Natty Narwhal (11.04) Backports";
        $kos["apt"]["natty-proposed"] = "Natty Narwhal (11.04) Proposed";
        $kos["apt"]["natty-security"] = "Natty Narwhal (11.04) Security";
        $kos["apt"]["natty-updates"] = "Natty Narwhal (11.04) Updates";
-       $kos["apt"]["oneiric"] = "Oneiric Ocelot (11.10)";
+       /*$kos["apt"]["oneiric"] = "Oneiric Ocelot (11.10)";
        $kos["apt"]["oneiric-backports"] = "Oneiric Ocelot (11.10) Backports";
        $kos["apt"]["oneiric-proposed"] = "Oneiric Ocelot (11.10) Proposed";
        $kos["apt"]["oneiric-security"] = "Oneiric Ocelot (11.10) Security";
@@ -85,7 +86,7 @@ function getKnownOSList()
        $kos["apt"]["squeeze"] = "Debian Squeeze";
        $kos["apt"]["wheezy"] = "Debian Wheezy";
        $kos["apt"]["stable"] = "Debian Stable";
-       $kos["apt"]["unstable"] = "Debian Unstable";
+       $kos["apt"]["unstable"] = "Debian Unstable";*/
        
        
 
index c201756..ee1f141 100644 (file)
@@ -804,9 +804,14 @@ class GLCASRepo {
                        //echo "<br>$key, $val<br>";
                        //echo "now check, $action1/$key";
                        if(glcas_isRemoteDir($action1."/$key")) {
-                               $existing_repos["knownrepo"][$repos] = $key;
-                               $repos++;
+                               $existing_repos["knownrepo"][$repos]["name"] = $key;
                                //echo "Found Distro $val<br>";
+                               if(glcas_fileExists($action1."/$key/Contents-amd64.gz")) $existing_repos["knownrepo"][$repos]["amd64"] = true;
+                               else $existing_repos["knownrepo"][$repos]["amd64"] = false;
+                               if(glcas_fileExists($action1."/$key/Contents-i386.gz")) $existing_repos["knownrepo"][$repos]["i386"] = true;
+                               else $existing_repos["knownrepo"][$repos]["i386"] = false;
+                               $repos++;
+                               
                        }
                }
                $existing_repos["nrepos"] = $repos;