www-apps/icingaweb2: 2.7.0 bump
[gentoo.git] / x11-libs / gtk+ / gtk+-2.24.32-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 GNOME2_LA_PUNT="yes"
6 GNOME2_EAUTORECONF="yes"
7
8 inherit eutils flag-o-matic gnome2 multilib multilib-minimal readme.gentoo-r1 virtualx
9
10 DESCRIPTION="Gimp ToolKit +"
11 HOMEPAGE="https://www.gtk.org/"
12 SRC_URI+=" https://dev.gentoo.org/~leio/distfiles/${P}-patchset-r1.tar.xz"
13
14 LICENSE="LGPL-2+"
15 SLOT="2"
16 IUSE="aqua cups examples +introspection test vim-syntax xinerama"
17 REQUIRED_USE="
18         xinerama? ( !aqua )
19 "
20
21 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
22
23 # Upstream wants us to do their job:
24 # https://bugzilla.gnome.org/show_bug.cgi?id=768663#c1
25 RESTRICT="test"
26
27 COMMON_DEPEND="
28         >=dev-libs/atk-2.10.0[introspection?,${MULTILIB_USEDEP}]
29         >=dev-libs/glib-2.34.3:2[${MULTILIB_USEDEP}]
30         >=media-libs/fontconfig-2.10.92[${MULTILIB_USEDEP}]
31         >=x11-libs/cairo-1.12.14-r4:=[aqua?,svg,${MULTILIB_USEDEP}]
32         >=x11-libs/gdk-pixbuf-2.30.7:2[introspection?,${MULTILIB_USEDEP}]
33         >=x11-libs/pango-1.36.3[introspection?,${MULTILIB_USEDEP}]
34         x11-misc/shared-mime-info
35
36         cups? ( >=net-print/cups-1.7.1-r2:=[${MULTILIB_USEDEP}] )
37         introspection? ( >=dev-libs/gobject-introspection-0.9.3:= )
38         !aqua? (
39                 >=x11-libs/cairo-1.12.14-r4:=[aqua?,svg,X,${MULTILIB_USEDEP}]
40                 >=x11-libs/libXrender-0.9.8[${MULTILIB_USEDEP}]
41                 >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
42                 >=x11-libs/libXi-1.7.2[${MULTILIB_USEDEP}]
43                 >=x11-libs/libXext-1.3.2[${MULTILIB_USEDEP}]
44                 >=x11-libs/libXrandr-1.5[${MULTILIB_USEDEP}]
45                 >=x11-libs/libXcursor-1.1.14[${MULTILIB_USEDEP}]
46                 >=x11-libs/libXfixes-5.0.1[${MULTILIB_USEDEP}]
47                 >=x11-libs/libXcomposite-0.4.4-r1[${MULTILIB_USEDEP}]
48                 >=x11-libs/libXdamage-1.1.4-r1[${MULTILIB_USEDEP}]
49                 xinerama? ( >=x11-libs/libXinerama-1.1.3[${MULTILIB_USEDEP}] )
50         )
51 "
52 # docbook-4.1.2 and xsl required for man pages
53 # docbook-4.3 required for gtk-doc
54 DEPEND="${COMMON_DEPEND}
55         app-text/docbook-xsl-stylesheets
56         app-text/docbook-xml-dtd:4.1.2
57         app-text/docbook-xml-dtd:4.3
58         dev-libs/libxslt
59         dev-libs/gobject-introspection-common
60         dev-util/glib-utils
61         >=dev-util/gtk-doc-am-1.20
62         >=sys-devel/gettext-0.18.3[${MULTILIB_USEDEP}]
63         >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
64         !aqua? ( x11-base/xorg-proto )
65         test? (
66                 x11-themes/hicolor-icon-theme
67                 media-fonts/font-misc-misc
68                 media-fonts/font-cursor-misc )
69 "
70
71 # gtk+-2.24.8 breaks Alt key handling in <=x11-libs/vte-0.28.2:0
72 # Add blocker against old gtk-builder-convert to be sure we maintain both
73 # in sync.
74 RDEPEND="${COMMON_DEPEND}
75         >=dev-util/gtk-update-icon-cache-2
76         !<gnome-base/gail-1000
77         !<dev-util/gtk-builder-convert-${PV}
78         !<x11-libs/vte-0.28.2-r201:0
79         >=x11-themes/adwaita-icon-theme-3.14
80         x11-themes/gnome-themes-standard
81 "
82 # librsvg for svg icons (PDEPEND to avoid circular dep), bug #547710
83 PDEPEND="
84         x11-themes/gtk-engines-adwaita
85         gnome-base/librsvg[${MULTILIB_USEDEP}]
86         vim-syntax? ( app-vim/gtk-syntax )
87 "
88
89 DISABLE_AUTOFORMATTING="yes"
90 DOC_CONTENTS="To make the gtk2 file chooser use 'current directory' mode by default,
91 edit ~/.config/gtk-2.0/gtkfilechooser.ini to contain the following:
92 [Filechooser Settings]
93 StartupMode=cwd"
94
95 MULTILIB_CHOST_TOOLS=(
96         /usr/bin/gtk-query-immodules-2.0$(get_exeext)
97 )
98
99 PATCHES=(
100         # Fix tests running when building out of sources, bug #510596, upstream bug #730319
101         "${FILESDIR}"/${PN}-2.24.24-out-of-source.patch
102         # Rely on split gtk-update-icon-cache package, bug #528810
103         "${FILESDIR}"/${PN}-2.24.31-update-icon-cache.patch # requires eautoreconf
104         # Upstream gtk-2-24 branch up to 2018-09-08 state, bug #650536 safety
105         "${WORKDIR}"/patches/ # requires eautoreconf
106 )
107
108 strip_builddir() {
109         local rule=$1
110         shift
111         local directory=$1
112         shift
113         sed -e "s/^\(${rule} =.*\)${directory}\(.*\)$/\1\2/" -i $@ \
114                 || die "Could not strip director ${directory} from build."
115 }
116
117 set_gtk2_confdir() {
118         # An arch specific config directory is used on multilib systems
119         GTK2_CONFDIR="/etc/gtk-2.0/${CHOST}"
120 }
121
122 src_prepare() {
123         # Various glib marshaller churn could break build against a different glib version, force regeneration
124         rm -v gdk/gdkmarshalers.{c,h} gtk/gtkmarshal.{c,h} gtk/gtkmarshalers.{c,h} \
125                 perf/marshalers.{c,h} gtk/gtkaliasdef.c gtk/gtkalias.h || die
126
127         # Stop trying to build unmaintained docs, bug #349754, upstream bug #623150
128         strip_builddir SUBDIRS tutorial docs/Makefile.{am,in}
129         strip_builddir SUBDIRS faq docs/Makefile.{am,in}
130
131         # -O3 and company cause random crashes in applications, bug #133469
132         replace-flags -O3 -O2
133         strip-flags
134
135         if ! use test ; then
136                 # don't waste time building tests
137                 strip_builddir SRC_SUBDIRS tests Makefile.{am,in}
138                 strip_builddir SUBDIRS tests gdk/Makefile.{am,in} gtk/Makefile.{am,in}
139         else
140                 # Non-working test in gentoo's env
141                 sed 's:\(g_test_add_func ("/ui-tests/keys-events.*\):/*\1*/:g' \
142                         -i gtk/tests/testing.c || die "sed 1 failed"
143
144                 # Cannot work because glib is too clever to find real user's home
145                 # gentoo bug #285687, upstream bug #639832
146                 # XXX: /!\ Pay extra attention to second sed when bumping /!\
147                 sed '/TEST_PROGS.*recentmanager/d' -i gtk/tests/Makefile.am \
148                         || die "failed to disable recentmanager test (1)"
149                 sed '/^TEST_PROGS =/,+3 s/recentmanager//' -i gtk/tests/Makefile.in \
150                         || die "failed to disable recentmanager test (2)"
151                 sed 's:\({ "GtkFileChooserButton".*},\):/*\1*/:g' -i gtk/tests/object.c \
152                         || die "failed to disable recentmanager test (3)"
153
154                 # https://bugzilla.gnome.org/show_bug.cgi?id=617473
155                 sed -i -e 's:pltcheck.sh:$(NULL):g' \
156                         gtk/Makefile.am || die
157
158                 # UI tests require immodules already installed; bug #413185
159                 if ! has_version 'x11-libs/gtk+:2'; then
160                         ewarn "Disabling UI tests because this is the first install of"
161                         ewarn "gtk+:2 on this machine. Please re-run the tests after $P"
162                         ewarn "has been installed."
163                         sed '/g_test_add_func.*ui-tests/ d' \
164                                 -i gtk/tests/testing.c || die "sed 2 failed"
165                 fi
166         fi
167
168         if ! use examples; then
169                 # don't waste time building demos
170                 strip_builddir SRC_SUBDIRS demos Makefile.{am,in}
171         fi
172
173         gnome2_src_prepare
174 }
175
176 multilib_src_configure() {
177         [[ ${ABI} == ppc64 ]] && append-flags -mminimal-toc
178
179         ECONF_SOURCE=${S} \
180         gnome2_src_configure \
181                 $(usex aqua --with-gdktarget=quartz --with-gdktarget=x11) \
182                 $(usex aqua "" --with-xinput) \
183                 $(use_enable cups cups auto) \
184                 $(multilib_native_use_enable introspection) \
185                 $(use_enable xinerama) \
186                 --disable-papi \
187                 --enable-man \
188                 --with-xml-catalog="${EPREFIX}"/etc/xml/catalog \
189                 CUPS_CONFIG="${EPREFIX}/usr/bin/${CHOST}-cups-config"
190
191         # work-around gtk-doc out-of-source brokedness
192         if multilib_is_native_abi; then
193                 local d
194                 for d in gdk gtk libgail-util; do
195                         ln -s "${S}"/docs/reference/${d}/html docs/reference/${d}/html || die
196                 done
197         fi
198 }
199
200 multilib_src_test() {
201         virtx emake check
202 }
203
204 multilib_src_install() {
205         gnome2_src_install
206 }
207
208 multilib_src_install_all() {
209         # see bug #133241
210         # Also set more default variables in sync with gtk3 and other distributions
211         echo 'gtk-fallback-icon-theme = "gnome"' > "${T}/gtkrc"
212         echo 'gtk-theme-name = "Adwaita"' >> "${T}/gtkrc"
213         echo 'gtk-icon-theme-name = "Adwaita"' >> "${T}/gtkrc"
214         echo 'gtk-cursor-theme-name = "Adwaita"' >> "${T}/gtkrc"
215
216         insinto /usr/share/gtk-2.0
217         doins "${T}"/gtkrc
218
219         einstalldocs
220
221         # dev-util/gtk-builder-convert split off into a separate package, #402905
222         rm "${ED}"usr/bin/gtk-builder-convert || die
223         rm "${ED}"usr/share/man/man1/gtk-builder-convert.* || die
224
225         readme.gentoo_create_doc
226 }
227
228 pkg_preinst() {
229         gnome2_pkg_preinst
230
231         multilib_pkg_preinst() {
232                 # Make immodules.cache belongs to gtk+ alone
233                 local cache="usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.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         multilib_parallel_foreach_abi multilib_pkg_preinst
242 }
243
244 pkg_postinst() {
245         gnome2_pkg_postinst
246
247         multilib_pkg_postinst() {
248                 gnome2_query_immodules_gtk2 \
249                         || die "Update immodules cache failed (for ${ABI})"
250         }
251         multilib_parallel_foreach_abi multilib_pkg_postinst
252
253         set_gtk2_confdir
254
255         if [ -e "${EROOT%/}/etc/gtk-2.0/gtk.immodules" ]; then
256                 elog "File /etc/gtk-2.0/gtk.immodules has been moved to \$CHOST"
257                 elog "aware location. Removing deprecated file."
258                 rm -f ${EROOT%/}/etc/gtk-2.0/gtk.immodules
259         fi
260
261         if [ -e "${EROOT%/}${GTK2_CONFDIR}/gtk.immodules" ]; then
262                 elog "File /etc/gtk-2.0/gtk.immodules has been moved to"
263                 elog "${EROOT%/}/usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache"
264                 elog "Removing deprecated file."
265                 rm -f ${EROOT%/}${GTK2_CONFDIR}/gtk.immodules
266         fi
267
268         # pixbufs are now handled by x11-libs/gdk-pixbuf
269         if [ -e "${EROOT%/}${GTK2_CONFDIR}/gdk-pixbuf.loaders" ]; then
270                 elog "File ${EROOT%/}${GTK2_CONFDIR}/gdk-pixbuf.loaders is now handled by x11-libs/gdk-pixbuf"
271                 elog "Removing deprecated file."
272                 rm -f ${EROOT%/}${GTK2_CONFDIR}/gdk-pixbuf.loaders
273         fi
274
275         # two checks needed since we dropped multilib conditional
276         if [ -e "${EROOT%/}/etc/gtk-2.0/gdk-pixbuf.loaders" ]; then
277                 elog "File ${EROOT%/}/etc/gtk-2.0/gdk-pixbuf.loaders is now handled by x11-libs/gdk-pixbuf"
278                 elog "Removing deprecated file."
279                 rm -f ${EROOT%/}/etc/gtk-2.0/gdk-pixbuf.loaders
280         fi
281
282         if [ -e "${EROOT%/}"/usr/lib/gtk-2.0/2.[^1]* ]; then
283                 elog "You need to rebuild ebuilds that installed into" "${EROOT%/}"/usr/lib/gtk-2.0/2.[^1]*
284                 elog "to do that you can use qfile from portage-utils:"
285                 elog "emerge -va1 \$(qfile -qC ${EPREFIX}/usr/lib/gtk-2.0/2.[^1]*)"
286         fi
287
288         if ! has_version "app-text/evince"; then
289                 elog "Please install app-text/evince for print preview functionality."
290                 elog "Alternatively, check \"gtk-print-preview-command\" documentation and"
291                 elog "add it to your gtkrc."
292         fi
293
294         readme.gentoo_print_elog
295 }
296
297 pkg_postrm() {
298         gnome2_pkg_postrm
299
300         if [[ -z ${REPLACED_BY_VERSION} ]]; then
301                 multilib_pkg_postrm() {
302                         rm -f "${EROOT}"usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache
303                 }
304                 multilib_foreach_abi multilib_pkg_postrm
305         fi
306 }