Create directories in /var/cache as required

These can be nuked at any time by users, so don't rely on the package manager
or installer to create these for us.
This commit is contained in:
Richard Hughes 2017-04-12 14:09:04 +01:00
parent 8b90f3543a
commit e643fb283f
3 changed files with 9 additions and 6 deletions

View File

@ -162,9 +162,6 @@ make check VERBOSE=1
%dir %{_localstatedir}/lib/fwupd
%{_libdir}/libfwupd*.so.*
%{_libdir}/girepository-1.0/Fwupd-1.0.typelib
%dir %{_localstatedir}/cache/app-info
%dir %{_localstatedir}/cache/app-info/icons
%dir %{_localstatedir}/cache/app-info/xmls
/usr/lib/udev/rules.d/*.rules
%dir %{_libdir}/fwupd-plugins-2
%{_libdir}/fwupd-plugins-2/libfu_plugin_altos.so

View File

@ -164,8 +164,6 @@ install-data-hook:
if test -w $$(dirname $(DESTDIR)$(localstatedir)/); then \
mkdir -p $(DESTDIR)$(localstatedir)/lib/fwupd; \
chmod 0755 $(DESTDIR)$(localstatedir)/lib/fwupd; \
mkdir -p $(DESTDIR)$(localstatedir)/cache/app-info/xmls; \
mkdir -p $(DESTDIR)$(localstatedir)/cache/app-info/icons; \
fi
BUILT_SOURCES = \

View File

@ -1266,6 +1266,7 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
g_autoptr(FuKeyring) kr = NULL;
g_autoptr(GConverter) converter = NULL;
g_autoptr(GFile) file = NULL;
g_autoptr(GFile) file_parent = NULL;
g_autoptr(GInputStream) stream_buf = NULL;
g_autoptr(GInputStream) stream_fd = NULL;
g_autoptr(GInputStream) stream = NULL;
@ -1335,9 +1336,16 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
as_store_add_app (priv->store, app);
}
/* ensure directory exists */
file = g_file_new_for_path ("/var/cache/app-info/xmls/fwupd.xml");
file_parent = g_file_get_parent (file);
if (!g_file_query_exists (file_parent, NULL)) {
if (!g_file_make_directory_with_parents (file_parent, NULL, error))
return FALSE;
}
/* save the new file */
as_store_set_api_version (priv->store, 0.9);
file = g_file_new_for_path ("/var/cache/app-info/xmls/fwupd.xml");
if (!as_store_to_file (priv->store, file,
AS_NODE_TO_XML_FLAG_ADD_HEADER |
AS_NODE_TO_XML_FLAG_FORMAT_MULTILINE |