summaryrefslogtreecommitdiff
path: root/buildmaster/dependencies.php
diff options
context:
space:
mode:
Diffstat (limited to 'buildmaster/dependencies.php')
-rw-r--r--buildmaster/dependencies.php190
1 files changed, 190 insertions, 0 deletions
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"
+);