#!/usr/bin/php query( kl_str_sql( "insert into revs (id, hash, author, time, message) values (!i, !s, !s, !t, !s)", $id, $hash, $author, $date, $msg)); } function update_source() { exec("git reset --hard", $out, $res); if ($res) { DBH::log("Command failed: ", implode("\n", $out)); return; } exec("git pull", $out, $res); if ($res) { DBH::log("Command failed: ", implode("\n", $out)); return; } 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 count(*) as c from builds"))) { $DB->query("create table builds(nr integer, chan varchar, version varchar, file varchar, modified timestamp, primary key(nr, chan))"); } for ($i=0; $iquery(kl_str_sql("select count(*) as c from builds where nr=!i and chan=!s", $build, $chan)); $row = $DB->fetchRow($res); if ($row["c"] === "0") { $DB->query(kl_str_sql("insert into builds (nr, chan, version, file, modified) ". "values (!i, !s, !s, !s, !t)", $build, $chan, $version, $file, $modified)); } } } } chdir(SITE_ROOT . "/lib/source"); update_source(); update_revs(); chdir(SITE_ROOT); update_builds(); /* * 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 */