?>
<a href="<?php echo $BASE_URL ?>">Home</a>
<a href="<?php echo $BASE_URL."/admin/"?>">Admin</a>
+<a href="<?php echo $BASE_URL."/adhoc/"?>">Adhoc</a>
<?php
}
--- /dev/null
+<?php
+
+error_log("adhoc loaded");
+
+global $URL_HANDLERS;
+$URL_HANDLERS["adhoc.*"] = "GLCASAdhoc";
+
+class GLCASAdhoc {
+ function __construct($config)
+ {
+ $this->config = $config;
+ error_log("constructor for GLCASAdhoc");
+
+ $repostore = $this->config->getConfigVar("storagelocation");
+ if(!is_dir("$repostore/adhoc")) {
+ error_log("Creating dir for adhoc component");
+ mkdir("$repostore/adhoc");
+ }
+
+ }
+
+ function go($url)
+ {
+ if(isset($_REQUEST["action"])) {
+ switch($_REQUEST["action"]) {
+ case "addpackage":
+ error_log("in updaterepo");
+ GLCASpageBuilder($this,"addPackage");
+ return;
+ }
+ }
+
+ GLCASpageBuilder($this,"mainBody");
+ return;
+
+ }
+
+ function addPackage($url)
+ {
+ $repostore = $this->config->getConfigVar("storagelocation");
+
+ if(!isset($_REQUEST["pkgname"])) {
+ echo "<font color=\"red\">Error: No package name set</font><br>";
+ }
+ if($_REQUEST["pkgname"] == "") {
+ echo "<font color=\"red\">Error: Package name cant be blank</font><br>";
+ }
+
+
+ $fname = "";
+ $lname = "";
+ $ultfileurl = "";
+ if($_FILES["uploadedfile"]["name"] == "") {
+ $uploaded = false;
+ $ultfileurl = "uploaded";
+ } else {
+ $fname = $_FILES["uploadedfile"]["tmp_name"];
+ $lname = $_FILES["uploadedfile"]["name"];
+ $uploaded = true;
+ }
+
+ if($_REQUEST["fileurl"] == "") {
+ $fileurl = false;
+ $ultfileurl = $_REQUEST["fileurl"];
+ } else {
+ $fname = $_REQUEST["fileurl"];
+ $lname = basename($fname);
+ $fileurl = true;
+ }
+
+ if(!$uploaded && !$fileurl) {
+ echo "<font color=\"red\">Error: no uploaded file and no file url, you need one or the other buddy</font><br>";
+ }
+
+ $getfile = "";
+ if($fileurl) {
+ $getfile = file_get_contents($_REQUEST["fileurl"]);
+ }
+
+ if($uploaded||$fileurl) {
+ echo "Got a file named $fname, $lname";
+ }
+
+ $pkgs = unserialize($this->config->getConfigVar("adhocpackages"));
+
+ $n = -1;
+ foreach($pkgs as $key => $var) {
+ $n = $key;
+ }
+ $n++;
+
+ echo "Would add package as $n";
+
+ $pkgs[$n]["arch"] = $_REQUEST["arch"];
+ $pkgs[$n]["type"] = $_REQUEST["type"];
+ $pkgs[$n]["fileurl"] = $ultfileurl;
+
+ if($uploaded) {
+ copy("$fname", "$repostore/adhoc/$n");
+ } else {
+ file_put_contents("$repostore/adhoc/$n", $fetfile);
+ }
+
+ $this->config->saveConfig();
+
+ echo "Done";
+
+
+ echo "<pre>";
+ print_r($_SERVER);
+ print_r($_FILES);
+ print_r($_REQUEST);
+ print_r($pkgs);
+ echo "</pre>";
+ }
+
+
+ function mainBody($url)
+ {
+ echo "<h2>Packages</h2>";
+
+ $kos = getKnownOSList();
+
+ echo "<hr>";
+ echo "<h3>Add a Package</h3><br>";
+ echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"?action=addpackage\">";
+ echo "Name <input type=\"text\" name=\"pkgname\"><br>";
+ echo "Arch <select name=\"arch\">";
+ foreach($kos["pkgarch"] as $key => $val) {
+ echo "<option value=\"$key\">$val</option>";
+ }
+ echo "</select><br>";
+ echo "Type <select name=\"type\">";
+ foreach($kos["pkg"] as $key => $val) {
+ echo "<option value=\"$key\">$val</option>";
+ }
+ echo "</select><br>";
+ echo "Upload <input type=\"file\" name=\"uploadedfile\"><br>";
+ echo "From URL <input type=\"text\" name=\"fileurl\"><br>";
+ echo "<input type=\"submit\" name=\"add\" value=\"Add\">";
+ echo "</form>";
+ }
+}
+
+?>
error_log("call setstorage");
GLCASpageBuilder($this, "setStorage");
return;
+ case "freezerepo":
+ error_log("call freezerepo");
+ GLCASpageBuilder($this, "freezeRepo");
+ return;
case "scanrepo":
break;
}
$this->mainBody($url);
}
+ function freezeRepo($url)
+ {
+ $repo = $_REQUEST["repo"];
+
+
+ $myRep = new GLCASRepo($this->config);
+
+
+ error_log("called freeze repo on $repo");
+ $myRep->freezeRepo($repo);
+
+ global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+ header("Location: $BASE_URL/admin/");
+
+ }
+
function doRemoveRepo($url)
{
$repo = $_REQUEST["repo"];
$repotype = $rval["repotype"];
$prefix = $rval["prefix"];
$shorturl = $rval["shorturl"];
+ if(isset($rval["frozen"])) $frozen = $rval["frozen"];
+ else $frozen = false;
if($prefix == "") $prefix = "-";
if($shorturl == "") $shorturl = "-";
- echo "<tr><td>$desc</td><td>$repotype</td><td>$os</td><td>$version</td><td>$arch</td><td>$other</td><td>$prefix</td><td>$shorturl</td>";
+ if($frozen) {
+ $bgcol = "bgcolor=\"#bbbbff\"";
+ $frotext = "Unfreeze";
+ } else {
+ $frotext = "Freeze";
+ $bgcol = "";
+ }
+ echo "<tr $bgcol><td>$desc</td><td>$repotype</td><td>$os</td><td>$version</td><td>$arch</td><td>$other</td><td>$prefix</td><td>$shorturl</td>";
// get url
$browseurl = "$BASE_URL/repo/$rkey";
// Edit
echo "<a href=\"?action=editrepo&repo=$rkey\">Edit</a> ";
// update
- echo "<a href=\"?action=updaterepo&repo=$rkey\">Update</a> ";
+ if(!$frozen) echo "<a href=\"?action=updaterepo&repo=$rkey\">Update</a> ";
// freeze
- echo "<a href=\"?action=freezerepo&repo=$rkey\">Freeze</a> ";
+ echo "<a href=\"?action=freezerepo&repo=$rkey\">$frotext</a> ";
// deactivate
echo "<a href=\"?action=disablerepo&repo=$rkey\">Disable</a> ";
// clean
$kos["arch"]["amd64_2"] = "amd64";
+ // package archs
+ $kos["pkgarch"]["i386"] = "i386";
+ $kos["pkgarch"]["x86_64"] = "x86_64";
+ $kos["pkgarch"]["noarch"] = "noarch";
+
+ // package types
+ $kos["pkg"]["rpm"] = "RPM";
+ $kos["pkg"]["deb"] = "DEB";
+
return $kos;
}
foreach($uconf as $rkey => $repo) {
echo "Repo $rkey: ".$repo["desc"]."<br>";
+ if(isset($repo["frozen"])) {
+ error_log("repo froze set");
+ $repofrozen = $repo["frozen"];
+ } else {
+ error_log("repo froze not set");
+ $repofrozen = false;
+ }
if(!isset($repo["expiretime"])) {
echo " - Expire time not set, setting to 2 days by default<br>";
$uconf[$rkey]["expiretime"] = 2;
$this->config->setConfigVar("repodata", serialize($uconf));
$this->config->saveConfig();
} else if($repo["repotype"] == "YUM") {
- if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
- echo " - <font color=\"red\">Repo locked for update</font><br>";
-
- }
-
- // we still do this next bit, even if its locked because it may be a stray file
- echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
- error_log("checking $repostore/$rkey/repodata/repomd.xml");
- $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml");
- $maxtdiff = $repo["expiretime"] * 24 * 3600;
- if($tdiff > $maxtdiff) {
- echo " - <font color=\"green\">updating repo</font><br>";
- $this->updateRepo($rkey);
+ if($repofrozen) {
+ error_log("repo frozen");
+ echo " - <font color=\"blue\">Repo Frozen</font><br>";
} else {
- echo " - not updating repo<br>";
+ if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
+ echo " - <font color=\"red\">Repo locked for update</font><br>";
+
+ }
+
+ // we still do this next bit, even if its locked because it may be a stray file
+ echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
+ error_log("checking $repostore/$rkey/repodata/repomd.xml");
+ $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml");
+ $maxtdiff = $repo["expiretime"] * 24 * 3600;
+ if($tdiff > $maxtdiff) {
+ echo " - <font color=\"green\">updating repo</font><br>";
+ $this->updateRepo($rkey);
+ } else {
+ echo " - not updating repo<br>";
+ }
}
} else if($repo["repotype"] == "APT") {
- if(file_exists("$repostore/$rkey/update.lock")) {
- echo " - <font color=\"red\">Repo locaked for update</font><br>";
- }
- echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
- $maxtdiff = $repo["expiretime"] * 24 * 3600;
- // now we check for outdated release files
- $dh = opendir("$repostore/$rkey/dists/");
- $needsupdate = false;
- while(($fn = readdir($dh))!==false) {
- if($fn != "." && $fn != "..") {
- if(file_exists("$repostore/$rkey/dists/$fn/Release")) {
- $tdiff = time() - filemtime("$repostore/$rkey/dists/$fn/Release");
- if($tdiff > $maxtdiff) $needsupdate = true;
+ if($repofrozen) {
+ error_log("repo frozen");
+ echo " - <font color=\"blue\">Repo Frozen</font><br>";
+ } else {
+ if(file_exists("$repostore/$rkey/update.lock")) {
+ echo " - <font color=\"red\">Repo locaked for update</font><br>";
+ }
+ echo " - Expire time is ".$repo["expiretime"]." days, checking repo<br>";
+ $maxtdiff = $repo["expiretime"] * 24 * 3600;
+ // now we check for outdated release files
+ $dh = opendir("$repostore/$rkey/dists/");
+ $needsupdate = false;
+ while(($fn = readdir($dh))!==false) {
+ if($fn != "." && $fn != "..") {
+ if(file_exists("$repostore/$rkey/dists/$fn/Release")) {
+ $tdiff = time() - filemtime("$repostore/$rkey/dists/$fn/Release");
+ if($tdiff > $maxtdiff) $needsupdate = true;
+ }
}
}
- }
- if($needsupdate) {
- echo " - Spawn updater<br>";
- $this->updateRepo($rkey);
- } else {
- echo " - Up to date<br>";
+ if($needsupdate) {
+ echo " - Spawn updater<br>";
+ $this->updateRepo($rkey);
+ } else {
+ echo " - Up to date<br>";
+ }
}
}
}
return $glt;
}
+ function freezeRepo($rkey)
+ {
+
+ $uconf = $this->config->getConfigVar("repodata");
+ $repostore = $this->config->getConfigVar("storagelocation");
+
+ if($uconf !== false) {
+ $conf = unserialize($uconf);
+ foreach($conf as $key => $vla) {
+ if($key == $rkey) {
+ if(isset($conf["$rkey"]["frozen"])) {
+ if($conf["$rkey"]["frozen"]) {
+ $conf["$rkey"]["frozen"] = false;
+ error_log("Unfreeze repo");
+ } else {
+ $conf["$rkey"]["frozen"] = true;
+ error_log("freeze repo");
+ }
+ } else {
+ $conf["$rkey"]["frozen"] = true;
+ }
+ $nconf = serialize($conf);
+ error_log("freeze repo as $rkey");
+ $this->config->setConfigVar("repodata", $nconf);
+ $this->config->saveConfig();
+ }
+ }
+ }
+ }
+
function deleteRepo($rkey)
{
$uconf = $this->config->getConfigVar("repodata");
{
// we only do yum yet
$repod = $this->getRepo($repokey);
+ if(isset($repod["frozen"])) if($repod["frozen"]) {
+ error_log("in update repo for frozen repo, ignore update");
+ return;
+ }
error_log("in update repo");