[aur-dev] [PATCH] Group package dependencies by their type

Mathieu Gaborit mat.gaborit at gmx.com
Sat Aug 9 15:28:03 EDT 2014


Sort dependencies by type, implements feature request in FS#40888

Dependencies are fetched like before and a sort is applied on dependencies type if
$deps array is not empty. Display is adjusted accordingly.

diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 7f01d2f..0d1824e 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -26,8 +26,19 @@ $urlpath = URL_DIR . substr($row['BaseName'], 0, 2) . "/" . $row['BaseName'];
 $lics = pkg_licenses($row["ID"]);
 $grps = pkg_groups($row["ID"]);
 
-$deps = pkg_dependencies($row["ID"]);
 $requiredby = pkg_required($row["Name"]);
+$deps = pkg_dependencies($row["ID"]);
+if (count($deps) > 0) {
+
+	// extract dependencies
+	$dep_types = array_map(function ($a) { return $a[1]; }, $deps);
+	asort($dep_types);
+	// reconstruct deps array using the new order
+	$sorted_deps = Array();
+	foreach(array_keys($dep_types) as $t) {
+		$sorted_deps[] = $deps[$t];
+	}
+}
 
 $rels = pkg_relations($row["ID"]);
 $rels_c = $rels_p = $rels_r = array();
@@ -333,7 +344,7 @@ if ($row["PackagerUID"]):
 			<h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
 <?php if (count($deps) > 0): ?>
 			<ul id="pkgdepslist">
-<?php while (list($k, $darr) = each($deps)): ?>
+<?php while (list($k, $darr) = each($sorted_deps)): ?>
 	<li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3]); ?></li>
 <?php endwhile; ?>
 			</ul>


-- 
Mathieu (matael) Gaborit
mat.gaborit at gmx.com
Merci de ne m'imprimer que si nécessaire
Please don't print this unless it's necessary

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://mailman.archlinux.org/pipermail/aur-dev/attachments/20140809/78f2ff94/attachment.asc>


More information about the aur-dev mailing list