[virt-tools-list] [virt-viewer] Update shared mime database on install/uninstall

Christophe Fergeau cfergeau at redhat.com
Wed Dec 18 10:16:54 UTC 2013


remomte-viewer installs a file to $datadir/share/mime to register a
mime-type for its .vv files. However, after installing this file,
update-mime-database must be run in order to update the shared mime
database. This commit (inspired by what Nautilus/planner are doing) adds
what is needed for that.
If the mime type is not correctly registered, gvfs-info console.vv will not
return the correct mime type, and xdg-open console.vv will fail to start
remote-viewer, and will fall back to running gedit as the .vv file is a
text file.

https://bugzilla.redhat.com/show_bug.cgi?id=1044209
---
 configure.ac        | 10 ++++++++++
 data/Makefile.am    | 12 ++++++++++++
 virt-viewer.spec.in |  4 +++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index bb0b591..03a3273 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,6 +216,16 @@ build=`expr $micro \* 256 + $buildid`
 WINDOWS_PRODUCTVERSION="$major.$minor.$build"
 AC_SUBST([WINDOWS_PRODUCTVERSION])
 
+
+AC_PATH_PROG(UPDATE_MIME_DATABASE, update-mime-database, no)
+
+AC_ARG_ENABLE(update-mimedb,
+   AS_HELP_STRING([--disable-update-mimedb],
+                   [disable the update-mime-database after install [default=no]]),,
+    enable_update_mimedb=yes)
+AM_CONDITIONAL(ENABLE_UPDATE_MIMEDB, test x$enable_update_mimedb = xyes)
+
+
 AC_CONFIG_FILES([
     Makefile
     data/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index a43374e..086efca 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -63,6 +63,18 @@ mimedir = $(datadir)/mime/packages
 mime_DATA = virt-viewer-mime.xml
 @INTLTOOL_XML_RULE@
 
+install-data-hook:
+if ENABLE_UPDATE_MIMEDB
+	@if $(AM_V_P); then set -x; else echo "  INSTALL  update-mime-database"; fi; \
+	$(UPDATE_MIME_DATABASE) "$(DESTDIR)$(datadir)/mime";
+endif
+
+uninstall-hook:
+if ENABLE_UPDATE_MIMEDB
+	@if $(AM_V_P); then set -x; else echo "  UNINSTALL update-mime-database"; fi; \
+	$(UPDATE_MIME_DATABASE) "$(DESTDIR)$(datadir)/mime";
+endif
+
 CLEANFILES += $(mime_DATA) $(desktop_DATA)
 EXTRA_DIST += $(MIMEFILES) $(DESKTOPFILES)
 
diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
index 56c1c4b..c9871d1 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -109,7 +109,7 @@ autoreconf -if
 %define govirt_arg --with-ovirt
 %endif
 
-%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=-%{release}
+%configure %{spice_arg} %{gtk_arg} %{govirt_arg} --with-buildid=-%{release} --disable-update-mimedb
 %__make %{?_smp_mflags}
 
 
@@ -129,6 +129,7 @@ rm -rf $RPM_BUILD_ROOT
 %{_sbindir}/update-alternatives --install %{_libexecdir}/spice-xpi-client \
   spice-xpi-client %{_libexecdir}/spice-xpi-client-remote-viewer 25
 update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %postun
 if [ $1 -eq 0 ] ; then
@@ -137,6 +138,7 @@ if [ $1 -eq 0 ] ; then
   %{_sbindir}/update-alternatives --remove spice-xpi-client %{_libexecdir}/spice-xpi-client-remote-viewer
 fi
 update-desktop-database -q %{_datadir}/applications
+%{_bindir}/update-mime-database %{_datadir}/mime &> /dev/null
 
 %posttrans
 /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-- 
1.8.4.2




More information about the virt-tools-list mailing list