* [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime
@ 2015-06-10 14:12 Gilles Dartiguelongue
2015-06-10 15:04 ` Mike Gilbert
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-10 14:12 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 1336 bytes --]
This is an attempt to fix bug #208047 [1] and bug #444568 [2]
Current fdo-mime eclass is often not used when it should be. I suppose
this is partly because one has to think too much about whether it is
needed or not and what to do with the functions.
The proposed solution is to not have to worry about it and just inherit
it when you have any kind of XDG specifications support and let the
exported phases do their job in a similar fashion to the gnome
eclasses.
For now, this covers .desktop and shared mime-info files and creating
base directory for packages that rely on it one way or another.
This helps solve problems like bug #545128 [3] and others that have
been covered by previous work resulting in gnome2_environment_reset
function and similar in other eclasses (cmake-utils, gstreamer, kde4
-base, mono, mono-env, qt4-*).
[1] [Bug 208047] fdo-mime.eclass should depend on desktop-file-utils
https://bugs.gentoo.org/show_bug.cgi?id=208047
[2] [Bug 444568] [Future EAPI] Export XDG_* variables in ebuild
environment
https://bugs.gentoo.org/show_bug.cgi?id=444568
[3] [Bug 545128] media-sound/pulseaudio-6.0 XDG_RUNTIME_DIR
(/run/user/1000) is not owned by us (uid 0)
https://bugs.gentoo.org/show_bug.cgi?id=545128
--
Gilles Dartiguelongue <eva@gentoo.org>
Gentoo
[-- Attachment #1.2: xdg.eclass --]
[-- Type: text/plain, Size: 1787 bytes --]
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: xdg.eclass
# @MAINTAINER:
# freedesktop-bugs@gentoo.org
# @AUTHOR:
# Original author: Gilles Dartiguelongue <eva@gentoo.org>
# @BLURB: Provides phases for XDG compliant packages.
# @DESCRIPTION:
# Utility eclass to update the desktop and shared mime info as laid
# out in the freedesktop specs & implementations
inherit xdg-utils
case "${EAPI:-0}" in
4|5)
EXPORT_FUNCTIONS src_prepare pkg_preinst pkg_postinst pkg_postrm
;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
DEPEND="
dev-util/desktop-file-utils
x11-misc/shared-mime-info
"
# @FUNCTION: xdg_src_prepare
# @DESCRIPTION:
# Prepare sources to work with XDG standards.
xdg_src_prepare() {
# Prepare XDG base directories
export XDG_DATA_HOME="${T}/.local/share"
export XDG_CONFIG_HOME="${T}/.config"
export XDG_CACHE_HOME="${T}/.cache"
export XDG_RUNTIME_DIR="${T}/run"
mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" \
"${XDG_RUNTIME_DIR}"
# This directory needs to be owned by the user, and chmod 0700
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
chmod 0700 "${XDG_RUNTIME_DIR}"
}
# @FUNCTION: xdg_pkg_preinst
# @DESCRIPTION:
# Finds .desktop and mime info files for later handling in pkg_postinst
xdg_pkg_preinst() {
xdg_desktopfiles_savelist
xdg_mimeinfo_savelist
}
# @FUNCTION: xdg_pkg_postinst
# @DESCRIPTION:
# Handle desktop and mime info database updates.
xdg_pkg_postinst() {
xdg_desktop_database_update
xdg_mimeinfo_database_update
}
# @FUNCTION: xdg_pkg_postrm
# @DESCRIPTION:
# Handle desktop and mime info database updates.
xdg_pkg_postrm() {
xdg_desktop_database_update
xdg_mimeinfo_database_update
}
[-- Attachment #1.3: xdg-utils.eclass --]
[-- Type: text/plain, Size: 3283 bytes --]
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: xdg-utils.eclass
# @MAINTAINER:
# gnome@gentoo.org
# @AUTHOR:
# Original author: Gilles Dartiguelongue <eva@gentoo.org>
# @BLURB: Auxiliary functions commonly used by XDG compliant packages.
# @DESCRIPTION:
# This eclass provides a set of auxiliary functions needed by most XDG
# compliant packages.
# It provides XDG stack related functions such as:
# * XDG .desktop files cache management
# * XDG mime information database management
case "${EAPI:-0}" in
4|5) ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
# @ECLASS-VARIABLE: DESKTOP_DATABASE_UPDATE_BIN
# @INTERNAL
# @DESCRIPTION:
# Path to update-desktop-database
: ${DESKTOP_DATABASE_UPDATE_BIN:="/usr/bin/update-desktop-database"}
# @ECLASS-VARIABLE: DESKTOP_DATABASE_DIR
# @INTERNAL
# @DESCRIPTION:
# Directory where .desktop files database is stored
: ${DESKTOP_DATABASE_DIR="/usr/share/applications"}
# @ECLASS-VARIABLE: MIMEINFO_DATABASE_UPDATE_BIN
# @INTERNAL
# @DESCRIPTION:
# Path to update-desktop-database
: ${MIMEINFO_DATABASE_UPDATE_BIN:="/usr/bin/update-mime-database"}
# @ECLASS-VARIABLE: MIMEINFO_DATABASE_DIR
# @INTERNAL
# @DESCRIPTION:
# Directory where .desktop files database is stored
: ${MIMEINFO_DATABASE_DIR:="/usr/share/mime"}
# @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
export XDG_ECLASS_DESKTOPFILES=$(find 'usr/share/applications' -type f 2> /dev/null)
popd &> /dev/null
}
# @FUNCTION: fdo-xdg_desktop_database_update
# @DESCRIPTION:
# Updates the .desktop files database.
# Generates a list of mimetypes linked to applications that can handle them
xdg_desktop_database_update() {
local updater="${EROOT}${DESKTOP_DATABASE_UPDATE_BIN}"
if [[ ! -x "${updater}" ]] ; then
debug-print "${updater} is not executable"
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
export XDG_ECLASS_MIMEINFOFILES=$(find 'usr/share/mime' -type f 2> /dev/null)
popd &> /dev/null
}
# @FUNCTION: xdg_mimeinfo_database_update
# @DESCRIPTION:
# Update the mime database.
# Creates a general list of mime types from several sources
xdg_mimeinfo_database_update() {
local updater="${EROOT}${MIMEINFO_DATABASE_UPDATE_BIN}"
if [[ ! -x "${updater}" ]] ; then
debug-print "${updater} is not executable"
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 $?
}
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime
2015-06-10 14:12 [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime Gilles Dartiguelongue
@ 2015-06-10 15:04 ` Mike Gilbert
2015-06-10 15:40 ` Gilles Dartiguelongue
0 siblings, 1 reply; 4+ messages in thread
From: Mike Gilbert @ 2015-06-10 15:04 UTC (permalink / raw
To: Gentoo Dev
On Wed, Jun 10, 2015 at 10:12 AM, Gilles Dartiguelongue <eva@gentoo.org> wrote:
> This is an attempt to fix bug #208047 [1] and bug #444568 [2]
>
> Current fdo-mime eclass is often not used when it should be. I suppose
> this is partly because one has to think too much about whether it is
> needed or not and what to do with the functions.
>
> The proposed solution is to not have to worry about it and just inherit
> it when you have any kind of XDG specifications support and let the
> exported phases do their job in a similar fashion to the gnome
> eclasses.
>
> For now, this covers .desktop and shared mime-info files and creating
> base directory for packages that rely on it one way or another.
>
> This helps solve problems like bug #545128 [3] and others that have
> been covered by previous work resulting in gnome2_environment_reset
> function and similar in other eclasses (cmake-utils, gstreamer, kde4
> -base, mono, mono-env, qt4-*).
> xdg_desktopfiles_savelist() {
> pushd "${D}" &> /dev/null
> export XDG_ECLASS_DESKTOPFILES=$(find 'usr/share/applications' -type f 2> /dev/null)
> popd &> /dev/null
> }
Why are you sending stderr from pushd/popd to /dev/null? If they fail,
we want to see that in the log. As well, they should probably die, or
at least return from the function with a non-zero status.
This may also need some adjusting to work on prefix, but I will leave
that for someone else to figure out.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime
2015-06-10 15:04 ` Mike Gilbert
@ 2015-06-10 15:40 ` Gilles Dartiguelongue
2015-11-25 8:08 ` Gilles Dartiguelongue
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-10 15:40 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]
Le mercredi 10 juin 2015 à 11:04 -0400, Mike Gilbert a écrit :
> On Wed, Jun 10, 2015 at 10:12 AM, Gilles Dartiguelongue <
> eva@gentoo.org> wrote:
> > This is an attempt to fix bug #208047 [1] and bug #444568 [2]
> >
> > Current fdo-mime eclass is often not used when it should be. I
> > suppose
> > this is partly because one has to think too much about whether it
> > is
> > needed or not and what to do with the functions.
> >
> > The proposed solution is to not have to worry about it and just
> > inherit
> > it when you have any kind of XDG specifications support and let the
> > exported phases do their job in a similar fashion to the gnome
> > eclasses.
> >
> > For now, this covers .desktop and shared mime-info files and
> > creating
> > base directory for packages that rely on it one way or another.
> >
> > This helps solve problems like bug #545128 [3] and others that have
> > been covered by previous work resulting in gnome2_environment_reset
> > function and similar in other eclasses (cmake-utils, gstreamer,
> > kde4
> > -base, mono, mono-env, qt4-*).
>
> > xdg_desktopfiles_savelist() {
> > pushd "${D}" &> /dev/null
> > export XDG_ECLASS_DESKTOPFILES=$(find 'usr/share/applications'
> > -type f 2> /dev/null)
> > popd &> /dev/null
> > }
>
> Why are you sending stderr from pushd/popd to /dev/null? If they
> fail,
> we want to see that in the log. As well, they should probably die, or
> at least return from the function with a non-zero status.
>
> This may also need some adjusting to work on prefix, but I will leave
> that for someone else to figure out.
This is blind copy-paste from gnome2-utils functions, I will clean that
out.
>
--
Gilles Dartiguelongue <eva@gentoo.org>
Gentoo
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime
2015-06-10 15:40 ` Gilles Dartiguelongue
@ 2015-11-25 8:08 ` Gilles Dartiguelongue
0 siblings, 0 replies; 4+ messages in thread
From: Gilles Dartiguelongue @ 2015-11-25 8:08 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
Hello all,
just a heads up that these eclass were slightly enhanced and pushed to
the tree. gnome2.eclass and gstreamer.eclass are now using it. If you
need to do any kind of hackery with XDG_* environment variable or are
using fdo-mime.eclass, you might want to update to xdg*.eclass.
--
Gilles Dartiguelongue <eva@gentoo.org>
Gentoo
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-25 8:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-10 14:12 [gentoo-dev] new eclass: xdg and xdg-utils as a replacement for fdo-mime Gilles Dartiguelongue
2015-06-10 15:04 ` Mike Gilbert
2015-06-10 15:40 ` Gilles Dartiguelongue
2015-11-25 8:08 ` Gilles Dartiguelongue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox