- Add web interface (in ops) for app version creation

- Add --no_conf option to update_versions
This commit is contained in:
David Anderson 2021-11-30 20:06:32 -08:00
parent 9ec07a8b0d
commit dc0f3846f9
3 changed files with 135 additions and 6 deletions

View File

@ -0,0 +1,121 @@
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2021 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// web-based app version creation.
require_once("../inc/util_ops.inc");
function show_form() {
admin_page_head("Create app version");
echo "
<form action=create_app_version.php method=post ENCTYPE=\"multipart/form-data\">"
;
form_input_text("App name", "app_name");
form_input_text("Version number", "version_num");
form_input_text("Platform name", "platform_name");
form_input_text("Plan class", "plan_class");
form_input_hidden("action", "create");
echo "
<input size=80 style=\"background-color: white;\" type=file name=\"new_file[]\" multiple>
<p>
<input class=\"btn btn-success\" type=submit value=OK>
</form>
";
admin_page_tail();
}
function create_version() {
$app_name = post_str("app_name");
$version_num = post_str("version_num");
$platform_name = post_str("platform_name");
$plan_class = post_str("plan_class");
$app_name = BoincDb::escape_string($app_name);
$app = BoincApp::lookup("name='$app_name'");
if (!$app) {
admin_error_page("No such app");
}
$platform_name = BoincDb::escape_string($platform_name);
$platform = BoincPlatform::lookup("name='$platform_name'");
if (!$platform) {
admin_error_page("No such platform");
}
// make directories as needed
//
$apps_dir = "../../apps";
$app_dir = "$apps_dir/$app_name";
if (!is_dir($app_dir)) {
mkdir($app_dir);
}
$version_dir = "$app_dir/$version_num";
if (!is_dir($version_dir)) {
mkdir($version_dir);
}
$platform_dir = "$version_dir/$platform_name";
if ($plan_class) {
$platform_dir .= "__$plan_class";
}
if (is_dir($platform_dir)) {
admin_error_page("App version dir already exists");
}
mkdir($platform_dir);
// copy files to app version dir
//
$count = count($_FILES['new_file']['tmp_name']);
for ($i=0; $i<$count; $i++) {
$tmp_name = $_FILES['new_file']['tmp_name'][$i];
if (!is_uploaded_file($tmp_name)) {
admin_error_page("$tmp_name is not uploaded file");
}
$name = $_FILES['new_file']['name'][$i];
if (strstr($name, "/")) {
admin_error_page("no / allowed");
}
$ret = rename($tmp_name, "$platform_dir/$name");
if (!$ret) {
admin_error_page("can't rename $tmp_name to $platform_dir/$name");
}
}
admin_page_head("Updating app versions");
echo "<pre>\n";
$cmd = "cd ../..; bin/update_versions --no_conf";
system($cmd);
echo "</pre>\n";
admin_page_tail();
}
// creating app versions must be secure
//
auth_ops_privilege(); // user must be S_ADMIN or S_DEV
if (!parse_bool(get_config(), "enable_web_app_version_creation")) {
admin_error_page("Disabled");
}
$action = post_str("action", true);
if ($action == 'create') {
create_version();
} else {
show_form();
}
?>

View File

@ -287,7 +287,7 @@ function show_info() {
page_tail();
}
if (!parse_bool($config, "autodock_submit_enabled")) {
if (!parse_bool($config, "enable_autodock_submit")) {
error_page("Autodock not enabled");
}

View File

@ -22,6 +22,8 @@
// script to create app versions,
// and stage their files in the download dir.
// See https://boinc.berkeley.edu/trac/wiki/AppVersionNew
//
// --no_conf: don't pause for user confirmation
error_reporting(E_ALL);
@ -237,7 +239,7 @@ function confirm_sig_gen($name) {
// process a file
//
function process_file($a, $v, $p, $name, $fds) {
global $key_dir;
global $key_dir, $no_conf;
$fd = lookup_file($fds, $name);
if (!$fd) {
$fd = new StdClass;
@ -259,7 +261,9 @@ function process_file($a, $v, $p, $name, $fds) {
} else {
$keypath = "$key_dir/code_sign_private";
if (is_file($keypath)) {
confirm_sig_gen($name);
if (!$no_conf) {
confirm_sig_gen($name);
}
$handle = popen("bin/sign_executable $path $keypath", "r");
$fd->signature = fread($handle, 8192);
pclose($handle);
@ -419,6 +423,7 @@ function convert_simplexml($x) {
}
function process_version($a, $v, $p) {
global $no_conf;
echo "Found app version directory for: $a $v $p\n";
$app = lookup_app($a);
parse_platform_name($p, $platform, $plan_class);
@ -467,12 +472,14 @@ function process_version($a, $v, $p) {
// if API version isn't specified in version.xml,
// try to find it embedded in the executable
//
if (!strlen($vers->api_version)) {
if (!property_exists($vers, 'api_version') || !strlen($vers->api_version)) {
$vers->api_version = get_api_version($a, $v, $p, $fds);
}
if (!confirm($fds, $vers)) {
return;
if (!$no_conf) {
if (!confirm($fds, $vers)) {
return;
}
}
$xml = "";
@ -550,6 +557,7 @@ function scan_apps() {
}
}
$no_conf = count($argv)>1 && $argv[1]='--no_conf';
scan_apps();
touch("reread_db"); // if feeder is running, tell it to reread DB