Florent Thoumie mentioned today that FreshPorts should not supply package installation instructions for Restricted ports. Why? This extract from /usr/ports/Mk/bsd.port.mk indicates why
# RESTRICTED - Prevent the distribution of distfiles and packages to
# the FTP sites or on CDROM (e.g. forbidden by license
# considerations).
If we are not allowed to distribution the package, then we won’t be building the package. So let’s not include the standard FreshPorts instructions:
To add the package: pkg_add -r FOO
I went to look at the code and found two issues (code has been rearranged to fit the column):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
if (IsSet($port->no_package) && $port->no_package != '') { $HTML .= '<p><b>No package is available:</b> ' . $port->no_package . '</p>'; } else { if ($port->forbidden || $port->broken || $port->ignore) { $HTML .= '<p><b>No package because port is marked as ' . 'Forbidden/Broken/Ignore</b></p>'; } else { $HTML .= '<p><b>To install <a href="/faq.php#port" TITLE="what is a port?">the port</a>:</b> <code class="code">cd /usr/ports/' . $port->category . '/' . $port->port . '/ && make install clean</code><br>'; $HTML .= '<b>To add the <a href="/faq.php#package" TITLE="what is a package?">package</a>:</b> <code class="code">pkg_add -r ' . $port->latest_link . '</code></p>'; } } |
There are two issues related to the problem at hand:
- Unless no_package is set, instructions are given
- line 7 should be moved up to be before line 1. Always give the port instructions.
To solve the issues, I changed the code to this:
1 2 3 4 5 6 7 8 9 10 |
$HTML .= '<p><b>To install <a href="/faq.php#port" TITLE="what is a port?">the port</a>:</b> <code class="code">cd /usr/ports/' . $port->category . '/' . $port->port . '/ && make install clean</code><br>'; if (IsSet($port->no_package) && $port->no_package != '') { $HTML .= '<p><b>No <a href="/faq.php#package" TITLE="what is a package?">package</a> is available:</b> ' . $port->no_package . '</p>'; } else { if ($port->forbidden || $port->broken || $port->ignore || $port->restricted) { $HTML .= '<p><b>No package because port is marked as Forbidden / Broken / Ignore / Restricted</b></p>'; } else { $HTML .= '<b>To add the <a href="/faq.php#package" TITLE="what is a package?">package</a>:</b> <code class="code">pkg_add -r ' . $port->latest_link . '</code></p>'; } } |
With this change we:
- Always display how to install the port
- Display package as a hyperlink (we did it only for some places before)
- Do not display package instructions for Restricted ports
Comments welcome.
[Yes, I know the lines don’t wrap]