Depend on appstream-glib >= 0.5.0

This commit is contained in:
Richard Hughes 2015-09-08 13:47:26 +01:00
parent 5c35abb1a5
commit 51f5083b09
10 changed files with 8 additions and 190 deletions

View File

@ -119,7 +119,7 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.36.0 gobject-2.0 gthread-2.0 gio-2.0 >= 2.
PKG_CHECK_MODULES(GUDEV, gudev-1.0)
PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= 0.103)
PKG_CHECK_MODULES(GCAB, libgcab-1.0)
PKG_CHECK_MODULES(APPSTREAM_GLIB, appstream-glib >= 0.3.5)
PKG_CHECK_MODULES(APPSTREAM_GLIB, appstream-glib >= 0.5.0)
PKG_CHECK_MODULES(GUSB, gusb >= 0.2.2)
PKG_CHECK_MODULES(SQLITE, sqlite3)
PKG_CHECK_MODULES(ARCHIVE, libarchive)

View File

@ -38,8 +38,6 @@ bin_PROGRAMS = fwupdmgr
fwupdmgr_SOURCES = \
fu-device.c \
fu-device.h \
fu-guid.c \
fu-guid.h \
fu-pending.c \
fu-pending.h \
fu-rom.c \
@ -91,8 +89,6 @@ fwupd_SOURCES = \
fu-debug.h \
fu-device.c \
fu-device.h \
fu-guid.c \
fu-guid.h \
fu-keyring.c \
fu-keyring.h \
fu-pending.c \
@ -159,8 +155,6 @@ fu_self_test_SOURCES = \
fu-cab.h \
fu-device.c \
fu-device.h \
fu-guid.c \
fu-guid.h \
fu-keyring.c \
fu-keyring.h \
fu-pending.c \

View File

@ -1,80 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <appstream-glib.h>
#include <fwupd.h>
#include <glib-object.h>
#include <string.h>
#include "fu-cleanup.h"
#include "fu-guid.h"
/**
* fu_guid_is_valid:
**/
gboolean
fu_guid_is_valid (const gchar *guid)
{
#if AS_CHECK_VERSION(0,5,0)
return as_utils_guid_is_valid (guid);
#else
_cleanup_strv_free_ gchar **split = NULL;
if (guid == NULL)
return FALSE;
split = g_strsplit (guid, "-", -1);
if (g_strv_length (split) != 5)
return FALSE;
if (strlen (split[0]) != 8)
return FALSE;
if (strlen (split[1]) != 4)
return FALSE;
if (strlen (split[2]) != 4)
return FALSE;
if (strlen (split[3]) != 4)
return FALSE;
if (strlen (split[4]) != 12)
return FALSE;
return TRUE;
#endif
}
/**
* fu_guid_generate_from_string:
**/
gchar *
fu_guid_generate_from_string (const gchar *str)
{
#if AS_CHECK_VERSION(0,5,0)
return as_utils_guid_from_string (str);
#else
gchar *tmp;
tmp = g_compute_checksum_for_string (G_CHECKSUM_SHA1, str, -1);
tmp[8] = '-';
tmp[13] = '-';
tmp[18] = '-';
tmp[23] = '-';
tmp[36] = '\0';
g_assert (fu_guid_is_valid (tmp));
return tmp;
#endif
}

View File

@ -1,31 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __FU_GUID_H
#define __FU_GUID_H
gboolean fu_guid_is_valid (const gchar *guid);
gchar *fu_guid_generate_from_string (const gchar *str);
G_END_DECLS
#endif /* __FU_GUID_H */

View File

