Starting work on the build site

This commit is contained in:
Latif Khalifa
2012-02-10 19:01:51 +01:00
parent 36882eb5e8
commit 7167240c3b
2 changed files with 64 additions and 31 deletions

View File

@@ -8,16 +8,16 @@ header("Content-Type: text/plain");
$chan = "SingularityAlpha";
if (isset($_GET["chan"])) {
$chan = preg_replace("%[^\\w_-]%i", "", $_GET["chan"]);
$chan = preg_replace("%[^\\w_-]%i", "", $_GET["chan"]);
}
$files = glob($chan . "_*.exe");
if (count($files) === 0) {
header("HTTP/1.0 404 Not Found");
header("Content-Type: text/plain");
print "Requested channel was not found";
die();
header("HTTP/1.0 404 Not Found");
header("Content-Type: text/plain");
print "Requested channel was not found";
die();
}
$files = array_reverse($files);
@@ -26,5 +26,14 @@ $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$latest = urlencode($files[0]);
header("Location: http://${host}${uri}/${latest}");
?>
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/

View File

@@ -9,7 +9,7 @@ if (PHP_SAPI != "cli") {
// create table revs(id integer, hash varchar, author varchar, time timestamp, message text, diff text, primary key(id));
// create index hash_index on revs(hash);
define("SITE_ROOT", dirname(__file__) . "/..");
define("SITE_ROOT", realpath(dirname(__file__) . "/.."));
require_once SITE_ROOT . "/lib/init.php";
function import_rev($id, $hash)
@@ -40,7 +40,7 @@ function import_rev($id, $hash)
$DB->query(
kl_str_sql(
"Insert into revs (id, hash, author, time, message) values (!i, !s, !s, !t, !s)",
"insert into revs (id, hash, author, time, message) values (!i, !s, !s, !t, !s)",
$id, $hash, $author, $date, $msg));
}
@@ -62,31 +62,55 @@ function update_source()
print implode("\n", $out) . "\n";
}
function update_revs()
{
global $DB;
$revsStr = rtrim(`git rev-list HEAD | tac`);
$revs = explode("\n", $revsStr);
$nrRevs = count($revs);
$latest = 0;
$res = $DB->query("select max(id) as id from revs");
if ($row = $DB->fetchRow($res)) {
if ($DB->loadFromDbRow($dbLatest, $res, $row)) {
$latest = (int)$dbLatest->id;
}
}
print "Found $nrRevs revisions\n";
print "Latest revision in the database: $latest\n";
if ($latest < $nrRevs) {
for ($rev = $latest + 1; $rev <= $nrRevs; $rev++) {
import_rev($rev, $revs[$rev - 1]);
}
}
}
function update_builds()
{
global $DB;
$builds = glob(SITE_ROOT . "/*_*_Setup.exe");
$latest = 0;
// check if table exists
if (!($res = $DB->query("select max(id) as id from builds"))) {
$DB->query("create table builds(nr integer, channel varchar, file varchar, primary key(nr, channel)");
}
var_dump($builds);
}
chdir(SITE_ROOT . "/lib/source");
// update_source();
// update_revs();
# update_source();
$revsStr = rtrim(`git rev-list HEAD | tac`);
$revs = explode("\n", $revsStr);
$nrRevs = count($revs);
$latest = 0;
$res = $DB->query("select max(id) as id from revs");
if ($row = $DB->fetchRow($res)) {
if ($DB->loadFromDbRow($dbLatest, $res, $row)) {
$latest = (int)$dbLatest->id;
}
}
print "Found $nrRevs revisions\n";
print "Latest revision in the database: $latest\n";
if ($latest < $nrRevs) {
for ($rev = $latest + 1; $rev <= $nrRevs; $rev++) {
import_rev($rev, $revs[$rev - 1]);
}
}
chdir(SITE_ROOT);
update_builds();
/*
* Local variables: