x11-misc/colord: fix modern c issue (32-bit ptr truncation)

Closes: https://bugs.gentoo.org/918990
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2023-12-02 05:13:36 +00:00
parent 3c99277497
commit 17ee1596c7
3 changed files with 202 additions and 0 deletions
+129
View File
@@ -0,0 +1,129 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
VALA_USE_DEPEND="vapigen"
inherit bash-completion-r1 meson-multilib tmpfiles udev vala
DESCRIPTION="System service to accurately color manage input and output devices"
HOMEPAGE="https://www.freedesktop.org/software/colord/"
SRC_URI="https://www.freedesktop.org/software/colord/releases/${P}.tar.xz"
LICENSE="GPL-2+"
SLOT="0/2" # subslot = libcolord soname version
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
IUSE="gtk-doc argyllcms examples extra-print-profiles +introspection scanner selinux systemd test vala"
RESTRICT="!test? ( test ) test" # Tests try to read and write files in /tmp
REQUIRED_USE="vala? ( introspection )"
DEPEND="
>=dev-libs/glib-2.58.0:2[${MULTILIB_USEDEP}]
>=media-libs/lcms-2.6:2=[${MULTILIB_USEDEP}]
dev-db/sqlite:3=[${MULTILIB_USEDEP}]
>=dev-libs/libgusb-0.2.7[introspection?,${MULTILIB_USEDEP}]
dev-libs/libgudev:=[${MULTILIB_USEDEP}]
virtual/libudev:=[${MULTILIB_USEDEP}]
virtual/udev
systemd? ( >=sys-apps/systemd-44:0= )
scanner? (
media-gfx/sane-backends
sys-apps/dbus
)
>=sys-auth/polkit-0.114
argyllcms? ( media-gfx/argyllcms )
introspection? ( >=dev-libs/gobject-introspection-1.56:= )
"
RDEPEND="${DEPEND}
acct-group/colord
acct-user/colord
selinux? ( sec-policy/selinux-colord )
"
BDEPEND="
acct-group/colord
acct-user/colord
app-text/docbook-xsl-ns-stylesheets
dev-libs/libxslt
>=sys-devel/gettext-0.17
virtual/pkgconfig
extra-print-profiles? ( media-gfx/argyllcms )
gtk-doc? (
dev-util/gtk-doc
app-text/docbook-xml-dtd:4.1.2
)
vala? ( $(vala_depend) )
"
PATCHES=(
"${FILESDIR}"/${P}-lcms2-corruption.patch
"${FILESDIR}"/${P}-time_t-ptr-truncation.patch
"${FILESDIR}"/${P}-FILE_OFFSET_BITS.patch
)
src_prepare() {
default
use vala && vala_src_prepare
# Test requires a running session
# https://github.com/hughsie/colord/issues/94
sed -i -e "/test('colord-test-daemon'/d" lib/colord/meson.build || die
# Adapt to Gentoo paths
sed -i \
-e "s|find_program('spotread'|find_program('argyll-spotread'|" \
-e "s|find_program('colprof'|find_program('argyll-colprof'|" \
meson.build || die
# meson gnome.generate_vapi properly handles VAPIGEN and other vala
# environment variables. It is counter-productive to check for an
# unversioned vapigen, as that breaks versioned VAPIGEN usages.
sed -i -e "/find_program('vapigen')/d" meson.build || die
}
multilib_src_configure() {
local emesonargs=(
$(meson_native_true daemon)
-Dbash_completion=false
$(meson_native_true udev_rules) # Install udev rules only from native build
$(meson_native_use_bool systemd)
-Dlibcolordcompat=true
$(meson_native_use_bool argyllcms argyllcms_sensor)
$(meson_native_use_bool scanner sane)
$(meson_native_use_bool introspection)
$(meson_native_use_bool vala vapi)
$(meson_native_use_bool extra-print-profiles print_profiles)
$(meson_use test tests)
-Dinstalled_tests=false
-Ddaemon_user=colord
$(meson_native_true man)
$(meson_use gtk-doc docs)
--localstatedir="${EPREFIX}"/var
)
meson_src_configure
}
multilib_src_install_all() {
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
}
pkg_postinst() {
udev_reload
tmpfiles_process colord.conf
}
pkg_postrm() {
udev_reload
}
@@ -0,0 +1,38 @@
https://github.com/hughsie/colord/pull/159
From 72cc7bb299de09ec53aa4ce125af370158127d0e Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Sat, 2 Dec 2023 05:07:46 +0000
Subject: [PATCH] meson.build: set FILE_OFFSET_BITS explicitly
This is needed if building introspection because:
a) Meson's own setting of FILE_OFFSET_BITS (which it does by default) doesn't
affect the introspection tooling;
b) glibc's headers seem to react poorly to _just_ _TIME_BITS being set, even
though in this cas, the failure was for a 64-bit ABI anyway.
Fixes: ce9732a87bc2a0ddca841b49b9b9e24351ea78c8
Signed-off-by: Sam James <sam@gentoo.org>
---
meson.build | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 072a612..b0b1af8 100644
--- a/meson.build
+++ b/meson.build
@@ -215,7 +215,9 @@ add_project_arguments('-DCD_COMPILATION', language: 'c')
# Needed for realpath() and PATH_MAX
add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c')
# Needed to opt-in to 64-bit time_t on glibc. We pass 64-bit pointers into
-# gmtime_r.
+# gmtime_r. We have to set F_O_B here despite Meson defaulting to it because
+# it doesn't get passed down to introspection otherwise.
+add_project_arguments('-D_FILE_OFFSET_BITS=64', language : 'c')
add_project_arguments('-D_TIME_BITS=64', language : 'c')
prefix = get_option('prefix')
--
2.43.0
@@ -0,0 +1,35 @@
https://bugs.gentoo.org/918990
https://github.com/hughsie/colord/issues/157
https://github.com/hughsie/colord/commit/ce9732a87bc2a0ddca841b49b9b9e24351ea78c8
From ce9732a87bc2a0ddca841b49b9b9e24351ea78c8 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Fri, 1 Dec 2023 22:20:17 +0000
Subject: [PATCH] meson.build: use 64-bit time_t
We call `gmtime_r` (which expects `time_t`) with a 64-bit pointer (`gint64*`).
On 32-bit systems, `time_t` is 32-bit unless you opt-in to a 64-bit wide version
(at least on glibc). To avoid truncation and -Wincompatible-pointer-types,
opt-in to 64-bit `time_t` for glibc with `-D_TIME_BITS=64` in meson.
This should be fine ABI wise because the time is only passed down into lcms2
into `_cmsEncodeDateTimeNumber` where it seems to decompose it and it worked already
for 64-bit systems. Plus, they use their own types like `cmsUInt16Number` to ensure
they're wide enough.
Fixes: https://github.com/hughsie/colord/issues/157
Signed-off-by: Sam James <sam@gentoo.org>
--- a/meson.build
+++ b/meson.build
@@ -214,6 +214,9 @@ add_project_arguments('-DCD_COMPILATION', language: 'c')
# Needed for realpath() and PATH_MAX
add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c')
+# Needed to opt-in to 64-bit time_t on glibc. We pass 64-bit pointers into
+# gmtime_r.
+add_project_arguments('-D_TIME_BITS=64', language : 'c')
prefix = get_option('prefix')