From 5c5ed42237757efcf698a36c37cf9bd0630232c3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 17 Apr 2018 10:04:07 +0200 Subject: buildmaster/*.php: use lib/mysql.php --- buildmaster/blacklist.php | 61 ++++++++++++++++------------- buildmaster/build-slaves.php | 46 +++++++++++----------- buildmaster/dependencies.php | 73 +++++++++++++--------------------- buildmaster/mysql-issues.php | 93 ++++++++++++++++++++++---------------------- buildmaster/packages.php | 20 ---------- buildmaster/statistics.php | 43 ++++++++++---------- buildmaster/status.php | 22 +++++------ buildmaster/to-delete.php | 41 +++++++++---------- buildmaster/todos.php | 9 ++--- 9 files changed, 187 insertions(+), 221 deletions(-) delete mode 100644 buildmaster/packages.php (limited to 'buildmaster') diff --git a/buildmaster/blacklist.php b/buildmaster/blacklist.php index c2810c6..274d769 100644 --- a/buildmaster/blacklist.php +++ b/buildmaster/blacklist.php @@ -1,33 +1,41 @@ + - -Blacklisted packages - - - - - + + Blacklisted packages + + + +
architecturepackagereason
+ + + + + connect_error) { - die("Connection failed: " . $mysql->connect_error); -} -if ( ! $result = $mysql -> query( - "SELECT DISTINCT `architectures`.`name` AS `architecture`,`package_sources`.`pkgbase`,`build_assignments`.`is_black_listed` " . - "FROM `build_assignments` " . - "JOIN `architectures` ON `build_assignments`.`architecture`=`architectures`.`id` " . - "JOIN `package_sources` ON `build_assignments`.`package_source`=`package_sources`.`id` " . - "WHERE `build_assignments`.`is_black_listed` IS NOT NULL " . - "ORDER BY `package_sources`.`pkgbase`")) { - die($mysql->error); -} if ($result -> num_rows > 0) { while($row = $result->fetch_assoc()) { - print "\n"; + print " \n"; + print " \n"; + print " \n"; + print "\n"; + print " \n"; } } ?> -
architecturepackagereason
"; + print "
"; print $row["architecture"]; - print ""; + print ""; print $row["pkgbase"]; - print ""; + print ""; print preg_replace( array ( "/FS32#(\\d+)/", @@ -39,10 +47,11 @@ if ($result -> num_rows > 0) { ), $row["is_black_listed"] ); - print "
- + + diff --git a/buildmaster/build-slaves.php b/buildmaster/build-slaves.php index b6afc2d..9a45afd 100644 --- a/buildmaster/build-slaves.php +++ b/buildmaster/build-slaves.php @@ -1,28 +1,30 @@ -list of build slaves connect_error) { - die("Connection to mysql database failed: " . $conn->connect_error); - } + include "lib/mysql.php"; + + $result = mysql_run_query( + "SELECT" . + " `build_slaves`.`name`," . + "`build_slaves`.`operator`," . + "`package_sources`.`pkgbase`," . + "`build_slaves`.`last_connection`," . + "`build_slaves`.`logged_lines`," . + "`build_slaves`.`last_action`" . + " FROM `build_slaves`" . + " LEFT JOIN `build_assignments` ON" . + " `build_slaves`.`currently_building`=`build_assignments`.`id`" . + " LEFT JOIN `package_sources` ON" . + " `build_assignments`.`package_source`=`package_sources`.`id`" . + " ORDER BY `build_slaves`.`last_connection`" + ); - if (!$result = - $conn->query( - "SELECT" . - " `build_slaves`.`name`," . - "`build_slaves`.`operator`," . - "`package_sources`.`pkgbase`," . - "`build_slaves`.`last_connection`," . - "`build_slaves`.`logged_lines`," . - "`build_slaves`.`last_action`" . - " FROM `build_slaves`" . - " LEFT JOIN `build_assignments` ON" . - " `build_slaves`.`currently_building`=`build_assignments`.`id`" . - " LEFT JOIN `package_sources` ON" . - " `build_assignments`.`package_source`=`package_sources`.`id`" . - " ORDER BY `build_slaves`.`last_connection`" - )) - die($conn->error); +?> + + + list of build slaves + + +\n"; if ($result->num_rows > 0) { diff --git a/buildmaster/dependencies.php b/buildmaster/dependencies.php index 3a38ac8..af37e5e 100644 --- a/buildmaster/dependencies.php +++ b/buildmaster/dependencies.php @@ -1,9 +1,6 @@ connect_error) { - die("Connection failed: " . $mysql->connect_error); -} +include "lib/mysql.php"; $match = ""; @@ -28,15 +25,15 @@ $colors["virtual"]="#800080"; $limit=200; -if (! $result = $mysql -> query( +mysql_run_query( "CREATE TEMPORARY TABLE `cons` (" . "`dep` BIGINT, " . "`itp` BIGINT, " . "UNIQUE KEY `content` (`dep`,`itp`)" . - ")")) - die($mysql->error); + ")" +); -if (! $result = $mysql -> query( +mysql_run_query( "INSERT IGNORE INTO `cons` (`dep`,`itp`)" . " SELECT `dependencies`.`id`,`install_target_providers`.`id`". " FROM `binary_packages`" . @@ -53,10 +50,9 @@ if (! $result = $mysql -> query( " JOIN `install_target_providers` ON `install_target_providers`.`install_target`=`dependencies`.`depending_on`" . " WHERE (`dependency_types`.`relevant_for_binary_packages` OR `repository_stabilities`.`name`=\"unbuilt\")" . " LIMIT " . $limit - )) - die($mysql->error); +); -if (! $result = $mysql -> query( +mysql_run_query( "INSERT IGNORE INTO `cons` (`dep`,`itp`)" . " SELECT `dependencies`.`id`,`install_target_providers`.`id`". " FROM `binary_packages`" . @@ -73,46 +69,39 @@ if (! $result = $mysql -> query( " JOIN `dependency_types` ON `dependencies`.`dependency_type`=`dependency_types`.`id`" . " WHERE (`dependency_types`.`relevant_for_binary_packages` OR `d_rs`.`name`=\"unbuilt\")" . " LIMIT " . $limit - )) - die($mysql->error); +); unset($knots); unset($edges); -if (! $result = $mysql -> query( +$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`" - )) - die($mysql->error); +); -if ($result -> num_rows > 0) - while ($row = $result->fetch_assoc()) - $edges .= "\"p" . $row["package"] . "\" -> \"i" . $row["install_target"] . "\" [color = \"#000080\"];\n"; +while ($row = $result->fetch_assoc()) + $edges .= "\"p" . $row["package"] . "\" -> \"i" . $row["install_target"] . "\" [color = \"#000080\"];\n"; -if (! $result = $mysql -> query( +$result = mysql_run_query( "SELECT DISTINCT `dependencies`.`dependent`,`dependencies`.`depending_on`,`dependency_types`.`name`" . " FROM `cons`" . " JOIN `dependencies` ON `cons`.`dep`=`dependencies`.`id`" . " JOIN `dependency_types` ON `dependencies`.`dependency_type`=`dependency_types`.`id`" - )) - die($mysql->error); +); -if ($result -> num_rows > 0) - while ($row = $result->fetch_assoc()) - $edges .= "\"i" . $row["depending_on"] . "\" -> \"p" . $row["dependent"] . "\" [taillabel = \"" . $row["name"] . "\"];\n"; +while ($row = $result->fetch_assoc()) + $edges .= "\"i" . $row["depending_on"] . "\" -> \"p" . $row["dependent"] . "\" [taillabel = \"" . $row["name"] . "\"];\n"; -if (! $result = $mysql -> query( +$result = mysql_run_query( "SELECT DISTINCT `install_targets`.`id`,`install_targets`.`name`" . " FROM `cons`" . " JOIN `dependencies` ON `cons`.`dep`=`dependencies`.`id`" . " JOIN `install_targets` ON `dependencies`.`depending_on`=`install_targets`.`id`" - )) - die($mysql->error); +); -if ($result -> num_rows > 0) - while ($row = $result->fetch_assoc()) - $knots .= "\"i" . $row["id"] . "\" [label = \"" . $row["name"] . "\", fontcolor = \"#000080\"];\n"; +while ($row = $result->fetch_assoc()) + $knots .= "\"i" . $row["id"] . "\" [label = \"" . $row["name"] . "\", fontcolor = \"#000080\"];\n"; $pkgfile_query = "CONCAT(". @@ -125,7 +114,7 @@ $pkgfile_query = "`architectures`.`name`" . ") AS `filename`"; -if (! $result = $mysql -> query( +$result = mysql_run_query( "SELECT DISTINCT " . "`binary_packages`.`id`," . "`repository_stabilities`.`name` AS `stability`," . @@ -136,14 +125,12 @@ if (! $result = $mysql -> query( " JOIN `architectures` ON `architectures`.`id`=`binary_packages`.`architecture`" . " JOIN `repositories` ON `repositories`.`id`=`binary_packages`.`repository`" . " JOIN `repository_stabilities` ON `repository_stabilities`.`id`=`repositories`.`stability`" - )) - die($mysql->error); +); -if ($result -> num_rows > 0) - while ($row = $result->fetch_assoc()) - $knots .= "\"p" . $row["id"] . "\" [label = \"" . $row["filename"] . "\", fontcolor = \"" . $colors[$row["stability"]] . "\"];\n"; +while ($row = $result->fetch_assoc()) + $knots .= "\"p" . $row["id"] . "\" [label = \"" . $row["filename"] . "\", fontcolor = \"" . $colors[$row["stability"]] . "\"];\n"; -if (! $result = $mysql -> query( +$result = mysql_run_query( "SELECT DISTINCT " . "`binary_packages`.`id`," . "`repository_stabilities`.`name` AS `stability`," . @@ -154,12 +141,10 @@ if (! $result = $mysql -> query( " JOIN `architectures` ON `architectures`.`id`=`binary_packages`.`architecture`" . " JOIN `repositories` ON `repositories`.`id`=`binary_packages`.`repository`" . " JOIN `repository_stabilities` ON `repository_stabilities`.`id`=`repositories`.`stability`" - )) - die($mysql->error); +); -if ($result -> num_rows > 0) - while ($row = $result->fetch_assoc()) - $knots .= "\"p" . $row["id"] . "\" [label = \"" . $row["filename"] . "\", fontcolor = \"" . $colors[$row["stability"]] . "\"];\n"; +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); @@ -175,5 +160,3 @@ passthru( "}\n" . "EOF\n" ); - -?> diff --git a/buildmaster/mysql-issues.php b/buildmaster/mysql-issues.php index 5342ba4..2b54c34 100644 --- a/buildmaster/mysql-issues.php +++ b/buildmaster/mysql-issues.php @@ -1,23 +1,13 @@ - - -More and less critical issues with the database - - - -Start page
connect_error) { - die("Connection failed: " . $mysql->connect_error); - } - - if (! $result = $mysql -> query( + $result = mysql_run_query( "SELECT CONCAT(" . "`repositories`.`name`,\"/\"," . "`binary_packages`.`pkgname`,\"-\"," . @@ -56,30 +46,13 @@ ")" . $ignore . " ORDER BY `is_to_be_deleted`, `binary_packages`.`pkgname`" - )) - die($mysql -> error); - - print "Found " . ($result -> num_rows) . " serious issues.
\n"; + ); - if ($result -> num_rows > 0) { - - while ($row = $result->fetch_assoc()) { - if ($row["is_to_be_deleted"]==1) - print "(marked as to-be-deleted) "; - else - print ""; - print $row["pkgfile"] . " depends on " . $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 ".
"; - print "
\n"; - } - - } + $serious_issues = array(); + while ( $row = $result -> fetch_assoc() ) + $serious_issues[] = $row; - if (! $result = $mysql -> query( + $result = mysql_run_query( "SELECT CONCAT(" . "`repositories`.`name`,\"/\"," . "`binary_packages`.`pkgname`,\"-\"," . @@ -114,21 +87,47 @@ ")" . $ignore . " ORDER BY `is_to_be_deleted`, `binary_packages`.`pkgname`" - )) - die($mysql -> error); + ); - print "Found " . ($result -> num_rows) . " stability issues.
\n"; + $stability_issues = array(); + while ( $row = $result -> fetch_assoc() ) + $stability_issues[] = $row; + +?> + + +More and less critical issues with the database + + + +Start page
+\n"; + + foreach ( $serious_issues as $row ) { + if ($row["is_to_be_deleted"]==1) + print "(marked as to-be-deleted) "; + else + print ""; + print $row["pkgfile"] . " depends on " . $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 ".
"; + print "
\n"; + } - if ($result -> num_rows > 0) { - while ($row = $result->fetch_assoc()) { - if ($row["is_to_be_deleted"]==1) - print "(marked as to-be-deleted) "; - else - print ""; - print $row["pkgfile"] . " depends on " . $row["install_target"] . " which is not provided by any package installable from enabled " . $row["stability"] . " repositories.
"; - print "
\n"; - } + print "Found " . count( $stability_issues ) . " stability issues.
\n"; + foreach ( $stability_issues as $row ) { + if ($row["is_to_be_deleted"]==1) + print "(marked as to-be-deleted) "; + else + print ""; + print $row["pkgfile"] . " depends on " . $row["install_target"] . " which is not provided by any package installable from enabled " . $row["stability"] . " repositories.
"; + print "
\n"; } ?> diff --git a/buildmaster/packages.php b/buildmaster/packages.php deleted file mode 100644 index b7c0196..0000000 --- a/buildmaster/packages.php +++ /dev/null @@ -1,20 +0,0 @@ -connect_error) { - die("Connection to mysql database failed: " . $mysql->connect_error); - } - - $result = $mysql -> query("SELECT * FROM `binary_packages`"); - if ($result -> num_rows > 0) { - while($row = $result->fetch_assoc()) { - foreach ($row as $key => $val) { - print $key .": ".$val." - "; - } - print "
\n"; - } - } - - print 'OK'; - -?> diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php index 47f1418..8c13548 100644 --- a/buildmaster/statistics.php +++ b/buildmaster/statistics.php @@ -1,33 +1,30 @@ connect_error) { - die("Connection failed: " . $mysql->connect_error); -} -if (! $result = $mysql -> query( - "SELECT DISTINCT ". - "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," . - "`statistics`.`pending_tasks_count`," . - "`statistics`.`pending_packages_count`," . - "`statistics`.`staging_packages_count`," . - "`statistics`.`testing_packages_count`," . - "`statistics`.`tested_packages_count`," . - "`statistics`.`broken_tasks_count`," . - "`statistics`.`dependency_loops_count`," . - "`statistics`.`dependency_looped_tasks_count`," . - "`statistics`.`locked_tasks_count`," . - "`statistics`.`blocked_tasks_count`," . - "`statistics`.`next_tasks_count`" . - "FROM `statistics` " . - "WHERE `statistics`.`date`>=ADDTIME(NOW()," . $min_time . ") " . - "ORDER BY `statistics`.`date`" - )) - die($mysql->error); +$result = mysql_run_query( + "SELECT DISTINCT ". + "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," . + "`statistics`.`pending_tasks_count`," . + "`statistics`.`pending_packages_count`," . + "`statistics`.`staging_packages_count`," . + "`statistics`.`testing_packages_count`," . + "`statistics`.`tested_packages_count`," . + "`statistics`.`broken_tasks_count`," . + "`statistics`.`dependency_loops_count`," . + "`statistics`.`dependency_looped_tasks_count`," . + "`statistics`.`locked_tasks_count`," . + "`statistics`.`blocked_tasks_count`," . + "`statistics`.`next_tasks_count`" . + "FROM `statistics` " . + "WHERE `statistics`.`date`>=ADDTIME(NOW()," . $min_time . ") " . + "ORDER BY `statistics`.`date`" +); $t_min = -1; $t_max = -1; diff --git a/buildmaster/status.php b/buildmaster/status.php index 32f386d..28eee69 100644 --- a/buildmaster/status.php +++ b/buildmaster/status.php @@ -1,3 +1,13 @@ + Build master status @@ -7,19 +17,7 @@ Start page
connect_error) { - die("Connection failed: " . $mysql->connect_error); -} - -if ( ! $result = $mysql -> query( - "SELECT MAX(`package_sources`.`commit_time`) AS `last`" . - "FROM `package_sources`" - )) - die($mysql->error); - if ($result -> num_rows > 0) { - $row = $result->fetch_assoc(); print "latest package source is from " . $row["last"] . ".
\n"; } diff --git a/buildmaster/to-delete.php b/buildmaster/to-delete.php index dfa5a39..4da10a2 100644 --- a/buildmaster/to-delete.php +++ b/buildmaster/to-delete.php @@ -1,3 +1,24 @@ + List of packages to be deleted @@ -6,26 +27,6 @@ connect_error) { - die("Connection failed: " . $mysql->connect_error); -} - -$result = $mysql -> 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` " . - "JOIN `architectures` ON `binary_packages`.`architecture`=`architectures`.`id` " . - "JOIN `repositories` ON `binary_packages`.`repository`=`repositories`.`id` " . - "WHERE `binary_packages`.`is_to_be_deleted` " . - "AND NOT `repositories`.`name` IN (\"build-support\",\"build-list\",\"deletion-list\")" -); if ($result -> num_rows > 0) { $count = 0; diff --git a/buildmaster/todos.php b/buildmaster/todos.php index 99e991c..ba870fc 100644 --- a/buildmaster/todos.php +++ b/buildmaster/todos.php @@ -1,11 +1,8 @@ connect_error) { - die("Connection failed: " . $mysql->connect_error); -} +include "lib/mysql.php"; -$result = $mysql -> query( +$result = mysql_run_query( "SELECT DISTINCT " . "`todos`.`id`," . "`todos`.`file`," . @@ -28,7 +25,7 @@ if (isset($_GET["graph"])) { } - $result = $mysql -> query( + $result = mysql_run_query( "SELECT DISTINCT " . "`todo_links`.`dependent`," . "`todo_links`.`depending_on` " . -- cgit v1.2.3-70-g09d2