Verified Commit 6527a1fa authored by noplanman's avatar noplanman

Add helper function to get binary download link.

parent fb9ef98f
......@@ -14,6 +14,15 @@ function human_filesize($bytes, $decimals = 2)
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . $suff;
}
function get_dl_link($flavor, $version, $file = null)
{
$base = 'https://dl.bintray.com/borg-binary-builder/borg-binaries';
if ($file !== null) {
return "{$base}/{$file}";
}
return "{$base}/borg-{$version}-{$flavor}";
}
$files = [];
foreach ($_files as $file) {
$files[$file->name] = $file;
......@@ -26,13 +35,13 @@ uasort($files, static function ($a, $b) {
$stable = reset($files)->version;
$binaries = [];
foreach (['armv5', 'armv6', 'arm64'] as $flavor) {
$binary = "borg-{$stable}-{$flavor}";
$binaries[$flavor] = [
'version' => $files["borg-{$stable}-{$flavor}"]->version,
'size' => $files["borg-{$stable}-{$flavor}"]->size,
'sha256' => $files["borg-{$stable}-{$flavor}"]->sha256,
'url' => "https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-{$stable}-{$flavor}",
'version' => $files[$binary]->version,
'size' => $files[$binary]->size,
'sha256' => $files[$binary]->sha256,
'url' => get_dl_link($flavor, $stable),
];
}
......@@ -72,7 +81,7 @@ fclose($fp);
<h1>Borg ARM builds</h1> <br>Currently there are automated builds for three different versions of ARM hardware:
<span class="flavor">
<a class="download" href="https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-armv5">
<a class="download" href="<?= get_dl_link('armv5', $stable) ?>">
<h2>ARMv5 / ARMv4t</h2><br>
<b class="download-link">Borg <?= $stable ?><br><br><?= human_filesize($files["borg-{$stable}-armv5"]->size) ?></b>
</a>
......@@ -80,14 +89,14 @@ fclose($fp);
This version is built for 32Bit-ARM CPUs without a Floating-Point-Unit (ARM v4t and v5).<br>
<br>A lot of NAS devices are using this type of hardware.<br>
<span class="code">
<b style="color:#2aa198">wget</b> <b style="color:#d33682">https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-armv5</b> -O /usr/bin/borg<br>
<b style="color:#2aa198">wget</b> <b style="color:#d33682"><?= get_dl_link('armv5', $stable) ?></b> -O /usr/bin/borg<br>
<b style="color:#2aa198">chmod</b> a+x /usr/bin/borg
</span>
</span>
</span>
<span class="flavor">
<a class="download" href="https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-armv6">
<a class="download" href="<?= get_dl_link('armv6', $stable) ?>">
<h2>ARMv7 / ARMv6</h2><br>
<b class="download-link">Borg <?= $stable ?><br><br><?= human_filesize($files["borg-{$stable}-armv6"]->size) ?></b>
</a>
......@@ -96,14 +105,14 @@ fclose($fp);
<br>A lot of modern ARM boards and devices ship with a floating-point unit (FPU).
This includes Raspberry Pis and some powerful NAS devices.<br>
<span class="code">
<b style="color:#2aa198">wget</b> <b style="color:#d33682">https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-armv6</b> -O /usr/bin/borg<br>
<b style="color:#2aa198">wget</b> <b style="color:#d33682"><?= get_dl_link('armv6', $stable) ?></b> -O /usr/bin/borg<br>
<b style="color:#2aa198">chmod</b> a+x /usr/bin/borg
</span>
</span>
</span>
<span class="flavor">
<a class="download" href="https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-arm64">
<a class="download" href="<?= get_dl_link('arm64', $stable) ?>">
<h2>ARMv8 (or ARM64)</h2><br>
<b class="download-link">Borg <?= $stable ?><br><br><?= human_filesize($files["borg-{$stable}-arm64"]->size) ?></b>
</a>
......@@ -111,7 +120,7 @@ fclose($fp);
This version is built for modern 64Bit-ARM CPUs (ARM v8).<br>
Examples include modern smartphones or the Pine64.<br>
<span class="code">
<b style="color:#2aa198">wget</b> <b style="color:#d33682">https://dl.bintray.com/borg-binary-builder/borg-binaries/borg-<?= $stable ?>-arm64</b> -O /usr/bin/borg<br>
<b style="color:#2aa198">wget</b> <b style="color:#d33682"><?= get_dl_link('arm64', $stable) ?></b> -O /usr/bin/borg<br>
<b style="color:#2aa198">chmod</b> a+x /usr/bin/borg
</span>
</span>
......@@ -152,7 +161,7 @@ fclose($fp);
</li>
<?php foreach ($files as $f) : ?>
<li class="item file">
<a href="https://dl.bintray.com/borg-binary-builder/borg-binaries/<?= $f->name ?>">
<a href="<?= get_dl_link(null, null, $f->name) ?>">
<span class="label" title="<?= $f->name ?>"><?= $f->name ?></span>
<span class="date" data-time="<?= $f->created ?>"><?= $f->created ?></span>
<span class="size" data-bytes="<?= $f->size ?>"><?= human_filesize($f->size) ?></span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment