diff options
Diffstat (limited to 'buildmaster')
-rw-r--r-- | buildmaster/blacklist.php | 63 | ||||
-rw-r--r-- | buildmaster/build-list-links.php | 231 | ||||
-rw-r--r-- | buildmaster/build-list.php | 583 | ||||
-rw-r--r-- | buildmaster/build-slaves.php | 216 | ||||
-rw-r--r-- | buildmaster/deletion-links.php | 246 | ||||
-rw-r--r-- | buildmaster/dependencies.php | 190 | ||||
-rw-r--r-- | buildmaster/gpg-keys.php | 48 | ||||
-rw-r--r-- | buildmaster/index.php | 80 | ||||
-rw-r--r-- | buildmaster/log.php | 93 | ||||
-rw-r--r-- | buildmaster/mysql-issues.php | 183 | ||||
-rw-r--r-- | buildmaster/statistics.php | 200 | ||||
-rw-r--r-- | buildmaster/status.php | 144 | ||||
-rw-r--r-- | buildmaster/to-delete.php | 77 | ||||
-rw-r--r-- | buildmaster/todos.php | 97 |
14 files changed, 2451 insertions, 0 deletions
diff --git a/buildmaster/blacklist.php b/buildmaster/blacklist.php new file mode 100644 index 0000000..24247e8 --- /dev/null +++ b/buildmaster/blacklist.php @@ -0,0 +1,63 @@ +<?php +require_once "../init.php"; + +require_once BASE . "/lib/mysql.php"; + + $result = mysql_run_query( + "SELECT DISTINCT" . + " GROUP_CONCAT(`architectures`.`name`) AS `architectures`," . + "`package_sources`.`pkgbase`," . + "`build_assignments`.`is_black_listed` " . + "FROM `build_assignments` " . + mysql_join_build_assignments_architectures() . + mysql_join_build_assignments_package_sources() . + "WHERE `build_assignments`.`is_black_listed` IS NOT NULL " . + "GROUP BY CONCAT(to_base64(`package_sources`.`pkgbase`),\" - \",to_base64(`build_assignments`.`is_black_listed`)) " . + "ORDER BY `package_sources`.`pkgbase`" + ); + +?> +<html> + <head> + <title>Blacklisted packages</title> + <link rel="stylesheet" type="text/css" href="/static/style.css"> + </head> + <body> +<?php show_warning_on_offline_slave(); ?> + <table> + <tr> + <th>architectures</th> + <th>package</th> + <th>reason</th> + </tr> +<?php + +if ($result -> num_rows > 0) { + while($row = $result->fetch_assoc()) { + print " <tr>\n"; + print " <td>"; + print $row["architectures"]; + print "</td>\n"; + print " <td>"; + print $row["pkgbase"]; + print "</td>\n"; + print " <td>"; + print 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>" + ), + $row["is_black_listed"] + ); + print "</td>\n"; + print " </tr>\n"; + } +} +?> + </table> + </body> +</html> diff --git a/buildmaster/build-list-links.php b/buildmaster/build-list-links.php new file mode 100644 index 0000000..e3d2779 --- /dev/null +++ b/buildmaster/build-list-links.php @@ -0,0 +1,231 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + +$edges = ""; +$knots = ""; + +if (!isset($_GET["raw"])) + $limit = " LIMIT 150"; + +$query = + "CREATE TEMPORARY TABLE `ba` (" . + "`id` BIGINT, " . + "`group` VARCHAR(256), " . + "`color` VARCHAR(7), " . + "UNIQUE KEY `id` (`id`), " . + "KEY `group` (`group`)" . + ")"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "INSERT IGNORE INTO `ba` (`id`,`color`)" . + " SELECT DISTINCT" . + " `build_assignments`.`id`," . + "IF(`build_assignments`.`is_broken`,\"#ff0000\",IF(`build_assignments`.`is_blocked` IS NULL,\"#000000\",\"#800000\"))" . + " FROM `binary_packages_in_repositories`" . + mysql_join_binary_packages_in_repositories_binary_packages() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_binary_packages_build_assignments() . + " WHERE `repositories`.`name`=\"build-list\"" . + $limit; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "CREATE TEMPORARY TABLE `ba_copy` (" . + "`id` BIGINT, " . + "`group` VARCHAR(256), " . + "`color` VARCHAR(7), " . + "UNIQUE KEY `id` (`id`)" . + ")"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "INSERT IGNORE INTO `ba_copy` (`id`,`color`)" . + " SELECT `ba`.`id`,`ba`.`color`" . + " FROM `ba`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "CREATE TEMPORARY TABLE `ba_links` (" . + "`from` BIGINT, " . + "`to` BIGINT, " . + "`type` MEDIUMINT, " . + "UNIQUE KEY `content` (`from`,`to`,`type`)" . + ")"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "INSERT IGNORE INTO `ba_links` (`from`,`to`,`type`)" . + "SELECT `i_bp`.`build_assignment`," . + "`d_bp`.`build_assignment`," . + "`dependencies`.`dependency_type`" . + " FROM `ba`" . + mysql_join_build_assignments_binary_packages('ba','d_bp') . + mysql_join_binary_packages_dependencies('d_bp') . + mysql_join_dependencies_install_target_providers() . + mysql_join_install_target_providers_binary_packages('','i_bp') . + " JOIN `ba_copy` ON `i_bp`.`build_assignment`=`ba_copy`.`id`" . + " WHERE `d_bp`.`build_assignment`!=`i_bp`.`build_assignment`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "CREATE TEMPORARY TABLE `ba_links_copy` (" . + "`from` BIGINT, " . + "`to` BIGINT, " . + "`type` MEDIUMINT, " . + "UNIQUE KEY `content` (`from`,`to`,`type`)" . + ")"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "INSERT IGNORE INTO `ba_links_copy` (`from`,`to`,`type`)" . + " SELECT `ba_links`.`from`,`ba_links`.`to`,`ba_links`.`type` FROM `ba_links`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "UPDATE `ba`" . + " JOIN (" . + "SELECT" . + " `ba_copy`.`id`," . + "SHA2(" . + "GROUP_CONCAT(CONCAT(" . + "IFNULL(`ba_copy`.`color`,\"0\"),\":\"," . + "IFNULL(`ba_links`.`to`,\"0\"),\":\"," . + "IFNULL(`ba_links`.`type`,\"0\"),\":\"," . + "IFNULL(`ba_links_copy`.`from`,\"0\"),\":\"," . + "IFNULL(`ba_links_copy`.`type`,\"0\")" . + "))" . + ",256) AS `hash`" . + " FROM `ba_copy`" . + " LEFT JOIN `ba_links` ON `ba_links`.`from`=`ba_copy`.`id`" . + " LEFT JOIN `ba_links_copy` ON `ba_links_copy`.`to`=`ba_copy`.`id`" . + " GROUP BY `ba_copy`.`id`" . + ") AS `grouped_ba` ON `grouped_ba`.`id`=`ba`.`id`" . + " SET `ba`.`group`=`grouped_ba`.`hash`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "UPDATE `ba_copy`" . + " JOIN `ba` ON `ba`.`id`=`ba_copy`.`id`" . + " SET `ba_copy`.`group`=`ba`.`group`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +mysql_run_query($query); + +$query = + "SELECT MAX(`build_assignments`.`id`) AS `id`," . + "GROUP_CONCAT(CONCAT(" . + "`architectures`.`name`,\"/\"," . + "`package_sources`.`pkgbase`" . + ") SEPARATOR \",\n\") AS `name`," . + " `ba`.`color`" . + " FROM `ba`" . + " JOIN `build_assignments` ON `ba`.`id`=`build_assignments`.`id`" . + mysql_join_build_assignments_package_sources() . + mysql_join_build_assignments_architectures() . + " GROUP BY `ba`.`group`"; +if (isset($_GET["raw"])) + print $query . ";\n"; +$result = mysql_run_query($query); + +while ($row = $result->fetch_assoc()) + $knots .= + "\"ba" . + $row["id"] . + "\" [label = \"" . + $row["name"] . + "\", + fontcolor = \"" . + $row["color"] . + "\"];\n"; + +$query = + "SELECT MAX(`ba_links`.`to`) AS `dependent`," . + "`dependency_types`.`name` AS `dep_type`," . + "MAX(`ba_links`.`from`) AS `depending_on`" . + " FROM `ba_links`" . + " JOIN `dependency_types` ON `ba_links`.`type`=`dependency_types`.`id`" . + " JOIN `ba` ON `ba_links`.`from`=`ba`.`id`" . + " JOIN `ba_copy` ON `ba_links`.`to`=`ba_copy`.`id`" . + " GROUP BY CONCAT(`ba`.`group`,\"-\",`ba_copy`.`group`)"; +if (isset($_GET["raw"])) + print $query . ";\n"; +$result = mysql_run_query($query); + +while ($row = $result->fetch_assoc()) { + $edges .= + "\"ba" . + $row["depending_on"] . + "\" -> \"ba" . + $row["dependent"] . + "\" [color = \""; + switch ($row["dep_type"]) { + case "run": + $edges .= "#000000"; + break; + case "make": + $edges .= "#0000ff"; + break; + case "link": + $edges .= "#008000"; + break; + case "check": + $edges .= "#000080"; + break; + default: + $edges .= "#ff00ff"; + } + $edges .= + "#000080"; + $edges .= + "\"];\n"; +} + +if (isset($_GET["raw"])) { + print + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n"; +} else { + $input_file = tempnam("/tmp", "build-list-links."); + + $handle = fopen($input_file,"w"); + fwrite($handle, + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n" + ); + fclose($handle); + + header ("Content-type: image/png"); + passthru( + "timeout 30 dot -Tpng -o/dev/stdout " . $input_file + ); + + unlink($input_file); +} diff --git a/buildmaster/build-list.php b/buildmaster/build-list.php new file mode 100644 index 0000000..79313e4 --- /dev/null +++ b/buildmaster/build-list.php @@ -0,0 +1,583 @@ +<?php +require_once "../init.php"; + +require_once BASE . "/lib/helper.php"; +require_once BASE . "/lib/mysql.php"; +require_once BASE . "/lib/style.php"; + +$filter = " WHERE "; + +if (isset($_GET["invq"])) + $filter .= "NOT "; + +if (isset($_GET["q"])) + $filter .= "`ba_q`.`pkgbase` LIKE from_base64(\"".base64_encode("%".$_GET["q"]."%")."\")"; +else + $filter .= "1"; + +$multi_select_search_criteria = array( + "arch" => array( + "name" => "arch", + "title" => "CPU architecture", + "label" => "Arch", + "source_table" => "architectures", + "query_pre" => "`ba_q`.`arch` IN (", + "query_in_pre" => "\"", + "query_in_post" => "\",", + "query_post" => "\"\")", + "values" => array() + ), + "repo" => array( + "name" => "repo", + "title" => "Repository", + "label" => "Repo", + "source_table" => "upstream_repositories", + "query_pre" => "`ba_q`.`package_repository` IN (", + "query_in_pre" => "\"", + "query_in_post" => "\",", + "query_post" => "\"\")", + "values" => array() + ), + "failures" => array( + "name" => "failures", + "title" => "Fail Reasons", + "label" => "Failures", + "source_table" => "fail_reasons", + "query_pre" => "(0", + "query_in_pre" => " OR `fr_q`.`fail_reasons_raw` LIKE \"%,", + "query_in_post" => ",%\"", + "query_post" => ")", + "values" => array() + ) +); + +foreach ( $multi_select_search_criteria as $criterium => $content ) { + $result = mysql_run_query( + "SELECT `name` FROM `" . $content["source_table"] . "` ORDER BY `name`" + ); + while ($row = $result -> fetch_assoc()) + $multi_select_search_criteria[$criterium]["values"][] = $row["name"]; +} + +foreach ( $multi_select_search_criteria as $criterium ) { + if (isset($_GET[$criterium["name"]])) { + $filter .= " AND " . $criterium["query_pre"]; + foreach ($criterium["values"] as $value) + if (strpos("&" . $_SERVER["QUERY_STRING"] . "&", "&" . $criterium["name"] . "=" . urlencode($value) . "&") !== false) + $filter .= $criterium["query_in_pre"] . $value . $criterium["query_in_post"]; + $filter .= $criterium["query_post"]; + } +} +$single_select_search_criteria = array( + "broken" => array( + "name" => "broken", + "label" => "Is Broken", + "title" => "is broken", + "options" => array( + "All" => "1", + "Broken" => "(`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)", + "Not Broken" => "NOT (`ba_q`.`is_broken` OR `ba_q`.`is_blocked` IS NOT NULL)" + ) + ), + "next" => array( + "name" => "next", + "label" => "Can Be Built", + "title" => "can be built", + "options" => array( + "All" => "1", + "Can" => "(`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))", + "Can't" => "NOT (`l_q`.`loops` IS NOT NULL OR (`rd_q`.`run_dependencies_pending` IS NULL AND `md_q`.`make_dependencies_pending` IS NULL))" + ) + ) +); + +foreach ($single_select_search_criteria as $criterium) + if (isset($_GET[$criterium["name"]]) && + isset($criterium["options"][$_GET[$criterium["name"]]])) + $filter .= " AND " . $criterium["options"][$_GET[$criterium["name"]]]; + +$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=\"," . + mysql_url_encode("`ba_q`.`pkgbase`") . "," . + "\"&a=\"," . + mysql_url_encode("`ba_q`.`arch`") . ",". + "\"&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/\"," . + mysql_url_encode("`ba_q`.`git_repository`") . "," . + "\".git/tree/\"," . + mysql_url_encode("`ba_q`.`pkgbase`") . "," . + "\"/repos/\"," . + mysql_url_encode("`ba_q`.`package_repository`") . "," . + "\"-\"," . + mysql_url_encode("IF(`ba_q`.`arch`=\"any\",\"any\",\"x86_64\")") . "," . + "\"?id=\"," . + mysql_url_encode("`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", + "\"," . mysql_url_encode("`ba_q`.`mod_git_revision`") . ",\"", + "\"," . mysql_url_encode("`ba_q`.`package_repository`") . ",\"/\"," . + mysql_url_encode("`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_print`", + "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" + ) +); + +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`" . + mysql_join_build_assignments_architectures() . + mysql_join_build_assignments_package_sources() . + mysql_join_package_sources_upstream_repositories() . + mysql_join_upstream_repositories_git_repositories() . + mysql_join_build_assignments_binary_packages() . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + " 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`" . + mysql_join_binary_packages_dependencies('dependent_bp') . + mysql_join_dependencies_dependency_types() . + mysql_join_dependencies_install_target_providers() . + mysql_join_install_target_providers_binary_packages('','dependency_bp') . + mysql_join_binary_packages_binary_packages_in_repositories('dependency_bp') . + mysql_join_binary_packages_build_assignments('dependent_bp','dependent_ba') . + mysql_join_binary_packages_build_assignments('dependency_bp','dependency_ba') . + " JOIN `architecture_compatibilities` AS `ac_a`". + " ON `ac_a`.`fully_compatible`". + " AND `ac_a`.`built_for`=`dependency_ba`.`architecture`". + " JOIN `architecture_compatibilities` AS `ac_b`". + " ON `ac_b`.`fully_compatible`". + " AND `ac_b`.`built_for`=`dependent_ba`.`architecture`". + " AND `ac_b`.`runs_on`=`ac_a`.`runs_on`". + mysql_join_binary_packages_in_repositories_repositories() . + " 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`" . + mysql_join_binary_packages_dependencies('dependent_bp') . + mysql_join_dependencies_dependency_types() . + mysql_join_binary_packages_build_assignments('dependent_bp','dependent_ba') . + " JOIN `architecture_compatibilities` AS `ac_b`". + " ON `ac_b`.`fully_compatible`". + " AND `ac_b`.`built_for`=`dependent_ba`.`architecture`". + " WHERE NOT EXISTS(" . + "SELECT 1 FROM `install_target_providers`" . + mysql_join_install_target_providers_binary_packages('','dependency_bp') . + mysql_join_binary_packages_binary_packages_in_repositories('dependency_bp','dependency_bpir') . + mysql_join_binary_packages_in_repositories_repositories('dependency_bpir') . + mysql_join_binary_packages_build_assignments('dependency_bp','dependency_ba') . + " JOIN `architecture_compatibilities` AS `ac_a`". + " ON `ac_a`.`fully_compatible`". + " AND `ac_a`.`built_for`=`dependency_ba`.`architecture`". + " WHERE `install_target_providers`.`install_target` = `dependencies`.`depending_on`" . + " AND `repositories`.`is_on_master_mirror`" . + " AND `ac_b`.`runs_on`=`ac_a`.`runs_on`". + ")" . + " 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/\"," . + mysql_url_encode("`rfb`.`log_file`") . "," . + "\"\\\">\"," . + "`fail_reasons`.`name`," . + "\"</a>\"" . + ")" . + " ORDER BY `fail_reasons`.`name`" . + ") AS `fail_reasons_print`," . + "CONCAT(" . + "\",\"," . + "GROUP_CONCAT(" . + "`fail_reasons`.`name`" . + ")," . + "\",\"" . + ") AS `fail_reasons_raw`" . + " 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`" . + mysql_join_failed_builds_fail_reasons('rfb') . + " 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`" . + $filter . + " 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] = " "; + 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 Package Builds"); + +?> + <a href="https://buildmaster.archlinux32.org/build-logs/">build logs</a> + <div id="pkglist-search" class="box filter-criteria"> + <h2>Package Build Search</h2> + <form id="pkg-search" method="get" action="/buildmaster/build-list.php"> + <p><input id="id_sort" name="sort" type="hidden" /></p> + <fieldset> + <legend>Enter search criteria</legend> +<?php + +foreach ($multi_select_search_criteria as $criterium) { + print " <div>\n"; + print " <label for=\"id_" . $criterium["name"] . "\" title=\"Limit results to a specific " . $criterium["title"] . "\">"; + print $criterium["label"]; + print "</label>\n"; + print " <select multiple=\"multiple\" id=\"id_" . $criterium["name"] . "\" name=\"" . $criterium["name"] . "\">\n"; + foreach ($criterium["values"] as $value) { + print " <option value=\"" . $value . "\""; + if (strpos( "&" . $_SERVER["QUERY_STRING"] . "&", "&" . $criterium["name"] . "=" . urlencode($value) . "&") !== false) + print " selected=\"selected\""; + print ">" . $value . "</option>\n"; + } + print " </select>\n"; + print " </div>\n"; +} + +?> + <div> + <label for="id_q" title="Enter keywords as desired">Keywords</label> + <input id="id_q" name="q" size="30" type="text" <?php +if (isset($_GET["q"])) + print "value=\"".$_GET["q"]."\""; +?>/><br> + <input id="id_invq" name="invq" type="checkbox" value="invq" title="list all non-matching package builds"<?php +if (isset($_GET["invq"])) + print " checked"; +?>> + invert match + </div> +<?php + +foreach ($single_select_search_criteria as $criterium) { + print " <div>\n"; + print " <label for=\"id_"; + print $criterium["name"]; + print "\" title=\"Limit results based on "; + print $criterium["title"]; + print "\">"; + print $criterium["label"]; + print "</label><select id=\"id_"; + print $criterium["name"]; + print "\" name=\""; + print $criterium["name"]; + print "\">\n"; + foreach ($criterium["options"] as $label => $option) { + print " <option value=\""; + if ($label != "All") + print $label; + print "\""; + if (array_key_exists($criterium["name"],$_GET) && ($_GET[$criterium["name"]]==$label)) + print " selected=\"selected\""; + print ">" . $label . "</option>\n"; + } + print " </select>\n"; + print " </div>\n"; +} +?> + <div> + <label> </label> + <input title="Search for packages using this criteria" type="submit" value="Search"> + </div> + </fieldset> + </form> + </div> +<?php + +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=\"?"; + print substr( + str_replace( + "&sort=".$_GET["sort"]."&", + "&", + "&" . $_SERVER["QUERY_STRING"] . "&" + ), + 1 + ) . "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(); diff --git a/buildmaster/build-slaves.php b/buildmaster/build-slaves.php new file mode 100644 index 0000000..36a1522 --- /dev/null +++ b/buildmaster/build-slaves.php @@ -0,0 +1,216 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/style.php"; +require_once BASE . "/lib/mysql.php"; + +$columns = array( + "name" => array( + "label" => "name", + "mysql_name" => "name", + "mysql_query" => "`build_slaves`.`name`", + "sort" => "name", + "title" => "name" + ), + "operator" => array( + "label" => "operator", + "mysql_name" => "operator", + "mysql_query" => "`persons`.`name`", + "sort" => "operator", + "title" => "operator" + ), + "currently_building" => array( + "label" => "currently building", + "mysql_name" => "cb", + "mysql_query" => "`ba_q`.`cb`", + "mysql_ba_q_name" => "cb", + "mysql_ba_q_query" => "CONCAT(`architectures`.`name`,\"/\",`package_sources`.`pkgbase`)", + "sort" => "currently_building", + "title" => "pkgbase of currently building package" + ), + "last_connection" => array( + "label" => "last connection", + "mysql_name" => "lc", + "mysql_query" => "`sl_q`.`lc`", + "mysql_sl_q_name" => "lc", + "mysql_sl_q_query" => "MAX(`ssh_log`.`date`)", + "sort" => "last_connection", + "title" => "time of last connection" + ), + "building_since" => array( + "label" => "building since", + "mysql_name" => "bs", + "mysql_query" => "`sl_q`.`bs`", + "mysql_sl_q_name" => "bs", + "mysql_sl_q_query" => "MAX(IF(`ssh_log`.`action`=\"get-assignment\",`ssh_log`.`date`,NULL))", + "sort" => "building_since", + "title" => "start of build" + ), + "trials" => array( + "label" => "trials", + "mysql_name" => "trials", + "mysql_query" => "`build_slaves`.`trials`", + "sort" => "trials", + "title" => "number of trials" + ), + "logged_lines" => array( + "label" => "logged lines", + "mysql_name" => "ll", + "mysql_query" => "`build_slaves`.`logged_lines`", + "sort" => "logged_lines", + "title" => "number of logged lines so far" + ), + "last_action" => array( + "label" => "last action", + "mysql_name" => "la", + "mysql_query" => "`build_slaves`.`last_action`", + "sort" => "last_action", + "title" => "last action" + ) +); + +if (!isset($_GET["sort"])) + $_GET["sort"]="-last_connection"; + +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(`sub_query`.`" . $columns[$sort]["mysql_name"] . "`,0) " . $direction . ","; +else + $order = ""; + +function combine_fields($cln) { + return $cln["mysql_query"] . " AS `" . $cln["mysql_name"] . "`"; +} + +function combine_ba_q_fields($cln) { + if (isset($cln["mysql_ba_q_query"]) && isset($cln["mysql_ba_q_name"])) + return $cln["mysql_ba_q_query"] . " AS `" . $cln["mysql_ba_q_name"] . "`"; +} + +function combine_sl_q_fields($cln) { + if (isset($cln["mysql_sl_q_query"]) && isset($cln["mysql_sl_q_name"])) + return $cln["mysql_sl_q_query"] . " AS `" . $cln["mysql_sl_q_name"] . "`"; +} + +function non_empty($val) { + return ! empty($val); +} + +$result = mysql_run_query( + "SELECT `sub_query`.* FROM (" . + "SELECT " . + implode(",",array_map("combine_fields",$columns)) . + " FROM `build_slaves`" . + mysql_join_build_slaves_ssh_keys() . + mysql_join_ssh_keys_persons(). + + " LEFT JOIN (" . + "SELECT " . + "`build_assignments`.`id` AS `id`," . + implode(",",array_filter(array_map("combine_ba_q_fields",$columns),"non_empty")) . + " FROM `build_assignments`" . + mysql_join_build_assignments_package_sources() . + mysql_join_build_assignments_architectures() . + ") AS `ba_q`" . + " ON `ba_q`.`id`=`build_slaves`.`currently_building`" . + + " LEFT JOIN (" . + "SELECT " . + "`ssh_log`.`build_slave` AS `build_slave`," . + implode(",",array_filter(array_map("combine_sl_q_fields",$columns),"non_empty")) . + " FROM `ssh_log`" . + " WHERE `ssh_log`.`date`>=ADDDATE(NOW(),\"-5 00:00:00\")" . + " GROUP BY `ssh_log`.`build_slave`" . + ") AS `sl_q`" . + " ON `sl_q`.`build_slave`=`build_slaves`.`id`" . + ") AS `sub_query`" . + " ORDER BY " . $order . "`sub_query`.`name`" +); + +$count = 0; + +while($row = $result->fetch_assoc()) { + + foreach ($row as $name => $value) { + if (!isset($row[$name])) + $rows[$count][$name] = " "; + else + $rows[$count][$name] = $value; + } + $rows[$count]["name"] = + "<a href=\"/buildmaster/log.php?show=ssh&slave=" . + $row["name"] . + "\">" . + $row["name"] . + "</a>"; + + $count++; +} + +print_header("List of Build Slaves"); + +if ($count > 0) { + +?> + <div id="buildslaveslist-results" class="box"> + <table class="results"> + <thead> + <tr> +<?php + +foreach ($columns as $column) { + + print " <th>\n"; + print " <a href=\"?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(); diff --git a/buildmaster/deletion-links.php b/buildmaster/deletion-links.php new file mode 100644 index 0000000..066bf8d --- /dev/null +++ b/buildmaster/deletion-links.php @@ -0,0 +1,246 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + +$edges = ""; +$knots = ""; + +if (isset($_GET["show_all"])) + $available_filter = " LEFT"; +else + $available_filter = ""; + +if (isset($_GET["pkgname"])) + $filter = " AND `binary_packages`.`pkgname` REGEXP from_base64(\"" . base64_encode($_GET["pkgname"]) . "\")"; +else + $filter = ""; + +$memcache = new Memcache; +$memcache->connect('localhost', 11211) or die ('Memcached Connection Error'); +$available_upstream_packages = $memcache->get('available_upstream_packages'); +if ($available_upstream_packages === false) { + $available_upstream_packages = explode( + "\n", + shell_exec( + "find /var/lib/pacman/ -name '*.db' -exec tar -tzf {} \; " . + "| sed -n 's,-[^-]\+-[^-]\+/$,,;T;p' " . + "| sort -u" + ) + ); + $memcache->set('available_upstream_packages',$available_upstream_packages,0,1800); +} + +mysql_run_query( + "CREATE TEMPORARY TABLE `available` (" . + "`pkgname` VARCHAR(88), " . + "UNIQUE KEY `name` (`pkgname`)" . + ")" +); + +mysql_run_query( + "INSERT INTO `available` (`pkgname`) VALUES (\"" . + implode(array_map("base64_encode", $available_upstream_packages), "\"),(\"") . + "\")" +); + +mysql_run_query( + "DELETE FROM `available` WHERE `available`.`pkgname`=\"\"" +); + +mysql_run_query( + "UPDATE `available` SET `available`.`pkgname`=from_base64(`available`.`pkgname`)" +); + +mysql_run_query( + "CREATE TEMPORARY TABLE `d_bpir` (" . + "`id` BIGINT, " . + "`group` VARCHAR(256), " . + "`color` VARCHAR(7), " . + "UNIQUE KEY `id` (`id`)" . + ")" +); + +mysql_run_query( + "INSERT IGNORE INTO `d_bpir` (`id`,`color`)" . + " SELECT" . + " `binary_packages_in_repositories`.`id`," . + "IF(" . + "`available`.`pkgname` IS NULL," . + "\"#00ff00\"," . + "IF(" . + "`build_assignments`.`is_black_listed` IS NULL," . + "\"#800000\"," . + "\"#ff0000\"" . + ")" . + ") AS `color`" . + " FROM `binary_packages_in_repositories`" . + mysql_join_binary_packages_in_repositories_binary_packages() . + mysql_join_binary_packages_build_assignments() . + $available_filter . + " JOIN `available` ON `available`.`pkgname`=`binary_packages`.`pkgname`" . + " WHERE `binary_packages_in_repositories`.`is_to_be_deleted`" . + " AND `binary_packages`.`pkgname` NOT LIKE \"lib32-%\"" . + $filter +); + +mysql_run_query( + "CREATE TEMPORARY TABLE `d_bpir_copy` (" . + "`id` BIGINT, " . + "`group` VARCHAR(256), " . + "`color` VARCHAR(7), " . + "UNIQUE KEY `id` (`id`)" . + ")" +); + +mysql_run_query( + "INSERT IGNORE INTO `d_bpir_copy` (`id`,`color`)" . + " SELECT `d_bpir`.`id`,`d_bpir`.`color`" . + " FROM `d_bpir`" +); + +mysql_run_query( + "CREATE TEMPORARY TABLE `d_bpir_links` (" . + "`dependent` BIGINT, " . + "`depending_on` BIGINT, " . + "`dep_type` SMALLINT, " . + "UNIQUE KEY `content` (`dependent`,`depending_on`,`dep_type`)" . + ")" +); + +mysql_run_query( + "INSERT IGNORE INTO `d_bpir_links` (`dependent`,`depending_on`,`dep_type`)" . + " SELECT `d_bpir`.`id`," . + " `itp_bpir`.`id`," . + " `dependencies`.`dependency_type`" . + " FROM `d_bpir`" . + " JOIN `binary_packages_in_repositories` ON `d_bpir`.`id`=`binary_packages_in_repositories`.`id`" . + mysql_join_binary_packages_in_repositories_dependencies() . + mysql_join_dependencies_install_target_providers() . + mysql_join_install_target_providers_binary_packages_in_repositories('','itp_bpir') . + " JOIN `d_bpir_copy` ON `itp_bpir`.`id`=`d_bpir_copy`.`id`" . + " WHERE `dependencies`.`dependent`!=`install_target_providers`.`package`" +); + +mysql_run_query( + "CREATE TEMPORARY TABLE `d_bpir_links_copy` (" . + "`dependent` BIGINT, " . + "`depending_on` BIGINT, " . + "`dep_type` SMALLINT, " . + "UNIQUE KEY `content` (`dependent`,`depending_on`,`dep_type`)" . + ")" +); + +mysql_run_query( + "INSERT IGNORE INTO `d_bpir_links_copy` (`dependent`,`depending_on`,`dep_type`)" . + " SELECT `d_bpir_links`.`dependent`,`d_bpir_links`.`depending_on`,`d_bpir_links`.`dep_type`" . + " FROM `d_bpir_links`" +); + +mysql_run_query( + "UPDATE `d_bpir`" . + " JOIN (" . + "SELECT" . + " `d_bpir_copy`.`id`," . + "SHA2(" . + "GROUP_CONCAT(CONCAT(" . + "IFNULL(`d_bpir_copy`.`color`,\"0\"),\":\"," . + "IFNULL(`d_bpir_links`.`depending_on`,\"0\"),\":\"," . + "IFNULL(`d_bpir_links`.`dep_type`,\"0\"),\":\"," . + "IFNULL(`d_bpir_links_copy`.`dependent`,\"0\"),\":\"," . + "IFNULL(`d_bpir_links_copy`.`dep_type`,\"0\")" . + "))" . + ",256) AS `hash`" . + " FROM `d_bpir_copy`" . + " LEFT JOIN `d_bpir_links` ON `d_bpir_links`.`dependent`=`d_bpir_copy`.`id`" . + " LEFT JOIN `d_bpir_links_copy` ON `d_bpir_links_copy`.`depending_on`=`d_bpir_copy`.`id`" . + " GROUP BY `d_bpir_copy`.`id`" . + ") AS `grouped_d_bpir` ON `grouped_d_bpir`.`id`=`d_bpir`.`id`" . + " SET `d_bpir`.`group`=`grouped_d_bpir`.`hash`" +); + +mysql_run_query( + "UPDATE `d_bpir_copy`" . + " JOIN `d_bpir` ON `d_bpir`.`id`=`d_bpir_copy`.`id`" . + " SET `d_bpir_copy`.`group`=`d_bpir`.`group`" +); + +$result = mysql_run_query( + "SELECT MAX(`d_bpir`.`id`) AS `id`," . + "GROUP_CONCAT(CONCAT(" . + "`architectures`.`name`,\"/\"," . + "`repositories`.`name`,\"/\"," . + "`binary_packages`.`pkgname`" . + ") SEPARATOR \",\n\") AS `name`," . + "`d_bpir`.`color`" . + " FROM `d_bpir`" . + " JOIN `binary_packages_in_repositories` ON `d_bpir`.`id`=`binary_packages_in_repositories`.`id`" . + mysql_join_binary_packages_in_repositories_binary_packages() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_architectures() . + " GROUP BY `d_bpir`.`group`" +); + +while ($row = $result->fetch_assoc()) + $knots .= + "\"p" . + $row["id"] . + "\" [label = \"" . + $row["name"] . + "\", + fontcolor = \"" . + $row["color"] . + "\"];\n"; + +$result = mysql_run_query( + "SELECT MAX(`d_bpir_links`.`dependent`) AS `dependent`," . + "`dependency_types`.`name` AS `dep_type`," . + "MAX(`d_bpir_links`.`depending_on`) AS `depending_on`" . + " FROM `d_bpir_links`" . + " JOIN `dependency_types` ON `d_bpir_links`.`dep_type`=`dependency_types`.`id`" . + " JOIN `d_bpir` ON `d_bpir`.`id`=`d_bpir_links`.`dependent`" . + " JOIN `d_bpir_copy` ON `d_bpir_copy`.`id`=`d_bpir_links`.`depending_on`" . + " GROUP BY CONCAT(`d_bpir`.`group`,\"-\",`d_bpir_copy`.`group`)" +); + +while ($row = $result->fetch_assoc()) { + $edges .= + "\"p" . + $row["depending_on"] . + "\" -> \"p" . + $row["dependent"] . + "\" [color = \""; + switch ($row["dep_type"]) { + case "run": + $edges .= "#000000"; + break; + case "make": + $edges .= "#0000ff"; + break; + case "link": + $edges .= "#008000"; + break; + case "check": + $edges .= "#000080"; + break; + default: + $edges .= "#ff00ff"; + } + $edges .= + "#000080"; + $edges .= + "\"];\n"; +} + +header ("Content-type: image/png"); +passthru( + "echo '" . base64_encode( + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n" + ) . "' | " . + "base64 -d | " . + "timeout 30 dot -Tpng -o/dev/stdout /dev/stdin" +); diff --git a/buildmaster/dependencies.php b/buildmaster/dependencies.php new file mode 100644 index 0000000..a8beb5d --- /dev/null +++ b/buildmaster/dependencies.php @@ -0,0 +1,190 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + +$match = ""; + +function dependency_arch_join($name) { + if (isset($_GET["ba_a"])) { + return + " JOIN `architecture_compatibilities`" . + " ON `architecture_compatibilities`.`fully_compatible`" . + " AND `architecture_compatibilities`.`built_for`=`" . $name . "`.`architecture`" . + " JOIN `architectures` AS `ba_a`" . + " ON `architecture_compatibilities`.`runs_on`=`ba_a`.`id`" . + " AND `ba_a`.`name`=from_base64(\"" . base64_encode($_GET["ba_a"]) . "\")"; + } elseif (isset($_GET["a"])) { + return + " JOIN `architecture_compatibilities` AS `ac_1`" . + " ON `ac_1`.`fully_compatible`" . + " AND `ac_1`.`built_for`=`" . $name . "`.`architecture`" . + " JOIN `architecture_compatibilities` AS `ac_2`" . + " ON `ac_2`.`fully_compatible`" . + " AND `ac_1`.`runs_on`=`ac_2`.`runs_on`" . + " AND `ac_2`.`built_for`=`architectures`.`id`"; + } else + return ""; +} + +if (isset($_GET["a"])) + $match .= " AND `architectures`.`name`=from_base64(\"" . base64_encode($_GET["a"]) . "\")"; +if (isset($_GET["b"])) + $match .= " AND `package_sources`.`pkgbase`=from_base64(\"" . base64_encode($_GET["b"]) . "\")"; +if (isset($_GET["p"])) + $match .= " AND `binary_packages`.`pkgname`=from_base64(\"" . base64_encode($_GET["p"]) . "\")"; +if (isset($_GET["r"])) + $match .= " AND `repositories`.`name`=from_base64(\"" . base64_encode($_GET["r"]) . "\")"; + +$ignore_install_targets = " AND NOT `install_targets`.`name` IN (\"base\",\"base-devel\")"; + +$colors["stable"]="#000000"; +$colors["testing"]="#008000"; +$colors["staging"]="#00ff00"; +$colors["standalone"]="#000000"; +$colors["unbuilt"]="#ff0000"; +$colors["forbidden"]="#808080"; +$colors["virtual"]="#800080"; + +$limit=200; + +mysql_run_query( + "CREATE TEMPORARY TABLE `cons` (" . + "`dep` BIGINT, " . + "`itp` BIGINT, " . + "UNIQUE KEY `content` (`dep`,`itp`)" . + ")" +); + +mysql_run_query( + "INSERT IGNORE INTO `cons` (`dep`,`itp`)" . + " SELECT `dependencies`.`id`,`install_target_providers`.`id`". + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() . + mysql_join_binary_packages_architectures() . + mysql_join_binary_packages_build_assignments() . + mysql_join_build_assignments_package_sources() . + $match . + mysql_join_binary_packages_dependencies() . + mysql_join_dependencies_dependency_types() . + mysql_join_dependencies_install_targets() . + $ignore_install_targets . + mysql_join_dependencies_install_target_providers() . + mysql_join_install_target_providers_binary_packages('','itp_bp') . + dependency_arch_join('itp_bp') . + " WHERE (`dependency_types`.`relevant_for_binary_packages` OR `repository_stabilities`.`name`=\"unbuilt\")" . + " LIMIT " . $limit +); + +mysql_run_query( + "INSERT IGNORE INTO `cons` (`dep`,`itp`)" . + " SELECT `dependencies`.`id`,`install_target_providers`.`id`". + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_binary_packages_architectures() . + mysql_join_binary_packages_build_assignments() . + mysql_join_build_assignments_package_sources() . + $match . + mysql_join_binary_packages_install_target_providers() . + mysql_join_install_target_providers_dependencies() . + mysql_join_dependencies_binary_packages('','d_bp') . + dependency_arch_join('d_bp') . + mysql_join_binary_packages_binary_packages_in_repositories('d_bp','d_bpir') . + mysql_join_binary_packages_in_repositories_repositories('d_bpir','d_r') . + mysql_join_repositories_repository_stabilities('d_r','d_rs') . + mysql_join_dependencies_dependency_types() . + " WHERE (`dependency_types`.`relevant_for_binary_packages` OR `d_rs`.`name`=\"unbuilt\")" . + " LIMIT " . $limit +); + +$edges = ""; +$knots = ""; + +$result = mysql_run_query( + "SELECT DISTINCT `install_target_providers`.`install_target`,`install_target_providers`.`package`" . + " FROM `cons`" . + " JOIN `install_target_providers` ON `cons`.`itp`=`install_target_providers`.`id`" +); + +while ($row = $result->fetch_assoc()) + $edges .= "\"p" . $row["package"] . "\" -> \"i" . $row["install_target"] . "\" [color = \"#000080\"];\n"; + +$result = mysql_run_query( + "SELECT DISTINCT `dependencies`.`dependent`,`dependencies`.`depending_on`,`dependency_types`.`name`" . + " FROM `cons`" . + " JOIN `dependencies` ON `cons`.`dep`=`dependencies`.`id`" . + mysql_join_dependencies_dependency_types() +); + +while ($row = $result->fetch_assoc()) + $edges .= "\"i" . $row["depending_on"] . "\" -> \"p" . $row["dependent"] . "\" [taillabel = \"" . $row["name"] . "\"];\n"; + +$result = mysql_run_query( + "SELECT DISTINCT `install_targets`.`id`,`install_targets`.`name`" . + " FROM `cons`" . + " JOIN `dependencies` ON `cons`.`dep`=`dependencies`.`id`" . + mysql_join_dependencies_install_targets() +); + +while ($row = $result->fetch_assoc()) + $knots .= "\"i" . $row["id"] . "\" [label = \"" . $row["name"] . "\", fontcolor = \"#000080\"];\n"; + +$pkgfile_query = + "CONCAT(". + "`repositories`.`name`,\"/\"," . + "`binary_packages`.`pkgname`,\"-\"," . + mysql_query_package_version("binary_packages") . + ",\"-\"," . + "`architectures`.`name`" . + ") AS `filename`"; + +$result = mysql_run_query( + "SELECT DISTINCT " . + "`binary_packages`.`id`," . + "`repository_stabilities`.`name` AS `stability`," . + $pkgfile_query . + " FROM `cons`" . + " JOIN `dependencies` ON `cons`.`dep`=`dependencies`.`id`" . + mysql_join_dependencies_binary_packages() . + mysql_join_binary_packages_architectures() . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() +); + +while ($row = $result->fetch_assoc()) + $knots .= "\"p" . $row["id"] . "\" [label = \"" . $row["filename"] . "\", fontcolor = \"" . $colors[$row["stability"]] . "\"];\n"; + +$result = mysql_run_query( + "SELECT DISTINCT " . + "`binary_packages`.`id`," . + "`repository_stabilities`.`name` AS `stability`," . + $pkgfile_query . + " FROM `cons`" . + " JOIN `install_target_providers` ON `cons`.`itp`=`install_target_providers`.`id`" . + mysql_join_install_target_providers_binary_packages() . + mysql_join_binary_packages_architectures() . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() +); + +while ($row = $result->fetch_assoc()) + $knots .= "\"p" . $row["id"] . "\" [label = \"" . $row["filename"] . "\", fontcolor = \"" . $colors[$row["stability"]] . "\"];\n"; + +$knots = str_replace("\$","\\\$",$knots); +$edges = str_replace("\$","\\\$",$edges); + +header ("Content-type: image/png"); +passthru( + "timeout 30 dot -Tpng -o/dev/stdout /dev/stdin <<EOF\n" . + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n" . + "EOF\n" +); diff --git a/buildmaster/gpg-keys.php b/buildmaster/gpg-keys.php new file mode 100644 index 0000000..db990c2 --- /dev/null +++ b/buildmaster/gpg-keys.php @@ -0,0 +1,48 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + + $result = mysql_run_query( + "SELECT" . + " GROUP_CONCAT(`email_actions`.`name`) AS `action`," . + "`persons`.`name` AS `person`," . + "`gpg_keys`.`fingerprint`" . + " FROM `email_actions`" . + mysql_join_email_actions_allowed_email_actions() . + " RIGHT" . mysql_join_allowed_email_actions_gpg_keys() . + mysql_join_gpg_keys_persons() . + " GROUP BY `gpg_keys`.`id`" . + " ORDER BY `persons`.`name`" + ); + +?> +<html> + <head> + <title>list of gpg-keys</title> + </head> + <body> +<?php +show_warning_on_offline_slave(); + + print "<table border=1>\n"; + if ($result->num_rows > 0) { + print "<tr><th>person</th><th>action</th><th>fingerprint</th></tr>\n"; + while ($row = $result -> fetch_assoc()) { + foreach ($row as $key => $value) { + if ($value=="") { + $row[$key]=" "; + } + } + print "<tr>"; + print "<td>" . $row["person"] . "</td>"; + print "<td>" . $row["action"] . "</td>"; + print "<td><a href=\"http://pgp.mit.edu/pks/lookup?op=get&search=0x" . + substr($row["fingerprint"],-16) . + "\">" . $row["fingerprint"] . "</a></td>"; + print "</tr>\n"; + } + } + print "</table>\n"; + +?> +</body></html> diff --git a/buildmaster/index.php b/buildmaster/index.php new file mode 100644 index 0000000..0ea0376 --- /dev/null +++ b/buildmaster/index.php @@ -0,0 +1,80 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + +if (array_key_exists("arch",$_GET)) { + $archs = array(); + foreach (explode("&",$_SERVER["QUERY_STRING"]) as $param) { + if (strpos($param,"arch=")!==0) + continue; + $param = substr($param,5); + if ($param == "") + continue; + $archs[$param] = $param; + } + if (count($archs)==0) { + $archs = array("i486" => "i486", "i686" => "i686", "any" => "any"); + } +} else { + $archs = array("i686" => "i686", "any" => "any"); +} + +function encode_arch($a) { + return "arch=" . urlencode($a); +} + +$sarch_param = implode("&",array_map('encode_arch',$archs)); +$march_param = ""; +if ($sarch_param != "") { + $march_param = "&" . $sarch_param; + $sarch_param = "?" . $sarch_param; +} + +?> +<html> + <head> + <title>Buildmaster for Archlinux32 packages (<?php print implode(", ",$archs); ?>)</title> + </head> + <body> +<?php show_warning_on_offline_slave(); ?> + <a href="/buildmaster/build-list.php<?php print $sarch_param; ?>">build list</a> + as <a href="/buildmaster/build-list-links.php">graph</a> -- + <a href="/buildmaster/build-list.php?broken=Broken<?php print $march_param; ?>">broken packages</a> -- + <a href="/buildmaster/build-list.php?next=Can<?php print $march_param; ?>">buildable packages</a><br> + <a href="/buildmaster/build-slaves.php">build-slaves</a> -- + <a href="/buildmaster/gpg-keys.php">gpg-keys</a> -- + <a href="/buildmaster/status.php">status</a><br> + <a href="https://buildmaster.archlinux32.org/build-logs/">build logs</a> -- + <a href="/buildmaster/log.php?show=ssh">ssh-log</a> -- + <a href="/buildmaster/log.php?show=email">email-log</a><br> + sanity: of <a href="https://buildmaster.archlinux32.org/master-sanity.html">state files</a>, + of <a href="https://buildmaster.archlinux32.org/mysql-sanity.html">mysql database</a> and + <a href="/buildmaster/mysql-issues.php?ignore-i486">broken dependencies in the database</a><br> + <a href="/buildmaster/todos.php">todos</a> + as <a href="/buildmaster/todos.php?graph">graph</a><br> + <a href="https://buildmaster.archlinux32.org/database-layout.png">database layout</a><br> + <a href="/buildmaster/blacklist.php">blacklisted packages</a> -- + <a href="/buildmaster/to-delete.php">packages to be deleted</a> + and <a href="/buildmaster/deletion-links.php">links between them</a><br> + <img src="/buildmaster/statistics.php?log<?php print $march_param; ?>"><br> +<?php + +foreach (array("any", "i486", "i686", "") as $a) { + print " <a href=\"?arch=" . $a . "\">"; + switch ($a) { + case "": + print "all packages"; + break; + case "any": + print "architecture independent packages"; + break; + default: + print "packages for " . $a; + } + print "</a>\n"; +} + +?><br> + <img src="https://buildmaster.archlinux32.org/vnstat.png"><br> + </body> +</html> diff --git a/buildmaster/log.php b/buildmaster/log.php new file mode 100644 index 0000000..f6de94b --- /dev/null +++ b/buildmaster/log.php @@ -0,0 +1,93 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + + + $filter = ""; + if (isset($_GET["show"]) && + ($_GET["show"] == "ssh")) { + $to_show = "ssh"; + $columns = array( + "date" => "`ssh_log`.`date`", + "build slave" => "`build_slaves`.`name`", + "action" => "`ssh_log`.`action`", + "parameters" => "`ssh_log`.`parameters`" + ); + $join = " LEFT" . mysql_join_ssh_log_build_slaves(); + if (isset($_GET["action"])) + $filter .= " AND `ssh_log`.`action` LIKE from_base64(\"" . base64_encode($_GET["action"]) . "\")"; + if (isset($_GET["slave"])) + $filter .= " AND `build_slaves`.`name` LIKE from_base64(\"" . base64_encode($_GET["slave"]) . "\")"; + } else { + $to_show = "email"; + $columns = array( + "date" => "`email_log`.`date`", + "action" => "`email_actions`.`name`", + "count" => "`email_log`.`count`", + "success" => "`email_log`.`success`", + "person" => "`persons`.`name`", + "comment" => "`email_log`.`comment`" + ); + $join = + " LEFT" . mysql_join_email_log_email_actions() . + " LEFT JOIN (" . + "`gpg_keys`" . + mysql_join_gpg_keys_persons() . + ") ON `email_log`.`gpg_key`=`gpg_keys`.`id`"; + } + + if (isset($_GET["from"])) + $min_time = $_GET["from"]; + elseif ($to_show == "email") + $min_time = "1 00:00:00"; + else + $min_time = "00:42:00"; + + $query = "SELECT "; + foreach ($columns as $name => $column) + $query .= $column . " AS `".$name."`,"; + + $query = substr($query,0,-1); + $query .= " FROM `" . $to_show . "_log`" . $join . + " WHERE TIMEDIFF((" . + // NOW() is wrong here - due to differing time zones O.o + "SELECT MAX(`l`.`date`) FROM `" . $to_show . "_log` AS `l`" . + "),`" . $to_show . "_log`.`date`) < from_base64(\"" . base64_encode( $min_time ) . "\")" . + $filter . + " ORDER BY `" . $to_show . "_log`.`date` DESC"; + + $result = mysql_run_query($query); + +?> +<html> + <head> + <title><?php print $to_show; ?>-log</title> + <link rel="stylesheet" type="text/css" href="/static/style.css"> + </head> + <body> + <table> + <tr> +<?php + foreach ($columns as $label => $column) { + print " <th>\n"; + print " " . $label . "\n"; + print " </th>\n"; + } +?> + </tr> +<?php + + while ($row = $result -> fetch_assoc()) { + print " <tr>\n"; + foreach ($row as $val) { + print " <td>\n"; + print " " . $val . "\n"; + print " </td>\n"; + } + print " </tr>\n"; + } + +?> + </table> + </body> +</html> diff --git a/buildmaster/mysql-issues.php b/buildmaster/mysql-issues.php new file mode 100644 index 0000000..1397141 --- /dev/null +++ b/buildmaster/mysql-issues.php @@ -0,0 +1,183 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + + $ignore = ""; + + if (isset($_GET["ignore-haskell"])) + $ignore .= " AND `install_targets`.`name` NOT LIKE \"libHS%\""; + + if (isset($_GET["ignore-i486"])) + $ignore .= " AND `r_a`.`name` != \"i486\""; + + ob_start(); + +?> +<html> + <head> + <title>More and less critical issues with the database</title> + <link rel="stylesheet" type="text/css" href="/static/style.css"> + </head> + <body> +<?php show_warning_on_offline_slave(); ?> + <a href="https://buildmaster.archlinux32.org/">Start page</a><br> +<?php + + $limit = " LIMIT 10001"; + + $result = mysql_run_query( + "SELECT CONCAT(" . + "`r_a`.`name`,\"/\"," . + "`repositories`.`name`,\"/\"," . + "`binary_packages`.`pkgname`,\"-\"," . + mysql_query_package_version("binary_packages") . + ",\"-\"," . + "`architectures`.`name`) AS `pkgfile`," . + "`install_targets`.`name` AS `install_target`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`," . + "`subst_r`.`name` AS `subst_repository`," . + "`subst_buildlist_bp`.`id` AS `subst_buildlist`" . + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + " AND `repositories`.`is_on_master_mirror`" . + mysql_join_repositories_architectures('','r_a') . + mysql_join_binary_packages_dependencies() . + mysql_join_dependencies_dependency_types() . + " AND `dependency_types`.`relevant_for_binary_packages`" . + mysql_join_dependencies_install_targets() . + mysql_join_binary_packages_architectures() . + " LEFT JOIN (" . + "`binary_packages` AS `subst_bp`" . + mysql_join_binary_packages_binary_packages_in_repositories('subst_bp','subst_bpir') . + mysql_join_binary_packages_in_repositories_repositories('subst_bpir','subst_r') . + " JOIN `repository_stability_relations` ON `repository_stability_relations`.`less_stable`=`subst_r`.`stability`" . + ")" . + " ON `subst_bp`.`pkgname`=`binary_packages`.`pkgname`" . + " AND `subst_bp`.`id`!=`binary_packages`.`id`" . + " AND `repository_stability_relations`.`more_stable`=`repositories`.`stability`" . + " AND `subst_r`.`architecture`=`repositories`.`architecture`" . + " LEFT JOIN (" . + "`binary_packages` AS `subst_buildlist_bp`" . + mysql_join_binary_packages_binary_packages_in_repositories('subst_buildlist_bp','subst_buildlist_bpir') . + mysql_join_binary_packages_in_repositories_repositories('subst_buildlist_bpir','subst_buildlist_r') . + " AND `subst_buildlist_r`.`name`=\"build-list\"". + ") ON `subst_buildlist_bp`.`pkgname`=`binary_packages`.`pkgname`" . + " AND `subst_bp`.`architecture`=`binary_packages`.`architecture`" . + " WHERE NOT EXISTS (" . + "SELECT 1 FROM `install_target_providers`" . + mysql_join_install_target_providers_binary_packages_in_repositories('','i_bpir') . + mysql_join_binary_packages_in_repositories_repositories('i_bpir','i_r') . + " JOIN `architecture_compatibilities` ON `architecture_compatibilities`.`fully_compatible`" . + " AND `architecture_compatibilities`.`built_for`=`i_r`.`architecture`" . + " WHERE `install_target_providers`.`install_target`=`dependencies`.`depending_on`" . + " AND `repositories`.`architecture`=`architecture_compatibilities`.`runs_on`" . + ")" . + $ignore . + " ORDER BY " . + "`binary_packages_in_repositories`.`is_to_be_deleted`," . + "`repositories`.`name`," . + "`binary_packages`.`pkgname`," . + "`install_targets`.`name`" . + $limit + ); + + if ($result -> num_rows > 10000) + print " Found >10000 serious issues.<br>\n"; + else + print " Found " . $result -> num_rows . " serious issues.<br>\n"; + + while ( $row = $result -> fetch_assoc() ) { + if ($row["is_to_be_deleted"]==1) + print " <font color=\"#00ff00\">(marked as to-be-deleted) "; + else + print " <font color=\"#ff0000\">"; + print $row["pkgfile"] . " depends on " . htmlspecialchars($row["install_target"]) . " which is not provided by any package"; + if (isset($row["subst_repository"])) + print " - but can be replaced by the one in " . $row["subst_repository"]; + elseif (isset($row["subst_buildlist"])) + print " - but is already rescheduled"; + print ".<br>"; + print "</font>\n"; + unset($row); + } + + $result = mysql_run_query( + "SELECT CONCAT(" . + "`r_a`.`name`,\"/\"," . + "`repositories`.`name`,\"/\"," . + "`binary_packages`.`pkgname`,\"-\"," . + mysql_query_package_version("binary_packages") . + ",\"-\"," . + "`architectures`.`name`) AS `pkgfile`," . + "`install_targets`.`name` AS `install_target`," . + "`repository_stabilities`.`name` AS `stability`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`" . + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + " AND `repositories`.`is_on_master_mirror`" . + mysql_join_repositories_architectures('','r_a') . + mysql_join_repositories_repository_stabilities() . + mysql_join_binary_packages_dependencies() . + mysql_join_dependencies_dependency_types() . + " AND `dependency_types`.`relevant_for_binary_packages`" . + mysql_join_dependencies_install_targets() . + mysql_join_binary_packages_architectures() . + " WHERE EXISTS (" . + "SELECT 1 FROM `install_target_providers`" . + mysql_join_install_target_providers_binary_packages_in_repositories('','prov_bpir') . + mysql_join_binary_packages_in_repositories_repositories('prov_bpir','prov_r') . + " JOIN `architecture_compatibilities` ON `architecture_compatibilities`.`built_for`=`prov_r`.`architecture`" . + " AND `architecture_compatibilities`.`fully_compatible`" . + " WHERE `install_target_providers`.`install_target` = `dependencies`.`depending_on`" . + " AND `architecture_compatibilities`.`runs_on`=`repositories`.`architecture`" . + ")" . + " AND NOT EXISTS (" . + "SELECT 1 FROM `install_target_providers`" . + mysql_join_install_target_providers_binary_packages('','prov_bp') . + mysql_join_binary_packages_binary_packages_in_repositories('prov_bp','prov_bpir') . + mysql_join_binary_packages_in_repositories_repositories('prov_bpir','prov_r') . + " JOIN `repository_stability_relations` ON `prov_r`.`stability`=`repository_stability_relations`.`more_stable`" . + " WHERE `install_target_providers`.`install_target` = `dependencies`.`depending_on`" . + " AND `repositories`.`stability`=`repository_stability_relations`.`less_stable`" . + " AND `repositories`.`architecture`=`prov_r`.`architecture`" . + " AND NOT EXISTS (" . + "SELECT 1 FROM `binary_packages` AS `sup_bp`" . + mysql_join_binary_packages_binary_packages_in_repositories('sup_bp','sup_bpir') . + mysql_join_binary_packages_in_repositories_repositories('sup_bpir','sup_r') . + " JOIN `repository_stability_relations` AS `sup_rra` ON `sup_r`.`stability`=`sup_rra`.`more_stable`" . + " JOIN `repository_stability_relations` AS `sup_rrb` ON `sup_r`.`stability`=`sup_rrb`.`less_stable`" . + " WHERE `sup_bp`.`pkgname` = `prov_bp`.`pkgname`" . + " AND `sup_bp`.`architecture` = `prov_bp`.`architecture`" . + " AND `sup_bp`.`id` != `prov_bp`.`id`" . + " AND `repositories`.`stability`=`sup_rra`.`less_stable`" . + " AND `prov_r`.`stability`=`sup_rrb`.`more_stable`" . + " AND `prov_r`.`architecture`=`sup_r`.`architecture`" . + ")" . + ")" . + $ignore . + " ORDER BY `binary_packages_in_repositories`.`is_to_be_deleted`,`binary_packages`.`pkgname`,`install_targets`.`name`" . + $limit + ); + + if ($result -> num_rows > 10000) + print " Found >10000 stability issues.<br>\n"; + else + print " Found " . $result -> num_rows . " stability issues.<br>\n"; + + while ( $row = $result -> fetch_assoc() ) { + if ($row["is_to_be_deleted"]==1) + print " <font color=\"#00ff00\">(marked as to-be-deleted) "; + else + print " <font color=\"#800000\">"; + print $row["pkgfile"] . " depends on " . htmlspecialchars($row["install_target"]) . " which is not provided by any package installable from enabled " . $row["stability"] . " repositories.<br>"; + print "</font>\n"; + unset($row); + } + + ob_end_flush(); + +?> + </body> +</html> diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php new file mode 100644 index 0000000..4f2398b --- /dev/null +++ b/buildmaster/statistics.php @@ -0,0 +1,200 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + +if (array_key_exists("from",$_GET)) + $min_time="from_base64(\"" . base64_encode("-".$_GET["from"]) . "\")"; +else + $min_time="\"-7 00:00:00\""; + +if (array_key_exists("arch",$_GET)) { + $arch_filter="`architectures`.`name` IN (\"\""; + foreach (explode("&",$_SERVER["QUERY_STRING"]) as $param) { + if (strpos($param,"arch=")!==0) + continue; + $arch_filter .= ",from_base64(\"" . base64_encode(substr($param,5)) . "\")"; + } + $arch_filter .= ")"; + $combiner_left=""; + $combiner_right=""; + $grouper=""; + $joiner=" JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`"; +} else { + $arch_filter="1"; + $combiner_left="SUM("; + $combiner_right=")"; + $grouper=" GROUP BY `statistics`.`date`"; + $joiner=""; +}; + +$column_list = array( + "pending_tasks_count", + "pending_packages_count", + "staging_packages_count", + "testing_packages_count", + "tested_packages_count", + "broken_tasks_count", + "dependency_loops_count", + "dependency_looped_tasks_count", + "locked_tasks_count", + "blocked_tasks_count", + "next_tasks_count" +); + +function combine_column($name) { + global $combiner_left; + global $combiner_right; + return $combiner_left . "`statistics`.`" . $name . "`" . $combiner_right . " AS `" . $name . "`"; +} + +$result = mysql_run_query( + "SELECT DISTINCT ". + "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," . + implode(",",array_map("combine_column",$column_list)) . + "FROM `statistics` " . + $joiner . + "WHERE `statistics`.`date`>=ADDDATE(NOW()," . $min_time . ") " . + "AND " . $arch_filter . + $grouper . + "ORDER BY `statistics`.`date`" +); + +$t_min = -1; +$t_max = -1; +$val_max = -1; + +while($vals = $result->fetch_assoc()) { + if ($t_min == -1) + $t_min = $vals["date"]; + $t_max = $vals["date"]; + foreach ($vals as $column => $val) + if ($column != "date") { + $values[$column][$vals["date"]] = $val; + $val_max = max($val_max,$val); + } +}; +$print_columns = array_keys($values); + +$max_len = 0; +foreach ($print_columns as $column) { + $len = strlen($values[$column][$t_max])+1; + if ($len > $max_len) + $max_len = $len; +} + +$width = 1600; +$height = 600; +$border = 5; +$legend_line_length = 10; +$legend_height = 2 * ImageFontHeight(5) + $legend_line_length; + +$im = @ImageCreate ($width + $legend_line_length + $max_len * ImageFontWidth(5), $height + $legend_height) + or die ("Cannot create new gd-image-stream"); + +$background_color = ImageColorAllocate ($im, 255, 255, 255); +$foreground_color = ImageColorAllocate ($im, 0, 0, 0); + +$colors['stable_packages_count'] = ImageColorAllocate ($im, 0, 0, 0); +$colors['pending_tasks_count'] = ImageColorAllocate ($im, 0, 0, 128); +$colors['pending_packages_count'] = ImageColorAllocate ($im, 0, 0, 255); +$colors['staging_packages_count'] = ImageColorAllocate ($im, 0, 100, 0); +$colors['testing_packages_count'] = ImageColorAllocate ($im, 0, 200, 0); +$colors['tested_packages_count'] = ImageColorAllocate ($im, 100, 255, 0); +$colors['broken_tasks_count'] = ImageColorAllocate ($im, 255, 0, 0); +$colors['dependency_loops_count'] = ImageColorAllocate ($im, 128, 128, 0); +$colors['dependency_looped_tasks_count'] = ImageColorAllocate ($im, 255, 128, 128); +$colors['locked_tasks_count'] = ImageColorAllocate ($im, 128, 128, 128); +$colors['blocked_tasks_count'] = ImageColorAllocate ($im, 128, 0, 0); +$colors['next_tasks_count'] = ImageColorAllocate ($im, 0, 255, 255); + +function scale($x, $x_min, $x_max, $scale, $log) { + if ($log) { + $x = log($x + 10); + $x_min = log($x_min + 10); + $x_max = log($x_max + 10); + }; + if ($x_max == $x_min) + $frac = 0; + else + $frac = ($x - $x_min)/($x_max - $x_min); + if ($scale < 0) + return ($frac-1) * $scale; + else + return $frac * $scale; +}; + +function print_graph($data, $color) { + global $width, $height, $im, $t_min, $t_max, $val_max, $border, $legend_line_length; + ksort($data); + $last_t = -1; + $last_val = -1; + foreach ($data as $t => $val) { + if ($last_t != -1) + ImageLine( + $im, + scale($last_t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length, + scale($last_val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border, + scale($t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length, + scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border, + $color + ); + $last_t = $t; + $last_val = $val; + } + ImageString( + $im, + 5, + $width+$legend_line_length, + scale($last_val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border - ImageFontHeight(5)/2, + " ".$data[$t_max], + $color + ); +}; + +ImageRectangle($im, $legend_line_length, 0, $width-1+$legend_line_length, $height-1, $foreground_color); + +$xpos = $legend_line_length; +foreach ($print_columns as $column) { + print_graph($values[$column], $colors[$column]); + ImageString($im, 5, $xpos, $height + $legend_line_length + ImageFontHeight(5), substr($column,0,-strlen("_count")), $colors[$column]); + $xpos += (strlen($column) - strlen("_count") + 1.75) * ImageFontWidth(5); +} + +ImageString($im, 5, $legend_line_length, $height + $legend_line_length, date('Y-m-d H:i', $t_min), $foreground_color); +$s = date('Y-m-d H:i', $t_max); +ImageString($im, 5, $width+$legend_line_length - strlen($s)*ImageFontWidth(5), $height + $legend_line_length, $s, $foreground_color); + +for ($t=ceil($t_min/24/60/60); $t<=floor($t_max/24/60/60); $t++) + ImageLine( + $im, + scale($t*24*60*60,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length, + $height, + scale($t*24*60*60,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length, + $height+$legend_line_length, + $foreground_color + ); + +for ($val=0; $val<=$val_max;) { + ImageLine( + $im, + 0, + scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border, + $legend_line_length, + scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border, + $foreground_color + ); + if (! isset($_GET["log"])) + $val+=pow(10,round(log($val_max)/log(10))-1); + elseif ($val==0) + $val++; + else + $val=$val*10; +} + +// ImageString ($im, 1, 5, 5, "Test-String ".rand(), $foreground_color); + +header ("Content-type: image/png"); + +ImagePNG ($im); + +?> diff --git a/buildmaster/status.php b/buildmaster/status.php new file mode 100644 index 0000000..05a4455 --- /dev/null +++ b/buildmaster/status.php @@ -0,0 +1,144 @@ +<?php +require_once "../init.php"; +include BASE . "/lib/mysql.php"; +include BASE . "/lib/style.php"; +include BASE . "/lib/helper.php"; + +$result = mysql_run_query( + "SELECT MAX(`package_sources`.`commit_time`) AS `last_commit`" . + " FROM `package_sources`" +); + +if ($result -> num_rows > 0) { + $result = $result->fetch_assoc(); + $last_commit = $result["last_commit"]; +} + +$result = mysql_run_query( + "SELECT MAX(`build_assignments`.`return_date`) AS `last_return`" . + " FROM `build_assignments`" +); + +if ($result -> num_rows > 0) { + $result = $result->fetch_assoc(); + $last_return = $result["last_return"]; +} + +$result = mysql_run_query( + "SELECT MAX(`binary_packages_in_repositories`.`last_moved`) AS `last_moved`" . + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_build_assignments() . + " WHERE `binary_packages_in_repositories`.`last_moved`>`build_assignments`.`return_date`" +); + +if ($result -> num_rows > 0) { + $result = $result->fetch_assoc(); + $last_moved = $result["last_moved"]; +} + +$age_queries = array( + array( + "label" => "age of build-list-packages", + "column" => "`package_sources`.`commit_time`", + "table" => + "`package_sources`" . + " JOIN (" . + "SELECT " . + "`build_assignments`.`package_source`" . + " FROM `build_assignments`" . + mysql_join_build_assignments_binary_packages() . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + " WHERE `repositories`.`name`=\"build-list\"" . + " AND `build_assignments`.`is_blocked` IS NULL" . + " GROUP BY `build_assignments`.`package_source`" . + ") AS `build_assignments_grouped`" . + " ON `build_assignments_grouped`.`package_source`=`package_sources`.`id`" + ), + array( + "label" => "age of staging-packages", + "column" => "`binary_packages_in_repositories`.`first_last_moved`", + "table" => + "`binary_packages`" . + " JOIN (" . + "SELECT " . + "`binary_packages_in_repositories`.`package`," . + "MIN(`binary_packages_in_repositories`.`last_moved`) AS `first_last_moved`" . + " FROM `binary_packages_in_repositories`" . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() . + " WHERE `repository_stabilities`.`name`=\"staging\"" . + " GROUP BY `binary_packages_in_repositories`.`package`" . + ") AS `binary_packages_in_repositories`" . + " ON `binary_packages_in_repositories`.`package`=`binary_packages`.`id`" + ), + array( + "label" => "age of testing-packages", + "column" => "`binary_packages_in_repositories`.`first_last_moved`", + "table" => + "`binary_packages`" . + " JOIN (" . + "SELECT " . + "`binary_packages_in_repositories`.`package`," . + "MIN(`binary_packages_in_repositories`.`last_moved`) AS `first_last_moved`" . + " FROM `binary_packages_in_repositories`" . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() . + " WHERE `repository_stabilities`.`name`=\"testing\"" . + " GROUP BY `binary_packages_in_repositories`.`package`" . + ") AS `binary_packages_in_repositories`" . + " ON `binary_packages_in_repositories`.`package`=`binary_packages`.`id`" . + " WHERE NOT `binary_packages`.`has_issues`" . + " AND NOT `binary_packages`.`is_tested`" + ), + array( + "label" => "age of tested-packages", + "column" => "`binary_packages_in_repositories`.`first_last_moved`", + "table" => + "`binary_packages`" . + " JOIN (" . + "SELECT " . + "`binary_packages_in_repositories`.`package`," . + "MIN(`binary_packages_in_repositories`.`last_moved`) AS `first_last_moved`" . + " FROM `binary_packages_in_repositories`" . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_repository_stabilities() . + " WHERE `repository_stabilities`.`name`=\"testing\"" . + " GROUP BY `binary_packages_in_repositories`.`package`" . + ") AS `binary_packages_in_repositories`" . + " ON `binary_packages_in_repositories`.`package`=`binary_packages`.`id`" + ) +); + +foreach ($age_queries as $age_query) { + $result = mysql_run_query( + "SELECT " . + "AVG(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(" . $age_query["column"] . ")) AS `avg`," . + "STDDEV(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(" . $age_query["column"] . ")) AS `stddev`" . + " FROM " . $age_query["table"] + ); + if ($result -> num_rows > 0) { + $result = $result->fetch_assoc(); + foreach ($result as $key => $val) + $ages[$age_query["label"]][$key] = format_time_duration($val); + }; +}; + +print_header("Build Master Status"); + +if (isset($last_commit)) + print " latest package source is from " . $last_commit . ".<br>\n"; + +if (isset($last_return)) + print " latest built package is from " . $last_return . ".<br>\n"; + +if (isset($last_moved)) + print " latest package move was on " . $last_moved . ".<br>\n"; + +foreach ($ages as $label => $value) + print " " . $label . ": " . + $value["avg"] . " ± " . + $value["stddev"] . ".<br>\n"; + +print_footer(); diff --git a/buildmaster/to-delete.php b/buildmaster/to-delete.php new file mode 100644 index 0000000..df11750 --- /dev/null +++ b/buildmaster/to-delete.php @@ -0,0 +1,77 @@ +<?php +require_once "../init.php"; +require_once BASE . "/lib/mysql.php"; + + $result = mysql_run_query( + "SELECT " . + "`repositories`.`name` AS `repo`," . + "`binary_packages`.`pkgname`," . + "`binary_packages`.`epoch`," . + "`binary_packages`.`pkgver`," . + "`binary_packages`.`pkgrel`," . + "`binary_packages`.`sub_pkgrel`," . + "`architectures`.`name` AS `arch`" . + " FROM `binary_packages`" . + mysql_join_binary_packages_architectures() . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + "WHERE `binary_packages_in_repositories`.`is_to_be_deleted` " . + "AND `repositories`.`is_on_master_mirror`" + ); + + $available = explode( + "\n", + shell_exec("find /var/lib/pacman/ -name '*.db' -exec tar -tzf {} \; | sed -n 's,-[^-]\+-[^-]\+/$,,;T;p'") + ); + $available = array_combine( $available, $available); +?> +<html> +<head> +<title>List of packages to be deleted</title> +<link rel="stylesheet" type="text/css" href="/static/style.css"> +</head> +<body> +<?php + +show_warning_on_offline_slave(); + +if ($result -> num_rows > 0) { + + $count = 0; + + while ($row = $result->fetch_assoc()) { + + if (isset($available[$row["pkgname"]])) + $color = "#FF0000"; + else + $color = "#00FF00"; + + $rows[$count] = + "<font color=\"" . $color . "\">" . + $row["repo"] . "/" . + $row["pkgname"] . "-"; + if ($row["epoch"] != "0") + $rows[$count] = + $rows[$count] . + $row["epoch"] . ":"; + $rows[$count] = + $rows[$count] . + $row["pkgver"] . "-" . + $row["pkgrel"] . "." . + $row["sub_pkgrel"] . "-" . + $row["arch"] . ".pkg.tar.xz</font>"; + $count++; + } + + sort($rows); + + foreach ($rows as $row) { + print $row."<br>\n"; + } +} else { + print "No packages are to be deleted.\n"; +} + +?> +</body> +</html> diff --git a/buildmaster/todos.php b/buildmaster/todos.php new file mode 100644 index 0000000..bf77f08 --- /dev/null +++ b/buildmaster/todos.php @@ -0,0 +1,97 @@ +<?php +require_once "../init.php"; + +include BASE . "/lib/helper.php"; +include BASE . "/lib/mysql.php"; + +$result = mysql_run_query( + "SELECT DISTINCT " . + "`todos`.`id`," . + "`todos`.`file`," . + "`todos`.`line`," . + "`todos`.`description` " . + "FROM `todos`;" +); + +if (isset($_GET["graph"])) { + + if ($result -> num_rows > 0) { + + while ($row = $result->fetch_assoc()) + $knot_rows[$row["id"]] = + $row["file"]. " (line ".$row["line"].") #".$row["id"].":\\n". + str_replace("\"","\\\"",$row["description"]); + + $knots=""; + foreach ($knot_rows as $knot) + $knots=$knots . "\"" . $knot . "\";\n"; + + } + + $result = mysql_run_query( + "SELECT DISTINCT " . + "`todo_links`.`dependent`," . + "`todo_links`.`depending_on` " . + "FROM `todo_links`;" + ); + + if ($result -> num_rows > 0) { + $count = 0; + while ($row = $result->fetch_assoc()) { + $link_rows[$count]["dependent"] = + $knot_rows[$row["dependent"]]; + $link_rows[$count]["depending_on"] = + $knot_rows[$row["depending_on"]]; + $count++; + } + + $edges=""; + foreach ($link_rows as $link) + $edges=$edges . "\"" . $link["depending_on"] . "\" -> \"" . $link["dependent"] . "\";\n"; + } + + header ("Content-type: image/png"); + passthru( + "echo \"" . base64_encode( + "digraph dependencies {\n" . + "rankdir=LR;\n" . + "fontname=dejavu;\n" . + $knots . + $edges . + "}\n" + ) . "\" | " . + "base64 -d | " . + "timeout 30 dot -Tpng -o/dev/stdout /dev/stdin" + ); + +} else { // isset($_GET["graph"]) + + if ($result -> num_rows > 0) { + + print "<html>\n"; + print "<head>\n"; + print "<title>Todos in the build scripts</title>\n"; + print "</head>\n"; + print "<body>\n"; + show_warning_on_offline_slave(); + + while ($row = $result->fetch_assoc()) { + print "<a href=\"#TODO" . $row["id"] . "\" name=\"TODO" . $row["id"] ."\">TODO #" . $row["id"] . "</a>"; + print " - "; + print "<a href=\""; + print git_url("builder","tree","master",$row["file"],$row["line"]); + print "\">" . $row["file"] . "(line " . $row["line"] . ")</a>"; + print ":<br>\n"; + print str_replace("\\n","<br>\n",$row["description"]); + print "<br>\n"; + print "<br>\n"; + } + + print "</body>\n"; + print "</html>\n"; + + } + +} + +?> |