1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
8 inherit autotools bash-completion-r1 epunt-cxx flag-o-matic gnome2 libtool linux-info \
9 multilib multilib-minimal pax-utils python-any-r1 toolchain-funcs virtualx
11 # Until bug #537330 glib is a reverse dependency of pkgconfig and, then
12 # adding new dependencies end up making stage3 to grow. Every addition needs
13 # then to be think very closely.
15 DESCRIPTION="The GLib library of C routines"
16 HOMEPAGE="https://www.gtk.org/"
18 https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz" # pkg.m4 for eautoreconf
22 IUSE="dbus debug fam gtk-doc kernel_linux +mime selinux static-libs systemtap test utils xattr"
24 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~riscv s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
26 # Added util-linux multilib dependency to have libmount support (which
27 # is always turned on on linux systems, unless explicitly disabled, but
28 # this ebuild does not do that anyway) (bug #599586)
31 !<dev-util/gdbus-codegen-${PV}
32 >=dev-libs/libpcre-8.31:3[${MULTILIB_USEDEP},static-libs?]
33 >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
34 >=virtual/libffi-3.0.13-r1:=[${MULTILIB_USEDEP}]
35 >=virtual/libintl-0-r2[${MULTILIB_USEDEP}]
36 >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
37 kernel_linux? ( >=sys-apps/util-linux-2.23[${MULTILIB_USEDEP}] )
38 selinux? ( >=sys-libs/libselinux-2.2.2-r5[${MULTILIB_USEDEP}] )
39 xattr? ( >=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}] )
40 fam? ( >=virtual/fam-0-r1[${MULTILIB_USEDEP}] )
42 >=dev-util/gdbus-codegen-${PV}
47 app-text/docbook-xml-dtd:4.1.2
48 app-text/docbook-xsl-stylesheets
49 >=dev-libs/libxslt-1.0
50 >=sys-devel/gettext-0.11
51 gtk-doc? ( >=dev-util/gtk-doc-1.20 )
52 systemtap? ( >=dev-util/systemtap-1.3 )
56 >=dev-util/gdbus-codegen-${PV}
57 >=sys-apps/dbus-1.2.14 )
59 # configure.ac has gtk-doc-am stuff behind m4_ifdef, so we don't need a gtk-doc-am build dep
61 # Migration of glib-genmarshal, glib-mkenums and gtester-report to a separate
62 # python depending package, which can be buildtime depended in packages that
63 # need these tools, without pulling in python at runtime.
65 >=dev-util/glib-utils-${PV}"
67 dbus? ( gnome-base/dconf )
68 mime? ( x11-misc/shared-mime-info )
70 # shared-mime-info needed for gio/xdgmime, bug #409481
71 # dconf is needed to be able to save settings, bug #498436
73 MULTILIB_CHOST_TOOLS=(
74 /usr/bin/gio-querymodules$(get_exeext)
78 if use kernel_linux ; then
79 CONFIG_CHECK="~INOTIFY_USER"
82 WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
86 python-any-r1_pkg_setup
90 # Prevent build failure in stage3 where pkgconfig is not available, bug #481056
91 mv -f "${WORKDIR}"/pkg-config-*/pkg.m4 "${S}"/m4macros/ || die
94 # Disable tests requiring dev-util/desktop-file-utils when not installed, bug #286629, upstream bug #629163
95 if ! has_version dev-util/desktop-file-utils ; then
96 ewarn "Some tests will be skipped due dev-util/desktop-file-utils not being present on your system,"
97 ewarn "think on installing it to get these tests run."
98 sed -i -e "/appinfo\/associations/d" gio/tests/appinfo.c || die
99 sed -i -e "/g_test_add_func/d" gio/tests/desktop-app-info.c || die
102 # gdesktopappinfo requires existing terminal (gnome-terminal or any
103 # other), falling back to xterm if one doesn't exist
104 #if ! has_version x11-terms/xterm && ! has_version x11-terms/gnome-terminal ; then
105 # ewarn "Some tests will be skipped due to missing terminal program"
106 # These tests seem to sometimes fail even with a terminal; skip for now and reevulate with meson
107 # Also try https://gitlab.gnome.org/GNOME/glib/issues/1601 once ready for backport (or in a bump) and file new issue if still fails
108 sed -i -e "/appinfo\/launch/d" gio/tests/appinfo.c || die
109 # desktop-app-info/launch* might fail similarly
110 sed -i -e "/desktop-app-info\/launch-as-manager/d" gio/tests/desktop-app-info.c || die
113 # https://bugzilla.gnome.org/show_bug.cgi?id=722604
114 sed -i -e "/timer\/stop/d" glib/tests/timer.c || die
115 sed -i -e "/timer\/basic/d" glib/tests/timer.c || die
117 ewarn "Tests for search-utils have been skipped"
118 sed -i -e "/search-utils/d" glib/tests/Makefile.am || die
120 # Don't build tests, also prevents extra deps, bug #512022
121 sed -i -e 's/ tests//' {.,gio,glib}/Makefile.am || die
124 # gdbus-codegen is a separate package
125 eapply "${FILESDIR}"/${PN}-2.58.2-external-gdbus-codegen.patch
127 # gdbus message upper limit check fix from glib-2-58
128 eapply "${FILESDIR}"/${PV}-gdbusmessage-limit-fix.patch
129 # gfile copy fallback security fix (wrong permissions at start)
130 eapply "${FILESDIR}"/${PV}-CVE-2019-12450.patch
132 # Tarball doesn't come with gtk-doc.make and we can't unconditionally depend on dev-util/gtk-doc due
133 # to circular deps during bootstramp. If actually not building gtk-doc, an almost empty file will do
134 # fine as well - this is also what upstream autogen.sh does if gtkdocize is not found. If gtk-doc is
135 # installed, eautoreconf will call gtkdocize, which overwrites the empty gtk-doc.make with a full copy.
136 cat > gtk-doc.make << EOF
145 multilib_src_configure() {
146 # Avoid circular depend with dev-util/pkgconfig and
147 # native builds (cross-compiles won't need pkg-config
148 # in the target ROOT to work here)
149 if ! tc-is-cross-compiler && ! $(tc-getPKG_CONFIG) --version >& /dev/null; then
150 if has_version sys-apps/dbus; then
151 export DBUS1_CFLAGS="-I/usr/include/dbus-1.0 -I/usr/$(get_libdir)/dbus-1.0/include"
152 export DBUS1_LIBS="-ldbus-1"
154 export LIBFFI_CFLAGS="-I$(echo /usr/$(get_libdir)/libffi-*/include)"
155 export LIBFFI_LIBS="-lffi"
156 export PCRE_CFLAGS=" " # test -n "$PCRE_CFLAGS" needs to pass
157 export PCRE_LIBS="-lpcre"
160 # These configure tests don't work when cross-compiling.
161 if tc-is-cross-compiler ; then
162 # https://bugzilla.gnome.org/show_bug.cgi?id=756473
164 hppa*|metag*) export glib_cv_stack_grows=yes ;;
165 *) export glib_cv_stack_grows=no ;;
167 # https://bugzilla.gnome.org/show_bug.cgi?id=756474
168 export glib_cv_uscore=no
169 # https://bugzilla.gnome.org/show_bug.cgi?id=756475
170 export ac_cv_func_posix_get{pwuid,grgid}_r=yes
176 *-mingw*) myconf="${myconf} --with-threads=win32" ;;
177 *) myconf="${myconf} --with-threads=posix" ;;
180 # libelf used only by the gresource bin
181 ECONF_SOURCE="${S}" gnome2_src_configure ${myconf} \
182 $(usex debug --enable-debug=yes ' ') \
183 $(use_enable xattr) \
185 $(multilib_native_use_enable gtk-doc) \
186 $(use_enable kernel_linux libmount) \
187 $(use_enable selinux) \
188 $(use_enable static-libs static) \
189 $(use_enable systemtap dtrace) \
190 $(use_enable systemtap systemtap) \
191 $(multilib_native_use_enable utils libelf) \
192 --with-python=${EPYTHON} \
193 --disable-compile-warnings \
196 --with-xml-catalog="${EPREFIX}/etc/xml/catalog"
198 if multilib_is_native_abi; then
200 for d in glib gio gobject; do
201 ln -s "${S}"/docs/reference/${d}/html docs/reference/${d}/html || die
206 multilib_src_test() {
207 export XDG_CONFIG_DIRS=/etc/xdg
208 export XDG_DATA_DIRS=/usr/local/share:/usr/share
209 export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
210 export LC_TIME=C # bug #411967
211 unset GSETTINGS_BACKEND # bug #596380
214 # Related test is a bit nitpicking
215 mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
216 chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
218 # Hardened: gdb needs this, bug #338891
219 if host-is-pax ; then
220 pax-mark -mr "${BUILD_DIR}"/tests/.libs/assert-msg-test \
221 || die "Hardened adjustment failed"
224 # Need X for dbus-launch session X11 initialization
228 multilib_src_install() {
229 emake DESTDIR="${D}" completiondir="$(get_bashcompdir)" install
230 keepdir /usr/$(get_libdir)/gio/modules
233 multilib_src_install_all() {
236 # These are installed by dev-util/glib-utils
237 # TODO: With patching we might be able to get rid of the python-any deps and removals, and test depend on glib-utils instead; revisit with meson
238 rm "${ED}usr/bin/glib-genmarshal" || die
239 rm "${ED}usr/share/man/man1/glib-genmarshal.1" || die
240 rm "${ED}usr/bin/glib-mkenums" || die
241 rm "${ED}usr/share/man/man1/glib-mkenums.1" || die
242 rm "${ED}usr/bin/gtester-report" || die
243 rm "${ED}usr/share/man/man1/gtester-report.1" || die
245 # Do not install charset.alias even if generated, leave it to libiconv
246 rm -f "${ED}/usr/$(get_libdir)/charset.alias"
248 # Don't install gdb python macros, bug 291328
249 rm -rf "${ED}/usr/share/gdb/" "${ED}/usr/share/glib-2.0/gdb/"
251 # Completely useless with or without USE static-libs, people need to use pkg-config
252 find "${ED}" -name '*.la' -delete || die
258 # Make gschemas.compiled belong to glib alone
259 local cache="usr/share/glib-2.0/schemas/gschemas.compiled"
261 if [[ -e ${EROOT}${cache} ]]; then
262 cp "${EROOT}"${cache} "${ED}"/${cache} || die
264 touch "${ED}"/${cache} || die
267 multilib_pkg_preinst() {
268 # Make giomodule.cache belong to glib alone
269 local cache="usr/$(get_libdir)/gio/modules/giomodule.cache"
271 if [[ -e ${EROOT}${cache} ]]; then
272 cp "${EROOT}"${cache} "${ED}"/${cache} || die
274 touch "${ED}"/${cache} || die
278 # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
279 # file due to inability to create it and GIO might not look at any of the modules there
280 if ! tc-is-cross-compiler ; then
281 multilib_foreach_abi multilib_pkg_preinst
286 # force (re)generation of gschemas.compiled
287 GNOME2_ECLASS_GLIB_SCHEMAS="force"
291 multilib_pkg_postinst() {
292 gnome2_giomodule_cache_update \
293 || die "Update GIO modules cache failed (for ${ABI})"
295 if ! tc-is-cross-compiler ; then
296 multilib_foreach_abi multilib_pkg_postinst
298 ewarn "Updating of GIO modules cache skipped due to cross-compilation."
299 ewarn "You might want to run gio-querymodules manually on the target for"
300 ewarn "your final image for performance reasons and re-run it when packages"
301 ewarn "installing GIO modules get upgraded or added to the image."
308 if [[ -z ${REPLACED_BY_VERSION} ]]; then
309 multilib_pkg_postrm() {
310 rm -f "${EROOT}"usr/$(get_libdir)/gio/modules/giomodule.cache
312 multilib_foreach_abi multilib_pkg_postrm
313 rm -f "${EROOT}"usr/share/glib-2.0/schemas/gschemas.compiled