aboutsummaryrefslogtreecommitdiffstats
path: root/Report/Box/04_CauldronPackages.php
blob: c275f945397b0cc538eef8b9d4a4c874a5cf682a (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
 * Cauldron packages reporting box.
 *
 * PHP version 5
 *
 * @category Dashboard
 * @package  Buildsystem
 * @author   Romain d'Alverny <rda@mageia.org>
 * @license  MIT License, see LICENSE.txt
 * @link     http://svnweb.mageia.org/svn/soft/dashboard/
*/

/**
*/
class Report_Box_CauldronPackages extends Report_Box
{
    /**
    */
    var $title = "Cauldron Compiled Packages";
    
    /**
    */
    function _get_var_definitions() {
        return array(
            'size'     => '%5.1fGB',
            'count-i586-rpms' => '%d packages (i586)',
            'count-x86_64-rpms' => '%d packages (x86_64)',
            'broken-pkgs'  => array('l' => '%d have broken dependencies', 't' => '<=0'),
            'obs-bin'      => array('l' => '%d obsolete binaries', 't' => '<=0'),
            'obs-source'   => array('l' => '%d obsolete sources', 't' => '<=0'),
            'mis-source'   => array('l' => '%d missing sources', 't' => '<=0'),
            'missing-deps' => array('l' => '%d missing dependencies', 't' => '<=0')
        );
        /*
        ?GB
        ? packages
        Broken hdlist (i586/nonfree)
        Signatures: 23 missing (i586/nonfree, i586/tainted)
        Dependencies: 32 missing, 2 circular
        15 packages are not in sync with their source
        432 missing/broken signatures
        213 bugs
        @todo: per package test suite? rpmlint, other
        @todo: src => 32/64/arm
        Basesystem size: 437MB, w/o suggests: 163MB
        view repository, detailed report
        
        */
    }
    
    /**
    */
    function _get_links()
    {
        return 'View <a href="http://check.mageia.org/">youri-check report</a>';
    }


    /**
     * Uses youri-check report.
    */
    function _fetch_03_missing_dependencies()
    {
        $txt = file('http://check.mageia.org/missing.txt');
        array_shift($txt);
        array_shift($txt);
        array_shift($txt);

        $ret = array(
            'obs-source' => 0,
            'obs-bin'    => 0,
            'mis-source' => 0
        );
        foreach ($txt as $l)
        {
            $l = explode("\t", $l);
            if (!isset($l[3]) || !isset($l[5]))
                continue;

            $arch = trim($l[3]);
            $reason = substr(trim($l[5]), 0, 14);
            if ($arch == 'src') { //&& $l[5], 'Obsolete source')) {
                $ret['obs-source'] += 1;
            } elseif ($reason == 'Missing source') {
                $ret['mis-source'] += 1;
            } elseif ($reason == 'Obsolete binar') {
                $ret['obs-bin'] += 1;
            }
        }
        return $ret;
    }
    
    /**
     * Uses youri-check report.
    */
    function _fetch_02_broken_dependencies()
    {
        $txt = file('http://check.mageia.org/dependencies.txt');
        array_shift($txt);
        array_shift($txt);
        array_shift($txt);

        $package = null;

        $reports = array();
        foreach ($txt as $l)
        {
            $l = explode("\t", $l);
            if (isset($l[0]) && isset($l[4])) {
                $packages[] = trim($l[0]);
                $missing[] = trim($l[4]);
            }
        }

        $packages = array_unique($packages);
        sort($packages);
        $missing = array_unique($missing);
        sort($missing);
        
        return array(
            'broken-pkgs' => count($packages) - 1,
            'missing-deps' => count($missing) - 1
        );
    }

    /**
     * Uses sophie.zarb.org
    */
    function _fetch_01_packages()
    {
        $count_i586 = substr_count(
            file_get_contents('http://sophie.zarb.org/distrib/Mageia/cauldron/i586/rpms?json=1'),
            'pkgid'
        );
        $count_x86_64 = substr_count(
            file_get_contents('http://sophie.zarb.org/distrib/Mageia/cauldron/x86_64/rpms?json=1'),
            'pkgid'
        );
        
        return array(
            'count-i586-rpms' => $count_i586,
            'count-x86_64-rpms' => $count_x86_64
        );
    }
}