summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-03-07 13:58:16 +0100
committerErich Eckner <git@eckner.net>2019-03-07 13:58:16 +0100
commit229df61eba717104bbaa34b6112e0b4fd5503598 (patch)
tree237f1c4b0f8e650e17f232bbb103d4d901ab194c
parent96d39b398eb9b57fe808e34b40e7123204eef1db (diff)
downloadarchweb32-229df61eba717104bbaa34b6112e0b4fd5503598.tar.xz
table `upstream_packages` makes available_upstream_packages() obsolete
-rw-r--r--buildmaster/deletion-links.php28
-rw-r--r--buildmaster/to-delete.php14
-rw-r--r--lib/helper.php86
3 files changed, 11 insertions, 117 deletions
diff --git a/buildmaster/deletion-links.php b/buildmaster/deletion-links.php
index 54329bb..3a82c4e 100644
--- a/buildmaster/deletion-links.php
+++ b/buildmaster/deletion-links.php
@@ -16,29 +16,6 @@ if (array_key_exists("pkgname", $_GET))
else
$filter = "";
-$available_upstream_packages = available_upstream_packages('pkgname');
-
-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, " .
@@ -53,7 +30,7 @@ mysql_run_query(
" SELECT" .
" `binary_packages_in_repositories`.`id`," .
"IF(" .
- "`available`.`pkgname` IS NULL," .
+ "`upstream_packages`.`id` IS NULL," .
"\"#00ff00\"," .
"IF(" .
"`build_assignments`.`is_black_listed` IS NULL," .
@@ -65,7 +42,8 @@ mysql_run_query(
mysql_join_binary_packages_in_repositories_binary_packages() .
mysql_join_binary_packages_build_assignments() .
$available_filter .
- " JOIN `available` ON `available`.`pkgname`=`binary_packages`.`pkgname`" .
+ " JOIN `upstream_packages`" .
+ " ON `upstream_packages`.`pkgname`=`binary_packages`.`pkgname`" .
" WHERE `binary_packages_in_repositories`.`is_to_be_deleted`" .
" AND `binary_packages`.`pkgname` NOT LIKE \"lib32-%\"" .
$filter
diff --git a/buildmaster/to-delete.php b/buildmaster/to-delete.php
index 579bd62..8458c74 100644
--- a/buildmaster/to-delete.php
+++ b/buildmaster/to-delete.php
@@ -11,17 +11,19 @@ require_once BASE . "/lib/mysql.php";
"`binary_packages`.`pkgver`," .
"`binary_packages`.`pkgrel`," .
"`binary_packages`.`sub_pkgrel`," .
- "`architectures`.`name` AS `arch`" .
+ "`architectures`.`name` AS `arch`," .
+ "IF(`upstream_packages`.`id` IS NULL, 0, 1) AS `exists_upstream`" .
" 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`"
+ " LEFT JOIN `upstream_packages`" .
+ " ON `upstream_packages`.`pkgname`=`binary_packages`.`pkgname`" .
+ " WHERE `binary_packages_in_repositories`.`is_to_be_deleted`" .
+ " AND `repositories`.`is_on_master_mirror`" .
+ " GROUP BY CONCAT(`binary_packages_in_repositories`.`id`,\"-\",IFNULL(`upstream_packages`.`pkgname`,0))"
);
- $available = available_upstream_packages('pkgname');
- $available = array_combine( $available, $available);
?>
<html>
<head>
@@ -39,7 +41,7 @@ if ($result -> num_rows > 0) {
while ($row = $result->fetch_assoc()) {
- if (isset($available[$row["pkgname"]]))
+ if ($row['exists_upstream'] == 1)
$color = "#FF0000";
else
$color = "#00FF00";
diff --git a/lib/helper.php b/lib/helper.php
index 0d7c5e5..43bd8a8 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -187,89 +187,3 @@ function add_fancy_unit($value, $unit) {
$exponent = max(0,min(count($suffixes)-1,round(log(abs($value))/log(1024)-1)));
return sprintf("%.2f %s%s", $value / pow(1024,$exponent), $suffixes[8 + $exponent], $unit);
}
-
-function parse_package_filename($filename, $repo = NULL) {
- if (! preg_match(
- '/^(\S+)-(([^-:]+):)?([^-:]+)-([^-]+)-([^-]+)\.pkg\.tar\.xz$/',
- $filename,
- $matches
- ))
- return;
- $result = array(
- 'pkgname' => $matches[1],
- 'pkgver' => $matches[4],
- 'pkgrel' => $matches[5],
- 'arch' => $matches[6]
- );
- if (!empty($repo))
- $result['repo'] = $repo;
- if (empty($matches[3]))
- $result['epoch'] = '0';
- else
- $result['epoch'] = $matches[3];
-
- return $result;
-}
-
-function find_upstream_packages_in($repo) {
- $parse_package_filename_in_repo = function($filename) use ($repo) {
- return parse_package_filename($filename, $repo);
- };
- if (!file_exists("/var/lib/pacman/sync/" . $repo . ".db"))
- return NULL;
- return
- array_map(
- $parse_package_filename_in_repo,
- explode(
- "\n",
- shell_exec(
- "tar -Oxzf /var/lib/pacman/sync/" . $repo . ".db" .
- " | grep -xFA1 '%FILENAME%'" .
- " | grep -vxF '%FILENAME%\n--'"
- )
- )
- );
-}
-
-function available_upstream_packages($columns = NULL) {
- $available_upstream_packages = apcu_fetch('available_upstream_packages', $apcu_success);
- if ($apcu_success == false) {
- $available_upstream_packages_repowise = array_map(
- 'find_upstream_packages_in',
- array(
- 'core', 'extra', 'community'
- )
- );
- $available_upstream_packages = array();
- foreach ($available_upstream_packages_repowise as $sub_array)
- $available_upstream_packages =
- array_merge(
- $available_upstream_packages,
- $sub_array
- );
- apcu_store('available_upstream_packages', $available_upstream_packages, 1800);
- }
-
- if (!isset($columns))
- return $available_upstream_packages;
- if (!is_array($columns))
- return array_column($available_upstream_packages, $columns);
- $select_columns_of_interest = function($row) use ($columns) {
- $select = function($column) use ($row) {
- return $row[$column];
- };
- return
- array_combine(
- $columns,
- array_map(
- $select,
- $columns
- )
- );
- };
- return
- array_map(
- $select_columns_of_interest,
- $available_upstream_packages
- );
-}