--- /dev/null
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-misc/colord/colord-1.2.11.ebuild,v 1.1 2015/07/05 08:43:40 pacho Exp $
+
+EAPI="5"
+GCONF_DEBUG="no"
+GNOME2_LA_PUNT="yes"
+VALA_USE_DEPEND="vapigen"
+
+inherit autotools bash-completion-r1 check-reqs eutils gnome2 user systemd udev vala multilib-minimal
+
+DESCRIPTION="System service to accurately color manage input and output devices"
+HOMEPAGE="http://www.freedesktop.org/software/colord/"
+SRC_URI="http://www.freedesktop.org/software/colord/releases/${P}.tar.xz"
+
+LICENSE="GPL-2+"
+SLOT="0/2" # subslot = libcolord soname version
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
+
+# We prefer policykit enabled by default, bug #448058
+IUSE="argyllcms examples extra-print-profiles +gusb +introspection +policykit scanner systemd +udev vala"
+REQUIRED_USE="
+ gusb? ( udev )
+ scanner? ( udev )
+ vala? ( introspection )
+"
+
+COMMON_DEPEND="
+ dev-db/sqlite:3=
+ >=dev-libs/glib-2.36:2[${MULTILIB_USEDEP}]
+ >=media-libs/lcms-2.6:2=[${MULTILIB_USEDEP}]
+ argyllcms? ( media-gfx/argyllcms )
+ gusb? ( >=dev-libs/libgusb-0.2.2[introspection?,${MULTILIB_USEDEP}] )
+ introspection? ( >=dev-libs/gobject-introspection-0.9.8:= )
+ policykit? ( >=sys-auth/polkit-0.103 )
+ scanner? (
+ media-gfx/sane-backends
+ sys-apps/dbus )
+ systemd? ( >=sys-apps/systemd-44:0= )
+ udev? (
+ virtual/udev
+ virtual/libgudev:=
+ virtual/libudev:=[${MULTILIB_USEDEP}]
+ )
+"
+RDEPEND="${COMMON_DEPEND}
+ !media-gfx/shared-color-profiles
+ !<=media-gfx/colorhug-client-0.1.13
+"
+DEPEND="${COMMON_DEPEND}
+ dev-libs/libxslt
+ >=dev-util/gtk-doc-am-1.9
+ >=dev-util/intltool-0.35
+ >=sys-devel/gettext-0.17
+ virtual/pkgconfig[${MULTILIB_USEDEP}]
+ extra-print-profiles? ( media-gfx/argyllcms )
+ vala? ( $(vala_depend) )
+"
+
+# FIXME: needs pre-installed dbus service files
+RESTRICT="test"
+
+# According to upstream comment in colord.spec.in, building the extra print
+# profiles requires >=4G of memory
+CHECKREQS_MEMORY="4G"
+
+pkg_pretend() {
+ use extra-print-profiles && check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+ use extra-print-profiles && check-reqs_pkg_setup
+ enewgroup colord
+ enewuser colord -1 -1 /var/lib/colord colord
+}
+
+src_prepare() {
+ # Adapt to Gentoo paths
+ sed -i -e 's/spotread/argyll-spotread/' \
+ src/sensors/cd-sensor-argyll.c \
+ configure.ac || die
+
+ epatch "${FILESDIR}"/${P}-multiple-users.patch
+
+ eautoreconf
+ use vala && vala_src_prepare
+ gnome2_src_prepare
+}
+
+multilib_src_configure() {
+ # Reverse tools require gusb
+ # bash-completion test does not work on gentoo
+ local myconf=(
+ --disable-bash-completion
+ --disable-examples
+ --disable-static
+ --enable-libcolordcompat
+ --with-daemon-user=colord
+ --localstatedir="${EPREFIX}"/var
+ $(multilib_native_use_enable argyllcms argyllcms-sensor)
+ $(multilib_native_use_enable extra-print-profiles print-profiles)
+ $(multilib_native_usex extra-print-profiles COLPROF="$(type -P argyll-colprof)" "")
+ $(use_enable gusb)
+ $(multilib_native_use_enable gusb reverse)
+ $(multilib_native_use_enable introspection)
+ $(multilib_native_use_enable policykit polkit)
+ $(multilib_native_use_enable scanner sane)
+ $(multilib_native_use_enable systemd systemd-login)
+ $(use_enable udev)
+ --with-udevrulesdir="$(get_udevdir)"/rules.d
+ $(multilib_native_use_enable vala)
+ "$(systemd_with_unitdir)"
+ )
+
+ if ! multilib_is_native_abi; then
+ # disable some extraneous checks
+ myconf+=(
+ SQLITE_{CFLAGS,LIBS}=' '
+ GUDEV_{CFLAGS,LIBS}=' '
+ )
+ fi
+
+ ECONF_SOURCE=${S} \
+ gnome2_src_configure "${myconf[@]}"
+}
+
+multilib_src_compile() {
+ if multilib_is_native_abi; then
+ gnome2_src_compile
+ else
+ emake -C lib/colord
+ use gusb && emake -C lib/colorhug
+ emake -C lib/compat
+ fi
+}
+
+multilib_src_test() {
+ if multilib_is_native_abi; then
+ default
+ else
+ emake -C lib/colord check
+ use gusb && emake -C lib/colorhug check
+ emake -C lib/compat check
+ fi
+}
+
+multilib_src_install() {
+ if multilib_is_native_abi; then
+ gnome2_src_install
+ else
+ gnome2_src_install -C lib/colord
+ use gusb && gnome2_src_install -C lib/colorhug
+ gnome2_src_install -C lib/compat
+ gnome2_src_install -C contrib/session-helper install-libcolord_includeHEADERS
+ fi
+}
+
+multilib_src_install_all() {
+ DOCS="AUTHORS ChangeLog MAINTAINERS NEWS README.md TODO"
+ einstalldocs
+
+ newbashcomp data/colormgr colormgr
+
+ # Ensure config and profile directories exist and /var/lib/colord/*
+ # is writable by colord user
+ keepdir /var/lib/color{,d}/icc
+ fowners colord:colord /var/lib/colord{,/icc}
+
+ if use examples; then
+ docinto examples
+ dodoc examples/*.c
+ fi
+}
--- /dev/null
+From eeac836f256fe07004d67e13c3c89532982af9bd Mon Sep 17 00:00:00 2001
+From: Richard Hughes <richard@hughsie.com>
+Date: Mon, 20 Jul 2015 10:57:28 +0100
+Subject: [PATCH] Allow creating devices with the same device ID from different
+ users
+
+---
+ src/cd-device-array.c | 13 ++++++++-----
+ src/cd-device-array.h | 9 ++++++++-
+ src/cd-main.c | 15 ++++++++++-----
+ src/cd-self-test.c | 7 +++++--
+ 4 files changed, 31 insertions(+), 13 deletions(-)
+
+diff --git a/src/cd-device-array.c b/src/cd-device-array.c
+index 88d4b2c..41a9597 100644
+--- a/src/cd-device-array.c
++++ b/src/cd-device-array.c
+@@ -76,7 +76,8 @@ cd_device_array_remove (CdDeviceArray *device_array, CdDevice *device)
+ CdDevice *
+ cd_device_array_get_by_id_owner (CdDeviceArray *device_array,
+ const gchar *id,
+- guint owner)
++ guint owner,
++ CdDeviceArrayFlags flags)
+ {
+ CdDeviceArrayPrivate *priv = device_array->priv;
+ CdDevice *device_tmp;
+@@ -90,10 +91,12 @@ cd_device_array_get_by_id_owner (CdDeviceArray *device_array,
+ if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
+ return g_object_ref (device_tmp);
+ }
+- for (i = 0; i < priv->array->len; i++) {
+- device_tmp = g_ptr_array_index (priv->array, i);
+- if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
+- return g_object_ref (device_tmp);
++ if (flags & CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL) {
++ for (i = 0; i < priv->array->len; i++) {
++ device_tmp = g_ptr_array_index (priv->array, i);
++ if (g_strcmp0 (cd_device_get_id (device_tmp), id) == 0)
++ return g_object_ref (device_tmp);
++ }
+ }
+ return NULL;
+ }
+diff --git a/src/cd-device-array.h b/src/cd-device-array.h
+index b625dbf..31dc067 100644
+--- a/src/cd-device-array.h
++++ b/src/cd-device-array.h
+@@ -50,6 +50,12 @@ struct _CdDeviceArrayClass
+ GObjectClass parent_class;
+ };
+
++typedef enum {
++ CD_DEVICE_ARRAY_FLAG_NONE = 0,
++ CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL = 1,
++ CD_DEVICE_ARRAY_FLAG_LAST,
++} CdDeviceArrayFlags;
++
+ GType cd_device_array_get_type (void);
+ CdDeviceArray *cd_device_array_new (void);
+
+@@ -59,7 +65,8 @@ void cd_device_array_remove (CdDeviceArray *device_array,
+ CdDevice *device);
+ CdDevice *cd_device_array_get_by_id_owner (CdDeviceArray *device_array,
+ const gchar *id,
+- guint owner);
++ guint owner,
++ CdDeviceArrayFlags flags);
+ CdDevice *cd_device_array_get_by_object_path (CdDeviceArray *device_array,
+ const gchar *object_path);
+ CdDevice *cd_device_array_get_by_property (CdDeviceArray *device_array,
+diff --git a/src/cd-main.c b/src/cd-main.c
+index b5b3a4f..37817e3 100644
+--- a/src/cd-main.c
++++ b/src/cd-main.c
+@@ -720,7 +720,8 @@ cd_main_profile_auto_add_from_db (CdMainPrivate *priv,
+ device_id_tmp = g_ptr_array_index (array, i);
+ device_tmp = cd_device_array_get_by_id_owner (priv->devices_array,
+ device_id_tmp,
+- cd_profile_get_owner (profile));
++ cd_profile_get_owner (profile),
++ CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ if (device_tmp == NULL)
+ continue;
+
+@@ -747,7 +748,8 @@ cd_main_profile_auto_add_from_md (CdMainPrivate *priv,
+ return;
+ device = cd_device_array_get_by_id_owner (priv->devices_array,
+ device_id,
+- cd_profile_get_owner (profile));
++ cd_profile_get_owner (profile),
++ CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ if (device == NULL)
+ return;
+ cd_main_auto_add_from_md (priv, device, profile);
+@@ -1022,7 +1024,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
+ sender, device_id);
+ device = cd_device_array_get_by_id_owner (priv->devices_array,
+ device_id,
+- uid);
++ uid,
++ CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ if (device == NULL) {
+ g_dbus_method_invocation_return_error (invocation,
+ CD_CLIENT_ERROR,
+@@ -1279,7 +1282,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
+ }
+ device = cd_device_array_get_by_id_owner (priv->devices_array,
+ device_id,
+- uid);
++ uid,
++ CD_DEVICE_ARRAY_FLAG_NONE);
+ if (device != NULL) {
+ /* where we try to manually add an existing
+ * virtual device, which means promoting it to
+@@ -1399,7 +1403,8 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
+ sender, device_id);
+ device = cd_device_array_get_by_id_owner (priv->devices_array,
+ device_id,
+- uid);
++ uid,
++ CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ if (device == NULL) {
+ /* fall back to checking the object path */
+ device = cd_device_array_get_by_object_path (priv->devices_array,
+diff --git a/src/cd-self-test.c b/src/cd-self-test.c
+index 4a76d07..6536d3c 100644
+--- a/src/cd-self-test.c
++++ b/src/cd-self-test.c
+@@ -178,10 +178,13 @@ colord_device_array_func (void)
+ cd_device_array_add (device_array, device);
+ g_object_unref (device);
+
+- device = cd_device_array_get_by_id_owner (device_array, "does not exist", 0);
++ device = cd_device_array_get_by_id_owner (device_array, "does not exist", 0, CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ g_assert (device == NULL);
+
+- device = cd_device_array_get_by_id_owner (device_array, "dave", 0);
++ device = cd_device_array_get_by_id_owner (device_array, "dave", 999, CD_DEVICE_ARRAY_FLAG_NONE);
++ g_assert (device == NULL);
++
++ device = cd_device_array_get_by_id_owner (device_array, "dave", 0, CD_DEVICE_ARRAY_FLAG_OWNER_OPTIONAL);
+ g_assert (device != NULL);
+ g_assert_cmpstr (cd_device_get_id (device), ==, "dave");
+ g_object_unref (device);
+--
+2.4.3
+