mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
firmware: proper kernel size, unify format with pkg
This commit is contained in:
parent
92c7681c87
commit
453946df33
@ -46,14 +46,18 @@ class FirmwareController extends ApiControllerBase
|
||||
*/
|
||||
protected function formatBytes($bytes)
|
||||
{
|
||||
if (preg_match('/[^0-9]/', $bytes)) {
|
||||
/* already processed */
|
||||
return $bytes;
|
||||
}
|
||||
if ($bytes >= (1024 * 1024 * 1024)) {
|
||||
return sprintf("%d GB", $bytes / (1024 * 1024 * 1024));
|
||||
return sprintf('%.1F%s', $bytes / (1024 * 1024 * 1024), 'GiB');
|
||||
} elseif ($bytes >= 1024 * 1024) {
|
||||
return sprintf("%d MB", $bytes / (1024 * 1024));
|
||||
return sprintf('%.1F%s', $bytes / (1024 * 1024), 'MiB');
|
||||
} elseif ($bytes >= 1024) {
|
||||
return sprintf("%d KB", $bytes / 1024);
|
||||
return sprintf('%.1F%s', $bytes / 1024, 'KiB');
|
||||
} else {
|
||||
return sprintf("%d bytes", $bytes);
|
||||
return sprintf('%d%s', $bytes, 'B');
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,11 +743,11 @@ class FirmwareController extends ApiControllerBase
|
||||
$translated[$key] = $expanded[$index++];
|
||||
if (empty($translated[$key])) {
|
||||
$translated[$key] = gettext('N/A');
|
||||
} elseif ($key == 'flatsize') {
|
||||
$translated[$key] = $this->formatBytes($translated[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX fixup kernel/base set size */
|
||||
|
||||
/* mark remote packages as "provided", local as "installed" */
|
||||
$translated['provided'] = $type == 'remote' ? "1" : "0";
|
||||
$translated['installed'] = $type == 'local' ? "1" : "0";
|
||||
|
||||
@ -41,4 +41,4 @@ opnsense-update -Tb || BL=1
|
||||
opnsense-update -Tk || KL=1
|
||||
|
||||
echo "base${SEP}${BV%-*}${SEP}${OS} userland set${SEP}${BS}${SEP}${BL}${SEP}${LIC}"
|
||||
echo "kernel${SEP}${KV%-*}${SEP}${OS} kernel set${SEP}${BS}${SEP}${KL}${SEP}${LIC}"
|
||||
echo "kernel${SEP}${KV%-*}${SEP}${OS} kernel set${SEP}${KS}${SEP}${KL}${SEP}${LIC}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user