Honor virtual provisions in package requirements

Implements FS#14125.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2015-09-17 19:15:47 +02:00
parent dd808ac802
commit 9d2d8f1c8c
2 changed files with 30 additions and 9 deletions

View file

@ -343,12 +343,14 @@ function pkg_depend_link($name, $type, $cond, $arch, $pkg_id) {
* Get the HTML code to display a package requirement link * Get the HTML code to display a package requirement link
* *
* @param string $name The name of the requirement * @param string $name The name of the requirement
* @param string $depends The (literal) name of the dependency of $name
* @param string $type The name of the dependency type * @param string $type The name of the dependency type
* @param string $arch The package dependency architecture * @param string $arch The package dependency architecture
* @param string $pkgname The name of dependant package
* *
* @return string The HTML code of the link to display * @return string The HTML code of the link to display
*/ */
function pkg_requiredby_link($name, $type, $arch) { function pkg_requiredby_link($name, $depends, $type, $arch, $pkgname) {
if ($type == 'optdepends' && strpos($name, ':') !== false) { if ($type == 'optdepends' && strpos($name, ':') !== false) {
$tokens = explode(':', $name, 2); $tokens = explode(':', $name, 2);
$name = $tokens[0]; $name = $tokens[0];
@ -359,6 +361,18 @@ function pkg_requiredby_link($name, $type, $arch) {
$link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">'; $link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
$link .= htmlspecialchars($name) . '</a>'; $link .= htmlspecialchars($name) . '</a>';
if ($depends != $pkgname) {
$depname = $depends;
if (strpos($depends, ':') !== false) {
$tokens = explode(':', $depname, 2);
$depname = $tokens[0];
}
$link .= ' <span class="virtual-dep">(';
$link .= __('requires %s', htmlspecialchars($depname));
$link .= ')</span>';
}
return $link . pkg_deplink_annotation($type, $arch); return $link . pkg_deplink_annotation($type, $arch);
} }
@ -410,18 +424,25 @@ function pkg_source_link($url, $arch) {
* Determine packages that depend on a package * Determine packages that depend on a package
* *
* @param string $name The package name for the dependency search * @param string $name The package name for the dependency search
* @param array $provides A list of virtual provisions of the package
* *
* @return array All packages that depend on the specified package name * @return array All packages that depend on the specified package name
*/ */
function pkg_required($name="") { function pkg_required($name="", $provides) {
$deps = array(); $deps = array();
if ($name != "") { if ($name != "") {
$dbh = DB::connect(); $dbh = DB::connect();
$q = "SELECT p.Name, dt.Name, pd.DepArch FROM PackageDepends pd ";
$name_list = $dbh->quote($name);
foreach ($provides as $p) {
$name_list .= ',' . $dbh->quote($p[0]);
}
$q = "SELECT p.Name, pd.DepName, dt.Name, pd.DepArch FROM PackageDepends pd ";
$q.= "LEFT JOIN Packages p ON p.ID = pd.PackageID "; $q.= "LEFT JOIN Packages p ON p.ID = pd.PackageID ";
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID "; $q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.DepName = " . $dbh->quote($name) . " "; $q.= "WHERE pd.DepName IN (" . $name_list . ") ";
$q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = " . $dbh->quote($name) . " "; $q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) IN (" . $name_list . ") ";
$q.= "ORDER BY p.Name"; $q.= "ORDER BY p.Name";
$result = $dbh->query($q); $result = $dbh->query($q);
if (!$result) {return array();} if (!$result) {return array();}

View file

@ -40,9 +40,6 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($
$lics = pkg_licenses($row["ID"]); $lics = pkg_licenses($row["ID"]);
$grps = pkg_groups($row["ID"]); $grps = pkg_groups($row["ID"]);
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"]);
usort($deps, function($x, $y) { usort($deps, function($x, $y) {
if ($x[1] != $y[1]) { if ($x[1] != $y[1]) {
if ($x[1] == "depends") { if ($x[1] == "depends") {
@ -83,6 +80,9 @@ foreach ($rels as $rel) {
} }
} }
$deps = pkg_dependencies($row["ID"]);
$requiredby = pkg_required($row["Name"], $rels_p);
# $sources[0] = 'src'; # $sources[0] = 'src';
$sources = pkg_sources($row["ID"]); $sources = pkg_sources($row["ID"]);
@ -285,7 +285,7 @@ endif;
<?php if (count($requiredby) > 0): ?> <?php if (count($requiredby) > 0): ?>
<ul id="pkgreqslist"> <ul id="pkgreqslist">
<?php while (list($k, $darr) = each($requiredby)): ?> <?php while (list($k, $darr) = each($requiredby)): ?>
<li><?= pkg_requiredby_link($darr[0], $darr[1], $darr[2]); ?></li> <li><?= pkg_requiredby_link($darr[0], $darr[1], $darr[2], $darr[3], $row['Name']); ?></li>
<?php endwhile; ?> <?php endwhile; ?>
</ul> </ul>
<?php endif; ?> <?php endif; ?>