mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 05:17:31 +00:00
fwupdmgr/fwupdtool: Move firmware builder from fwupdmgr to fwupdtool
This command is really a power user command and should live in fwupdtool with similar debugging and development features.
This commit is contained in:
parent
cdcd6a2423
commit
f6d01b16de
@ -1,5 +1,4 @@
|
|||||||
_fwupdmgr_cmd_list=(
|
_fwupdmgr_cmd_list=(
|
||||||
'build-firmware'
|
|
||||||
'clear-history'
|
'clear-history'
|
||||||
'clear-offline'
|
'clear-offline'
|
||||||
'clear-results'
|
'clear-results'
|
||||||
@ -147,23 +146,6 @@ _fwupdmgr()
|
|||||||
_show_modifiers
|
_show_modifiers
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
build-firmware)
|
|
||||||
#file in
|
|
||||||
if [[ "$prev" = "$command" ]]; then
|
|
||||||
_filedir
|
|
||||||
#file out
|
|
||||||
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then
|
|
||||||
_filedir
|
|
||||||
#script
|
|
||||||
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then
|
|
||||||
_filedir
|
|
||||||
#output
|
|
||||||
elif [[ "$prev" = "${COMP_WORDS[4]}" ]]; then
|
|
||||||
_filedir
|
|
||||||
else
|
|
||||||
_show_modifiers
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
#find first command
|
#find first command
|
||||||
if [[ ${COMP_CWORD} = 1 ]]; then
|
if [[ ${COMP_CWORD} = 1 ]]; then
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
_fwupdtool_cmd_list=(
|
_fwupdtool_cmd_list=(
|
||||||
|
'build-firmware'
|
||||||
'get-details'
|
'get-details'
|
||||||
'get-devices'
|
'get-devices'
|
||||||
'get-plugins'
|
'get-plugins'
|
||||||
@ -66,6 +67,23 @@ _fwupdtool()
|
|||||||
_show_modifiers
|
_show_modifiers
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
build-firmware)
|
||||||
|
#file in
|
||||||
|
if [[ "$prev" = "$command" ]]; then
|
||||||
|
_filedir
|
||||||
|
#file out
|
||||||
|
elif [[ "$prev" = "${COMP_WORDS[2]}" ]]; then
|
||||||
|
_filedir
|
||||||
|
#script
|
||||||
|
elif [[ "$prev" = "${COMP_WORDS[3]}" ]]; then
|
||||||
|
_filedir
|
||||||
|
#output
|
||||||
|
elif [[ "$prev" = "${COMP_WORDS[4]}" ]]; then
|
||||||
|
_filedir
|
||||||
|
else
|
||||||
|
_show_modifiers
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
#find first command
|
#find first command
|
||||||
if [[ ${COMP_CWORD} = 1 ]]; then
|
if [[ ${COMP_CWORD} = 1 ]]; then
|
||||||
|
@ -906,6 +906,33 @@ fu_util_hwids (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_util_firmware_builder (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
|
{
|
||||||
|
const gchar *script_fn = "startup.sh";
|
||||||
|
const gchar *output_fn = "firmware.bin";
|
||||||
|
g_autoptr(GBytes) archive_blob = NULL;
|
||||||
|
g_autoptr(GBytes) firmware_blob = NULL;
|
||||||
|
if (g_strv_length (values) < 2) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid arguments");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
archive_blob = fu_common_get_contents_bytes (values[0], error);
|
||||||
|
if (archive_blob == NULL)
|
||||||
|
return FALSE;
|
||||||
|
if (g_strv_length (values) > 2)
|
||||||
|
script_fn = values[2];
|
||||||
|
if (g_strv_length (values) > 3)
|
||||||
|
output_fn = values[3];
|
||||||
|
firmware_blob = fu_common_firmware_builder (archive_blob, script_fn, output_fn, error);
|
||||||
|
if (firmware_blob == NULL)
|
||||||
|
return FALSE;
|
||||||
|
return fu_common_set_contents_bytes (values[1], firmware_blob, error);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -957,6 +984,12 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* add commands */
|
/* add commands */
|
||||||
priv->cmd_array = g_ptr_array_new_with_free_func ((GDestroyNotify) fu_util_item_free);
|
priv->cmd_array = g_ptr_array_new_with_free_func ((GDestroyNotify) fu_util_item_free);
|
||||||
|
fu_util_add (priv->cmd_array,
|
||||||
|
"build-firmware",
|
||||||
|
"FILE-IN FILE-OUT [SCRIPT] [OUTPUT]",
|
||||||
|
/* TRANSLATORS: command description */
|
||||||
|
_("Build firmware using a sandbox"),
|
||||||
|
fu_util_firmware_builder);
|
||||||
fu_util_add (priv->cmd_array,
|
fu_util_add (priv->cmd_array,
|
||||||
"smbios-dump",
|
"smbios-dump",
|
||||||
"FILE",
|
"FILE",
|
||||||
|
@ -1970,33 +1970,6 @@ fu_util_changed_cb (FwupdClient *client, gpointer user_data)
|
|||||||
g_print ("%s\n", _("Changed"));
|
g_print ("%s\n", _("Changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
fu_util_firmware_builder (FuUtilPrivate *priv, gchar **values, GError **error)
|
|
||||||
{
|
|
||||||
const gchar *script_fn = "startup.sh";
|
|
||||||
const gchar *output_fn = "firmware.bin";
|
|
||||||
g_autoptr(GBytes) archive_blob = NULL;
|
|
||||||
g_autoptr(GBytes) firmware_blob = NULL;
|
|
||||||
if (g_strv_length (values) < 2) {
|
|
||||||
g_set_error_literal (error,
|
|
||||||
FWUPD_ERROR,
|
|
||||||
FWUPD_ERROR_INVALID_ARGS,
|
|
||||||
"Invalid arguments");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
archive_blob = fu_common_get_contents_bytes (values[0], error);
|
|
||||||
if (archive_blob == NULL)
|
|
||||||
return FALSE;
|
|
||||||
if (g_strv_length (values) > 2)
|
|
||||||
script_fn = values[2];
|
|
||||||
if (g_strv_length (values) > 3)
|
|
||||||
output_fn = values[3];
|
|
||||||
firmware_blob = fu_common_firmware_builder (archive_blob, script_fn, output_fn, error);
|
|
||||||
if (firmware_blob == NULL)
|
|
||||||
return FALSE;
|
|
||||||
return fu_common_set_contents_bytes (values[1], firmware_blob, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_monitor (FuUtilPrivate *priv, gchar **values, GError **error)
|
fu_util_monitor (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
@ -2503,12 +2476,6 @@ main (int argc, char *argv[])
|
|||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Monitor the daemon for events"),
|
_("Monitor the daemon for events"),
|
||||||
fu_util_monitor);
|
fu_util_monitor);
|
||||||
fu_util_add (priv->cmd_array,
|
|
||||||
"build-firmware",
|
|
||||||
"FILE-IN FILE-OUT [SCRIPT] [OUTPUT]",
|
|
||||||
/* TRANSLATORS: command description */
|
|
||||||
_("Build firmware using a sandbox"),
|
|
||||||
fu_util_firmware_builder);
|
|
||||||
fu_util_add (priv->cmd_array,
|
fu_util_add (priv->cmd_array,
|
||||||
"modify-remote",
|
"modify-remote",
|
||||||
"REMOTE-ID KEY VALUE",
|
"REMOTE-ID KEY VALUE",
|
||||||
|
Loading…
Reference in New Issue
Block a user