Last active
July 13, 2016 14:03
-
-
Save dlangille/683ef1cded2409ffb4f646b64d74ed03 to your computer and use it in GitHub Desktop.
FreshPorts - printing recursive dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$deps = array('devel/gettext-runtime' => array('converters/libiconv', 'print/indexinfo'), | |
'devel/gettext-tools' => array('converters/libiconv', 'devel/gettext-runtime', 'print/indexinfo'), | |
'security/openssl' => array('lang/perl5.20'), | |
'sysutils/bacula-server' => array('archivers/lzo2', 'databases/postgresql93-client', 'devel/gettext-runtime', 'devel/gettext-tools', 'security/openssl', 'sysutils/bacula-client')); | |
function print_tree($AllDeps, $node = null, $indent = 1) { | |
if (empty($node)) return; | |
if (is_string($node)) { | |
printf('%' . $indent . "s%s \n", ' ', $node); | |
$PrintMe = $AllDeps[$node]; | |
if (is_array($PrintMe)) { | |
foreach ($PrintMe as $name => $dep) { | |
print_tree($AllDeps, $dep, $indent + 1); | |
} | |
} | |
} | |
} | |
print_tree($deps, 'sysutils/bacula-server'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php deps.php | |
sysutils/bacula-server | |
archivers/lzo2 | |
databases/postgresql93-client | |
devel/gettext-runtime | |
converters/libiconv | |
print/indexinfo | |
devel/gettext-tools | |
converters/libiconv | |
devel/gettext-runtime | |
converters/libiconv | |
print/indexinfo | |
print/indexinfo | |
security/openssl | |
lang/perl5.20 | |
sysutils/bacula-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
see https://news.freshports.org/2016/06/27/depends-direct-or-recursive/ | |
WITH RECURSIVE all_depends AS ( | |
SELECT port_id, port_id_dependent_upon, dependency_type | |
FROM port_dependencies | |
WHERE port_id = (select getport('sysutils/bacula-server')) | |
UNION | |
SELECT PD.port_id, PD.port_id_dependent_upon, PD.dependency_type | |
FROM port_dependencies PD | |
JOIN all_depends AD | |
ON (PD.port_id = AD.port_id_dependent_upon) | |
) | |
SELECT categoryport(port_id) AS ThisPort, categoryport(port_id_dependent_upon) AS IsDependentUpon, dependency_type AS DependencyType | |
FROM all_depends | |
ORDER BY ThisPort, IsDependentUpon; | |
thisport | isdependentupon | dependencytype | |
------------------------+-------------------------------+---------------- | |
devel/gettext-runtime | converters/libiconv | L | |
devel/gettext-runtime | print/indexinfo | R | |
devel/gettext-tools | converters/libiconv | L | |
devel/gettext-tools | devel/gettext-runtime | L | |
devel/gettext-tools | print/indexinfo | R | |
security/openssl | lang/perl5.20 | B | |
sysutils/bacula-server | archivers/lzo2 | L | |
sysutils/bacula-server | databases/postgresql93-client | L | |
sysutils/bacula-server | devel/gettext-runtime | L | |
sysutils/bacula-server | devel/gettext-tools | B | |
sysutils/bacula-server | security/openssl | B | |
sysutils/bacula-server | security/openssl | R | |
sysutils/bacula-server | sysutils/bacula-client | L | |
(13 rows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sysutils/bacula-server | |
|--archivers/lzo2 | |
|--databases/postgresql93-client | |
|--devel/gettext-runtime | |
| |--converters/libiconv | |
| |--print/indexinfo | |
|--devel/gettext-tools | |
| |--converters/libiconv | |
| |--devel/gettext-runtime | |
| | |--converters/libiconv | |
| | |--print/indexinfo | |
| |--print/indexinfo | |
|--security/openssl | |
| |-lang/perl5.20 | |
|-sysutils/bacula-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sysutils/bacula-server | |
|--archivers/lzo2 | |
| | |
|--databases/postgresql93-client | |
| | |
|--devel/gettext-runtime | |
| | | |
| |--converters/libiconv | |
| | | |
| |--print/indexinfo | |
| | |
|--devel/gettext-tools | |
| |--converters/libiconv | |
| | | |
| |--devel/gettext-runtime | |
| | |--converters/libiconv | |
| | | | |
| | |--print/indexinfo | |
| | | |
| |--print/indexinfo | |
| | |
|--security/openssl | |
| | | |
| |-lang/perl5.20 | |
| | |
|-sysutils/bacula-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sysutils/bacula-server | |
+---archivers/lzo2 | |
+---databases/postgresql93-client | |
+---devel/gettext-runtime | |
| |---converters/libiconv | |
| `---print/indexinfo | |
+---devel/gettext-tools | |
| +---converters/libiconv | |
| +---devel/gettext-runtime | |
| | |---converters/libiconv | |
| | `---print/indexinfo | |
| +---print/indexinfo | |
+---security/openssl | |
| `---lang/perl5.20 | |
`---sysutils/bacula-client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment