dev-libs/libnfc: bump
[gentoo.git] / dev-libs / glib / glib-2.64.2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python3_{6,7,8} )
6
7 inherit flag-o-matic gnome.org gnome2-utils linux-info meson multilib multilib-minimal python-any-r1 toolchain-funcs xdg
8
9 DESCRIPTION="The GLib library of C routines"
10 HOMEPAGE="https://www.gtk.org/"
11
12 LICENSE="LGPL-2.1+"
13 SLOT="2"
14 IUSE="dbus debug elibc_glibc fam gtk-doc kernel_linux +mime selinux static-libs systemtap test utils xattr"
15 RESTRICT="!test? ( test )"
16
17 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
18
19 # * libelf isn't strictly necessary, but makes gresource tool more useful, and
20 # the check is automagic in gio/meson.build. gresource is not a multilib tool
21 # right now, thus it doesn't matter if non-native ABI libelf exists or not
22 # (non-native binary is overwritten, it doesn't matter if libelf was linked to).
23 # * elfutils (via libelf) does not build on Windows. gresources are not embedded
24 # within ELF binaries on that platform anyway and inspecting ELF binaries from
25 # other platforms is not that useful so exclude the dependency in this case.
26 # * Technically static-libs is needed on zlib, util-linux and perhaps more, but
27 # these are used by GIO, which glib[static-libs] consumers don't really seem
28 # to need at all, thus not imposing the deps for now and once some consumers
29 # are actually found to static link libgio-2.0.a, we can revisit and either add
30 # them or just put the (build) deps in that rare consumer instead of recursive
31 # RDEPEND here (due to lack of recursive DEPEND).
32 RDEPEND="
33         !<dev-util/gdbus-codegen-${PV}
34         >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
35         >=dev-libs/libpcre-8.31:3[${MULTILIB_USEDEP},static-libs?]
36         >=dev-libs/libffi-3.0.13-r1:=[${MULTILIB_USEDEP}]
37         >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
38         >=virtual/libintl-0-r2[${MULTILIB_USEDEP}]
39         kernel_linux? ( >=sys-apps/util-linux-2.23[${MULTILIB_USEDEP}] )
40         selinux? ( >=sys-libs/libselinux-2.2.2-r5[${MULTILIB_USEDEP}] )
41         xattr? ( !elibc_glibc? ( >=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}] ) )
42         !kernel_Winnt? ( virtual/libelf:0= )
43         fam? ( >=virtual/fam-0-r1[${MULTILIB_USEDEP}] )
44 "
45 DEPEND="${RDEPEND}"
46 # libxml2 used for optional tests that get automatically skipped
47 BDEPEND="
48         app-text/docbook-xsl-stylesheets
49         dev-libs/libxslt
50         >=sys-devel/gettext-0.19.8
51         gtk-doc? ( >=dev-util/gtk-doc-1.20
52                 app-text/docbook-xml-dtd:4.2
53                 app-text/docbook-xml-dtd:4.5 )
54         systemtap? ( >=dev-util/systemtap-1.3 )
55         ${PYTHON_DEPS}
56         test? ( >=sys-apps/dbus-1.2.14 )
57         virtual/pkgconfig[${MULTILIB_USEDEP}]
58 "
59 # TODO: >=dev-util/gdbus-codegen-${PV} test dep once we modify gio/tests/meson.build to use external gdbus-codegen
60
61 PDEPEND="
62         dbus? ( gnome-base/dconf )
63         mime? ( x11-misc/shared-mime-info )
64 "
65 # shared-mime-info needed for gio/xdgmime, bug #409481
66 # dconf is needed to be able to save settings, bug #498436
67
68 MULTILIB_CHOST_TOOLS=(
69         /usr/bin/gio-querymodules$(get_exeext)
70 )
71
72 PATCHES=(
73         "${FILESDIR}"/${PN}-2.64.1-mark-gdbus-server-auth-test-flaky.patch
74 )
75
76 pkg_setup() {
77         if use kernel_linux ; then
78                 CONFIG_CHECK="~INOTIFY_USER"
79                 if use test ; then
80                         CONFIG_CHECK="~IPV6"
81                         WARNING_IPV6="Your kernel needs IPV6 support for running some tests, skipping them."
82                 fi
83                 linux-info_pkg_setup
84         fi
85         python-any-r1_pkg_setup
86 }
87
88 src_prepare() {
89         if use test; then
90                 # TODO: Review the test exclusions, especially now with meson
91                 # Disable tests requiring dev-util/desktop-file-utils when not installed, bug #286629, upstream bug #629163
92                 if ! has_version dev-util/desktop-file-utils ; then
93                         ewarn "Some tests will be skipped due dev-util/desktop-file-utils not being present on your system,"
94                         ewarn "think on installing it to get these tests run."
95                         sed -i -e "/appinfo\/associations/d" gio/tests/appinfo.c || die
96                         sed -i -e "/g_test_add_func/d" gio/tests/desktop-app-info.c || die
97                 fi
98
99                 # gdesktopappinfo requires existing terminal (gnome-terminal or any
100                 # other), falling back to xterm if one doesn't exist
101                 #if ! has_version x11-terms/xterm && ! has_version x11-terms/gnome-terminal ; then
102                 #       ewarn "Some tests will be skipped due to missing terminal program"
103                 # These tests seem to sometimes fail even with a terminal; skip for now and reevulate with meson
104                 # 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
105                 sed -i -e "/appinfo\/launch/d" gio/tests/appinfo.c || die
106                 # desktop-app-info/launch* might fail similarly
107                 sed -i -e "/desktop-app-info\/launch-as-manager/d" gio/tests/desktop-app-info.c || die
108                 #fi
109
110                 # https://bugzilla.gnome.org/show_bug.cgi?id=722604
111                 sed -i -e "/timer\/stop/d" glib/tests/timer.c || die
112                 sed -i -e "/timer\/basic/d" glib/tests/timer.c || die
113
114                 ewarn "Tests for search-utils have been skipped"
115                 sed -i -e "/search-utils/d" glib/tests/meson.build || die
116
117                 # Play nice with network-sandbox, but this approach would defeat the purpose of the test
118                 #sed -i -e "s/localhost/127.0.0.1/g" gio/tests/gsocketclient-slow.c || die
119         else
120                 # Don't build tests, also prevents extra deps, bug #512022
121                 sed -i -e '/subdir.*tests/d' {.,gio,glib}/meson.build || die
122         fi
123
124         # Don't build fuzzing binaries - not used
125         sed -i -e '/subdir.*fuzzing/d' meson.build || die
126
127         # gdbus-codegen is a separate package
128         sed -i -e '/install_dir/d' gio/gdbus-2.0/codegen/meson.build || die
129
130         # Same kind of meson-0.50 issue with some installed-tests files; will likely be fixed upstream soon
131         sed -i -e '/install_dir/d' gio/tests/meson.build || die
132
133         cat > "${T}/glib-test-ld-wrapper" <<-EOF
134                 #!/usr/bin/env sh
135                 exec \${LD:-ld} "\$@"
136         EOF
137         chmod a+x "${T}/glib-test-ld-wrapper" || die
138         sed -i -e "s|'ld'|'${T}/glib-test-ld-wrapper'|g" gio/tests/meson.build || die
139
140         xdg_src_prepare
141         gnome2_environment_reset
142         # TODO: python_name sedding for correct python shebang? Might be relevant mainly for glib-utils only
143 }
144
145 multilib_src_configure() {
146         if use debug; then
147                 append-cflags -DG_ENABLE_DEBUG
148         else
149                 append-cflags -DG_DISABLE_CAST_CHECKS # https://gitlab.gnome.org/GNOME/glib/issues/1833
150         fi
151
152         # TODO: figure a way to pass appropriate values for all cross properties that glib uses (search for get_cross_property)
153         #if tc-is-cross-compiler ; then
154                 # https://bugzilla.gnome.org/show_bug.cgi?id=756473
155                 # TODO-meson: This should be in meson cross file as 'growing_stack' property; and more, look at get_cross_property
156                 #case ${CHOST} in
157                 #hppa*|metag*) export glib_cv_stack_grows=yes ;;
158                 #*)            export glib_cv_stack_grows=no ;;
159                 #esac
160         #fi
161
162         local emesonargs=(
163                 -Ddefault_library=$(usex static-libs both shared)
164                 $(meson_feature selinux)
165                 $(meson_use xattr)
166                 -Dlibmount=enabled # only used if host_system == 'linux'
167                 -Dinternal_pcre=false
168                 -Dman=true
169                 $(meson_use systemtap dtrace)
170                 $(meson_use systemtap)
171                 -Dgtk_doc=$(multilib_native_usex gtk-doc true false)
172                 $(meson_use fam)
173                 -Dinstalled_tests=false
174                 -Dnls=enabled
175                 -Doss_fuzz=disabled
176         )
177         meson_src_configure
178 }
179
180 multilib_src_compile() {
181         meson_src_compile
182 }
183
184 multilib_src_test() {
185         export XDG_CONFIG_DIRS=/etc/xdg
186         export XDG_DATA_DIRS=/usr/local/share:/usr/share
187         export G_DBUS_COOKIE_SHA1_KEYRING_DIR="${T}/temp"
188         export LC_TIME=C # bug #411967
189         unset GSETTINGS_BACKEND # bug #596380
190         python_setup
191
192         # Related test is a bit nitpicking
193         mkdir "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
194         chmod 0700 "$G_DBUS_COOKIE_SHA1_KEYRING_DIR"
195
196         meson_src_test --timeout-multiplier 2 --no-suite flaky
197 }
198
199 multilib_src_install() {
200         meson_src_install
201         keepdir /usr/$(get_libdir)/gio/modules
202 }
203
204 multilib_src_install_all() {
205         einstalldocs
206
207         # These are installed by dev-util/glib-utils
208         # 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 now with meson
209         rm "${ED}/usr/bin/glib-genmarshal" || die
210         rm "${ED}/usr/share/man/man1/glib-genmarshal.1" || die
211         rm "${ED}/usr/bin/glib-mkenums" || die
212         rm "${ED}/usr/share/man/man1/glib-mkenums.1" || die
213         rm "${ED}/usr/bin/gtester-report" || die
214         rm "${ED}/usr/share/man/man1/gtester-report.1" || die
215         # gdbus-codegen manpage installed by dev-util/gdbus-codegen
216         rm "${ED}/usr/share/man/man1/gdbus-codegen.1" || die
217 }
218
219 pkg_preinst() {
220         xdg_pkg_preinst
221
222         # Make gschemas.compiled belong to glib alone
223         local cache="/usr/share/glib-2.0/schemas/gschemas.compiled"
224
225         if [[ -e ${EROOT}${cache} ]]; then
226                 cp "${EROOT}"${cache} "${ED}"/${cache} || die
227         else
228                 touch "${ED}"${cache} || die
229         fi
230
231         multilib_pkg_preinst() {
232                 # Make giomodule.cache belong to glib alone
233                 local cache="/usr/$(get_libdir)/gio/modules/giomodule.cache"
234
235                 if [[ -e ${EROOT}${cache} ]]; then
236                         cp "${EROOT}"${cache} "${ED}"${cache} || die
237                 else
238                         touch "${ED}"${cache} || die
239                 fi
240         }
241
242         # Don't run the cache ownership when cross-compiling, as it would end up with an empty cache
243         # file due to inability to create it and GIO might not look at any of the modules there
244         if ! tc-is-cross-compiler ; then
245                 multilib_foreach_abi multilib_pkg_preinst
246         fi
247 }
248
249 pkg_postinst() {
250         xdg_pkg_postinst
251         # glib installs no schemas itself, but we force update for fresh install in case
252         # something has dropped in a schemas file without direct glib dep; and for upgrades
253         # in case the compiled schema format could have changed
254         gnome2_schemas_update
255
256         multilib_pkg_postinst() {
257                 gnome2_giomodule_cache_update \
258                         || die "Update GIO modules cache failed (for ${ABI})"
259         }
260         if ! tc-is-cross-compiler ; then
261                 multilib_foreach_abi multilib_pkg_postinst
262         else
263                 ewarn "Updating of GIO modules cache skipped due to cross-compilation."
264                 ewarn "You might want to run gio-querymodules manually on the target for"
265                 ewarn "your final image for performance reasons and re-run it when packages"
266                 ewarn "installing GIO modules get upgraded or added to the image."
267         fi
268
269         for v in ${REPLACING_VERSIONS}; do
270                 if ver_test "$v" "-lt" "2.63.6"; then
271                         ewarn "glib no longer installs the gio-launch-desktop binary. You may need"
272                         ewarn "to restart your session for \"Open With\" dialogs to work."
273                 fi
274         done
275 }
276
277 pkg_postrm() {
278         xdg_pkg_postrm
279         gnome2_schemas_update
280
281         if [[ -z ${REPLACED_BY_VERSION} ]]; then
282                 multilib_pkg_postrm() {
283                         rm -f "${EROOT}"/usr/$(get_libdir)/gio/modules/giomodule.cache
284                 }
285                 multilib_foreach_abi multilib_pkg_postrm
286                 rm -f "${EROOT}"/usr/share/glib-2.0/schemas/gschemas.compiled
287         fi
288 }