I updated a centos machine from this code... you ripper, it works!
[glcas.git] / unittests / repomdxmlload.php
1 <?php
2
3 // begin unit test header
4 $WEB_ROOT_FS = realpath(dirname(__FILE__));
5 $BASE_URL = dirname($_SERVER["PHP_SELF"]);
6
7 global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
8
9 if(file_exists("../libglcas")) {
10         $path = realpath($WEB_ROOT_FS."/../");
11         error_log("added glcas path as $path");
12         set_include_path(get_include_path().PATH_SEPARATOR.$path);
13 }
14 require_once("../libglcas/lib.php");
15
16
17 glcas_pluginLoader();
18
19 // find our config
20 $configpath = "";
21
22 // TODO: do this better
23 if(file_exists($WEB_ROOT_FS."/../var")) {
24         
25         // is it there?
26         if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) {
27                 $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig");
28         } else {        
29                 // if not, attempt to create
30                 if(!file_exists($WEB_ROOT_FS."/../var/glcas")) {
31                         mkdir($WEB_ROOT_FS."/../var/glcas");
32                 }
33                 // success!
34                 touch("$WEB_ROOT_FS/../var/glcas/webconfig");
35                 $configpath = realpath("$WEB_ROOT_FS/../var/glcas/webconfig");
36         }
37 }
38
39
40 $glconfig = new GLCASConfig();
41 $glconfig->loadConfig($configpath);
42
43
44 // end unit test header
45 $repostore = $glconfig->getConfigVar("storagelocation");
46
47 // find a repomd.xml file
48 echo "<html><pre>";
49 $ckey =0;
50 for($i=0; $i<100; $i++) {
51         //echo "Checking $repostore/$i\n";
52         if(file_exists($repostore."/$i/repodata/repomd.xml")) $ckey = $i;
53 }
54
55 if($ckey == 0) {
56         echo "couldnt find a ckey";
57         return;
58 }
59
60 $xml = simplexml_load_file($repostore."/$ckey/repodata/repomd.xml");
61
62 //echo "XML $ckey is:\n";
63 //print_r($xml);
64
65 foreach($xml as $key => $var) {
66         //echo "for key $key has:\n";
67         //print_r($var);
68         if($key == "data") {
69                 $fileloc = $var->location["href"];
70                 echo "file loc to load: $fileloc\n";
71         }
72 }
73
74 echo "</pre></html>";
75
76 ?>