mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Show providers in dependencies
For all "virtual provisions" in package dependencies, show links to the actual packages providing the dependency. This partly implements FS#14125. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
209b0b6eda
commit
f9476c1093
1 changed files with 60 additions and 7 deletions
|
@ -154,6 +154,33 @@ function pkg_groups($pkgid) {
|
||||||
return $grps;
|
return $grps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get providers for a specific package
|
||||||
|
*
|
||||||
|
* @param string $name The name of the "package" to get providers for
|
||||||
|
*
|
||||||
|
* @return array The IDs and names of all providers of the package
|
||||||
|
*/
|
||||||
|
function pkg_providers($name) {
|
||||||
|
$dbh = DB::connect();
|
||||||
|
$q = "SELECT p.ID, p.Name FROM Packages p ";
|
||||||
|
$q.= "INNER JOIN PackageRelations pr ON pr.PackageID = p.ID ";
|
||||||
|
$q.= "INNER JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
|
||||||
|
$q.= "WHERE rt.Name = 'provides' ";
|
||||||
|
$q.= "AND pr.RelName = " . $dbh->quote($name);
|
||||||
|
$result = $dbh->query($q);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$providers = array();
|
||||||
|
while ($row = $result->fetch(PDO::FETCH_NUM)) {
|
||||||
|
$providers[] = $row;
|
||||||
|
}
|
||||||
|
return $providers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get package dependencies for a specific package
|
* Get package dependencies for a specific package
|
||||||
*
|
*
|
||||||
|
@ -232,15 +259,41 @@ function pkg_depend_link($name, $type, $cond, $arch, $pkg_id, $show_desc=true) {
|
||||||
$desc = '(unknown)';
|
$desc = '(unknown)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = '<a href="';
|
$providers = array();
|
||||||
if (is_null($pkg_id)) {
|
if (is_null($pkg_id)) {
|
||||||
$link .= 'https://www.archlinux.org/packages/?q=' . urlencode($name);
|
/*
|
||||||
} else {
|
* TODO: We currently perform one SQL query per nonexistent
|
||||||
$link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES);
|
* package dependency. It would be much better if we could
|
||||||
|
* annotate dependency data with providers so that we already
|
||||||
|
* know whether a dependency is a "provision name" or a package
|
||||||
|
* from the official repositories at this point.
|
||||||
|
*/
|
||||||
|
$providers = pkg_providers($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($providers) > 0) {
|
||||||
|
$link = htmlspecialchars($name) . ' ';
|
||||||
|
$link .= '<span class="virtual-dep">(';
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
$name = $provider[1];
|
||||||
|
$link .= '<a href="';
|
||||||
|
$link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES);
|
||||||
|
$link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
|
||||||
|
$link .= htmlspecialchars($name) . '</a>, ';
|
||||||
|
}
|
||||||
|
$link = substr($link, 0, -2);
|
||||||
|
$link .= ')</span>';
|
||||||
|
} else {
|
||||||
|
$link = '<a href="';
|
||||||
|
if (is_null($pkg_id)) {
|
||||||
|
$link .= 'https://www.archlinux.org/packages/?q=' . urlencode($name);
|
||||||
|
} else {
|
||||||
|
$link .= htmlspecialchars(get_pkg_uri($name), ENT_QUOTES);
|
||||||
|
}
|
||||||
|
$link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
|
||||||
|
$link .= htmlspecialchars($name) . '</a>';
|
||||||
|
$link .= htmlspecialchars($cond);
|
||||||
}
|
}
|
||||||
$link .= '" title="' . __('View packages details for') .' ' . htmlspecialchars($name) . '">';
|
|
||||||
$link .= htmlspecialchars($name) . '</a>';
|
|
||||||
$link .= htmlspecialchars($cond);
|
|
||||||
|
|
||||||
if ($type != 'depends' || $arch) {
|
if ($type != 'depends' || $arch) {
|
||||||
$link .= ' <em>(';
|
$link .= ' <em>(';
|
||||||
|
|
Loading…
Add table
Reference in a new issue