index : website | |
Archlinux32 website - obsolete | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | packages/favicon.ico | bin | 0 -> 501 bytes | |||
-rw-r--r-- | packages/index.php | 532 | ||||
-rw-r--r-- | packages/pkginfo.php | 701 |
diff --git a/packages/favicon.ico b/packages/favicon.ico Binary files differnew file mode 100644 index 0000000..8ef6f13 --- /dev/null +++ b/packages/favicon.ico diff --git a/packages/index.php b/packages/index.php new file mode 100644 index 0000000..1d3acca --- /dev/null +++ b/packages/index.php @@ -0,0 +1,532 @@ +<?php +require_once "../init.php"; + +require_once BASE . "/lib/mysql.php"; +require_once BASE . "/lib/style.php"; +require_once BASE . "/lib/format.php"; + + + foreach (array("bugs","sort","del","uses_upstream","uses_modification") as $expected_param) + if (! isset($_GET[$expected_param])) + $_GET[$expected_param] = ""; + + $multi_select_search_criteria = array( + "arch" => array( + "name" => "arch", + "title" => "CPU architecture", + "label" => "Arch", + "table" => "architectures", + "column" => "`architectures`.`name`", + "extra_condition" => "", + "values" => array() + ), + "repo" => array( + "name" => "repo", + "title" => "respository", + "label" => "Repository", + "table" => "repositories", + "column" => "CONCAT(`architectures`.`name`,\"/\",`repositories`.`name`)", + "extra_condition" => mysql_join_repositories_architectures() . " WHERE `repositories`.`is_on_master_mirror`", + "values" => array() + ) + ); + + foreach ( $multi_select_search_criteria as $criterium => $content ) { + $result = mysql_run_query( + "SELECT " . $content["column"] . " AS `name` FROM `" . $content["table"] . "`" . $content["extra_condition"] . " ORDER BY `name`" + ); + while ($row = $result -> fetch_assoc()) + $multi_select_search_criteria[$criterium]["values"][] = $row["name"]; + } + + $float_columns = array( + "has_issues", + "is_to_be_deleted" + ); + + $filter = " WHERE 1"; + foreach ($multi_select_search_criteria as $criterium) + if (isset($_GET[$criterium["name"]])) { + $filter .= " AND " . $criterium["column"] . " IN ("; + foreach ($criterium["values"] as $value) + if (strpos("&" . urldecode($_SERVER["QUERY_STRING"]) . "&", "&" . $criterium["name"] . "=" . $value . "&") !== false) + $filter .= "\"" . $value . "\","; + $filter .= "\"\")"; + } + + $single_select_search_criteria = array( + "bugs" => array( + "name" => "bugs", + "label" => "Bugs", + "title" => "bug-tracker status", + "options" => array( + "All" => "1", + "Bugs" => "`binary_packages`.`has_issues`", + "No Bugs" => "NOT `binary_packages`.`has_issues`" + ) + ), + "del" => array( + "name" => "del", + "label" => "To Be Deleted", + "title" => "to-be-deleted status", + "options" => array( + "All" => "1", + "To Be Deleted" => "`binary_packages_in_repositories`.`is_to_be_deleted`", + "Not To Be Deleted" => "NOT `binary_packages_in_repositories`.`is_to_be_deleted`" + ) + ), + "uses_upstream" => array( + "name" => "uses_upstream", + "label" => "Upstream", + "title" => "wether upstream source exists", + "options" => array( + "All" => "1", + "Uses Upstream" => "`package_sources`.`uses_upstream`", + "Does Not Use Upstream" => "NOT `package_sources`.`uses_upstream`" + ) + ), + "uses_modification" => array( + "name" => "uses_modification", + "label" => "Modification", + "title" => "wether modification exists", + "options" => array( + "All" => "1", + "Uses Modification" => "`package_sources`.`uses_modification`", + "Does Not Use Modification" => "NOT `package_sources`.`uses_modification`" + ) + ) + ); + + 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"]]]; + + if (isset($_GET["q"])) { + $exact_filter = " AND `binary_packages`.`pkgname` = from_base64(\"".base64_encode($_GET["q"])."\")"; + $fuzzy_filter = " AND `binary_packages`.`pkgname` LIKE from_base64(\"".base64_encode("%".$_GET["q"]."%")."\")"; + } else { + $exact_filter = " AND 0"; + $fuzzy_filter = ""; + } + + $query = " FROM `binary_packages`" . + mysql_join_binary_packages_architectures() . + 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_build_assignments() . + mysql_join_build_assignments_package_sources() . + $filter . $exact_filter . + " ORDER BY "; + + $query .= "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`"; + + $result = mysql_run_query( + "SELECT " . + "`binary_packages`.`pkgname`," . + "`package_sources`.`pkgbase`," . + "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`) AS `repo`," . + "`architectures`.`name` AS `arch`," . + mysql_query_package_version("binary_packages") . + " AS `version`," . + "IF(`binary_packages`.`has_issues`,1,0) AS `has_issues`," . + "`build_assignments`.`return_date` AS `build_date`," . + "`binary_packages_in_repositories`.`last_moved` AS `move_date`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`" . + $query + ); + $exact_matches = array(); + while ($row = $result -> fetch_assoc()) { + foreach ($float_columns as $float_column) + $row[$float_column] = floatval($row[$float_column]); + $exact_matches[] = $row; + } + + $sorts = array( + "arch" => array( + "title" => "architecture", + "label" => "Arch", + "mysql" => "`architectures`.`name`" + ), + "repo" => array( + "title" => "repository", + "label" => "Repo", + "mysql" => "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`)" + ), + "pkgname" => array( + "title" => "package name", + "label" => "Name", + "mysql" => "`binary_packages`.`pkgname`" + ), + "pkgver" => array( + "title" => "package version", + "label" => "Version", + "mysql" => mysql_query_package_version("binary_packages") + ), + "bugs" => array( + "title" => "bug status", + "label" => "Bugs", + "mysql" => "NOT `binary_packages`.`has_issues`" + ), + "build_date" => array( + "title" => "build date", + "label" => "Build Date", + "mysql" => "IFNULL(`build_assignments`.`return_date`,\"00-00-0000 00:00:00\")" + ), + "move_date" => array( + "title" => "last update", + "label" => "Last Updated", + "mysql" => "IFNULL(`binary_packages_in_repositories`.`last_moved`,\"00-00-0000 00:00:00\")" + ), + "del" => array( + "title" => "to be deleted", + "label" => "Delete", + "mysql" => "`binary_packages_in_repositories`.`is_to_be_deleted`" + ) + ); + + $query = " FROM `binary_packages`" . + mysql_join_binary_packages_architectures() . + 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_build_assignments() . + mysql_join_build_assignments_package_sources() . + $filter . $fuzzy_filter . + " ORDER BY "; + + if (isset($_GET["sort"])) { + if (isset($sorts[$_GET["sort"]]["mysql"])) + $query .= $sorts[$_GET["sort"]]["mysql"] . ","; + elseif (isset($sorts[substr($_GET["sort"],1)]["mysql"])) + $query .= $sorts[substr($_GET["sort"],1)]["mysql"] . " DESC,"; + } + + $query .= "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`"; + + $result = mysql_run_query( + "SELECT COUNT(1)" . $query + ); + $num_results = implode($result -> fetch_assoc()); + + $pages = max(ceil($num_results / 100), 1); + if (isset($_GET["page"])) + $page = max(min($_GET["page"]+0, $pages),1); + else + $page = 1; + + $result = mysql_run_query( + "SELECT " . + "`binary_packages`.`pkgname`," . + "`package_sources`.`pkgbase`," . + "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`) AS `repo`," . + "`architectures`.`name` AS `arch`," . + mysql_query_package_version("binary_packages") . + " AS `version`," . + "IF(`binary_packages`.`has_issues`,1,0) AS `has_issues`," . + "`build_assignments`.`return_date` AS `build_date`," . + "`binary_packages_in_repositories`.`last_moved` AS `move_date`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`" . + $query . + " LIMIT " . (($page-1)*100) . ", 100" + ); + $fuzzy_matches = array(); + while ($row = $result -> fetch_assoc()) { + foreach ($float_columns as $float_column) + $row[$float_column] = floatval($row[$float_column]); + $fuzzy_matches[] = $row; + } + + function print_results($results) { + $oddity="odd"; + foreach ($results as $row) { + print " <tr class=\"" . $oddity . "\">\n"; + print " <td>\n"; + print " " . $row["arch"] . "\n"; + print " </td>\n"; + print " <td>\n"; + print " " . $row["repo"] . "\n"; + print " </td>\n"; + print " <td>\n"; + print " <a href=\"/" . $row["repo"] . "/" . $row["pkgname"] ."/\" "; + print "title=\"View package details for " . $row["pkgname"] . "\">" . $row["pkgname"] . "</a>\n"; + print " </td>\n"; + print " <td>\n"; + print " " . $row["version"] . "\n"; + print " </td>\n"; + print " <td>\n"; + print " "; + if ($row["has_issues"]) + print "has open bug reports"; + else + print " "; + print "\n"; + print " </td>\n"; + print " <td>\n"; + print " "; + if (isset($row["build_date"])) + print $row["build_date"]; + else + print " "; + print "\n"; + print " </td>\n"; + print " <td>\n"; + print " "; + if (isset($row["move_date"])) + print $row["move_date"]; + else + print " "; + print "\n"; + print " </td>\n"; + print " <td>\n"; + print " "; + if ($row["is_to_be_deleted"]) + print "to be deleted"; + else + print " "; + print "\n"; + print " </td>\n"; + print " </tr>\n"; + if ($oddity == "odd" ) + $oddity = "even"; + else + $oddity = "odd"; + } + } + + function header_and_footer() { + + global $page, $pages, $num_results; + + print " <div class=\"pkglist-stats\">\n"; + print " <p>\n"; + print " " . $num_results . " matching package"; + if ($num_results != 1) + print "s"; + print " found.\n"; + + if ($pages != 1) + print " Page " . $page . " of " . $pages . ".\n"; + + print " </p>\n"; + + if ($pages != 1) { + print " <div class=\"pkglist-nav\">\n"; + print " <span class=\"prev\">\n"; + + print " "; + if ($page > 1) { + print "<a href=\"?"; + print substr(str_replace( + "&page=".$page."&", + "&", + "&".$_SERVER["QUERY_STRING"]."&" + ),1)."page=".($page-1); + print "\" title=\"Go to previous page\">"; + }; + print "< Prev"; + if ($page > 1) + print "</a>"; + print "\n"; + print " </span>\n"; + print " <span class=\"next\">\n"; + + print " "; + if ($page < $pages) { + print "<a href=\"?"; + print substr(str_replace( + "&page=".$page."&", + "&", + "&".$_SERVER["QUERY_STRING"]."&" + ),1)."page=".($page+1); + print "\" title=\"Go to next page\">"; + }; + print "Next >"; + if ($page < $pages) + print "</a>"; + print "\n"; + print " </span>\n"; + print " </div>\n"; + }; + print " </div>\n"; + + }; + + if (isset($_GET["exact"])) { + export_as_requested( + array( + "All" => $exact_matches + ) + ); + die(); + }; + + if (isset($_GET["fuzzy"])) { + export_as_requested( + array( + "All" => $fuzzy_matches + ) + ); + die(); + }; + + print_header("Package Search"); + +?> + <div id="pkglist-search" class="box filter-criteria"> + <h2>Package Search</h2> + <form id="pkg-search" method="get" action="/"> + <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( "&" . urldecode($_SERVER["QUERY_STRING"]) . "&", "&" . $criterium["name"] . "=" . $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"]."\""; +?>/> + </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 ($_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($exact_matches) > 0) { +?> + <div id="exact-matches" class="box"> + <div class="pkglist-stats"> + <p><?php print count($exact_matches); ?> exact match<?php if (count($exact_matches) != 1) print "es"; ?> found.</p> + </div> + <table class="results"> + <thead> + <tr> +<?php + + foreach ($sorts as $get => $sort) { + print " <th>\n"; + print " ".$sort["label"]."\n"; + print " </th>\n"; + } +?> + </tr> + </thead> + <tbody> +<?php + print_results($exact_matches); +?> + </tbody> + </table> + </div> +<?php +} + +?> + <div id="pkglist-results" class="box"> +<?php + + header_and_footer(); + +?> + <table class="results"> + <thead> + <tr> +<?php + + foreach ($sorts as $get => $sort) { + print " <th>\n"; + print " <a href=\"/?"; + print substr(str_replace( + "&sort=".$_GET["sort"]."&", + "&", + "&".$_SERVER["QUERY_STRING"]."&" + ),1)."sort="; + if ($_GET["sort"] == $get) + print "-"; + print $get."\" title=\"Sort package by ".$sort["title"]."\">".$sort["label"]."</a>\n"; + print " </th>\n"; + } +?> + </tr> + </thead> + <tbody> +<?php + + print_results($fuzzy_matches); + +?> + </tbody> + </table> +<?php + + header_and_footer(); + +?> + </div> + <div id="pkglist-about" class="box"> + <p> + Can't find what you are looking for? Try searching again + using different criteria, or try + searching the <a href="https://aur.archlinux.org/">AUR</a> + to see if the package can be found there. + </p> + <p> + You are browsing the Arch Linux 32 package database. From here you can find + detailed information about packages located in the 32 bit repositories. + </p> + </div> +<?php + + print_footer(); diff --git a/packages/pkginfo.php b/packages/pkginfo.php new file mode 100644 index 0000000..0717aa1 --- /dev/null +++ b/packages/pkginfo.php @@ -0,0 +1,701 @@ +<?php +require_once "../init.php"; + +if (($_GET['repo']=='i686') || ($_GET['repo']=='i486') || ($_GET['repo']=='any')) { + header('Location: /' . $_GET['repo'] . '/' . $_GET['repo_arch'] . '/' . $_GET['pkgname'] . '/'); + error_log('needed redirect URL: ' . $_SERVER['REQUEST_URI'] . ', HTTP_USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . ', HTTP_REFERER: ' . $_SERVER['HTTP_REFERER']); + die(); +} + +require_once BASE . "/lib/helper.php"; +require_once BASE . "/lib/mysql.php"; +require_once BASE . "/lib/style.php"; + + $memcache = new Memcache; + $memcache -> connect('localhost', 11211) or die ('Memcached Connection Error'); + $pkgapi_reachable = $memcache -> get('pkgapi_reachable'); + $tld = explode('.', $_SERVER['HTTP_HOST']); + end($tld); + $tld = current($tld); + if ((array_key_exists('HTTPS', $_SERVER) && + ($_SERVER['HTTPS'] == 'on')) || + (array_key_exists('HTTP_X_FORWARDED_PROTO', $_SERVER) && + ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))) + $protocol = 'https'; + else + $protocol = 'http'; + if ($pkgapi_reachable === false) { + if (site_is_reachable($protocol . '://pkgapi.archlinux32.' . $tld . '/')) + $pkgapi_reachable = 'YES'; + else + $pkgapi_reachable = 'NO'; + $memcache -> set('pkgapi_reachable', $pkgapi_reachable, 0, 300); + } + if ($pkgapi_reachable == 'YES') + $skip_json_checks = false; + else + $skip_json_checks = true; + + if (!array_key_exists("repo_arch",$_GET)) { + $_GET["repo_arch"] = $_GET["arch"]; + unset($_GET["arch"]); + } + + if (!$skip_json_checks) { + $json_content = json_decode( + file_get_contents( + $protocol . '://pkgapi.archlinux32.' . $tld . '/' . + urlencode($_GET["repo_arch"]) . '/' . + urlencode($_GET["repo"]) . '/' . + urlencode($_GET["pkgname"]) + ), + true + ); + + if (!isset($json_content) || !array_key_exists('Name', $json_content)) { + //throw_http_error(404, "Package Not Found In Sync Database"); + unset($json_content); + $skip_json_checks = true; + }; + } + + $mysql_result = mysql_run_query( + "SELECT " . + "`binary_packages`.`id`," . + "`binary_packages`.`pkgname`," . + "`sp_q`.`split_packages`," . + "`package_sources`.`pkgbase`," . + mysql_query_package_version("binary_packages") . + " AS `version`," . + "`repositories`.`stability` AS `repo_stability`," . + "`repository_stabilities`.`name` AS `repo_stability_name`," . + "`repositories`.`name` AS `repo`," . + "`r_a`.`name` AS `repo_arch`," . + "`architectures`.`name` AS `arch`," . + "`git_repositories`.`name` AS `git_repo`," . + "`package_sources`.`uses_upstream`," . + "`package_sources`.`uses_modification`," . + "MAX(`binary_packages_in_repositories`.`last_moved`) AS `last_moved`," . + "`sr`.`name` AS `stable_repo`" . + " FROM `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() . + mysql_join_repositories_architectures("","r_a") . + mysql_join_binary_packages_build_assignments() . + mysql_join_build_assignments_package_sources() . + mysql_join_package_sources_upstream_repositories() . + mysql_join_upstream_repositories_git_repositories() . + mysql_join_upstream_repositories_repository_moves() . + " JOIN `repositories` AS `sr` ON `sr`.`id`=`repository_moves`.`to_repository`" . + " JOIN (" . + "SELECT DISTINCT `binary_packages`.`build_assignment`," . + "GROUP_CONCAT(" . + "CONCAT(" . + "\"\\\"\",`binary_packages`.`id`,\"\\\": {" . + "\\\"pkgname\\\":" . + " \\\"\",`binary_packages`.`pkgname`,\"\\\"," . + "\\\"repository\\\":" . + " \\\"\",`repositories`.`name`,\"\\\"," . + "\\\"repo_arch\\\":" . + " \\\"\",`architectures`.`name`,\"\\\"" . + "}\"" . + ")" . + ") AS `split_packages`" . + " FROM `binary_packages`" . + mysql_join_binary_packages_binary_packages_in_repositories() . + mysql_join_binary_packages_in_repositories_repositories() . + mysql_join_repositories_architectures() . + " GROUP BY `binary_packages`.`build_assignment`" . + ") AS `sp_q`" . + " ON `sp_q`.`build_assignment`=`build_assignments`.`id`" . + " WHERE `binary_packages`.`pkgname`=from_base64(\"" . base64_encode($_GET["pkgname"]) . "\")" . + " AND `r_a`.`name`=from_base64(\"" . base64_encode($_GET["repo_arch"]) . "\")" . + " AND `repositories`.`name`=from_base64(\"" . base64_encode($_GET["repo"]) . "\")" . + " AND NOT EXISTS (" . + "SELECT 1" . + " FROM `repository_moves` AS `rm`" . + " WHERE `rm`.`from_repository`=`sr`.`id`" . + ")" . + " GROUP BY `binary_packages`.`id`" + ); + + if ($mysql_result -> num_rows != 1) + throw_http_error(404, "Package Not Found In Buildmaster's Database"); + + $mysql_content = $mysql_result -> fetch_assoc(); + $mysql_content["split_packages"] = array_map("unserialize", array_unique(array_map("serialize", json_decode("{".$mysql_content["split_packages"]."}",true)))); + + if (!$skip_json_checks) { + $same_keys = array ( + array("mysql" => "pkgname", "json" => "Name"), + array("mysql" => "version", "json" => "Version", "suffix_diff" => ".0"), + array("mysql" => "repo", "json" => "Repository"), + array("mysql" => "arch", "json" => "Architecture") + ); + + foreach ($same_keys as $same_key) + if (($mysql_content[$same_key["mysql"]] != $json_content[$same_key["json"]]) && + ((!array_key_exists('suffix_diff', $same_key)) || + ($mysql_content[$same_key["mysql"]] != $json_content[$same_key["json"]].$same_key["suffix_diff"]))) + die_500("Inconsistency in Database found:<br>\n" . + "buildmaster[" . $same_key["mysql"] . "] != repositories[" . $same_key["json"] . "]:<br>\n" . + "\"" . $mysql_content[$same_key["mysql"]] . "\" != \"" . $json_content[$same_key["json"]] . "\""); + } + + // query _all_ dependencies + + $mysql_result = mysql_run_query( + "SELECT DISTINCT " . + "`dependency_types`.`name` AS `dependency_type`," . + "GROUP_CONCAT(" . + "CONCAT(\"\\\"\",`install_target_providers`.`id`,\"\\\": \",\"{\\n\"," . + "\" \\\"repo\\\": \\\"\",`repositories`.`name`,\"\\\",\\n\"," . + "\" \\\"repo_arch\\\": \\\"\",`r_a`.`name`,\"\\\",\\n\"," . + "\" \\\"arch\\\": \\\"\",`architectures`.`name`,\"\\\",\\n\"," . + "\" \\\"pkgname\\\": \\\"\",`binary_packages`.`pkgname`,\"\\\",\\n\"," . + "\" \\\"is_to_be_deleted\\\": \\\"\",IF(`binary_packages_in_repositories`.`is_to_be_deleted`,\"1\",\"0\"),\"\\\"\\n\"," . + "\"}\"" . + ")) AS `deps`," . + "IF(" . + "(" . + "`versions`.`order`=1 AND `dependencies`.`version_relation`=\">=\"" . + ") OR (" . + "`versions`.`epoch`=8388607 AND `dependencies`.`version_relation`=\"<\"" . + ")," . + "\"\"," . + "CONCAT(" . + "`dependencies`.`version_relation`," . + "IF(" . + "`versions`.`epoch`=0," . + "\"\"," . + "CONCAT(" . + "`versions`.`epoch`," . + "\":\"" . + ")" . + ")," . + "`versions`.`version`" . + ")" . + ") AS `version`," . + "`install_targets`.`name` AS `install_target`" . + " FROM `dependencies`" . + " LEFT JOIN (". + "`binary_packages_in_repositories` AS `bpir`" . + mysql_join_binary_packages_in_repositories_repositories('bpir','r') . + mysql_join_repositories_architectures('r','r_a') . + ") ON `bpir`.`package`=`dependencies`.`dependent`" . + mysql_join_dependencies_dependency_types() . + mysql_join_dependencies_install_targets() . + " AND `install_targets`.`name` NOT IN (\"base\",\"base-devel\")" . + mysql_join_dependencies_versions() . + " LEFT JOIN (" . + "`install_target_providers`" . + 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() . + " JOIN `repository_stability_relations` ON `repository_stability_relations`.`more_stable`=`repositories`.`stability`" . + " AND `repository_stability_relations`.`less_stable`=" . $mysql_content["repo_stability"] . + ") ON `install_target_providers`.`install_target`=`dependencies`.`depending_on`" . + " AND `repositories`.`architecture`=`r`.`architecture`" . + " WHERE `dependencies`.`dependent`=" . $mysql_content["id"] . + " AND NOT EXISTS (" . + "SELECT 1 FROM `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') . + // the substitue must be truly less stable than the dependency + " JOIN `repository_stability_relations` AS `subst_rsr` ON `subst_rsr`.`less_stable`=`subst_r`.`stability`" . + " AND `subst_rsr`.`less_stable`!=`subst_rsr`.`more_stable`" . + // and more (or equally) stable than us + " JOIN `repository_stability_relations` AS `subst_rsr2` ON `subst_rsr2`.`more_stable`=`subst_r`.`stability`" . + " WHERE `subst_bp`.`pkgname`=`binary_packages`.`pkgname`" . + " AND `subst_rsr`.`more_stable`=`repositories`.`stability`" . + " AND `subst_rsr2`.`less_stable`=" . $mysql_content["repo_stability"] . + ")" . + " GROUP BY CONCAT(`install_targets`.`id`,\"-\",`versions`.`id`),`dependency_types`.`id`" . + " ORDER BY FIELD (`dependency_types`.`name`,\"run\",\"make\",\"check\",\"link\"), `install_targets`.`name`" + ); + + $dependencies = array(); + while ($row = $mysql_result -> fetch_assoc()) { + $row["deps"] = array_map("unserialize", array_unique(array_map("serialize", json_decode("{".$row["deps"]."}",true)))); + $dependencies[] = $row; + } + + if (!$skip_json_checks) { + function dependency_is_runtime($dep) { + return $dep["dependency_type"]=="run"; + }; + + function dependency_extract_name($dep) { + return $dep["install_target"]; + }; + + $dep_it = array_filter( $dependencies, "dependency_is_runtime"); + $dep_it = array_map("dependency_extract_name", $dep_it); + $dep_it = preg_replace("/[<=>].*$/","",$dep_it); + if (array_key_exists("Depends On",$json_content)) + $js_dep = preg_replace("/[<=>].*$/","",$json_content["Depends On"]); + elseif (array_key_exists("Requires",$json_content)) + $js_dep = preg_replace("/[<=>].*$/","",$json_content["Requires"]); + else + $js_dep = array(); + if (!is_array($js_dep)) + $js_dep = array(); + if (!isset($dep_it)) + $dep_it = array(); + $dep_errors = implode( + ", ", + array_diff( + array_merge($dep_it,$js_dep), + $dep_it + ) + ); + + if ($dep_errors != "") + die_500( + "Dependencies differ: " . $dep_errors. "<br>\n" . + "mysql: " . implode(", ",$dep_it) . "<br>\n" . + "json: " . implode(", ",$js_dep) + ); + + foreach ($dependencies as $key => $dep) { + if ($dep["dependency_type"]!="run") { + $dependencies[$key]["json"]="not required"; + continue; + } + foreach ($js_dep as $js) + if ($js == preg_replace("/[<=>].*$/","",$dep["install_target"])) + $dependencies[$key]["json"]=$js; + } + } + + // query dependent packages + + $mysql_result = mysql_run_query( + "SELECT DISTINCT " . + "`dependency_types`.`name` AS `dependency_type`," . + "`install_targets`.`name` AS `install_target`," . + "`repositories`.`name` AS `repo`," . + "`repositories`.`is_on_master_mirror`," . + "`r_a`.`name` AS `repo_arch`," . + "`architectures`.`name` AS `arch`," . + "`binary_packages`.`pkgname`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`" . + " FROM `install_target_providers`" . + " LEFT JOIN (". + "`binary_packages_in_repositories` AS `bpir`" . + mysql_join_binary_packages_in_repositories_repositories('bpir','r') . + ") ON `bpir`.`package`=`install_target_providers`.`package`" . + mysql_join_install_target_providers_install_targets() . + " AND `install_targets`.`name` NOT IN (\"base\",\"base-devel\")" . + mysql_join_install_target_providers_dependencies() . + mysql_join_dependencies_dependency_types() . + 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() . + " AND `repositories`.`architecture`=`r`.`architecture`" . + mysql_join_repositories_architectures("","r_a") . + " JOIN `repository_stability_relations` ON `repository_stability_relations`.`less_stable`=`repositories`.`stability`" . + " AND `repository_stability_relations`.`more_stable`=" . $mysql_content["repo_stability"] . + " WHERE `install_target_providers`.`package`=" . $mysql_content["id"] . + " AND NOT EXISTS (" . + "SELECT 1 FROM `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') . + // the substitue must be truly less stable than we + " JOIN `repository_stability_relations` AS `subst_rsr` ON `subst_rsr`.`less_stable`=`subst_r`.`stability`" . + " AND `subst_rsr`.`less_stable`!=`subst_rsr`.`more_stable`" . + // and more (or equally) stable than the required-by + " JOIN `repository_stability_relations` AS `subst_rsr2` ON `subst_rsr2`.`more_stable`=`subst_r`.`stability`" . + " WHERE `subst_bp`.`pkgname`=from_base64(\"" . base64_encode($mysql_content["pkgname"]) . "\")" . + " AND `subst_rsr2`.`less_stable`=`repositories`.`stability`" . + " AND `subst_rsr`.`more_stable`=" . $mysql_content["repo_stability"] . + ")" . + " GROUP BY `binary_packages`.`id`,`dependency_types`.`id`" . + " ORDER BY" . + " FIELD (`dependency_types`.`name`,\"run\",\"make\",\"check\",\"link\")," . + " `install_targets`.`name`!=`binary_packages`.`pkgname`," . + " `install_targets`.`name`," . + " `binary_packages`.`pkgname`," . + " `repositories`.`stability`," . + " `repositories`.`name`" + ); + + $dependent = array(); + while ($row = $mysql_result -> fetch_assoc()) + $dependent[] = $row; + + if ($skip_json_checks) + $content = $mysql_content; + else + $content = array_merge($mysql_content,$json_content); + + foreach (array("Download Size", "Installed Size") as $key) { + $content["Print " . $key] = + add_fancy_unit($content[$key], "B"); + } + + // query substitutes + + $mysql_result = mysql_run_query( + "SELECT " . + "`binary_packages`.`pkgname` AS `pkgname`," . + "IF(`binary_packages_in_repositories`.`is_to_be_deleted`,1,0) AS `is_to_be_deleted`," . + "`repositories`.`name` AS `repo`," . + "`repositories`.`is_on_master_mirror`," . + "`architectures`.`name` AS `arch`," . + "`r_a`.`name` AS `repo_arch`," . + mysql_query_package_version("binary_packages") . + " AS `version`" . + " FROM `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_architectures("","r_a") . + " JOIN `binary_packages` AS `original`" . + " ON `binary_packages`.`pkgname`=`original`.`pkgname`" . + " AND `binary_packages`.`id`!=`original`.`id`" . + " WHERE `original`.`id`=" . $mysql_content["id"] + ); + + $elsewhere = array(); + while ($row = $mysql_result -> fetch_assoc()) + $elsewhere[] = $row; + + print_header($content["pkgname"] . " " . $content["version"] . " (" . $content["arch"] . ")"); + +?> + <div id="archdev-navbar"> + </div> + <div id="pkgdetails" class="box"> + <h2><?php print $content["pkgname"]." ".$content["version"]; ?></h2> + <div id="detailslinks" class="listing"> + <div id="actionlist"> + <h4>Package Actions</h4> + <ul class="small"> +<?php + if ($content["uses_upstream"]) { + print " <li>\n"; + print " <a href=\"https://projects.archlinux.org/svntogit/"; + print $content["git_repo"]; + print ".git/tree/trunk?h=packages/"; + print $content["pkgbase"]; + print "\" title=\"View upstream's source files for "; + print $content["pkgname"]; + print "\">Upstream's Source Files</a> /\n"; + print " <a href=\"https://projects.archlinux.org/svntogit/"; + print $content["git_repo"]; + print ".git/log/trunk?h=packages/"; + print $content["pkgbase"]; + print "\" title=\"View upstream's changes for "; + print $content["pkgname"]; + print "\">Upstream's Changes</a>\n"; + print " </li>\n"; + } + if ($content["uses_modification"]) { + print " <li>\n"; + print " <a href=\""; + print git_url("packages","tree","master",$content["stable_repo"]."/".$content["pkgbase"]); + print "\" title=\"View archlinux32's source files for "; + print $content["pkgname"]; + print "\">Archlinux32's Source Files</a> /\n"; + print " <a href=\""; + print git_url("packages","log","master",$content["stable_repo"]."/".$content["pkgbase"]); + print "\" title=\"View upstream's changes for "; + print $content["pkgname"]; + print "\">Archlinux32's Changes</a>\n"; + print " </li>\n"; + } +?> + <li> +<?php + print " <a href=\"https://www.archlinux.org/packages/?sort=&q="; + print $content["pkgname"]; + print "&maintainer=&flagged=\">"; + print "Search for ".$content["pkgname"]." upstream"; + print "</a>\n"; +?> + </li> + <li> +<?php + print " <a href=\"https://bugs.archlinux32.org/index.php?string="; + print $content["pkgname"]; + print "\" title=\"View existing bug tickets for "; + print $content["pkgname"]; + print "\">Bug Reports</a> / \n"; + print " <a href=\"https://bugs.archlinux32.org/index.php?do=newtask&project=1&product_category="; + if ($content["repo_stability_name"]=="stable") + print "8"; // stable + elseif ($content["repo_stability_name"]=="testing") + print "6"; // testing + elseif ($content["repo_stability_name"]=="unbuilt") + print "7"; // build-list + else + print "1"; // packages + print "&item_summary=%5B"; + print $content["pkgname"]; + print "%5D+PLEASE+ENTER+SUMMARY\" title=\"Report new bug for "; + print $content["pkgname"]; + print "\">Add New Bug</a>\n"; +?> + </li> + <li> + <a href="http://pool.mirror.archlinux32.org/<?php + print $content["repo_arch"]."/".$content["repo"]."/".$content["pkgname"]."-".$content["version"]."-".$content["arch"]; +?>.pkg.tar.xz" rel="nofollow" title="Download <?php print $content["pkgname"]; ?> from mirror">Download From Mirror</a> + </li> + </ul> + </div> +<?php + +if (count($elsewhere)>0) { + print " <div id=\"elsewhere\" class=\"widget\">\n"; + print " <h4>Versions Elsewhere</h4>\n"; + foreach ($elsewhere as $subst) { + print " <ul>\n"; + print " <li>\n"; + if ($subst["is_on_master_mirror"]) { + print " <a href=\"/" . $subst["repo_arch"] . "/" . $subst["repo"] . "/" . $subst["pkgname"] ."/\""; + print " title=\"Package details for " . $subst["pkgname"] ."\">"; + } + if ($subst["is_to_be_deleted"]) + print "<s>"; + print $subst["pkgname"] . "-" . $subst["version"] . " [" . $subst["repo"] . "] (" . $subst["arch"] . ")"; + if ($subst["is_to_be_deleted"]) + print "</s>"; + if ($subst["is_on_master_mirror"]) + print "</a>\n"; + print " </li>\n"; + print " </ul>\n"; + } + print " </div>\n"; +} + +?> + </div> + <div itemscope itemtype="http://schema.org/SoftwareApplication"> + <meta itemprop="name" content="<?php print $content["pkgname"]; ?>"/> + <meta itemprop="version" content="<?php print $content["version"]; ?>"/> + <meta itemprop="softwareVersion" content="<?php print $content["version"]; ?>"/> + <meta itemprop="fileSize" content="<?php print if_unset($content, "Download Size", "0"); ?>"/> + <meta itemprop="dateCreated" content="<?php print if_unset($content,"Build Date","0"); ?>"/> + <meta itemprop="datePublished" content="<?php print $content["last_moved"]; ?>"/> + <meta itemprop="operatingSystem" content="Arch Linux 32"/> + <table id="pkginfo"> + <tr> + <th> + Architecture: + </th> + <td> + <a href="/?arch=<?php + print $content["arch"]; + ?>" title="Browse packages for <?php + print $content["arch"]; + ?> architecture"><?php + print $content["arch"]; + ?></a> + </td> + </tr> + <tr> + <th> + Repository: + </th> + <td> + <a href="/?repo=<?php + print urlencode($content["repo_arch"] . "/" . $content["repo"]); + ?>" title="Browse the <?php + print $content["repo_arch"] . "/" . $content["repo"]; + ?> repository"><?php + print $content["repo_arch"] . "/" . $content["repo"]; + ?></a> + </td> + </tr> +<?php +$count = count($content["split_packages"]); +if ($count > 1 || $content["pkgname"] != $content["pkgbase"]) { + print " <tr>\n"; + print " <th>\n"; + print " Split Packages:\n"; + print " </th>\n"; + print " <td>\n"; + foreach ($content["split_packages"] as $split_package) { + print " "; + if ($split_package["pkgname"] != $content["pkgname"]) { + print "<a href=\"/" . $split_package["repo_arch"]; + print "/" . $split_package["repository"]; + print "/" . $split_package["pkgname"]; + print "/\">"; + } + print $split_package["pkgname"]; + $count --; + if ($split_package["pkgname"] != $content["pkgname"]) + print "</a>"; + if ($count > 0) + print ", "; + } + if ($content["pkgname"] != $content["pkgbase"]) + print " (" . $content["pkgbase"] . ")"; + print "\n"; + print " </td>\n"; + print " </tr>\n"; +} +?> + <tr> + <th> + Description: + </th> + <td class="wrap" itemprop="description"> + <?php print if_unset($content, "Description", "<font color=\"#ff0000\">not found in pkg-api</font>")."\n"; ?> + </td> + </tr> + <tr> + <th> + Upstream URL: + </th> + <td> + <a itemprop="url" href="<?php print if_unset($content, "URL", ""); ?>" title="Visit the website for <?php print $content["pkgname"]; ?>"><?php print if_unset($content, "URL", "<font color=\"#ff0000\">not found in pkg-api</font>"); ?></a> + </td> + </tr> + <tr> + <th> + License(s): + </th> + <td class="wrap"> + <?php + $licenses = if_unset($content, "Licenses", "<font color=\"#ff0000\">not found in pkg-api</font>"); + if (is_array($licenses)) + print implode(", ",$licenses); + else + print $licenses; + print "\n"; +?> + </td> + </tr> + <tr> + <th> + Package Size: + </th> + <td> + <?php print if_unset($content, "Print Download Size", "<font color=\"#ff0000\">not found in pkg-api</font>")."\n"; ?> + </td> + </tr> + <tr> + <th> + Installed Size: + </th> + <td> + <?php print if_unset($content, "Print Installed Size", "<font color=\"#ff0000\">not found in pkg-api</font>")."\n"; ?> + </td> + </tr> + <tr> + <th> + Build Date: + </th> + <td> + <?php print if_unset($content, "Build Date", "<font color=\"#ff0000\">not found in pkg-api</font>")."\n"; ?> + </td> + </tr> + <tr> + <th> + Last Updated: + </th> + <td> + <?php print $content["last_moved"]."\n"; ?> + </td> + </tr> + </table> + </div> + <div id="metadata"> + <div id="pkgdeps" class="listing"> + <h3 title="<?php print $content["pkgname"]; ?> has the following dependencies"> + Dependencies (<?php print count($dependencies); ?>) + </h3> + <ul id="pkgdepslist"> +<?php + foreach ($dependencies as $dep) { + print " <li>\n"; + if (!$skip_json_checks && !array_key_exists ('json', $dep)) + print " (in database only)\n"; + if (count($dep["deps"]) == 0) { + print " <font color=\"#ff0000\">not satisfiable dependency: \"" . $dep["install_target"] . $dep["version"] . "\"</font>\n"; + } else { + $virtual_dep = ( + (count($dep["deps"]) > 1) || + (array_values($dep["deps"])[0]["pkgname"] != $dep["install_target"]) + ); + print " "; + if ($virtual_dep) { + print $dep["install_target"] . $dep["version"]; + print " <span class=\"virtual-dep\">("; + }; + $first = true; + foreach ($dep["deps"] as $d_p) { + if (!$first) + print ", "; + $first = false; + print "<a href=\"/".$d_p["repo_arch"]."/".$d_p["repo"]."/".$d_p["pkgname"]."/\" "; + print "title=\"View package details for ".$d_p["pkgname"]."\">"; + if ($d_p["is_to_be_deleted"]) + print "<s>"; + print $d_p["pkgname"]; + if ($d_p["is_to_be_deleted"]) + print "</s>"; + print "</a>"; + if (!$virtual_dep) + print $dep["version"]; + } + if ($virtual_dep) + print ")</span>"; + print "\n"; + }; + if ($dep["dependency_type"]!="run") + print " <span class=\"" . $dep["dependency_type"] . "-dep\">(" . $dep["dependency_type"] . ")</span>\n"; + print " </li>\n"; + } +?> + </ul> + </div> + <div id="pkgreqs" class="listing"> + <h3 title="Packages that require <?php print $content["pkgname"]; ?>"> + Required By (<?php print count($dependent); ?>) + </h3> + <ul id="pkgreqslist"> +<?php + foreach ($dependent as $dep) { + print " <li>\n"; + print " "; + if ($dep["install_target"] != $content["pkgname"]) + print $dep["install_target"] . " ("; + if ($dep["is_on_master_mirror"]=="1") { + print "<a href=\"/".$dep["repo_arch"]."/".$dep["repo"]."/".$dep["pkgname"]."/\" "; + print "title=\"View package details for ".$dep["pkgname"]."\">"; + } + if ($dep["is_to_be_deleted"]) + print "<s>"; + print $dep["pkgname"]; + if ($dep["is_to_be_deleted"]) + print "</s>"; + if ($dep["repo"] != $content["repo"]) + print " [" . $dep["repo"] . "]"; + if ($dep["is_on_master_mirror"]=="1") + print "</a>"; + if ($dep["install_target"] != $content["pkgname"]) + print ")\n"; + if ($dep["dependency_type"] != "run") + print " <span class=\"" . $dep["dependency_type"] . "-dep\">(" . $dep["dependency_type"] . ")</span>"; + print "\n"; + print " </li>\n"; + } +?> + </ul> + </div> + <div id="pkgfiles"> + </div> + </div> + </div> +<?php + + print_footer(); |