mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-29 16:38:47 +00:00
Allow customising the warning shown when enabling the remote
This commit is contained in:
parent
9e7d69ccb1
commit
972f6eaba5
@ -210,7 +210,7 @@ mkdir -p --mode=0700 $RPM_BUILD_ROOT%{_localstatedir}/lib/fwupd/gnupg
|
|||||||
%{_datadir}/dbus-1/system-services/org.freedesktop.fwupd.service
|
%{_datadir}/dbus-1/system-services/org.freedesktop.fwupd.service
|
||||||
%{_datadir}/man/man1/dfu-tool.1.gz
|
%{_datadir}/man/man1/dfu-tool.1.gz
|
||||||
%{_datadir}/man/man1/fwupdmgr.1.gz
|
%{_datadir}/man/man1/fwupdmgr.1.gz
|
||||||
%{_datadir}/metainfo/org.freedesktop.fwupd.metainfo.xml
|
%{_datadir}/metainfo/org.freedesktop.fwupd*.metainfo.xml
|
||||||
%{_datadir}/fwupd/firmware-packager
|
%{_datadir}/fwupd/firmware-packager
|
||||||
%{_unitdir}/fwupd-offline-update.service
|
%{_unitdir}/fwupd-offline-update.service
|
||||||
%{_unitdir}/fwupd.service
|
%{_unitdir}/fwupd.service
|
||||||
|
35
data/remotes.d/lvfs-testing.metainfo.xml
Normal file
35
data/remotes.d/lvfs-testing.metainfo.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright 2018 Richard Hughes <richard@hughsie.com> -->
|
||||||
|
|
||||||
|
<component type="source">
|
||||||
|
<id>org.freedesktop.fwupd.remotes.lvfs-testing</id>
|
||||||
|
<name>Linux Vendor Firmware Service (testing firmware)</name>
|
||||||
|
<metadata_license>CC0</metadata_license>
|
||||||
|
<agreement version_id="1.0">
|
||||||
|
<agreement_section>
|
||||||
|
<description>
|
||||||
|
<!-- TRANSLATORS: do not translate the variables marked using $ -->
|
||||||
|
<p>
|
||||||
|
The LVFS is a free service that operates as an independent legal
|
||||||
|
entity and has no connection with $OS_RELEASE:NAME$.
|
||||||
|
Your distributor may not have verified any of the firmware updates for
|
||||||
|
compatibility with your system or connected devices.
|
||||||
|
All firmware is provided only by the original equipment manufacturer.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
This remote contains firmware which is not embargoed, but is still being
|
||||||
|
tested by the hardware vendor.
|
||||||
|
You should ensure you have a way to manually downgrade the firmware if
|
||||||
|
the firmware update fails.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Enabling this functionality is done at your own risk, which means you
|
||||||
|
have to contact your original equipment manufacturer regarding any
|
||||||
|
problems caused by these updates.
|
||||||
|
Only problems with the update process itself should be filed at
|
||||||
|
$OS_RELEASE:BUG_REPORT_URL$.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</agreement_section>
|
||||||
|
</agreement>
|
||||||
|
</component>
|
29
data/remotes.d/lvfs.metainfo.xml
Normal file
29
data/remotes.d/lvfs.metainfo.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright 2018 Richard Hughes <richard@hughsie.com> -->
|
||||||
|
|
||||||
|
<component type="source">
|
||||||
|
<id>org.freedesktop.fwupd.remotes.lvfs</id>
|
||||||
|
<name>Linux Vendor Firmware Service (stable firmware)</name>
|
||||||
|
<metadata_license>CC0</metadata_license>
|
||||||
|
<agreement version_id="1.0">
|
||||||
|
<agreement_section>
|
||||||
|
<description>
|
||||||
|
<!-- TRANSLATORS: do not translate the variables marked using $ -->
|
||||||
|
<p>
|
||||||
|
The LVFS is a free service that operates as an independent legal
|
||||||
|
entity and has no connection with $OS_RELEASE:NAME$.
|
||||||
|
Your distributor may not have verified any of the firmware updates for
|
||||||
|
compatibility with your system or connected devices.
|
||||||
|
All firmware is provided only by the original equipment manufacturer.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Enabling this functionality is done at your own risk, which means you
|
||||||
|
have to contact your original equipment manufacturer regarding any
|
||||||
|
problems caused by these updates.
|
||||||
|
Only problems with the update process itself should be filed at
|
||||||
|
$OS_RELEASE:BUG_REPORT_URL$.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</agreement_section>
|
||||||
|
</agreement>
|
||||||
|
</component>
|
@ -5,6 +5,24 @@ if get_option('lvfs')
|
|||||||
],
|
],
|
||||||
install_dir : join_paths(sysconfdir, 'fwupd', 'remotes.d')
|
install_dir : join_paths(sysconfdir, 'fwupd', 'remotes.d')
|
||||||
)
|
)
|
||||||
|
i18n.merge_file(
|
||||||
|
input: 'lvfs.metainfo.xml',
|
||||||
|
output: 'org.freedesktop.fwupd.remotes.lvfs.metainfo.xml',
|
||||||
|
type: 'xml',
|
||||||
|
po_dir: join_paths(meson.source_root(), 'po'),
|
||||||
|
data_dirs: join_paths(meson.source_root(), 'po'),
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'metainfo')
|
||||||
|
)
|
||||||
|
i18n.merge_file(
|
||||||
|
input: 'lvfs-testing.metainfo.xml',
|
||||||
|
output: 'org.freedesktop.fwupd.remotes.lvfs-testing.metainfo.xml',
|
||||||
|
type: 'xml',
|
||||||
|
po_dir: join_paths(meson.source_root(), 'po'),
|
||||||
|
data_dirs: join_paths(meson.source_root(), 'po'),
|
||||||
|
install: true,
|
||||||
|
install_dir: join_paths(get_option('datadir'), 'metainfo')
|
||||||
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
install_data('README.md',
|
install_data('README.md',
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
data/org.freedesktop.fwupd.metainfo.xml
|
data/org.freedesktop.fwupd.metainfo.xml
|
||||||
|
data/remotes.d/lvfs.metainfo.xml
|
||||||
|
data/remotes.d/lvfs-testing.metainfo.xml
|
||||||
policy/org.freedesktop.fwupd.policy.in
|
policy/org.freedesktop.fwupd.policy.in
|
||||||
plugins/dfu/dfu-tool.c
|
plugins/dfu/dfu-tool.c
|
||||||
plugins/synapticsmst/synapticsmst-tool.c
|
plugins/synapticsmst/synapticsmst-tool.c
|
||||||
|
14
po/its/appdata.its
Normal file
14
po/its/appdata.its
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<its:rules xmlns:its="http://www.w3.org/2005/11/its"
|
||||||
|
version="2.0">
|
||||||
|
<its:translateRule selector="/component" translate="no"/>
|
||||||
|
<its:translateRule selector="/component/name |
|
||||||
|
/component/summary |
|
||||||
|
/component/description |
|
||||||
|
/component/developer_name |
|
||||||
|
/component/agreement/agreement_section/name |
|
||||||
|
/component/agreement/agreement_section/summary |
|
||||||
|
/component/agreement/agreement_section/description |
|
||||||
|
/component/screenshots/screenshot/caption"
|
||||||
|
translate="yes"/>
|
||||||
|
</its:rules>
|
9
po/its/appdata.loc
Normal file
9
po/its/appdata.loc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<locatingRules>
|
||||||
|
<locatingRule name="AppData" pattern="*.appdata.xml">
|
||||||
|
<documentRule localName="component" target="appdata.its"/>
|
||||||
|
</locatingRule>
|
||||||
|
<locatingRule name="AppData" pattern="*.metainfo.xml">
|
||||||
|
<documentRule localName="component" target="appdata.its"/>
|
||||||
|
</locatingRule>
|
||||||
|
</locatingRules>
|
102
src/fu-util.c
102
src/fu-util.c
@ -481,15 +481,111 @@ fu_util_get_remote_warning (FuUtilPrivate *priv, FwupdRemote *remote, GError **e
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GString *
|
||||||
|
fu_util_get_component_agreement (FuUtilPrivate *priv, AsApp *app, GError **error)
|
||||||
|
{
|
||||||
|
g_autofree gchar *tmp = NULL;
|
||||||
|
#if AS_CHECK_VERSION(0,7,8)
|
||||||
|
AsAgreement *agreement;
|
||||||
|
AsAgreementSection *section;
|
||||||
|
|
||||||
|
/* get the default agreement section */
|
||||||
|
agreement = as_app_get_agreement_default (app);
|
||||||
|
if (agreement == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_FOUND,
|
||||||
|
"No agreement found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
section = as_agreement_get_section_default (agreement);
|
||||||
|
if (section == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_FOUND,
|
||||||
|
"No default section for agreement found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
tmp = as_agreement_section_get_description (section, NULL);
|
||||||
|
if (tmp == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_FOUND,
|
||||||
|
"No description found in agreement section");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert to console text */
|
||||||
|
tmp = as_markup_convert_simple (tmp, error);
|
||||||
|
#else
|
||||||
|
AsFormat *format;
|
||||||
|
GNode *n;
|
||||||
|
g_autoptr(AsNode) root = NULL;
|
||||||
|
g_autoptr(GFile) file = NULL;
|
||||||
|
g_autoptr(GString) str = NULL;
|
||||||
|
|
||||||
|
/* parse the XML file */
|
||||||
|
format = as_app_get_format_default (app);
|
||||||
|
if (format == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_FOUND,
|
||||||
|
"No format for Metainfo file");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
file = g_file_new_for_path (as_format_get_filename (format));
|
||||||
|
root = as_node_from_file (file, AS_NODE_FROM_XML_FLAG_NONE, NULL, error);
|
||||||
|
if (root == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* manually find the first agreement section */
|
||||||
|
n = as_node_find (root, "component/agreement/agreement_section/description");
|
||||||
|
if (n == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_NOT_FOUND,
|
||||||
|
"No agreement description found");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
str = as_node_to_xml (n->children, AS_NODE_TO_XML_FLAG_INCLUDE_SIBLINGS);
|
||||||
|
tmp = as_markup_convert_simple (str->str, error);
|
||||||
|
#endif
|
||||||
|
return g_string_new (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_modify_remote_warning (FuUtilPrivate *priv, FwupdRemote *remote, GError **error)
|
fu_util_modify_remote_warning (FuUtilPrivate *priv, FwupdRemote *remote, GError **error)
|
||||||
{
|
{
|
||||||
|
AsApp *app;
|
||||||
|
g_autofree gchar *component_id = NULL;
|
||||||
|
g_autoptr(AsStore) store = NULL;
|
||||||
|
g_autoptr(GHashTable) os_release = NULL;
|
||||||
g_autoptr(GString) desc_plain_str = NULL;
|
g_autoptr(GString) desc_plain_str = NULL;
|
||||||
|
|
||||||
/* get a generic warning */
|
/* try to find a custom agreement, falling back to a generic warning */
|
||||||
desc_plain_str = fu_util_get_remote_warning (priv, remote, error);
|
store = as_store_new ();
|
||||||
if (desc_plain_str == NULL)
|
as_store_add_filter (store, AS_APP_KIND_SOURCE);
|
||||||
|
if (!as_store_load (store, AS_STORE_LOAD_FLAG_APPDATA, NULL, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
component_id = g_strdup_printf ("org.freedesktop.fwupd.remotes.%s",
|
||||||
|
fwupd_remote_get_id (remote));
|
||||||
|
app = as_store_get_app_by_id (store, component_id);
|
||||||
|
if (app != NULL) {
|
||||||
|
desc_plain_str = fu_util_get_component_agreement (priv, app, error);
|
||||||
|
if (desc_plain_str == NULL)
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
desc_plain_str = fu_util_get_remote_warning (priv, remote, error);
|
||||||
|
if (desc_plain_str == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* replace any dynamic values from os-release */
|
||||||
|
os_release = fwupd_get_os_release (error);
|
||||||
|
as_utils_string_replace (desc_plain_str, "$OS_RELEASE:NAME$",
|
||||||
|
g_hash_table_lookup (os_release, "NAME"));
|
||||||
|
as_utils_string_replace (desc_plain_str, "$OS_RELEASE:BUG_REPORT_URL$",
|
||||||
|
g_hash_table_lookup (os_release, "BUG_REPORT_URL"));
|
||||||
|
|
||||||
/* show and ask user to confirm */
|
/* show and ask user to confirm */
|
||||||
g_print ("%s", desc_plain_str->str);
|
g_print ("%s", desc_plain_str->str);
|
||||||
|
Loading…
Reference in New Issue
Block a user