13 if($url == "" || $file == "") {
14 echo "need a url and file\n";
18 if(file_exists("$file/repodata/repoupdate.lock")) {
20 $lf = fopen("$file/repodata/repoupdate.lock", "r");
22 $lockres = flock($lf, LOCK_EX|LOCK_NB);
24 error_log("flock did fail, all is right with the world a download is in progress");
28 error_log("weird problem");
32 $lf = fopen("$file/repodata/repoupdate.lock", "w");
33 flock($lf, LOCK_EX|LOCK_NB);
35 error_log("called with $url and $file");
37 $actionurl = "$url/repodata/repomd.xml";
38 $repomdxml = file_get_contents($actionurl);
39 file_put_contents("$file/repodata/repomd.xml", $repomdxml);
42 $xml = simplexml_load_file("$file/repodata/repomd.xml");
45 foreach($xml as $key => $var) {
46 //echo "for key $key has:\n";
49 $fileloc = $var->location["href"];
50 if(!file_exists("$file/$fileloc")) {
51 error_log("getting $file/$fileloc on $url/$fileloc");
52 $dlfile = file_get_contents("$url/$fileloc");
53 file_put_contents("$file/$fileloc", $dlfile);
55 error_log("Not getting $fileloc because we already have it");
60 unlink("$file/repodata/repoupdate.lock");