Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/buildmaster/build-list.php
blob: 4b67cfc564798564d6d098075894f5a6af9157be (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?php
require_once "../init.php";

require_once BASE . "/lib/helper.php";
require_once BASE . "/lib/mysql.php";
require_once BASE . "/lib/style.php";

if (isset($_GET["show"]))
  $to_show=$_GET["show"];
else
  $to_show="all";

$to_shows = array(
  "all" => "",
  "broken" => " WHERE (`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)",
  "next" => " WHERE (`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))"
);

$columns = array(
  "priority" => array(
    "label" => "Priority",
    "mysql_name" => "priority",
    "mysql_query" => "`ba_q`.`priority`",
    "sort" => "priority",
    "title" => "priority"
  ),
  "deps" => array(
    "label" => "Deps",
    "mysql_name" => "dependencies_pending",
    "mysql_query" => "IFNULL(`rd_q`.`run_dependencies_pending`,0)+IFNULL(`md_q`.`make_dependencies_pending`,0)",
    "sort" => "deps",
    "title" => "number of dependencies on the build-list"
  ),
  "arch" => array(
    "label" => "Arch",
    "mysql_name" => "arch",
    "mysql_query" => "`ba_q`.`arch`",
    "sort" => "arch",
    "title" => "arch"
  ),
  "pkgbase" => array(
    "label" => "Package",
    "mysql_name" => "pkgbase_print",
    "mysql_query" =>
      "CONCAT(" .
        "\"<a href=\\\"/buildmaster/dependencies.php?b=\"," .
        "`ba_q`.`pkgbase`," .
        "\"&r=build-list\\\">\"," .
        "`ba_q`.`pkgbase`," .
        "\"</a>\"" .
      ")",
    "sort" => "pkgbase",
    "title" => "package"
  ),
  "git_rev" => array(
    "label" => "Git Revision",
    "mysql_name" => "git_revision_print",
    "mysql_query" =>
      "IF(`ba_q`.`uses_upstream`," .
        "CONCAT(" .
          "\"<a href=\\\"https://git.archlinux.org/svntogit/\"," .
          "`ba_q`.`git_repository`," .
          "\".git/tree/\"," .
          "`ba_q`.`pkgbase`," .
          "\"/repos/\"," .
          "`ba_q`.`package_repository`," .
          "\"-\"," .
          "IF(`ba_q`.`arch`=\"any\",\"any\",\"x86_64\")," .
          "\"?id=\"," .
          "`ba_q`.`git_revision`," .
          "\"\\\">\"," .
          "`ba_q`.`git_revision`," .
          "\"</a>\"" .
        ")," .
        "`ba_q`.`git_revision`" .
      ")",
    "sort" => "git_rev",
    "title" => "revision hash of upstream git repository"
  ),
  "mod_git_rev" => array(
    "label" => "Modification Git Revision",
    "mysql_name" => "mod_git_revision_print",
    "mysql_query" =>
      "IF(`ba_q`.`uses_modification`," .
        "CONCAT(" .
          "\"<a href=\\\"" .
          git_url(
            "packages",
            "tree",
            "\",`ba_q`.`mod_git_revision`,\"",
            "\",`ba_q`.`package_repository`,\"/\",`ba_q`.`pkgbase`,\"",
            null,
            true
          ) .
          "\\\">\"," .
          "`ba_q`.`mod_git_revision`," .
          "\"</a>\"" .
        ")," .
        "`ba_q`.`mod_git_revision`" .
      ")" ,
    "sort" => "mod_git_rev",
    "title" => "revision hash of modification git repository"
  ),
  "repo" => array(
    "label" => "Repository",
    "mysql_name" => "package_repository",
    "mysql_query" => "`ba_q`.`package_repository`",
    "sort" => "repo",
    "title" => "package repository"
  ),
  "commit_time" => array(
    "label" => "Commit Time",
    "mysql_name" => "commit_time",
    "mysql_query" => "`ba_q`.`commit_time`",
    "sort" => "commit_time",
    "title" => "commit time of the source"
  ),
  "trials" => array(
    "label" => "Compilations",
    "mysql_name" => "trials",
    "mysql_query" => "IFNULL(`t_q`.`trials`,0)",
    "sort" => "trials",
    "title" => "number of compilations"
  ),
  "loops" => array(
    "label" => "Loops",
    "mysql_name" => "loops",
    "mysql_query" => "IFNULL(`l_q`.`loops`,0)",
    "sort" => "loops",
    "title" => "number of loops"
  ),
  "failure" => array(
    "label" => "Failures",
    "mysql_name" => "fail_reasons",
    "mysql_query" => "`fr_q`.`fail_reasons`",
    "sort" => "failure",
    "title" => "reason of build failure"
  ),
  "blocked" => array(
    "label" => "Blocked",
    "mysql_name" => "is_blocked",
    "mysql_query" => "`ba_q`.`is_blocked`",
    "sort" => "blocked",
    "title" => "block reason"
  ),
  "build_slave" => array(
    "label" => "Build Slave",
    "mysql_name" => "build_slave",
    "mysql_query" => "`bs_q`.`build_slave`",
    "sort" => "build_slave",
    "title" => "whom it is handed out to"
  )
);

$match = $to_shows[$to_show];
if (!isset($_GET["sort"]))
  $_GET["sort"]="trials";

if (substr($_GET["sort"],0,1) == "-") {
  $direction = " DESC";
  $sort = substr($_GET["sort"],1);
} else {
  $direction = " ASC";
  $sort = $_GET["sort"];
}

if (isset($columns[$sort]))
  $order = "IFNULL(" . $columns[$sort]["mysql_name"] . ",0) " . $direction . ",";
else
  $order = "";

function combine_fields($cln) {
  return $cln["mysql_query"] . " AS `" . $cln["mysql_name"] . "`";
}

$result = mysql_run_query(
  "SELECT " .
  implode(",",array_map("combine_fields",$columns)) .
  " FROM" .
  " (" .
    "SELECT DISTINCT " .
    "`build_assignments`.`id`," .
    "`build_assignments`.`is_blocked`," .
    "`build_assignments`.`is_broken`," .
    "`build_assignments`.`priority`," .
    "`package_sources`.`pkgbase`," .
    "`package_sources`.`git_revision`," .
    "`package_sources`.`mod_git_revision`," .
    "`package_sources`.`uses_upstream`," .
    "`package_sources`.`uses_modification`," .
    "`package_sources`.`commit_time`," .
    "`upstream_repositories`.`name` AS `package_repository`," .
    "`git_repositories`.`name` AS `git_repository`," .
    "`architectures`.`name` AS `arch`" .
    " FROM `build_assignments`" .
    " JOIN `architectures` ON `build_assignments`.`architecture` = `architectures`.`id`" .
    " JOIN `package_sources` ON `build_assignments`.`package_source` = `package_sources`.`id`" .
    " JOIN `upstream_repositories` ON `package_sources`.`upstream_package_repository` = `upstream_repositories`.`id`" .
    " JOIN `git_repositories` ON `upstream_repositories`.`git_repository`=`git_repositories`.`id`" .
    " JOIN `binary_packages` ON `binary_packages`.`build_assignment` = `build_assignments`.`id`" .
    " JOIN `binary_packages_in_repositories` ON `binary_packages`.`id` = `binary_packages_in_repositories`.`package`" .
    " JOIN `repositories` ON `binary_packages_in_repositories`.`repository` = `repositories`.`id`" .
    " WHERE `repositories`.`name`=\"build-list\"" .
  ") AS `ba_q`".
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`dependent_bp`.`build_assignment`," .
    "COUNT(DISTINCT `dependency_bp`.`build_assignment`) AS `run_dependencies_pending`" .
    " FROM `binary_packages` AS `dependent_bp`" .
    " JOIN `dependencies` ON `dependencies`.`dependent` = `dependent_bp`.`id`" .
    " JOIN `dependency_types` ON `dependencies`.`dependency_type` = `dependency_types`.`id`" .
    " JOIN `install_target_providers` ON `install_target_providers`.`install_target` = `dependencies`.`depending_on`" .
    " JOIN `binary_packages` AS `dependency_bp` ON `dependency_bp`.`id` = `install_target_providers`.`package`" .
    " JOIN `binary_packages_in_repositories` ON `dependency_bp`.`id` = `binary_packages_in_repositories`.`package`" .
    " JOIN `repositories` ON `binary_packages_in_repositories`.`repository` = `repositories`.`id`" .
    " WHERE `dependency_bp`.`build_assignment` != `dependent_bp`.`build_assignment`" .
    " AND `dependency_types`.`relevant_for_building`" .
    " AND `dependency_types`.`relevant_for_binary_packages`" .
    " AND `repositories`.`name`=\"build-list\"" .
    " GROUP BY `dependent_bp`.`build_assignment`" .
  ") AS `rd_q` ON `rd_q`.`build_assignment`=`ba_q`.`id`" .
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`dependent_bp`.`build_assignment`," .
    "COUNT(DISTINCT `dependencies`.`id`) AS `make_dependencies_pending`" .
    " FROM `binary_packages` AS `dependent_bp`" .
    " JOIN `dependencies` ON `dependencies`.`dependent` = `dependent_bp`.`id`" .
    " JOIN `dependency_types` ON `dependencies`.`dependency_type` = `dependency_types`.`id`" .
    " WHERE NOT EXISTS(" .
      "SELECT 1 FROM `install_target_providers`" .
      " JOIN `binary_packages` AS `dependency_bp` ON `dependency_bp`.`id` = `install_target_providers`.`package`" .
      " JOIN `binary_packages_in_repositories` ON `dependency_bp`.`id` = `binary_packages_in_repositories`.`package`" .
      " JOIN `repositories` ON `binary_packages_in_repositories`.`repository` = `repositories`.`id`" .
      " WHERE `install_target_providers`.`install_target` = `dependencies`.`depending_on`" .
      " AND `repositories`.`is_on_master_mirror`" .
    ")" .
    " AND `dependency_types`.`relevant_for_building`" .
    " AND NOT `dependency_types`.`relevant_for_binary_packages`" .
    " GROUP BY `dependent_bp`.`build_assignment`" .
  ") AS `md_q` ON `md_q`.`build_assignment`=`ba_q`.`id`" .
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`build_dependency_loops`.`build_assignment`," .
    "COUNT(1) AS `loops`" .
    " FROM `build_dependency_loops`" .
    " GROUP BY `build_dependency_loops`.`build_assignment`" .
  ") AS `l_q` ON `l_q`.`build_assignment`=`ba_q`.`id`" .
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`rfb`.`build_assignment`," .
    "GROUP_CONCAT(" .
      "CONCAT(" .
        "\"<a href=\\\"https://buildmaster.archlinux32.org/build-logs/error/\"," .
        "`rfb`.`log_file`," .
        "\"\\\">\"," .
        "`fail_reasons`.`name`," .
        "\"</a>\"" .
      ")" .
      " ORDER BY `fail_reasons`.`name`" .
    ") AS `fail_reasons`" .
    " FROM (" .
      "SELECT " .
      "`failed_builds`.`build_assignment`," .
      "`failed_builds`.`reason`," .
      "MAX(`failed_builds`.`date`) AS `max_date`" .
      " FROM `failed_builds`" .
      " GROUP BY `failed_builds`.`build_assignment`,`failed_builds`.`reason`" .
    ") AS `cfb`" .
    " JOIN" .
    " (" .
      "SELECT DISTINCT " .
      "`failed_builds`.*" .
      " FROM `failed_builds`" .
      " GROUP BY `failed_builds`.`build_assignment`,`failed_builds`.`reason`,`failed_builds`.`date`" .
    ") AS `rfb`" .
    " ON `cfb`.`build_assignment`=`rfb`.`build_assignment`" .
    " AND `cfb`.`reason`=`rfb`.`reason`" .
    " AND `cfb`.`max_date`=`rfb`.`date`" .
    " JOIN `fail_reasons` ON `rfb`.`reason`=`fail_reasons`.`id`" .
    " GROUP BY `rfb`.`build_assignment`" .
  ") AS `fr_q` ON `fr_q`.`build_assignment`=`ba_q`.`id`" .
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`failed_builds`.`build_assignment`," .
    "COUNT(`failed_builds`.`id`) AS `trials`" .
    " FROM `failed_builds`" .
    " GROUP BY `failed_builds`.`build_assignment`" .
  ") AS `t_q` ON `t_q`.`build_assignment`=`ba_q`.`id`" .
  " LEFT JOIN" .
  " (" .
    "SELECT " .
    "`build_slaves`.`currently_building`," .
    "GROUP_CONCAT(`build_slaves`.`name`) AS `build_slave`" .
    " FROM `build_slaves`" .
    " GROUP BY `build_slaves`.`currently_building`" .
  ") AS `bs_q` ON `bs_q`.`currently_building`=`ba_q`.`id`" .
  $match .
  " ORDER BY " . $order . "`trials` " . $direction . ",`dependencies_pending` " . $direction . ",`is_blocked` " . $direction . ",`pkgbase` " . $direction
);

$count = 0;

while($row = $result->fetch_assoc()) {

  foreach ($row as $name => $value) {
    if (!isset($row[$name]))
      $rows[$count][$name] = "&nbsp;";
    elseif ($name == "is_blocked")
      $rows[$count][$name] = preg_replace(
        array (
          "/FS32#(\\d+)/",
          "/FS#(\\d+)/"
        ),
        array (
          "<a href=\"https://bugs.archlinux32.org/index.php?do=details&task_id=$1\">$0</a>",
          "<a href=\"https://bugs.archlinux.org/task/$1\">$0</a>"
        ),
        $value
      );
    else
      $rows[$count][$name] = $value;
  }

  $count++;
}

print_header("List of " . strtoupper(substr($to_show,0,1)) . substr($to_show,1) . " Package Builds");

print "<a href=\"https://buildmaster.archlinux32.org/build-logs/\">build logs</a>\n";

foreach ($to_shows as $link => $dummy) {
  print "-\n";
  if ($link != $to_show)
    print "<a href=\"?show=" . $link . "\">";
  print $link . " package builds";
  if ($link != $to_show)
    print "</a>";
  print "\n";
}

if ($count > 0) {

?>
      <div id="pkglist-results" class="box">
        <table class="results">
          <thead>
            <tr>
<?php

foreach ($columns as $column) {

  print "            <th>\n";
  print "              <a href=\"?show=" . $to_show . "&sort=";
  if ($column["sort"] == $_GET["sort"])
    print "-";
  print $column["sort"] . "\" ";
  print "title=\"Sort build assignments by " . $column["title"] . "\">\n";
  print "                " . $column["label"] . "\n";
  print "              </a>\n";
  print "            </th>\n";

}

?>
            </tr>
          </thead>
          <tbody>
<?php

$oddity = "odd";

foreach($rows as $row) {

  print "            <tr class=\"" . $oddity . "\">\n";

  foreach ($columns as $column) {

    print "              <td>\n";
    print "                " . $row[$column["mysql_name"]] . "\n";
    print "              </td>\n";

  }
  print "            </tr>\n";

  if ($oddity == "odd" )
    $oddity = "even";
  else
    $oddity = "odd";

}

?>
          </tbody>
        </table>
      </div>
<?php
}

print_footer();