diff options
author | Richard Hughes <richard@hughsie.com> | 2015-08-05 12:01:03 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-08-05 12:06:01 +0100 |
commit | 62bca1ea41f27cc84b73cd8e6381517700ad39f2 (patch) | |
tree | 9bac6cfe22c79c772a31aff1ab8b9b746340724d | |
parent | 1e8e00567a608f28736d86acca6f8d5b6a199d4b (diff) | |
download | appstream-glib-62bca1ea41f27cc84b73cd8e6381517700ad39f2.tar.gz |
Make the DriverVer in the .inf file optional
This allows the release engineer to _only_ update the metainfo.xml file for
each release. If the firmware.inf file is not being used in Windows for driver
installation then we should make the file static.
-rw-r--r-- | data/tests/firmware/2_0_1/firmware.inf | 1 | ||||
-rw-r--r-- | libappstream-builder/asb-self-test.c | 2 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-firmware.c | 8 | ||||
-rw-r--r-- | libappstream-glib/as-app-inf.c | 27 | ||||
-rw-r--r-- | libappstream-glib/as-app.c | 7 | ||||
-rw-r--r-- | libappstream-glib/as-inf.c | 2 | ||||
-rw-r--r-- | libappstream-glib/as-inf.h | 2 |
7 files changed, 38 insertions, 11 deletions
diff --git a/data/tests/firmware/2_0_1/firmware.inf b/data/tests/firmware/2_0_1/firmware.inf index 61b6947..ca6ca8b 100644 --- a/data/tests/firmware/2_0_1/firmware.inf +++ b/data/tests/firmware/2_0_1/firmware.inf @@ -3,7 +3,6 @@ [Version] Class=Firmware ClassGuid={f2e7dd72-6468-4e36-b6f1-6488f42c1b52} -DriverVer=03/01/2015,2.0.1 [Firmware_CopyFiles] firmware.bin diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c index df366ea..e48dd83 100644 --- a/libappstream-builder/asb-self-test.c +++ b/libappstream-builder/asb-self-test.c @@ -940,7 +940,7 @@ asb_test_firmware_func (void) "</release>\n" "<release version=\"2.0.1\" timestamp=\"1424116753\">\n" "<location>http://www.hughski.com/downloads/colorhug2/firmware/colorhug-2.0.1.cab</location>\n" - "<checksum filename=\"colorhug-als-2.0.1.cab\" target=\"container\" type=\"sha1\">c7cc46d54d8d4ba452b677a2367214efbaa40fd5</checksum>\n" + "<checksum filename=\"colorhug-als-2.0.1.cab\" target=\"container\" type=\"sha1\">c61e55ccb2ce8de401550a731b0f364a18cb2639</checksum>\n" "<checksum filename=\"firmware.bin\" target=\"content\" type=\"sha1\">767a8a7b8a7b350b513f57761204b4aaa657aa44</checksum>\n" "<description><p>This unstable release adds the following features:</p>" "<ul><li>Use TakeReadings() to do a quick non-adaptive measurement</li>" diff --git a/libappstream-builder/plugins/asb-plugin-firmware.c b/libappstream-builder/plugins/asb-plugin-firmware.c index b5d7a29..64de525 100644 --- a/libappstream-builder/plugins/asb-plugin-firmware.c +++ b/libappstream-builder/plugins/asb-plugin-firmware.c @@ -130,13 +130,19 @@ asb_plugin_process_filename (AsbPlugin *plugin, return FALSE; } + /* get the default release, creating if required */ + release = as_app_get_release_default (AS_APP (app)); + if (release == NULL) { + release = as_release_new (); + as_app_add_release (AS_APP (app), release); + } + /* add the checksum for the .cab file */ checksum = asb_plugin_firmware_get_checksum (asb_package_get_filename (pkg), G_CHECKSUM_SHA1, error); if (checksum == NULL) return FALSE; - release = as_app_get_release_default (AS_APP (app)); /* add checksum */ csum = as_checksum_new (); diff --git a/libappstream-glib/as-app-inf.c b/libappstream-glib/as-app-inf.c index 3650e88..d50fdee 100644 --- a/libappstream-glib/as-app-inf.c +++ b/libappstream-glib/as-app-inf.c @@ -159,9 +159,20 @@ as_app_parse_inf_file (AsApp *app, as_app_set_comment (app, NULL, comment); /* parse the DriverVer */ - version = as_inf_get_driver_version (kf, ×tamp, error); - if (version == NULL) - return FALSE; + version = as_inf_get_driver_version (kf, ×tamp, &error_local); + if (version == NULL) { + if (g_error_matches (error_local, + AS_INF_ERROR, + AS_INF_ERROR_NOT_FOUND)) { + g_clear_error (&error_local); + } else { + g_set_error_literal (error, + AS_APP_ERROR, + AS_APP_ERROR_FAILED, + error_local->message); + return FALSE; + } + } /* find the firmware file we're installing */ source_keys = g_key_file_get_keys (kf, "SourceDisksFiles", NULL, NULL); @@ -187,10 +198,12 @@ as_app_parse_inf_file (AsApp *app, as_app_add_metadata (app, "CatalogBasename", catalog_basename); /* add a release with no real description */ - release = as_release_new (); - as_release_set_version (release, version); - as_release_set_timestamp (release, timestamp); - as_app_add_release (app, release); + if (version != NULL) { + release = as_release_new (); + as_release_set_version (release, version); + as_release_set_timestamp (release, timestamp); + as_app_add_release (app, release); + } /* add icon */ icon = as_icon_new (); diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index ed834e2..38ac45a 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -2126,6 +2126,11 @@ as_app_subsume_release (AsRelease *release, AsRelease *donor) if (tmp != NULL || as_release_get_timestamp (release) == 0) as_release_set_timestamp (release, as_release_get_timestamp (donor)); + /* overwrite the version */ + tmp = as_release_get_version (donor); + if (tmp != NULL && as_release_get_version (release) == NULL) + as_release_set_version (release, tmp); + /* copy all locations */ locations = as_release_get_locations (donor); for (i = 0; i < locations->len; i++) { @@ -2162,6 +2167,8 @@ as_app_add_release (AsApp *app, AsRelease *release) /* if already exists them update */ release_old = as_app_get_release (app, as_release_get_version (release)); + if (release_old == NULL) + release_old = as_app_get_release (app, NULL); if (release_old == release) return; if (release_old != NULL) { diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c index 95e3335..bfefe5c 100644 --- a/libappstream-glib/as-inf.c +++ b/libappstream-glib/as-inf.c @@ -932,7 +932,7 @@ as_inf_get_driver_version (GKeyFile *keyfile, guint64 *timestamp, GError **error if (driver_ver == NULL) { g_set_error_literal (error, AS_INF_ERROR, - AS_INF_ERROR_INVALID_TYPE, + AS_INF_ERROR_NOT_FOUND, "DriverVer is missing"); return FALSE; } diff --git a/libappstream-glib/as-inf.h b/libappstream-glib/as-inf.h index 3c92453..2ebfd98 100644 --- a/libappstream-glib/as-inf.h +++ b/libappstream-glib/as-inf.h @@ -34,12 +34,14 @@ G_BEGIN_DECLS * AsInfError: * @AS_INF_ERROR_FAILED: Generic failure * @AS_INF_ERROR_INVALID_TYPE: Invalid type + * @AS_INF_ERROR_NOT_FOUND: Data not found * * The error type. **/ typedef enum { AS_INF_ERROR_FAILED, AS_INF_ERROR_INVALID_TYPE, + AS_INF_ERROR_NOT_FOUND, /*< private >*/ AS_INF_ERROR_LAST } AsInfError; |