Skip to content

Commit

Permalink
Merge pull request #600 from FreshPorts/599-qemu-port-crashes-freshports
Browse files Browse the repository at this point in the history
599 qemu port crashes freshports
  • Loading branch information
dlangille authored Sep 15, 2024
2 parents 83db7a9 + 816c81a commit cf46b23
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/port-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -1515,9 +1515,9 @@ function Display() {
foreach ($package as $package_line) {
# convert FreeBSD:13:aarch64 to FreeBSD:13
$abi_prefix = substr($package_line['abi'], 0, strrpos($package_line['abi'], ':'));
$arch = substr($package_line['abi'], strrpos($package_line['abi'], ':') + 1);
$arch = substr($package_line['abi'], strrpos($package_line['abi'], ':') + 1);

$package_version_latest = empty($package_line['package_version_latest']) ? '-' : $package_line['package_version_latest'];
$package_version_latest = empty($package_line['package_version_latest']) ? '-' : $package_line['package_version_latest'];
$package_version_quarterly = empty($package_line['package_version_quarterly']) ? '-' : $package_line['package_version_quarterly'];

$packages_array[$package_name][$abi_prefix . ':latest'] [$arch]['version'] = $package_version_latest;
Expand Down
5 changes: 5 additions & 0 deletions include/freshports.php
Original file line number Diff line number Diff line change
Expand Up @@ -2797,6 +2797,11 @@ function pkg_prefix_sort($arr) {

foreach ($arr as $item) {
$halves = explode('-', $item, 2);
if (count($halves) < 2) {
# if there is nothing to split, return the data unsorted.
return $arr;
}

$runtimeBits = preg_split('/(?<=\D)(?=\d)|(?<=\d)(?=\D)/', $halves[0], PREG_SPLIT_DELIM_CAPTURE);

$splits[] = array('prefix' => $runtimeBits[0], 'runtime' => $runtimeBits[1], 'separator' => '-', 'lib' => $halves[1]);
Expand Down
43 changes: 43 additions & 0 deletions testing/interate-all-ports-pkg_prefix_sort.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$_SERVER['DOCUMENT_ROOT'] = "/usr/local/www/freshports/www";

require_once($_SERVER['DOCUMENT_ROOT'] . '/../include/common.php');
require_once('include/constants.php');
require_once('include/freshports.php');
require_once('include/databaselogin.php');
require_once('classes/port-display.php');
require_once('classes/ports.php');


$sql = "
select P.id, E.name as port, C.name as category
FROM ports P join element E on P.element_id = E.id
JOIN categories C on P.category_id = C.id
ORDER by category, port
";

$result = pg_query_params($db, "set client_encoding = 'ISO-8859-15'", array()) or die('query failed ' . pg_last_error($db));

$result = pg_query_params($db, $sql, array()) or die('query failed ' . pg_last_error($db));

$numrows = pg_num_rows($result);

echo "We have $numrows ports for testing\n";

$rows = pg_fetch_all($result);

foreach ($rows as $key => $row) {
echo $key . ' ' . $row['category'] . '/' . $row['port'] . "\n";
$port = new Port($db);
$port->FetchByID($row['id']);
$port_display = new port_display($db);
$port_display->SetPort($port);
$port_display->SetDetailsPackages();

$HTMLPortPackages = $port_display->Display();

unset($HTMLPortPackages);
unset($port_display);
unset($port);
}

0 comments on commit cf46b23

Please sign in to comment.