@ -671,9 +671,6 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
g_debug ("Store was %i size", as_store_get_size (store));
if (!as_store_from_xml (store,
g_bytes_get_data (bytes, NULL),
#if !AS_CHECK_VERSION(0,5,0)
-1,
#endif
NULL, error))
return FALSE;
g_debug ("Store now %i size", as_store_get_size (store));
@ -715,9 +712,7 @@ fu_main_get_updates (FuMainPrivate *priv, GError **error)
updates = g_ptr_array_new ();
for (i = 0; i < priv->devices->len; i++) {
const gchar *version;
#if AS_CHECK_VERSION(0,5,0)
AsChecksum *csum;
#endif
item = g_ptr_array_index (priv->devices, i);
@ -727,13 +722,9 @@ fu_main_get_updates (FuMainPrivate *priv, GError **error)
continue;
/* match the GUID in the XML */
#if AS_CHECK_VERSION(0,5,0)
app = as_store_get_app_by_provide (priv->store,
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
fu_device_get_guid (item->device));
#else
app = as_store_get_app_by_id (priv->store, fu_device_get_guid (item->device));
#endif
if (app == NULL)
continue;
@ -758,20 +749,12 @@ fu_main_get_updates (FuMainPrivate *priv, GError **error)
fu_device_set_metadata (item->device,
FU_DEVICE_KEY_UPDATE_VERSION, tmp);
}
#if AS_CHECK_VERSION(0,5,0)
csum = as_release_get_checksum_by_target (rel, AS_CHECKSUM_TARGET_CONTAINER);
if (csum != NULL) {
fu_device_set_metadata (item->device,
FU_DEVICE_KEY_UPDATE_HASH,
as_checksum_get_value (csum));
}
#else
tmp = as_release_get_checksum (rel, G_CHECKSUM_SHA1);
if (tmp != NULL) {
fu_device_set_metadata (item->device,
FU_DEVICE_KEY_UPDATE_HASH, tmp);
}
#endif
tmp = as_release_get_location_default (rel);
if (tmp != NULL) {
fu_device_set_metadata (item->device,
@ -929,9 +912,7 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
/* return 's' */
if (g_strcmp0 (method_name, "Verify") == 0) {
AsApp *app;
#if AS_CHECK_VERSION(0,5,0)
AsChecksum *csum;
#endif
AsRelease *release;
FuDeviceItem *item = NULL;
const gchar *hash = NULL;
@ -982,7 +963,6 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
}
/* find checksum */
#if AS_CHECK_VERSION(0,5,0)
csum = as_release_get_checksum_by_target (release, AS_CHECKSUM_TARGET_CONTENT);
if (csum == NULL) {
g_dbus_method_invocation_return_error (invocation,
@ -1003,15 +983,6 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
hash);
return;
}
#else
g_dbus_method_invocation_return_error (invocation,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"No information with %s",
hash);
return;
#endif
g_dbus_method_invocation_return_value (invocation, NULL);
return;
}

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <appstream-glib.h>
#include <archive_entry.h>
#include <archive.h>
#include <fwupd.h>
@ -29,7 +30,6 @@
#include <string.h>
#include "fu-cleanup.h"
#include "fu-guid.h"
#include "fu-device.h"
#include "fu-provider-rpi.h"
@ -294,7 +294,7 @@ fu_provider_rpi_coldplug (FuProvider *provider, GError **error)
/* create fake device */
device = fu_device_new ();
fu_device_set_id (device, "raspberry-pi");
guid = fu_guid_generate_from_string ("raspberrypi");
guid = as_utils_guid_from_string ("raspberrypi");
fu_device_set_guid (device, guid);
fu_device_set_display_name (device, "Raspberry Pi");
fu_device_add_flag (device, FU_DEVICE_FLAG_INTERNAL);

View File

@ -22,13 +22,13 @@
#include "config.h"
#include <fwupd.h>
#include <appstream-glib.h>
#include <glib-object.h>
#include <gudev/gudev.h>
#include <string.h>
#include "fu-cleanup.h"
#include "fu-device.h"
#include "fu-guid.h"
#include "fu-provider-udev.h"
#include "fu-rom.h"
@ -183,8 +183,8 @@ fu_provider_udev_client_add (FuProviderUdev *provider_udev, GUdevDevice *device)
/* no GUID from the ROM, so fix up the VID:PID */
if (guid_new == NULL) {
if (!fu_guid_is_valid (guid)) {
guid_new = fu_guid_generate_from_string (guid);
if (!as_utils_guid_is_valid (guid)) {
guid_new = as_utils_guid_from_string (guid);
g_debug ("Fixing GUID %s->%s", guid, guid_new);
} else {
guid_new = g_strdup (guid);

View File

@ -22,13 +22,13 @@
#include "config.h"
#include <fwupd.h>
#include <appstream-glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <string.h>
#include "fu-cleanup.h"
#include "fu-guid.h"
#include "fu-rom.h"
static void fu_rom_finalize (GObject *object);
@ -822,7 +822,7 @@ fu_rom_load_file (FuRom *rom, GFile *file, FuRomLoadFlags flags,
/* update guid */
id = g_strdup_printf ("0x%04x:0x%04x", priv->vendor, priv->model);
priv->guid = fu_guid_generate_from_string (id);
priv->guid = as_utils_guid_from_string (id);
g_debug ("using %s for %s", priv->guid, id);
/* not known */

View File

@ -29,7 +29,6 @@
#include "fu-cab.h"
#include "fu-cleanup.h"
#include "fu-guid.h"
#include "fu-keyring.h"
#include "fu-pending.h"
#include "fu-provider-fake.h"
@ -52,25 +51,6 @@ fu_test_get_filename (const gchar *filename)
return g_strdup (full_tmp);
}
static void
fu_guid_func (void)
{
_cleanup_free_ gchar *guid = NULL;
/* invalid */
g_assert (!fu_guid_is_valid (NULL));
g_assert (!fu_guid_is_valid (""));
g_assert (!fu_guid_is_valid ("1ff60ab2-3905-06a1-b476"));
g_assert (!fu_guid_is_valid (" 1ff60ab2-3905-06a1-b476-0371f00c9e9b"));
/* valid */
g_assert (fu_guid_is_valid ("1ff60ab2-3905-06a1-b476-0371f00c9e9b"));
/* make valid */
guid = fu_guid_generate_from_string ("0x8086:0x0406");
g_assert_cmpstr (guid, ==, "1ff60ab2-3905-06a1-b476-0371f00c9e9b");
}
static void
fu_rom_func (void)
{
@ -557,7 +537,6 @@ main (int argc, char **argv)
g_assert_cmpint (g_mkdir_with_parents ("/tmp/fwupd-self-test/var/lib/fwupd", 0755), ==, 0);
/* tests go here */
g_test_add_func ("/fwupd/guid", fu_guid_func);
g_test_add_func ("/fwupd/rom", fu_rom_func);
g_test_add_func ("/fwupd/rom{all}", fu_rom_all_func);
g_test_add_func ("/fwupd/cab", fu_cab_func);

View File

@ -36,7 +36,6 @@
#include <unistd.h>
#include "fu-cleanup.h"
#include "fu-guid.h"
#include "fu-pending.h"
#include "fu-provider.h"
#include "fu-rom.h"
@ -874,7 +873,6 @@ fu_util_verify_update_internal (FuUtilPrivate *priv,
gchar **values,
GError **error)
{
#if AS_CHECK_VERSION(0,5,0)
guint i;
_cleanup_object_unref_ AsStore *store = NULL;
_cleanup_object_unref_ GFile *xml_file = NULL;
@ -930,13 +928,6 @@ fu_util_verify_update_internal (FuUtilPrivate *priv,
NULL, error))
return FALSE;
return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"Required AppStreamGlib >= 0.5.0 to perform verify");
return FALSE;
#endif
}
/**
@ -1376,15 +1367,9 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
tmp = fu_device_get_metadata (dev, FU_DEVICE_KEY_UPDATE_DESCRIPTION);
if (tmp != NULL) {
_cleanup_free_ gchar *md = NULL;
#if AS_CHECK_VERSION(0,5,0)
md = as_markup_convert (tmp,
AS_MARKUP_CONVERT_FORMAT_SIMPLE,
NULL);
#else
md = as_markup_convert (tmp, -1,
AS_MARKUP_CONVERT_FORMAT_SIMPLE,
NULL);
#endif
if (md != NULL) {
/* TRANSLATORS: section header for long firmware desc */
fu_util_print_data (_("Description"), md);