firmware: warn on incomplete repository, change release type priority #4500

This commit is contained in:
Franco Fichtner 2021-02-10 15:56:25 +01:00
parent 75a7e2131a
commit bfbc0bdccb
2 changed files with 41 additions and 32 deletions

View File

@ -184,11 +184,7 @@ class FirmwareController extends ApiControllerBase
$response['all_packages'] = $sorted;
if (count($args)) {
$response['status_msg'] = gettext('The release type requires an update.');
$response['status_upgrade_action'] = 'rel';
$response['status'] = 'ok';
} elseif (array_key_exists('connection', $response) && $response['connection'] == 'busy') {
if (array_key_exists('connection', $response) && $response['connection'] == 'busy') {
$response['status_msg'] = gettext('The package manager is not responding.');
$response['status'] = 'error';
} elseif (array_key_exists('connection', $response) && $response['connection'] == 'unresolved') {
@ -215,12 +211,12 @@ class FirmwareController extends ApiControllerBase
} elseif (array_key_exists('repository', $response) && $response['repository'] == 'unsigned') {
$response['status_msg'] = gettext('The repository has no fingerprint.');
$response['status'] = 'error';
} elseif (array_key_exists('repository', $response) && $response['repository'] == 'incomplete') {
$response['status_msg'] = sprintf(gettext('The package "%s" is not available on this repository.'), $args[0]);
$response['status'] = 'error';
} elseif (array_key_exists('repository', $response) && $response['repository'] != 'ok') {
$response['status_msg'] = gettext('Could not find the repository on the selected mirror.');
$response['status'] = 'error';
} elseif (array_key_exists('updates', $response) && $response['updates'] == 0) {
$response['status_msg'] = gettext('There are no updates available on the selected mirror.');
$response['status'] = 'none';
} elseif (
array_key_exists(0, $response['upgrade_packages']) &&
$response['upgrade_packages'][0]['name'] == 'pkg'
@ -228,30 +224,39 @@ class FirmwareController extends ApiControllerBase
$response['status_upgrade_action'] = 'pkg';
$response['status'] = 'ok';
$response['status_msg'] = gettext('There is a mandatory update for the package manager available.');
} elseif (array_key_exists('updates', $response)) {
$response['status_upgrade_action'] = 'all';
$response['status'] = 'ok';
if ($response['updates'] == 1) {
/* keep this dynamic for template translation even though %s is always '1' */
$response['status_msg'] = sprintf(
gettext('There is %s update available, total download size is %s.'),
$response['updates'],
$download_size
);
} elseif (array_key_exists('updates', $response) && $response['updates'] != 0) {
if (count($args)) {
$response['status_msg'] = gettext('The release type requires an update.');
$response['status_upgrade_action'] = 'rel';
$response['status'] = 'ok';
} else {
$response['status_msg'] = sprintf(
gettext('There are %s updates available, total download size is %s.'),
$response['updates'],
$download_size
);
}
if ($response['upgrade_needs_reboot'] == 1) {
$response['status_msg'] = sprintf(
'%s %s',
$response['status_msg'],
gettext('This update requires a reboot.')
);
$response['status_upgrade_action'] = 'all';
$response['status'] = 'ok';
if ($response['updates'] == 1) {
/* keep this dynamic for template translation even though %s is always '1' */
$response['status_msg'] = sprintf(
gettext('There is %s update available, total download size is %s.'),
$response['updates'],
$download_size
);
} else {
$response['status_msg'] = sprintf(
gettext('There are %s updates available, total download size is %s.'),
$response['updates'],
$download_size
);
}
if ($response['upgrade_needs_reboot'] == 1) {
$response['status_msg'] = sprintf(
'%s %s',
$response['status_msg'],
gettext('This update requires a reboot.')
);
}
}
} elseif (array_key_exists('updates', $response) && $response['updates'] == 0) {
$response['status_msg'] = gettext('There are no updates available on the selected mirror.');
$response['status'] = 'none';
} else {
$response['status_msg'] = gettext('Unknown firmware status encountered.');
$response['status'] = 'unknown';

View File

@ -27,7 +27,7 @@
# This script generates a json structured file with the following content:
# connection: error|timeout|unauthenticated|misconfigured|unresolved|busy|ok
# repository: error|untrusted|unsigned|revoked|ok
# repository: error|untrusted|unsigned|revoked|incomplete|ok
# last_ckeck: <date_time_stamp>
# updates: <num_of_updates>
# download_size: <size_of_total_downloads>
@ -145,7 +145,11 @@ if [ -z "${pkg_running}" ]; then
## check if timeout is not reached
if [ $timer -gt 0 ]; then
# Check for additional repository errors
if ! grep -q 'Unable to update repository' ${outfile}; then
if grep -q 'Unable to update repository' ${outfile}; then
repository="error" # already set but reset here for clarity
elif grep -q "No packages available to install matching..${pkg_selected}" ${outfile}; then
repository="incomplete"
else
# Repository can be used for updates
repository="ok"
updates=$(grep 'The following' ${outfile} | awk -F '[ ]' '{print $3}')