diff --git a/macros.shared-mime-info b/macros.shared-mime-info new file mode 100644 index 0000000..a0d0c45 --- /dev/null +++ b/macros.shared-mime-info @@ -0,0 +1,40 @@ +# RPM macros for packages installing a MIME type according to the XDG specification +# +### +# +# When a package installs a MIME type as per the XDG specification, it should +# use both macros: +# +# - %mime_database_post in %post +# - %mime_database_postun in %postun +# +# Note that these macros can optionally take as argument the directory +# where the MIME type is installed. If no argument is passed, then +# %{_datadir}/mime will be used (which is where applications usually install +# the MIME type information). +# +### + +# On install, update the mime database +%mime_database_post() \ +if test -x %{_bindir}/update-mime-database; then \ +%if "x%1" != "x%%1" \ + %{_bindir}/update-mime-database "%1" || true \ +%else \ + %{_bindir}/update-mime-database "%{_datadir}/mime" || true \ +%endif \ +fi + +# On uninstall, update the mime database. Note: we ignore upgrades (already +# handled in %post of the new package). +%mime_database_postun() \ +if [ $1 -eq 0 ]; then \ + if test -x %{_bindir}/update-mime-database; then \ + %{_bindir}/update-mime-database "${MIME_DIR}" || true \ +%if "x%1" != "x%%1" \ + %{_bindir}/update-mime-database "%1" || true \ +%else \ + %{_bindir}/update-mime-database "%{_datadir}/mime" || true \ +%endif \ + fi \ +fi diff --git a/shared-mime-info.changes b/shared-mime-info.changes index f8457af..72dbe76 100644 --- a/shared-mime-info.changes +++ b/shared-mime-info.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Oct 7 14:09:38 CEST 2010 - vuntz@opensuse.org + +- Add rpm macros to update the mime database: %mime_database_post + and %mime_database_postun. +- Update %post to never fail, and to not redirect the output to + /dev/null: if there is output, then it's important. + ------------------------------------------------------------------- Fri Oct 1 19:40:56 CEST 2010 - vuntz@opensuse.org diff --git a/shared-mime-info.spec b/shared-mime-info.spec index a80bba2..fe28ce6 100644 --- a/shared-mime-info.spec +++ b/shared-mime-info.spec @@ -31,6 +31,7 @@ License: GPLv2+ Summary: Shared MIME Database Source: %{name}-%{version}.tar.bz2 Source1: mime-info-to-mime +Source2: macros.shared-mime-info # needed by mime-info-to-mime: Requires: /bin/rm /bin/mkdir /usr/bin/fgrep # needed by update-mime-database @@ -59,12 +60,14 @@ translation-update-upstream %makeinstall install %{S:1} $RPM_BUILD_ROOT%{_bindir}/ %find_lang %{name} +# Install rpm macros +install -D -m644 %{S:2} %{buildroot}%{_sysconfdir}/rpm/macros.shared-mime-info %clean rm -rf $RPM_BUILD_ROOT %post -usr/bin/update-mime-database usr/share/mime >/dev/null +%{_bindir}/update-mime-database %{_datadir}/mime || true %files -f %{name}.lang %defattr (-, root, root) @@ -74,5 +77,6 @@ usr/bin/update-mime-database usr/share/mime >/dev/null %{_datadir}/pkgconfig/*.pc %ghost %{_datadir}/mime/[a-ms-vxX]* %{_mandir}/man?/*.* +%{_sysconfdir}/rpm/macros.shared-mime-info %changelog