From 45b1b37dd9688baba31184815cc110f0f1839c1e Mon Sep 17 00:00:00 2001 From: paulr Date: Sat, 6 Aug 2011 22:01:42 +1000 Subject: [PATCH] getting apt up and running --- libglcas/web.php | 17 +++++++++++++++++ plugins/admin.php | 23 +++++++++++++++++++++-- plugins/knownos.php | 17 +++++++++-------- plugins/repo.php | 9 +++++++-- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/libglcas/web.php b/libglcas/web.php index f2182f3..8c415f7 100644 --- a/libglcas/web.php +++ b/libglcas/web.php @@ -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; diff --git a/plugins/admin.php b/plugins/admin.php index b37850a..13121c3 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -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
"; @@ -160,6 +162,10 @@ class GLCASAdmin { $version = $glt["versions"]; $archs = $glt["arch"]; + echo "
";
+			print_r($glt);
+			echo "
"; + echo "
"; echo ""; echo ""; @@ -168,7 +174,20 @@ class GLCASAdmin { echo "Description"; // 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 "Provides"; + echo "Provides (tick those you wish to BLOCK)"; + 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 " $reponame ($archs)
"; + } + + echo ""; + //echo "Provides"; echo "Short URL"; echo "URL Prefix (blank for none)"; echo "Expire time for Meta Data days"; diff --git a/plugins/knownos.php b/plugins/knownos.php index ee1b15a..b6dd89c 100644 --- a/plugins/knownos.php +++ b/plugins/knownos.php @@ -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";*/ diff --git a/plugins/repo.php b/plugins/repo.php index c201756..ee1f141 100644 --- a/plugins/repo.php +++ b/plugins/repo.php @@ -804,9 +804,14 @@ class GLCASRepo { //echo "
$key, $val
"; //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
"; + 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; -- 1.7.0.4