summaryrefslogtreecommitdiffstats
path: root/non-mandatory.php
blob: f6f5129f52f7586463d24cd3461161c34665347d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
 * Mageia build-system quick status report script.
 *
 * @copyright Copyright (C) 2011 Mageia.Org
 *
 * @author Olivier Blin
 * @author Pascal Terjan
 * @author Romain d'Alverny
 * @author Michael Scherer
 *
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License aspublished by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * Shows packages uploaded on mandatory arches but failed on some other.
 * Packages that are not current are ignored.
*/

error_reporting(E_ALL);

require __DIR__ . '/conf.php';
require __DIR__ . '/lib.php';

// sanity checks
if (!is_dir($upload_dir)) {
    $msg = "$upload_dir does not exist on this system. Please check your config.";
    error_log($msg);
    die($msg);
}


function get_srpm_path($distrib, $media, $section, $package) {
    $mirror_base = "/distrib/bootstrap/distrib";
    return "$mirror_base/$distrib/SRPMS/$media/$section/$package.src.rpm";
}

$matches = get_submitted_packages($upload_dir, 30);

list($pkgs, $hosts, $build_count, $build_dates, $buildtime_total) = get_refined_packages_list($matches, null, null, $mandatory_arches);
list($stats, $users, $total, $pkgs) = build_stats($pkgs);

echo "<table>\n";
    foreach ($pkgs as $key => $p) {
        if (trim($p['package']) == '') {
            continue;
        }
	if ($p['type'] != 'uploaded') {
            continue;
	}
	$failed_arches = array_keys($p['status']['fail']);
	if (empty($failed_arches)) {
            continue;
        }
	if(!file_exists(get_srpm_path($p['version'], $p['media'], $p['section'], $p['package']))) {
            continue;
        }
	echo '<tr><td>' . $p['package'] . '</td>';
	$status_file = $upload_dir . '/failure/' . $p['path'] . '/log/status.log';
	$status_line = trim(preg_replace('/.*: /', '', file_get_contents($status_file)));
	if ($status_line == 'missing_dep') {
	    $install_deps_files = glob($upload_dir . '/failure/' . $p['path'] . '/log/' . $p['package'] . '/install_deps*.log');
	    $install_deps_file = $install_deps_files[count($install_deps_files)-1];
	    $f = fopen($install_deps_file, "r");
	    $dep_line = "";
	    while(($line = fgets($f, 4096)) !== false) {
		if(preg_match('/due to unsatisfied (.*)\)/', $line, $matches) == 1) {
		    $dep_line = $matches[1];
		}
	    }
	    fclose($f);
	    $link = '/uploads/failure/' . $p['path'] . '/log/' . $p['package'] . '/' . basename($install_deps_file);
	    echo '<td><a rel="nofollow" href="' . $link . '">' . $status_line . '</a> ' . $dep_line . '</td>';
	} elseif ($status_line == 'recreate_srpm_failure') {
	    $botcmd_files = glob($upload_dir . '/failure/' . $p['path'] . '/log/botcmd.*.log');
	    $link = '/uploads/failure/' . $p['path'] . '/log/' . basename($botcmd_files[0]);
	    echo '<td><a rel="nofollow" href="' . $link . '">' . $status_line . '</a></td>';
	} else {
	    $link = '/uploads/failure/' . $p['path'] . '/log/' . $p['package'];
	    echo '<td><a rel="nofollow" href="' . $link . '">' . $status_line . '</a></td>';
	}
	echo "</tr>\n";
    }
echo "</table>\n";
?>