--- /dev/null
+<?php
+
+$url = "";
+$file = "";
+if(isset($argv[1])) {
+ $url = $argv[1];
+}
+
+if(isset($argv[2])) {
+ $file = $argv[2];
+}
+
+if($url == "" || $file == "") {
+ echo "need a url and file\n";
+ exit(0);
+}
+
+if(file_exists("$file/repodata/repoupdate.lock")) {
+ // try get a lock
+ $lf = fopen("$file/repodata/repoupdate.lock", "r");
+ if($lf) {
+ $lockres = flock($lf, LOCK_EX|LOCK_NB);
+ if(!$lockres) {
+ error_log("flock did fail, all is right with the world a download is in progress");
+ exit(0);
+ }
+ } else {
+ error_log("weird problem");
+ }
+}
+fclose($lf);
+$lf = fopen("$file/repodata/repoupdate.lock", "w");
+flock($lf, LOCK_EX|LOCK_NB);
+
+error_log("called with $url and $file");
+
+$actionurl = "$url/repodata/repomd.xml";
+$repomdxml = file_get_contents($actionurl);
+file_put_contents("$file/repodata/repomd.xml", $repomdxml);
+
+
+$xml = simplexml_load_file("$file/repodata/repomd.xml");
+
+
+foreach($xml as $key => $var) {
+ //echo "for key $key has:\n";
+ //print_r($var);
+ if($key == "data") {
+ $fileloc = $var->location["href"];
+ if(!file_exists("$file/$fileloc")) {
+ error_log("getting $file/$fileloc on $url/$fileloc");
+ $dlfile = file_get_contents("$url/$fileloc");
+ file_put_contents("$file/$fileloc", $dlfile);
+ } else {
+ error_log("Not getting $fileloc because we already have it");
+ }
+ }
+}
+
+unlink("$file/repodata/repoupdate.lock");
+
+?>
\ No newline at end of file