commit:     0913bfc8d9650ad4eb542ec9a1a30736013224f2
Author:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 24 17:42:27 2015 +0000
Commit:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Tue Nov 24 18:49:37 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0913bfc8

xdg*.eclass: move phase related logic to xdg.eclass

 eclass/xdg-utils.eclass | 32 --------------------------------
 eclass/xdg.eclass       | 34 +++++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass
index d140283..3dc9e8e 100644
--- a/eclass/xdg-utils.eclass
+++ b/eclass/xdg-utils.eclass
@@ -62,17 +62,6 @@ xdg_environment_reset() {
        unset DBUS_SESSION_BUS_ADDRESS
 }
 
-# @FUNCTION: xdg_desktopfiles_savelist
-# @DESCRIPTION:
-# Find the .desktop files about to be installed and save their location
-# in the XDG_ECLASS_DESKTOPFILES environment variable.
-# This function should be called from pkg_preinst.
-xdg_desktopfiles_savelist() {
-       pushd "${D}" > /dev/null || die
-       export XDG_ECLASS_DESKTOPFILES=$(find 'usr/share/applications' -type f 
2> /dev/null)
-       popd > /dev/null || die
-}
-
 # @FUNCTION: fdo-xdg_desktop_database_update
 # @DESCRIPTION:
 # Updates the .desktop files database.
@@ -85,27 +74,11 @@ xdg_desktop_database_update() {
                return
        fi
 
-       if [[ -z "${XDG_ECLASS_DESKTOPFILES}" ]]; then
-               debug-print "No .desktop files to add to database"
-               return
-       fi
-
        ebegin "Updating .desktop files database ..."
        "${updater}" -q "${EROOT}${DESKTOP_DATABASE_DIR}"
        eend $?
 }
 
-# @FUNCTION: xdg_mimeinfo_savelist
-# @DESCRIPTION:
-# Find the mime information files about to be installed and save their location
-# in the XDG_ECLASS_MIMEINFOFILES environment variable.
-# This function should be called from pkg_preinst.
-xdg_mimeinfo_savelist() {
-       pushd "${D}" > /dev/null || die
-       export XDG_ECLASS_MIMEINFOFILES=$(find 'usr/share/mime' -type f 2> 
/dev/null)
-       popd > /dev/null || die
-}
-
 # @FUNCTION: xdg_mimeinfo_database_update
 # @DESCRIPTION:
 # Update the mime database.
@@ -118,11 +91,6 @@ xdg_mimeinfo_database_update() {
                return
        fi
 
-       if [[ -z "${XDG_ECLASS_MIMEINFOFILES}" ]]; then
-               debug-print "No mime info files to add to database"
-               return
-       fi
-
        ebegin "Updating shared mime info database ..."
        "${updater}" "${EROOT}${MIMEINFO_DATABASE_DIR}"
        eend $?

diff --git a/eclass/xdg.eclass b/eclass/xdg.eclass
index 799d6a2..1813858 100644
--- a/eclass/xdg.eclass
+++ b/eclass/xdg.eclass
@@ -37,25 +37,45 @@ xdg_src_prepare() {
 
 # @FUNCTION: xdg_pkg_preinst
 # @DESCRIPTION:
-# Finds .desktop and mime info files for later handling in pkg_postinst
+# Finds .desktop and mime info files for later handling in pkg_postinst.
+# Locations are stored in XDG_ECLASS_DESKTOPFILES and XDG_ECLASS_MIMEINFOFILES
+# respectively.
 xdg_pkg_preinst() {
-       xdg_desktopfiles_savelist
-       xdg_mimeinfo_savelist
+       export XDG_ECLASS_DESKTOPFILES=( $(cd "${D}" && find 
'usr/share/applications' -type f -print0 2> /dev/null) )
+       export XDG_ECLASS_MIMEINFOFILES=( $(cd "${D}" && find 'usr/share/mime' 
-type f -print0 2> /dev/null) )
 }
 
 # @FUNCTION: xdg_pkg_postinst
 # @DESCRIPTION:
 # Handle desktop and mime info database updates.
 xdg_pkg_postinst() {
-       xdg_desktop_database_update
-       xdg_mimeinfo_database_update
+       if [[ -n "${XDG_ECLASS_DESKTOPFILES}" ]]; then
+               xdg_desktop_database_update
+       else
+               debug-print "No .desktop files to add to database"
+       fi
+
+       if [[ -n "${XDG_ECLASS_MIMEINFOFILES}" ]]; then
+               xdg_mimeinfo_database_update
+       else
+               debug-print "No mime info files to add to database"
+       fi
 }
 
 # @FUNCTION: xdg_pkg_postrm
 # @DESCRIPTION:
 # Handle desktop and mime info database updates.
 xdg_pkg_postrm() {
-       xdg_desktop_database_update
-       xdg_mimeinfo_database_update
+       if [[ -n "${XDG_ECLASS_DESKTOPFILES}" ]]; then
+               xdg_desktop_database_update
+       else
+               debug-print "No .desktop files to add to database"
+       fi
+
+       if [[ -n "${XDG_ECLASS_MIMEINFOFILES}" ]]; then
+               xdg_mimeinfo_database_update
+       else
+               debug-print "No mime info files to add to database"
+       fi
 }
 

Reply via email to