|
| 1 | +# Copyright 1999-2023 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=7 |
| 5 | + |
| 6 | +PYTHON_COMPAT=( python3_{9..11} ) |
| 7 | + |
| 8 | +inherit autotools bash-completion-r1 gnome2-utils python-r1 toolchain-funcs vala virtualx xdg-utils |
| 9 | + |
| 10 | +UPSTREAM_VER=0 |
| 11 | +GENTOO_VER= |
| 12 | +DESCRIPTION="Intelligent Input Bus for Linux / Unix OS" |
| 13 | +HOMEPAGE="https://github.com/ibus/ibus/wiki" |
| 14 | + |
| 15 | +[[ -n ${UPSTREAM_VER} ]] && \ |
| 16 | + UPSTREAM_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P}-upstream-patches-${UPSTREAM_VER}.tar.xz" |
| 17 | +[[ -n ${GENTOO_VER} ]] && \ |
| 18 | + GENTOO_PATCHSET_URI="https://dev.gentoo.org/~dlan/distfiles/${P}-gentoo-patches-${GENTOO_VER}.tar.xz" |
| 19 | +SRC_URI="https://github.com/${PN}/${PN}/releases/download/${PV}/${P}.tar.gz |
| 20 | + ${UPSTREAM_PATCHSET_URI} ${GENTOO_PATCHSET_URI}" |
| 21 | + |
| 22 | +LICENSE="LGPL-2.1" |
| 23 | +SLOT="0" |
| 24 | +KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86" |
| 25 | +IUSE="X appindicator +emoji gtk2 +gtk3 +gtk4 +gui +introspection libnotify nls +python systemd test +unicode vala wayland" |
| 26 | +RESTRICT="!test? ( test )" |
| 27 | +REQUIRED_USE=" |
| 28 | + appindicator? ( gtk3 ) |
| 29 | + python? ( |
| 30 | + ${PYTHON_REQUIRED_USE} |
| 31 | + introspection |
| 32 | + ) |
| 33 | + test? ( gtk3 ) |
| 34 | + vala? ( introspection ) |
| 35 | + X? ( gtk3 ) |
| 36 | +" |
| 37 | +DEPEND=" |
| 38 | + app-text/iso-codes |
| 39 | + >=dev-libs/glib-2.65.0:2 |
| 40 | + gnome-base/dconf |
| 41 | + gnome-base/librsvg:2 |
| 42 | + sys-apps/dbus[X?] |
| 43 | + X? ( |
| 44 | + x11-libs/libX11 |
| 45 | + >=x11-libs/libXfixes-6.0.0 |
| 46 | + ) |
| 47 | + gtk2? ( x11-libs/gtk+:2 ) |
| 48 | + gtk3? ( x11-libs/gtk+:3 ) |
| 49 | + gtk4? ( gui-libs/gtk:4 ) |
| 50 | + gui? ( |
| 51 | + x11-libs/libX11 |
| 52 | + x11-libs/libXi |
| 53 | + ) |
| 54 | + introspection? ( dev-libs/gobject-introspection ) |
| 55 | + libnotify? ( x11-libs/libnotify ) |
| 56 | + nls? ( virtual/libintl ) |
| 57 | + python? ( |
| 58 | + ${PYTHON_DEPS} |
| 59 | + dev-python/pygobject:3[${PYTHON_USEDEP}] |
| 60 | + ) |
| 61 | + wayland? ( |
| 62 | + dev-libs/wayland |
| 63 | + x11-libs/libxkbcommon |
| 64 | + )" |
| 65 | +RDEPEND="${DEPEND} |
| 66 | + python? ( |
| 67 | + gui? ( |
| 68 | + x11-libs/gtk+:3[introspection] |
| 69 | + ) |
| 70 | + )" |
| 71 | +BDEPEND=" |
| 72 | + $(vala_depend) |
| 73 | + dev-libs/glib:2 |
| 74 | + dev-util/glib-utils |
| 75 | + virtual/pkgconfig |
| 76 | + x11-misc/xkeyboard-config |
| 77 | + emoji? ( |
| 78 | + app-i18n/unicode-cldr |
| 79 | + app-i18n/unicode-emoji |
| 80 | + ) |
| 81 | + nls? ( sys-devel/gettext ) |
| 82 | + test? ( x11-apps/setxkbmap ) |
| 83 | + unicode? ( app-i18n/unicode-data )" |
| 84 | + |
| 85 | +src_prepare() { |
| 86 | + vala_src_prepare --ignore-use |
| 87 | + if ! has_version 'x11-libs/gtk+:3[wayland]'; then |
| 88 | + touch ui/gtk3/panelbinding.vala \ |
| 89 | + ui/gtk3/panel.vala \ |
| 90 | + ui/gtk3/emojierapp.vala || die |
| 91 | + fi |
| 92 | + if ! use emoji; then |
| 93 | + touch \ |
| 94 | + tools/main.vala \ |
| 95 | + ui/gtk3/panel.vala || die |
| 96 | + fi |
| 97 | + if ! use appindicator; then |
| 98 | + touch ui/gtk3/panel.vala || die |
| 99 | + fi |
| 100 | + |
| 101 | + if [[ -n ${UPSTREAM_VER} ]]; then |
| 102 | + einfo "Try to apply Upstream specific patch set" |
| 103 | + eapply "${WORKDIR}"/patches-upstream/*.patch |
| 104 | + fi |
| 105 | + |
| 106 | + if [[ -n ${GENTOO_VER} ]]; then |
| 107 | + einfo "Try to apply Gentoo specific patch set" |
| 108 | + eapply "${WORKDIR}"/patches-gentoo/*.patch |
| 109 | + fi |
| 110 | + |
| 111 | + # for multiple Python implementations |
| 112 | + sed -i "s/^\(PYGOBJECT_DIR =\).*/\1/" bindings/Makefile.am || die |
| 113 | + # fix for parallel install |
| 114 | + sed -i "/^if ENABLE_PYTHON2/,/^endif/d" bindings/pygobject/Makefile.am || die |
| 115 | + # require user interaction |
| 116 | + sed -i "/^TESTS_C += ibus-\(compose\|keypress\)/d" src/tests/Makefile.am || die |
| 117 | + |
| 118 | + sed -i "/^bash_completion/d" tools/Makefile.am || die |
| 119 | + |
| 120 | + default |
| 121 | + eautoreconf |
| 122 | + xdg_environment_reset |
| 123 | +} |
| 124 | + |
| 125 | +src_configure() { |
| 126 | + local unicodedir="${EPREFIX}"/usr/share/unicode |
| 127 | + local python_conf=() |
| 128 | + if use python; then |
| 129 | + python_setup |
| 130 | + python_conf+=( |
| 131 | + $(use_enable gui setup) |
| 132 | + --with-python=${EPYTHON} |
| 133 | + ) |
| 134 | + else |
| 135 | + python_conf+=( --disable-setup ) |
| 136 | + fi |
| 137 | + |
| 138 | + if tc-is-cross-compiler && { use emoji || use unicode; }; then |
| 139 | + mkdir -p "${S}-build" |
| 140 | + pushd "${S}-build" >/dev/null 2>&1 || die |
| 141 | + ECONF_SOURCE=${S} econf_build --enable-static \ |
| 142 | + --disable-{dconf,gtk{2,3},python-library,shared,xim} \ |
| 143 | + ISOCODES_{CFLAG,LIB}S=-DSKIP \ |
| 144 | + $(use_enable emoji emoji-dict) \ |
| 145 | + $(use_enable unicode unicode-dict) \ |
| 146 | + $(use_with unicode ucd-dir "${EPREFIX}/usr/share/unicode-data") |
| 147 | + popd >/dev/null 2>&1 || die |
| 148 | + fi |
| 149 | + |
| 150 | + local myconf=( |
| 151 | + $(use_enable X xim) |
| 152 | + $(use_enable appindicator) |
| 153 | + $(use_enable emoji emoji-dict) |
| 154 | + $(use_with emoji unicode-emoji-dir "${unicodedir}"/emoji) |
| 155 | + $(use_with emoji emoji-annotation-dir "${unicodedir}"/cldr/common/annotations) |
| 156 | + $(use_enable gtk2) |
| 157 | + $(use_enable gtk3) |
| 158 | + $(use_enable gtk4) |
| 159 | + $(use_enable gui ui) |
| 160 | + $(use_enable introspection) |
| 161 | + $(use_enable libnotify) |
| 162 | + $(use_enable nls) |
| 163 | + $(use_enable systemd systemd-services) |
| 164 | + $(use_enable test tests) |
| 165 | + $(use_enable unicode unicode-dict) |
| 166 | + $(use_with unicode ucd-dir "${EPREFIX}/usr/share/unicode-data") |
| 167 | + $(use_enable vala) |
| 168 | + $(use_enable wayland) |
| 169 | + "${python_conf[@]}" |
| 170 | + ) |
| 171 | + econf "${myconf[@]}" |
| 172 | +} |
| 173 | + |
| 174 | +src_compile() { |
| 175 | + if tc-is-cross-compiler && { use emoji || use unicode; }; then |
| 176 | + emake -C "${S}-build/src" \ |
| 177 | + $(usex emoji emoji-parser '') \ |
| 178 | + $(usex unicode unicode-parser '') |
| 179 | + emake -C src \ |
| 180 | + $(usex emoji emoji-parser '') \ |
| 181 | + $(usex unicode unicode-parser '') |
| 182 | + cp \ |
| 183 | + $(usex emoji "${S}-build/src/emoji-parser" '') \ |
| 184 | + $(usex unicode "${S}-build/src/unicode-parser" '') \ |
| 185 | + src || die |
| 186 | + fi |
| 187 | + emake |
| 188 | +} |
| 189 | + |
| 190 | +src_test() { |
| 191 | + unset DBUS_SESSION_BUS_ADDRESS |
| 192 | + virtx emake -j1 check |
| 193 | +} |
| 194 | + |
| 195 | +src_install() { |
| 196 | + default |
| 197 | + # Remove la files |
| 198 | + find "${ED}" -name '*.la' -delete || die |
| 199 | + |
| 200 | + # Remove stray python files generated by the build system |
| 201 | + find "${ED}" -name '*.pyc' -exec rm -f {} \; || die |
| 202 | + find "${ED}" -name '*.pyo' -exec rm -f {} \; || die |
| 203 | + |
| 204 | + if use python; then |
| 205 | + python_install() { |
| 206 | + emake -C bindings/pygobject \ |
| 207 | + pyoverridesdir="$(${EPYTHON} -c 'import gi; print(gi._overridesdir)')" \ |
| 208 | + DESTDIR="${D}" \ |
| 209 | + install |
| 210 | + |
| 211 | + python_optimize |
| 212 | + } |
| 213 | + python_foreach_impl python_install |
| 214 | + fi |
| 215 | + |
| 216 | + keepdir /usr/share/ibus/engine |
| 217 | + |
| 218 | + newbashcomp tools/${PN}.bash ${PN} |
| 219 | + |
| 220 | + insinto /etc/X11/xinit/xinput.d |
| 221 | + newins xinput-${PN} ${PN}.conf |
| 222 | + |
| 223 | + # Undo compression of man page |
| 224 | + find "${ED}"/usr/share/man -type f -name '*.gz' -exec gzip -d {} \; || die |
| 225 | +} |
| 226 | + |
| 227 | +pkg_postinst() { |
| 228 | + use gtk2 && gnome2_query_immodules_gtk2 |
| 229 | + use gtk3 && gnome2_query_immodules_gtk3 |
| 230 | + xdg_icon_cache_update |
| 231 | + gnome2_schemas_update |
| 232 | + dconf update |
| 233 | +} |
| 234 | + |
| 235 | +pkg_postrm() { |
| 236 | + use gtk2 && gnome2_query_immodules_gtk2 |
| 237 | + use gtk3 && gnome2_query_immodules_gtk3 |
| 238 | + xdg_icon_cache_update |
| 239 | + gnome2_schemas_update |
| 240 | +} |
0 commit comments