Mageia build system status';
$robots = 'index,nofollow,nosnippet,noarchive';
if ($g_user) {
$title .= ' for ' . $g_user . "'s packages";
$robots = 'no' . $robots;
}
$tz = new DateTimeZone('UTC');
# Temporary until initial mirror is ready
chdir("data");
$nb_rpm = shell_exec('rpm -qp --qf "%{SOURCERPM}\n" /distrib/bootstrap/distrib/cauldron/i586/media/core/release/*.rpm | sort -u | tee src.txt | wc -l');
$nb_rpm_mga = shell_exec('grep mga src.txt | tee src.mga.txt | wc -l');
shell_exec('grep -v mga src.txt > src.mdv.txt');
#########################################
chdir($upload_dir);
$all_files = shell_exec("find \( -name '*.rpm' -o -name '*.src.rpm.info' -o -name '*.youri' -o -name '*.lock' -o -name '*.done' \) ! -ctime $max_modified");
preg_match_all("!^\./(\w+)/((\w+)/(\w+)/(\w+)/(\d+)\.(\w+)\.(\w+)\.(\d+))_?(.+)(\.src\.rpm(?:\.info)?|\.youri|\.lock|\.done)$!m", $all_files, $matches, PREG_SET_ORDER);
$pkgs = array();
foreach ($matches as $val) {
if ($_GET['user'] && ($_GET['user'] != $val[7])) {
continue;
}
$key = $val[6] . $val[7];
if (!is_array($pkgs[$key])) {
$pkgs[$key] = array(
'status' => array(),
'path' => $val[2],
'version' => $val[3],
'media' => $val[4],
'section' => $val[5],
'user' => $val[7],
'host' => $val[8],
'job' => $val[9]
);
}
$status = $val[1];
$data = $val[10];
$pkgs[$key]['status'][$status] = 1;
$ext = $val[11];
if ($ext == '.src.rpm.info') {
preg_match("!^(?:@\d+:)?(.*)!", $data, $name);
$pkgs[$key]['package'] = $name[1];
} else if ($ext == '.src') {
$pkgs[$key]['status']['src'] = 1;
} else if ($ext == '.youri') {
$pkgs[$key]['status']['youri'] = 1;
} else if ($ext == '.lock') {
// parse build bot from $data
$pkgs[$key]['status']['build'] = 1;
}
}
// sort by key in reverse order to have more recent pkgs first
krsort($pkgs);
/**
* @param array $pkg
*
* @return string
*/
function pkg_gettype($pkg) {
if (array_key_exists("rejected", $pkg["status"]))
return "rejected";
if (array_key_exists("youri", $pkg["status"])) {
if (array_key_exists("src", $pkg["status"]))
return "youri";
else
return "uploaded";
}
if (array_key_exists("failure", $pkg["status"]))
return "failure";
if (array_key_exists("done", $pkg["status"]))
return "partial";
if (array_key_exists("build", $pkg["status"]))
return "building";
if (array_key_exists("todo", $pkg["status"]))
return "todo";
return "unknown";
}
/**
* @param integer $num
*
* @return string
*/
function plural($num) {
if ($num > 1)
return "s";
}
/**
* @param string $key
*
* @return string
*/
function key2date($key) {
global $tz;
$date = DateTime::createFromFormat("YmdHis", $key+0, $tz);
$diff = time() - $date->getTimestamp();
if ($diff<60)
return $diff . " second" . plural($diff) . " ago";
$diff = round($diff/60);
if ($diff<60)
return $diff . " minute" . plural($diff) . " ago";
$diff = round($diff/60);
if ($diff<24)
return $diff . " hour" . plural($diff) . " ago";
$diff = round($diff/24);
return $diff . " day" . plural($diff) . " ago";
}
?>
%d src.rpm rebuilt for Mageia out of %d
(list of Mandriva packages still present).',
'data/src.mga.txt', $nb_rpm_mga,
'data/src.txt', $nb_rpm,
'data/src.mdv.txt'
);
#########################################
echo '',
'Submitted | User | Package | Target | Media | Status |
';
$s = '';
$tmpl = <<
%s |
%s |
%s |
%s |
%s/%s |
|
T;
$stats = array(
'uploaded' => 0,
'failure' => 0,
'todo' => 0,
'building' => 0,
'partial' => 0,
'built' => 0,
);
$total = count($pkgs);
foreach ($pkgs as $key => $p) {
$p['type'] = pkg_gettype($p);
$stats[$p['type']] += 1;
$s .= sprintf($tmpl,
$p['type'],
key2date($key),
$p['user'], $p['user'],
$p['package'],
$p['version'],
$p['media'], $p['section']
);
$typelink = '';
if ($p['type'] == 'failure') {
$typelink = '/uploads/' . $p['type'] . '/' . $p['path'];
} elseif ($p['type'] == 'rejected') {
$typelink = '/uploads/' . $p['type'] . '/' . $p['path'] . '.youri';
}
$s .= '';
$s .= ($typelink != '') ?
sprintf('%s', $typelink, $p['type']) :
$p['type'];
$s .= ' | ';
}
echo $s, '
';
$s = 'Status | Count | % |
';
foreach ($stats as $k => $v) {
$s .= sprintf('%s | %d | %d%% |
',
$k, $v, round($v/$total*100));
}
$s .= '
';
echo $s;
?>