Add a new firmware-upgrade mode for use by fwupd

This allows us to have accurate localised text, and also to use the vendor BIOS
logo when applying firmware updates.
This commit is contained in:
Richard Hughes 2019-03-25 09:39:24 +00:00 committed by Ray Strode
parent f7142e72f3
commit cd4a601094
8 changed files with 44 additions and 5 deletions

View file

@ -787,6 +787,7 @@ on_change_mode_request (state_t *state,
bool reboot = false;
bool updates = false;
bool system_upgrade = false;
bool firmware_upgrade = false;
const char *mode = NULL;
ply_command_parser_get_command_options (state->command_parser,
@ -796,6 +797,7 @@ on_change_mode_request (state_t *state,
"reboot", &reboot,
"updates", &updates,
"system-upgrade", &system_upgrade,
"firmware-upgrade", &firmware_upgrade,
NULL);
if (boot_up)
@ -808,6 +810,8 @@ on_change_mode_request (state_t *state,
mode = "updates";
else if (system_upgrade)
mode = "system-upgrade";
else if (firmware_upgrade)
mode = "firmware-upgrade";
if (mode) {
ply_boot_client_change_mode (state->client, mode,
@ -901,6 +905,8 @@ main (int argc,
PLY_COMMAND_OPTION_TYPE_FLAG,
"system-upgrade", "Upgrading the OS to a new version",
PLY_COMMAND_OPTION_TYPE_FLAG,
"firmware-upgrade", "Upgrading firmware to a new version",
PLY_COMMAND_OPTION_TYPE_FLAG,
NULL);
ply_command_parser_add_command (state.command_parser,

View file

@ -41,8 +41,9 @@ typedef enum
PLY_BOOT_SPLASH_MODE_REBOOT,
PLY_BOOT_SPLASH_MODE_UPDATES,
PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE,
PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE,
PLY_BOOT_SPLASH_MODE_INVALID,
PLY_BOOT_SPLASH_MODE_COUNT = PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE + 1,
PLY_BOOT_SPLASH_MODE_COUNT = PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE + 1,
} ply_boot_splash_mode_t;
typedef struct _ply_boot_splash_plugin ply_boot_splash_plugin_t;

View file

@ -206,6 +206,8 @@ on_change_mode (state_t *state,
state->mode = PLY_BOOT_SPLASH_MODE_UPDATES;
else if (strcmp (mode, "system-upgrade") == 0)
state->mode = PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE;
else if (strcmp (mode, "firmware-upgrade") == 0)
state->mode = PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE;
else
return;
@ -675,6 +677,7 @@ get_cache_file_for_mode (ply_boot_splash_mode_t mode)
break;
case PLY_BOOT_SPLASH_MODE_UPDATES:
case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE:
case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE:
filename = NULL;
break;
case PLY_BOOT_SPLASH_MODE_INVALID:
@ -704,6 +707,7 @@ get_log_file_for_state (state_t *state)
case PLY_BOOT_SPLASH_MODE_REBOOT:
case PLY_BOOT_SPLASH_MODE_UPDATES:
case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE:
case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE:
filename = _PATH_DEVNULL;
break;
case PLY_BOOT_SPLASH_MODE_INVALID:
@ -730,6 +734,7 @@ get_log_spool_file_for_mode (ply_boot_splash_mode_t mode)
case PLY_BOOT_SPLASH_MODE_REBOOT:
case PLY_BOOT_SPLASH_MODE_UPDATES:
case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE:
case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE:
filename = NULL;
break;
case PLY_BOOT_SPLASH_MODE_INVALID:
@ -2149,6 +2154,8 @@ main (int argc,
state.mode = PLY_BOOT_SPLASH_MODE_UPDATES;
else if (strcmp (mode_string, "system-upgrade") == 0)
state.mode = PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE;
else if (strcmp (mode_string, "firmware-upgrade") == 0)
state.mode = PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE;
else
state.mode = PLY_BOOT_SPLASH_MODE_BOOT_UP;

View file

@ -79,6 +79,9 @@ static script_return_t plymouth_get_mode (script_state_t *state,
case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE:
obj = script_obj_new_string ("system-upgrade");
break;
case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE:
obj = script_obj_new_string ("firmware-upgrade");
break;
case PLY_BOOT_SPLASH_MODE_INVALID:
default:
obj = script_obj_new_string ("unknown");

View file

@ -723,7 +723,8 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
double total_duration;
if (plugin->mode == PLY_BOOT_SPLASH_MODE_UPDATES ||
plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE)
plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE ||
plugin->mode == PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
return;
total_duration = duration / percent_done;
@ -935,7 +936,8 @@ system_update (ply_boot_splash_plugin_t *plugin,
ply_list_node_t *node;
if (plugin->mode != PLY_BOOT_SPLASH_MODE_UPDATES &&
plugin->mode != PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE)
plugin->mode != PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE &&
plugin->mode != PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
return;
node = ply_list_get_first_node (plugin->views);

View file

@ -253,6 +253,7 @@ view_load_end_animation (view_t *view)
case PLY_BOOT_SPLASH_MODE_BOOT_UP:
case PLY_BOOT_SPLASH_MODE_UPDATES:
case PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE:
case PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE:
animation_prefix = "startup-animation-";
break;
case PLY_BOOT_SPLASH_MODE_SHUTDOWN:
@ -1006,6 +1007,7 @@ create_plugin (ply_key_file_t *key_file)
load_mode_settings (plugin, key_file, "reboot", PLY_BOOT_SPLASH_MODE_REBOOT);
load_mode_settings (plugin, key_file, "updates", PLY_BOOT_SPLASH_MODE_UPDATES);
load_mode_settings (plugin, key_file, "system-upgrade", PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE);
load_mode_settings (plugin, key_file, "firmware-upgrade", PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE);
if (plugin->use_firmware_background)
plugin->background_bgrt_image = ply_image_new ("/sys/firmware/acpi/bgrt/image");
@ -1583,7 +1585,8 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin,
double percent_done)
{
if (plugin->mode == PLY_BOOT_SPLASH_MODE_UPDATES ||
plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE)
plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE ||
plugin->mode == PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
return;
if (plugin->state != PLY_BOOT_SPLASH_DISPLAY_NORMAL)
@ -1791,7 +1794,8 @@ system_update (ply_boot_splash_plugin_t *plugin,
char buf[64];
if (plugin->mode != PLY_BOOT_SPLASH_MODE_UPDATES &&
plugin->mode != PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE)
plugin->mode != PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE &&
plugin->mode != PLY_BOOT_SPLASH_MODE_FIRMWARE_UPGRADE)
return;
node = ply_list_get_first_node (plugin->views);

View file

@ -46,3 +46,11 @@ ProgressBarShowPercentComplete=true
UseProgressBar=true
_Title=Upgrading System...
_SubTitle=Do not turn off your computer
[firmware-upgrade]
SuppressMessages=true
ProgressBarShowPercentComplete=true
UseProgressBar=true
UseFirmwareBackground=true
_Title=Upgrading Firmware...
_SubTitle=Do not turn off your computer

View file

@ -36,3 +36,11 @@ ProgressBarShowPercentComplete=true
UseProgressBar=true
_Title=Upgrading System...
_SubTitle=Do not turn off your computer
[firmware-upgrade]
SuppressMessages=true
ProgressBarShowPercentComplete=true
UseProgressBar=true
UseFirmwareBackground=true
_Title=Upgrading Firmware...
_SubTitle=Do not turn off your computer