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