Skip to content

Commit

Permalink
Panel: Implement export build backup
Browse files Browse the repository at this point in the history
Exports a list of builds per platform in order to run a backup script to 
locally back them up
  • Loading branch information
AniLeo committed Sep 15, 2024
1 parent 3f8f497 commit 6a37325
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
'flag_build_as_broken' => array(
'title' => "Flag Build as Broken",
'success' => ""
),
'export_build_backup' => array(
'title' => "Export Build Backup",
'success' => ""
)
);

Expand Down
47 changes: 47 additions & 0 deletions includes/inc.panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -923,3 +923,50 @@ function flag_build_as_broken() : void
printf("<p>Flagged <b>%d</b> as broken.</p>",
$pr);
}

function export_build_backup() : void
{
$form = new HTMLForm("", "POST");
$select = new HTMLSelect("os");
$select->add_option(new HTMLOption("win", "Windows (x64)"));
$select->add_option(new HTMLOption("linux", "Linux (x64)"));
$select->add_option(new HTMLOption("mac", "macOS (x64)"));
$form->add_select($select);
$form->add_button(new HTMLButton("backupRequest", "submit", "Backup Request"));
$form->print();

if (!isset($_POST['os']) || !in_array($_POST['os'], array("win", "linux", "mac")))
{
return;
}

print("<p>");
print("Save the following builds list to a text file and run command<br>");
print("<b>cat builds.txt | parallel --gnu \"wget -nc -nv --content-disposition --trust-server-names {}\"</b><br><br>");
print("</p>");

$os = $_POST['os'];

$url_prefix = "https://github.com/RPCS3/rpcs3-binaries-{$os}/releases/download/build-";

$db = getDatabase();

$q_builds = mysqli_query($db, "SELECT CONCAT('{$url_prefix}', `commit`, '/', `filename_{$os}`) AS `url`
FROM `builds` WHERE `filename_{$os}` IS NOT NULL AND `filename_{$os}` <> ''
ORDER BY `merge_datetime` DESC;");

mysqli_close($db);

if (is_bool($q_builds))
{
print("<b>Error while fetching the builds list</b>");
return;
}

print("<p>");
while ($row = mysqli_fetch_object($q_builds))
{
print($row->url."<br>");
}
print("</p>");
}

0 comments on commit 6a37325

Please sign in to comment.