Advertisement
Guest User

Untitled

a guest
May 11th, 2024
81
0
144 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 161.40 KB | Source Code | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_S390=""
  4. declare -x ABI_X86="64"
  5. declare -x ADA_TARGET=""
  6. declare -x ALSA_CARDS=""
  7. declare -x AMDGPU_TARGETS=""
  8. declare -x ANT_HOME="/usr/share/ant"
  9. declare -x APACHE2_MODULES=""
  10. declare -x APACHE2_MPMS=""
  11. declare -x ARCH="amd64"
  12. declare BDEPEND="
  13.     || ( dev-lang/python:3.12[xml(+)] dev-lang/python:3.11[xml(+)] dev-lang/python:3.10[xml(+)] )
  14.     || (  ( dev-lang/ruby:3.1 virtual/rubygems[ruby_targets_ruby31(-)] ) ( dev-lang/ruby:3.2 virtual/rubygems[ruby_targets_ruby32(-)] ) ( dev-lang/ruby:3.3 virtual/rubygems[ruby_targets_ruby33(-)] ) )
  15.     >=app-accessibility/at-spi2-core-2.5.3
  16.     dev-util/gdbus-codegen
  17.     dev-util/glib-utils
  18.     >=dev-util/gperf-3.0.1
  19.     dev-util/unifdef
  20.     >=sys-devel/bison-2.4.3
  21.     || ( >=sys-devel/gcc-7.3 >=sys-devel/clang-5 )
  22.     sys-devel/gettext
  23.     virtual/pkgconfig
  24.  
  25.     >=dev-lang/perl-5.10
  26.     virtual/perl-Data-Dumper
  27.     virtual/perl-Carp
  28.     virtual/perl-JSON-PP
  29.  
  30.     wayland? ( dev-util/wayland-scanner )
  31. >=app-portage/elt-patches-20240116 app-arch/xz-utils app-alternatives/ninja >=dev-build/cmake-3.20.5"
  32. declare -x BINPKG_FORMAT="xpak"
  33. declare -x BINPKG_GPG_SIGNING_BASE_COMMAND="/usr/bin/flock /run/lock/portage-binpkg-gpg.lock /usr/bin/gpg --sign --armor [PORTAGE_CONFIG]"
  34. declare -x BINPKG_GPG_SIGNING_DIGEST="SHA512"
  35. declare -x BINPKG_GPG_VERIFY_BASE_COMMAND="/usr/bin/gpg --verify --batch --no-tty --no-auto-check-trustdb --status-fd 2 [PORTAGE_CONFIG] [SIGNATURE]"
  36. declare -x BINPKG_GPG_VERIFY_GPG_HOME="/etc/portage/gnupg"
  37. declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr xml python_targets_python3_11 python_single_target_python3_11 multilib zstd cet"
  38. declare -- BUILD_DIR="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/work/webkitgtk-2.44.1_build"
  39. declare -x CALLIGRA_FEATURES=""
  40. declare -x CAMERAS=""
  41. declare -x CBUILD="x86_64-pc-linux-gnu"
  42. declare -x CFLAGS="-O3 -march=haswell -pipe"
  43. declare -x CFLAGS_amd64="-m64"
  44. declare -x CFLAGS_default
  45. declare -x CFLAGS_x32="-mx32"
  46. declare -x CFLAGS_x86="-m32 -mfpmath=sse"
  47. declare -- CHECKREQS_DISK_BUILD="18G"
  48. declare -x CHOST="x86_64-pc-linux-gnu"
  49. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  50. declare -x CHOST_default="x86_64-pc-linux-gnu"
  51. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  52. declare -x CHOST_x86="i686-pc-linux-gnu"
  53. declare -- CMAKE_BINARY="cmake"
  54. declare -- CMAKE_BUILD_TYPE="RelWithDebInfo"
  55. declare -- CMAKE_MAKEFILE_GENERATOR="ninja"
  56. declare -a CMAKE_REMOVE_MODULES_LIST=([0]="FindBLAS" [1]="FindLAPACK")
  57. declare -- CMAKE_USE_DIR="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/work/webkitgtk-2.44.1"
  58. declare -- CMAKE_VERBOSE="ON"
  59. declare -- CMAKE_WARN_UNUSED_CLI="yes"
  60. declare -x COLLECTD_PLUGINS=""
  61. declare -x CPU_FLAGS_ARM=""
  62. declare -x CPU_FLAGS_PPC=""
  63. declare -x CPU_FLAGS_X86=""
  64. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  65. declare -x CURL_SSL=""
  66. declare -x CXXFLAGS="-O3 -march=haswell -pipe"
  67. declare -x DEFAULT_ABI="amd64"
  68. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare pretend setup test"
  69. declare DEPEND="
  70.     >=x11-libs/cairo-1.16.0[X?]
  71.     >=media-libs/fontconfig-2.13.0:1.0
  72.     >=media-libs/freetype-2.9.0:2
  73.     >=dev-libs/libgcrypt-1.7.0:0=
  74.     dev-libs/libtasn1:=
  75.     >=x11-libs/gtk+-3.22.0:3[aqua?,introspection?,wayland?,X?]
  76.     >=media-libs/harfbuzz-1.4.2:=[icu(+)]
  77.     >=dev-libs/icu-61.2:=
  78.     media-libs/libjpeg-turbo:0=
  79.     >=media-libs/libepoxy-1.5.4[egl(+)]
  80.     >=net-libs/libsoup-3.0.8:3.0[introspection?]
  81.     >=dev-libs/libxml2-2.8.0:2
  82.     >=media-libs/libpng-1.4:0=
  83.     dev-db/sqlite:3
  84.     sys-libs/zlib:0
  85.     media-libs/libwebp:=
  86.     >=app-accessibility/at-spi2-core-2.46.0:2
  87.  
  88.     >=dev-libs/glib-2.70.0:2
  89.     >=dev-libs/libxslt-1.1.7
  90.     media-libs/woff2
  91.     keyring? ( app-crypt/libsecret )
  92.     introspection? ( >=dev-libs/gobject-introspection-1.59.1:= )
  93.     x11-libs/libdrm
  94.     media-libs/mesa
  95.     spell? ( >=app-text/enchant-0.22:2 )
  96.     gstreamer? (
  97.         >=media-libs/gstreamer-1.20:1.0
  98.         >=media-libs/gst-plugins-base-1.20:1.0[egl,X?]
  99.         media-libs/gst-plugins-base:1.0[opengl]
  100.         >=media-plugins/gst-plugins-opus-1.20:1.0
  101.         >=media-libs/gst-plugins-bad-1.20:1.0
  102.     )
  103.  
  104.     X? ( x11-libs/libX11 )
  105.  
  106.     dev-libs/hyphen
  107.     jpegxl? ( >=media-libs/libjxl-0.7.0:= )
  108.     avif? ( >=media-libs/libavif-0.9.0:= )
  109.     lcms? ( media-libs/lcms:2 )
  110.  
  111.     media-libs/libglvnd
  112.     wayland? (
  113.         >=dev-libs/wayland-1.20
  114.         >=dev-libs/wayland-protocols-1.24
  115.     )
  116.  
  117.     seccomp? (
  118.         >=sys-apps/bubblewrap-0.3.1
  119.         sys-libs/libseccomp
  120.         sys-apps/xdg-dbus-proxy
  121.     )
  122.  
  123.     systemd? ( sys-apps/systemd:= )
  124.     gamepad? ( >=dev-libs/libmanette-0.2.4 )
  125.     !<net-libs/webkit-gtk-2.38:4
  126. "
  127. declare DESCRIPTION="Open source web browser engine"
  128. declare -- DESKTOP_DATABASE_DIR="/usr/share/applications"
  129. declare -x DIROPTIONS="-m0755"
  130. declare -x EAPI="8"
  131. declare -x ELIBC="glibc"
  132. declare -- ELTCONF=""
  133. declare -x ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
  134. declare -- EPOCHREALTIME="1715435914,262001"
  135. declare -- EPOCHSECONDS="1715435914"
  136. declare -x EPYTHON="python3.12"
  137. declare -x EXEOPTIONS="-m0755"
  138. declare -- E_IDEPEND="
  139.     dev-util/desktop-file-utils
  140.     x11-misc/shared-mime-info
  141. "
  142. declare -x FCFLAGS="-O2 -pipe"
  143. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  144. declare -x FFLAGS="-O2 -pipe"
  145. declare -x FFTOOLS=""
  146. declare -x GCC_SPECS=""
  147. declare -- GCONFTOOL_BIN="/usr/bin/gconftool-2"
  148. declare -- GLIB_COMPILE_RESOURCES="/usr/bin/glib-compile-resources"
  149. declare -- GLIB_COMPILE_SCHEMAS="/usr/bin/glib-compile-schemas"
  150. declare -- GNOME2_EAUTORECONF=""
  151. declare -- GNOME2_LA_PUNT=""
  152. declare -- GNOME_ORG_MODULE="webkit-gtk"
  153. declare -- GNOME_ORG_PV="2.44.1"
  154. declare -- GNOME_ORG_RELEASE="2.44"
  155. declare -- GNOME_TARBALL_SUFFIX="xz"
  156. declare -x GPG_VERIFY_GROUP_DROP="nogroup"
  157. declare -x GPG_VERIFY_USER_DROP="nobody"
  158. declare -x GPSD_PROTOCOLS=""
  159. declare -x GRUB_PLATFORMS=""
  160. declare -x GSETTINGS_BACKEND="memory"
  161. declare -x GST_REGISTRY="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/temp/registry.xml"
  162. declare -x G_HOME="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/temp"
  163. declare HOMEPAGE="https://www.webkitgtk.org"
  164. declare -x ICAROOT="/opt/Citrix/ICAClient"
  165. declare IDEPEND="
  166.     dev-util/desktop-file-utils
  167.     x11-misc/shared-mime-info
  168. "
  169. declare -x INHERITED=" check-reqs toolchain-funcs multilib flag-o-matic libtool gnome.org xdg-utils gnome2-utils xdg gnome2 optfeature multiprocessing python-utils-r1 python-any-r1 ruby-utils ruby-single ninja-utils cmake"
  170. declare -x INPUT_DEVICES=""
  171. declare -x INSOPTIONS="-m0644"
  172. declare IUSE="aqua avif examples gamepad keyring +gstreamer +introspection pdf jpegxl +jumbo-build lcms seccomp spell systemd wayland X "
  173. declare -x IUSE_EFFECTIVE="X abi_x86_64 alpha amd64 amd64-linux aqua arm arm64 arm64-macos avif elibc_Darwin elibc_SunOS elibc_bionic elibc_glibc elibc_mingw elibc_musl examples gamepad gstreamer hppa ia64 introspection jpegxl jumbo-build kernel_Darwin kernel_SunOS kernel_linux keyring lcms loong m68k mips pdf ppc ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack riscv s390 seccomp sparc spell systemd wayland x64-macos x64-solaris x86 x86-linux"
  174. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest prefix-stack"
  175. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  176. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  177. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  178. declare -x KERNEL="linux"
  179. declare -x KERNEL_ABI="amd64"
  180. declare -x KEYWORDS="amd64 arm arm64 ~loong ppc ppc64 ~riscv ~sparc x86"
  181. declare -x L10N=""
  182. declare -x LADSPA_PATH="/usr/lib64/ladspa"
  183. declare -x LANG="de_DE.utf8"
  184. declare -x LCD_DEVICES=""
  185. declare -x LC_COLLATE="C"
  186. declare -x LC_MESSAGES="C"
  187. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
  188. declare -x LDFLAGS_amd64="-m elf_x86_64"
  189. declare -x LDFLAGS_default
  190. declare -x LDFLAGS_x32="-m elf32_x86_64"
  191. declare -x LDFLAGS_x86="-m elf_i386"
  192. declare -x LEX="flex"
  193. declare -x LIBDIR_amd64="lib64"
  194. declare -x LIBDIR_default="lib"
  195. declare -x LIBDIR_x32="libx32"
  196. declare -x LIBDIR_x86="lib"
  197. declare -x LIBOPTIONS="-m0644"
  198. declare -x LIBREOFFICE_EXTENSIONS=""
  199. declare -x LICENSE="LGPL-2+ BSD"
  200. declare -x LINGUAS="de de_DE en en-GB en_GB ja_JP ja"
  201. declare -x LIRC_DEVICES="devinput inputlirc"
  202. declare -x LLVM_SLOT=""
  203. declare -x LLVM_TARGETS=""
  204. declare -x LUA_SINGLE_TARGET=""
  205. declare -x LUA_TARGETS=""
  206. declare -x LV2_PATH="/usr/lib64/lv2"
  207. declare -x MAKEOPTS="-j13"
  208. declare -x MANPAGER="manpager"
  209. declare -- MIMEINFO_DATABASE_DIR="/usr/share/mime"
  210. declare -x MONKEYD_PLUGINS=""
  211. declare -x MOZ_GMP_PATH="/usr/lib64/nsbrowser/plugins/gmp-gmpopenh264/system-installed"
  212. declare -x MULTILIB_ABIS="amd64 x86"
  213. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  214. declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
  215. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  216. declare -- MY_P="webkitgtk-2.44.1"
  217. declare -x NGINX_MODULES_HTTP=""
  218. declare -x NGINX_MODULES_MAIL=""
  219. declare -x NGINX_MODULES_STREAM=""
  220. declare -- NINJA="ninja"
  221. declare -- NINJA_DEPEND="app-alternatives/ninja"
  222. declare -- NINJA_VERBOSE="ON"
  223. declare -x NPM_CONFIG_GLOBALCONFIG="/etc/npm/npmrc"
  224. declare -x OFFICE_IMPLEMENTATION=""
  225. declare -x OPENCL_PROFILE="nvidia"
  226. declare -x OPENGL_PROFILE="xorg-x11"
  227. declare -x OPENMPI_FABRICS=""
  228. declare -x OPENMPI_OFED_FEATURES=""
  229. declare -x OPENMPI_RM=""
  230. declare -a PATCHES=()
  231. declare -x PATH="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/temp/python3.12/bin:/usr/lib/portage/python3.11/ebuild-helpers/xattr:/usr/lib/portage/python3.11/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/17/bin:/usr/lib/llvm/16/bin:/usr/lib/llvm/15/bin:/usr/lib/llvm/14/bin"
  232. declare PDEPEND=""
  233. declare -x PERL_FEATURES=""
  234. declare -x PHP_TARGETS=""
  235. declare -x PKG_CONFIG_PATH="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/temp/python3.12/pkgconfig"
  236. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  237. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  238. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  239. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/webkit-gtk-2.44.1-r410/html")
  240. declare -a PORTAGE_DOSTRIP=([0]="/")
  241. declare -a PORTAGE_DOSTRIP_SKIP=()
  242. declare -x PORTAGE_NICENESS="19"
  243. declare -x POSTGRES_TARGETS=""
  244. declare -x PROFILE_23_USRTYPE="split-usr"
  245. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL"
  246. declare -- PROPERTIES=""
  247. declare -x PYTHON="/usr/bin/python3.12"
  248. declare -x PYTHONDONTWRITEBYTECODE="1"
  249. declare -a PYTHON_COMPAT=([0]="python3_10" [1]="python3_11" [2]="python3_12")
  250. declare -- PYTHON_DEPS="|| ( dev-lang/python:3.12[xml(+)] dev-lang/python:3.11[xml(+)] dev-lang/python:3.10[xml(+)] )"
  251. declare -- PYTHON_REQUIRED_USE="I-DO-NOT-EXIST-IN-PYTHON-ANY-R1"
  252. declare -- PYTHON_REQ_USE="xml(+)"
  253. declare -x PYTHON_SINGLE_TARGET=""
  254. declare -x PYTHON_TARGETS=""
  255. declare -x QEMU_SOFTMMU_TARGETS=""
  256. declare -x QEMU_USER_TARGETS=""
  257. declare -x QT_GRAPHICSSYSTEM="raster"
  258. declare RDEPEND="
  259.     >=x11-libs/cairo-1.16.0[X?]
  260.     >=media-libs/fontconfig-2.13.0:1.0
  261.     >=media-libs/freetype-2.9.0:2
  262.     >=dev-libs/libgcrypt-1.7.0:0=
  263.     dev-libs/libtasn1:=
  264.     >=x11-libs/gtk+-3.22.0:3[aqua?,introspection?,wayland?,X?]
  265.     >=media-libs/harfbuzz-1.4.2:=[icu(+)]
  266.     >=dev-libs/icu-61.2:=
  267.     media-libs/libjpeg-turbo:0=
  268.     >=media-libs/libepoxy-1.5.4[egl(+)]
  269.     >=net-libs/libsoup-3.0.8:3.0[introspection?]
  270.     >=dev-libs/libxml2-2.8.0:2
  271.     >=media-libs/libpng-1.4:0=
  272.     dev-db/sqlite:3
  273.     sys-libs/zlib:0
  274.     media-libs/libwebp:=
  275.     >=app-accessibility/at-spi2-core-2.46.0:2
  276.  
  277.     >=dev-libs/glib-2.70.0:2
  278.     >=dev-libs/libxslt-1.1.7
  279.     media-libs/woff2
  280.     keyring? ( app-crypt/libsecret )
  281.     introspection? ( >=dev-libs/gobject-introspection-1.59.1:= )
  282.     x11-libs/libdrm
  283.     media-libs/mesa
  284.     spell? ( >=app-text/enchant-0.22:2 )
  285.     gstreamer? (
  286.         >=media-libs/gstreamer-1.20:1.0
  287.         >=media-libs/gst-plugins-base-1.20:1.0[egl,X?]
  288.         media-libs/gst-plugins-base:1.0[opengl]
  289.         >=media-plugins/gst-plugins-opus-1.20:1.0
  290.         >=media-libs/gst-plugins-bad-1.20:1.0
  291.     )
  292.  
  293.     X? ( x11-libs/libX11 )
  294.  
  295.     dev-libs/hyphen
  296.     jpegxl? ( >=media-libs/libjxl-0.7.0:= )
  297.     avif? ( >=media-libs/libavif-0.9.0:= )
  298.     lcms? ( media-libs/lcms:2 )
  299.  
  300.     media-libs/libglvnd
  301.     wayland? (
  302.         >=dev-libs/wayland-1.20
  303.         >=dev-libs/wayland-protocols-1.24
  304.     )
  305.  
  306.     seccomp? (
  307.         >=sys-apps/bubblewrap-0.3.1
  308.         sys-libs/libseccomp
  309.         sys-apps/xdg-dbus-proxy
  310.     )
  311.  
  312.     systemd? ( sys-apps/systemd:= )
  313.     gamepad? ( >=dev-libs/libmanette-0.2.4 )
  314.     !<net-libs/webkit-gtk-2.38:4
  315. "
  316. declare REPOSITORY
  317. declare REQUIRED_USE="|| ( aqua wayland X ) "
  318. declare RESTRICT="test"
  319. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  320. declare -- RUBY_DEPS="|| (  ( dev-lang/ruby:3.1 virtual/rubygems[ruby_targets_ruby31(-)] ) ( dev-lang/ruby:3.2 virtual/rubygems[ruby_targets_ruby32(-)] ) ( dev-lang/ruby:3.3 virtual/rubygems[ruby_targets_ruby33(-)] ) )"
  321. declare -x RUBY_TARGETS=""
  322. declare -- RUBY_TARGETS_PREFERENCE="ruby31 ruby32 ruby33"
  323. declare -x S="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/work/webkitgtk-2.44.1"
  324. declare -x SANDBOX_DEBUG="0"
  325. declare -x SANDBOX_DENY=""
  326. declare -x SANDBOX_METHOD="any"
  327. declare -x SANDBOX_PREDICT="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir:/dev/crypto:/var/cache/man:/dev/nvidiactl:/dev/nvidia-caps:/dev/char:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  328. declare -x SANDBOX_READ="/:/tmp/portage"
  329. declare -x SANDBOX_VERBOSE="1"
  330. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/tmp/portage:/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir/.bash_history:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp/"
  331. declare -x SANE_BACKENDS=""
  332. declare -- SCROLLKEEPER_DIR="/var/lib/scrollkeeper"
  333. declare -- SCROLLKEEPER_UPDATE_BIN="/usr/bin/scrollkeeper-update"
  334. declare -x SHELL="/bin/bash"
  335. declare -x SLOT="4.1/0"
  336. declare -i SRANDOM="1547163946"
  337. declare SRC_URI="https://www.webkitgtk.org/releases/webkitgtk-2.44.1.tar.xz"
  338. declare -x SYMLINK_LIB="no"
  339. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  340. declare -x USE="X abi_x86_64 amd64 elibc_glibc gstreamer introspection jumbo-build kernel_linux lcms pdf seccomp spell"
  341. declare -x USERLAND="GNU"
  342. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL"
  343. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  344. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-linux arm arm64 arm64-macos hppa ia64 loong m68k mips ppc ppc64 ppc64-linux ppc-macos riscv s390 sparc x64-macos x64-solaris x86 x86-linux"
  345. declare -x USE_EXPAND_VALUES_ELIBC="bionic Darwin glibc mingw musl SunOS"
  346. declare -x USE_EXPAND_VALUES_KERNEL="Darwin linux SunOS"
  347. declare -- USE_RUBY="ruby31 ruby32 ruby33"
  348. declare -x UWSGI_PLUGINS=""
  349. declare -x VBOX_APP_HOME="/usr/lib64/virtualbox"
  350. declare -x VBOX_INSTALL_PATH="/usr/lib64/virtualbox"
  351. declare -x VBOX_SDK_PATH="/usr/lib64/virtualbox/sdk"
  352. declare -x VIDEO_CARDS=""
  353. declare -x VOICEMAIL_STORAGE=""
  354. declare -x XDG_CACHE_HOME="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir/.cache"
  355. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  356. declare -x XDG_CONFIG_HOME="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir/.config"
  357. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  358. declare -x XDG_DATA_HOME="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir/.local/share"
  359. declare -x XDG_RUNTIME_DIR="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/temp/run"
  360. declare -x XDG_STATE_HOME="/tmp/portage/net-libs/webkit-gtk-2.44.1-r410/homedir/.local/state"
  361. declare -x XTABLES_ADDONS=""
  362. declare -- _CHECK_REQS_ECLASS="1"
  363. declare -- _CMAKE_ECLASS="1"
  364. declare -- _CMAKE_SRC_PREPARE_HAS_RUN="1"
  365. declare -- _FLAG_O_MATIC_ECLASS="1"
  366. declare -- _GNOME2_ECLASS="1"
  367. declare -- _GNOME_ORG_ECLASS="1"
  368. declare -- _LIBTOOL_ECLASS="1"
  369. declare -- _MULTILIB_ECLASS="1"
  370. declare -- _MULTIPROCESSING_ECLASS="1"
  371. declare -- _NINJA_UTILS_ECLASS="1"
  372. declare -- _OPTFEATURE_DEFAULT_HEADER="Install additional packages for optional runtime features:"
  373. declare -- _OPTFEATURE_DOHEADER="true"
  374. declare -- _OPTFEATURE_ECLASS="1"
  375. declare -- _OPTFEATURE_HEADER=""
  376. declare -a _PYTHON_ALL_IMPLS=([0]="pypy3" [1]="python3_10" [2]="python3_11" [3]="python3_12" [4]="python3_13")
  377. declare -- _PYTHON_ANY_R1_ECLASS="1"
  378. declare -a _PYTHON_HISTORICAL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy1_8" [3]="pypy1_9" [4]="pypy2_0" [5]="python2_5" [6]="python2_6" [7]="python2_7" [8]="python3_1" [9]="python3_2" [10]="python3_3" [11]="python3_4" [12]="python3_5" [13]="python3_6" [14]="python3_7" [15]="python3_8" [16]="python3_9")
  379. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python3_10" [1]="python3_11" [2]="python3_12")
  380. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="pypy3" [1]="python3_13")
  381. declare -- _PYTHON_UTILS_R1_ECLASS="1"
  382. declare -- _RUBY_SINGLE_ECLASS="1"
  383. declare -- _RUBY_UTILS="1"
  384. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  385. declare -- _XDG_ECLASS="1"
  386. declare -x __E_DESTTREE="/usr"
  387. declare -x __E_DOCDESTTREE=""
  388. declare -x __E_EXEDESTTREE=""
  389. declare -x __E_INSDESTTREE=""
  390. declare -x ac_cv_c_undeclared_builtin_options="none needed"
  391. declare -x enable_year2038="no"
  392. declare -x gl_cv_compiler_check_decl_option="-Werror=implicit-function-declaration"
  393. declare -x gl_cv_func_getcwd_path_max="yes"
  394. __eapi6_src_install ()
  395. {
  396.     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  397.         emake DESTDIR="${D}" install;
  398.     fi;
  399.     einstalldocs
  400. }
  401. __eapi6_src_prepare ()
  402. {
  403.     if ___is_indexed_array_var PATCHES; then
  404.         [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  405.     else
  406.         if [[ -n ${PATCHES} ]]; then
  407.             eapply ${PATCHES};
  408.         fi;
  409.     fi;
  410.     eapply_user
  411. }
  412. __eapi7_ver_compare ()
  413. {
  414.     local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  415.     re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  416.     [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  417.     an=${BASH_REMATCH[1]};
  418.     al=${BASH_REMATCH[3]};
  419.     as=${BASH_REMATCH[4]};
  420.     ar=${BASH_REMATCH[7]};
  421.     [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  422.     bn=${BASH_REMATCH[1]};
  423.     bl=${BASH_REMATCH[3]};
  424.     bs=${BASH_REMATCH[4]};
  425.     br=${BASH_REMATCH[7]};
  426.     __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  427.     while [[ ${an} == *.* && ${bn} == *.* ]]; do
  428.         an=${an#*.};
  429.         bn=${bn#*.};
  430.         a=${an%%.*};
  431.         b=${bn%%.*};
  432.         if [[ ${a} == 0* || ${b} == 0* ]]; then
  433.             [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  434.            [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  435.             [[ ${a} > ${b} ]] && return 3;
  436.             [[ ${a} < ${b} ]] && return 1;
  437.         else
  438.             __eapi7_ver_compare_int "${a}" "${b}" || return;
  439.         fi;
  440.     done;
  441.     [[ ${an} == *.* ]] && return 3;
  442.     [[ ${bn} == *.* ]] && return 1;
  443.     [[ ${al} > ${bl} ]] && return 3;
  444.     [[ ${al} < ${bl} ]] && return 1;
  445.     as=${as#_}${as:+_};
  446.     bs=${bs#_}${bs:+_};
  447.     while [[ -n ${as} && -n ${bs} ]]; do
  448.         a=${as%%_*};
  449.         b=${bs%%_*};
  450.         if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  451.             __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  452.         else
  453.             [[ ${a%%[0-9]*} == p ]] && return 3;
  454.             [[ ${b%%[0-9]*} == p ]] && return 1;
  455.             [[ ${a} > ${b} ]] && return 3 || return 1;
  456.         fi;
  457.         as=${as#*_};
  458.         bs=${bs#*_};
  459.     done;
  460.     if [[ -n ${as} ]]; then
  461.         [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  462.     else
  463.         if [[ -n ${bs} ]]; then
  464.             [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  465.         fi;
  466.     fi;
  467.     __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  468.     return 2
  469. }
  470. __eapi7_ver_compare_int ()
  471. {
  472.     local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  473.     if [[ ${d} -gt 0 ]]; then
  474.         printf -v b "%0${d}d%s" 0 "${b}";
  475.     else
  476.         if [[ ${d} -lt 0 ]]; then
  477.             printf -v a "%0$(( -d ))d%s" 0 "${a}";
  478.         fi;
  479.     fi;
  480.     [[ ${a} > ${b} ]] && return 3;
  481.     [[ ${a} == "${b}" ]]
  482. }
  483. __eapi7_ver_parse_range ()
  484. {
  485.     local range=${1};
  486.     local max=${2};
  487.     [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  488.     start=${range%-*};
  489.     [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  490.     if [[ -n ${end} ]]; then
  491.         [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  492.         [[ ${end} -le ${max} ]] || end=${max};
  493.     else
  494.         end=${max};
  495.     fi
  496. }
  497. __eapi7_ver_split ()
  498. {
  499.     local v=${1} LC_ALL=C;
  500.     comp=();
  501.     local s c;
  502.     while [[ -n ${v} ]]; do
  503.         s=${v%%[a-zA-Z0-9]*};
  504.         v=${v:${#s}};
  505.         [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  506.         v=${v:${#c}};
  507.         comp+=("${s}" "${c}");
  508.     done
  509. }
  510. __eapi8_src_prepare ()
  511. {
  512.     local f;
  513.     if ___is_indexed_array_var PATCHES; then
  514.         [[ ${#PATCHES[@]} -gt 0 ]] && eapply -- "${PATCHES[@]}";
  515.     else
  516.         if [[ -n ${PATCHES} ]]; then
  517.             eapply -- ${PATCHES};
  518.         fi;
  519.     fi;
  520.     eapply_user
  521. }
  522. _check-reqs_disk ()
  523. {
  524.     debug-print-function ${FUNCNAME} "$@";
  525.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [path] [size]";
  526.     local path=${1};
  527.     local size=${2};
  528.     local space_kbi;
  529.     _check-reqs_start_phase ${size} "disk space at \"${path}\"";
  530.     space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}');
  531.     if [[ $? == 0 && -n ${space_kbi} ]]; then
  532.         if [[ ${space_kbi} -lt $(_check-reqs_get_kibibytes ${size}) ]]; then
  533.             eend 1;
  534.             _check-reqs_unsatisfied ${size} "disk space at \"${path}\"";
  535.         else
  536.             eend 0;
  537.         fi;
  538.     else
  539.         eend 1;
  540.         ewarn "Couldn't determine disk space, skipping...";
  541.     fi
  542. }
  543. _check-reqs_get_kibibytes ()
  544. {
  545.     debug-print-function ${FUNCNAME} "$@";
  546.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  547.     local unit=${1:(-1)};
  548.     local size=${1%[GMT]};
  549.     case ${unit} in
  550.         M)
  551.             echo $((1024 * size))
  552.         ;;
  553.         G)
  554.             echo $((1024 * 1024 * size))
  555.         ;;
  556.         T)
  557.             echo $((1024 * 1024 * 1024 * size))
  558.         ;;
  559.         *)
  560.             die "${FUNCNAME}: Unknown unit: ${unit}"
  561.         ;;
  562.     esac
  563. }
  564. _check-reqs_get_number ()
  565. {
  566.     debug-print-function ${FUNCNAME} "$@";
  567.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  568.     local size=${1%[GMT]};
  569.     [[ ${size} == ${1} ]] && die "${FUNCNAME}: Missing unit: ${1}";
  570.     echo ${size}
  571. }
  572. _check-reqs_get_unit ()
  573. {
  574.     debug-print-function ${FUNCNAME} "$@";
  575.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  576.     local unit=${1:(-1)};
  577.     case ${unit} in
  578.         M)
  579.             echo "MiB"
  580.         ;;
  581.         G)
  582.             echo "GiB"
  583.         ;;
  584.         T)
  585.             echo "TiB"
  586.         ;;
  587.         *)
  588.             die "${FUNCNAME}: Unknown unit: ${unit}"
  589.         ;;
  590.     esac
  591. }
  592. _check-reqs_memory ()
  593. {
  594.     debug-print-function ${FUNCNAME} "$@";
  595.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  596.     local size=${1};
  597.     local actual_memory;
  598.     local actual_swap;
  599.     _check-reqs_start_phase ${size} "RAM";
  600.     if [[ -r /proc/meminfo ]]; then
  601.         actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo);
  602.         actual_swap=$(awk '/SwapTotal/ { print $2 }' /proc/meminfo);
  603.     else
  604.         actual_memory=$(sysctl hw.physmem 2>/dev/null);
  605.         [[ $? -eq 0 ]] && actual_memory=$(echo "${actual_memory}"           | sed -e 's/^[^:=]*[:=][[:space:]]*//');
  606.         actual_swap=$(sysctl vm.swap_total 2>/dev/null);
  607.         [[ $? -eq 0 ]] && actual_swap=$(echo "${actual_swap}"           | sed -e 's/^[^:=]*[:=][[:space:]]*//');
  608.     fi;
  609.     if [[ -n ${actual_memory} ]]; then
  610.         if [[ ${actual_memory} -ge $(_check-reqs_get_kibibytes ${size}) ]]; then
  611.             eend 0;
  612.         else
  613.             if [[ -n ${actual_swap} && $((${actual_memory} + ${actual_swap})) -ge $(_check-reqs_get_kibibytes ${size}) ]]; then
  614.                 ewarn "Amount of main memory is insufficient, but amount";
  615.                 ewarn "of main memory combined with swap is sufficient.";
  616.                 ewarn "Build process may make computer very slow!";
  617.                 eend 0;
  618.             else
  619.                 eend 1;
  620.                 _check-reqs_unsatisfied ${size} "RAM";
  621.             fi;
  622.         fi;
  623.     else
  624.         eend 1;
  625.         ewarn "Couldn't determine amount of memory, skipping...";
  626.     fi
  627. }
  628. _check-reqs_output ()
  629. {
  630.     debug-print-function ${FUNCNAME} "$@";
  631.     local msg="ewarn";
  632.     [[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror";
  633.     if [[ -n ${CHECKREQS_FAILED} ]]; then
  634.         ${msg};
  635.         ${msg} "Memory or space constraints set in the ebuild were not met!";
  636.         ${msg} "The build will most probably fail, you should:";
  637.         ${msg} "- enhance the memory (reduce MAKEOPTS, add swap), or";
  638.         ${msg} "- add more space";
  639.         ${msg} "as required depending on the failed tests.";
  640.         ${msg};
  641.         [[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && die "Build requirements not met!";
  642.     fi
  643. }
  644. _check-reqs_prepare ()
  645. {
  646.     debug-print-function ${FUNCNAME} "$@";
  647.     if [[ -z ${CHECKREQS_MEMORY} && -z ${CHECKREQS_DISK_BUILD} && -z ${CHECKREQS_DISK_USR} && -z ${CHECKREQS_DISK_VAR} ]]; then
  648.         eerror "Set some check-reqs eclass variables if you want to use it.";
  649.         eerror "If you are user and see this message file a bug against the package.";
  650.         die "${FUNCNAME}: check-reqs eclass called but not actually used!";
  651.     fi
  652. }
  653. _check-reqs_run ()
  654. {
  655.     debug-print-function ${FUNCNAME} "$@";
  656.     unset CHECKREQS_FAILED;
  657.     if [[ ${MERGE_TYPE} != binary ]]; then
  658.         [[ -n ${CHECKREQS_MEMORY} ]] && _check-reqs_memory ${CHECKREQS_MEMORY};
  659.         [[ -n ${CHECKREQS_DISK_BUILD} ]] && _check-reqs_disk "${T}" "${CHECKREQS_DISK_BUILD}";
  660.     fi;
  661.     if [[ ${MERGE_TYPE} != buildonly ]]; then
  662.         [[ -n ${CHECKREQS_DISK_USR} ]] && _check-reqs_disk "${EROOT%/}/usr" "${CHECKREQS_DISK_USR}";
  663.         [[ -n ${CHECKREQS_DISK_VAR} ]] && _check-reqs_disk "${EROOT%/}/var" "${CHECKREQS_DISK_VAR}";
  664.     fi
  665. }
  666. _check-reqs_start_phase ()
  667. {
  668.     debug-print-function ${FUNCNAME} "$@";
  669.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]";
  670.     local size=${1};
  671.     local location=${2};
  672.     local sizeunit="$(_check-reqs_get_number ${size}) $(_check-reqs_get_unit ${size})";
  673.     ebegin "Checking for at least ${sizeunit} ${location}"
  674. }
  675. _check-reqs_unsatisfied ()
  676. {
  677.     debug-print-function ${FUNCNAME} "$@";
  678.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]";
  679.     local msg="ewarn";
  680.     local size=${1};
  681.     local location=${2};
  682.     local sizeunit="$(_check-reqs_get_number ${size}) $(_check-reqs_get_unit ${size})";
  683.     [[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror";
  684.     ${msg} "There is NOT at least ${sizeunit} ${location}";
  685.     CHECKREQS_FAILED="true"
  686. }
  687. _clang_fullversion ()
  688. {
  689.     local ver="$1";
  690.     shift;
  691.     set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  692.     eval echo "${ver}"
  693. }
  694. _cmake_banned_func ()
  695. {
  696.     die "${FUNCNAME[1]} is banned. use -D$1<related_CMake_variable>=\"\$(usex $2)\" instead"
  697. }
  698. _cmake_check_build_dir ()
  699. {
  700.     if [[ ${EAPI} == 7 ]]; then
  701.         : "${CMAKE_USE_DIR:=${S}}";
  702.     else
  703.         : "${CMAKE_USE_DIR:=${PWD}}";
  704.     fi;
  705.     if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  706.         BUILD_DIR="${CMAKE_USE_DIR}";
  707.     else
  708.         : "${BUILD_DIR:=${CMAKE_USE_DIR}_build}";
  709.         if [[ ${S} == "${WORKDIR}" && ${BUILD_DIR} == "${WORKDIR}_build" ]]; then
  710.             eqawarn "QA notice: S=WORKDIR is deprecated for cmake.eclass.";
  711.             eqawarn "Please relocate the sources in src_unpack.";
  712.             BUILD_DIR="${WORKDIR}"/${P}_build;
  713.         fi;
  714.     fi;
  715.     einfo "Source directory (CMAKE_USE_DIR): \"${CMAKE_USE_DIR}\"";
  716.     einfo "Build directory  (BUILD_DIR):     \"${BUILD_DIR}\"";
  717.     mkdir -p "${BUILD_DIR}" || die
  718. }
  719. _cmake_modify-cmakelists ()
  720. {
  721.     debug-print-function ${FUNCNAME} "$@";
  722.     grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0;
  723.     find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' -i {} + || die "${LINENO}: failed to disable hardcoded settings";
  724.     local x;
  725.     for x in $(find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec grep -l "^#_cmake_modify_IGNORE" {} +;);
  726.     do
  727.         einfo "Hardcoded definition(s) removed in $(echo "${x}" | cut -c $((${#CMAKE_USE_DIR}+2))-):";
  728.         einfo "$(grep -se '^#_cmake_modify_IGNORE' ${x} | cut -c 22-99)";
  729.     done;
  730.     cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<-_EOF_ ||
  731.  
  732. message(STATUS "<<< Gentoo configuration >>>
  733. Build type      \${CMAKE_BUILD_TYPE}
  734. Install path    \${CMAKE_INSTALL_PREFIX}
  735. Compiler flags:
  736. C               \${CMAKE_C_FLAGS}
  737. C++             \${CMAKE_CXX_FLAGS}
  738. Linker flags:
  739. Executable      \${CMAKE_EXE_LINKER_FLAGS}
  740. Module          \${CMAKE_MODULE_LINKER_FLAGS}
  741. Shared          \${CMAKE_SHARED_LINKER_FLAGS}\n")
  742. _EOF_
  743.  die
  744. }
  745. _eapply_patch ()
  746. {
  747.     local f=${1};
  748.     local prefix=${2};
  749.     ebegin "${prefix:-Applying }${f##*/}";
  750.     local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  751.     if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  752.         all_opts+=(-s -F0);
  753.     fi;
  754.     ${patch_cmd} "${all_opts[@]}" < "${f}";
  755.     failed=${?};
  756.     if ! eend "${failed}"; then
  757.         __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  758.     fi
  759. }
  760. _filter-hardened ()
  761. {
  762.     local f;
  763.     for f in "$@";
  764.     do
  765.         case "${f}" in
  766.             -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  767.                 if ! gcc-specs-pie && ! tc-enables-pie; then
  768.                     continue;
  769.                 fi;
  770.                 if ! is-flagq -nopie && ! is-flagq -no-pie; then
  771.                     if test-flags -nopie > /dev/null; then
  772.                         append-flags -nopie;
  773.                     else
  774.                         append-flags -no-pie;
  775.                     fi;
  776.                 fi
  777.             ;;
  778.             -fstack-protector | -fstack-protector-strong)
  779.                 if ! gcc-specs-ssp && ! tc-enables-ssp && ! tc-enables-ssp-strong; then
  780.                     continue;
  781.                 fi;
  782.                 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  783.             ;;
  784.             -fstack-protector-all)
  785.                 if ! gcc-specs-ssp-to-all && ! tc-enables-ssp-all; then
  786.                     continue;
  787.                 fi;
  788.                 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  789.             ;;
  790.             -fno-strict-overflow)
  791.                 gcc-specs-nostrict || continue;
  792.                 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  793.             ;;
  794.             -D_GLIBCXX_ASSERTIONS | -D_LIBCPP_ENABLE_ASSERTIONS | -D_LIBCPP_ENABLE_HARDENED_MODE)
  795.                 tc-enables-cxx-assertions || continue;
  796.                 append-cppflags -U_GLIBCXX_ASSERTIONS -U_LIBCPP_ENABLE_ASSERTIONS -U_LIBCPP_ENABLE_HARDENED_MODE
  797.             ;;
  798.             -D_FORTIFY_SOURCE=*)
  799.                 tc-enables-fortify-source || continue;
  800.                 append-cppflags -U_FORTIFY_SOURCE
  801.             ;;
  802.         esac;
  803.     done
  804. }
  805. _filter-var ()
  806. {
  807.     local f x var=$1 new=();
  808.     shift;
  809.     for f in ${!var};
  810.     do
  811.         for x in "$@";
  812.         do
  813.             [[ ${f} == ${x} ]] && continue 2;
  814.         done;
  815.         new+=("${f}");
  816.     done;
  817.     export ${var}="${new[*]}"
  818. }
  819. _gcc-install-dir ()
  820. {
  821.     echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |      awk '$1=="install:" {print $2}')"
  822. }
  823. _gcc-specs-directive_raw ()
  824. {
  825.     local cc=$(tc-getCC);
  826.     local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  827.     ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  828. $1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
  829.     outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  830.     spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  831.     { spec=spec $0 }
  832. END { print spec }';
  833.     return 0
  834. }
  835. _gcc-specs-exists ()
  836. {
  837.     [[ -f $(_gcc-install-dir)/$1 ]]
  838. }
  839. _gcc_fullversion ()
  840. {
  841.     local ver="$1";
  842.     shift;
  843.     set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  844.     eval echo "${ver}"
  845. }
  846. _get_all_makeopts ()
  847. {
  848.     echo "${MAKEOPTS} ${GNUMAKEFLAGS} ${MAKEFLAGS}"
  849. }
  850. _is_flagq ()
  851. {
  852.     local x var="$1[*]";
  853.     for x in ${!var};
  854.     do
  855.         [[ ${x} == $2 ]] && return 0;
  856.     done;
  857.     return 1
  858. }
  859. _python_check_EPYTHON ()
  860. {
  861.     if [[ -z ${EPYTHON} ]]; then
  862.         die "EPYTHON unset, invalid call context";
  863.     fi
  864. }
  865. _python_check_locale_sanity ()
  866. {
  867.     local -x LC_ALL=${1};
  868.     local IFS=;
  869.     local lc=({a..z});
  870.     local uc=({A..Z});
  871.     local input="${lc[*]}${uc[*]}";
  872.     local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  873.     [[ ${output} == "${uc[*]}${lc[*]}" ]]
  874. }
  875. _python_check_occluded_packages ()
  876. {
  877.     debug-print-function ${FUNCNAME} "${@}";
  878.     [[ -z ${BUILD_DIR} || ! -d ${BUILD_DIR}/install ]] && return;
  879.     local sitedir="${BUILD_DIR}/install$(python_get_sitedir)";
  880.     [[ ${sitedir} -ef . ]] && return;
  881.     local f fn diff l;
  882.     for f in "${sitedir}"/*/;
  883.     do
  884.         f=${f%/};
  885.         fn=${f##*/};
  886.         [[ ${fn} == *.dist-info || ${fn} == *.egg-info ]] && continue;
  887.         if [[ -d ${fn} ]]; then
  888.             diff=$(
  889.                 comm -1 -3 <(
  890.                     find "${fn}" -type f -not -path '*/__pycache__/*' |
  891.                         sort
  892.                     assert
  893.                 ) <(
  894.                     cd "${sitedir}" &&
  895.                         find "${fn}" -type f -not -path '*/__pycache__/*' |
  896.                         sort
  897.                     assert
  898.                 )
  899.             );
  900.             if [[ -n ${diff} ]]; then
  901.                 eqawarn "The directory ${fn} occludes package installed for ${EPYTHON}.";
  902.                 eqawarn "The installed package includes additional files:";
  903.                 eqawarn;
  904.                 while IFS= read -r l; do
  905.                     eqawarn "    ${l}";
  906.                 done <<< "${diff}";
  907.                 eqawarn;
  908.                 if [[ ! -n ${_PYTHON_WARNED_OCCLUDED_PACKAGES} ]]; then
  909.                     eqawarn "For more information on occluded packages, please see:";
  910.                     eqawarn "https://projects.gentoo.org/python/guide/test.html#importerrors-for-c-extensions";
  911.                     _PYTHON_WARNED_OCCLUDED_PACKAGES=1;
  912.                 fi;
  913.             fi;
  914.         fi;
  915.     done
  916. }
  917. _python_export ()
  918. {
  919.     debug-print-function ${FUNCNAME} "${@}";
  920.     local impl var;
  921.     case "${1}" in
  922.         python* | jython*)
  923.             impl=${1/_/.};
  924.             shift
  925.         ;;
  926.         pypy | pypy3)
  927.             impl=${1};
  928.             shift
  929.         ;;
  930.         *)
  931.             impl=${EPYTHON};
  932.             if [[ -z ${impl} ]]; then
  933.                 die "_python_export called without a python implementation and EPYTHON is unset";
  934.             fi
  935.         ;;
  936.     esac;
  937.     debug-print "${FUNCNAME}: implementation: ${impl}";
  938.     for var in "$@";
  939.     do
  940.         case "${var}" in
  941.             EPYTHON)
  942.                 export EPYTHON=${impl};
  943.                 debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  944.             ;;
  945.             PYTHON)
  946.                 export PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl};
  947.                 debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  948.             ;;
  949.             PYTHON_SITEDIR)
  950.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  951.                 PYTHON_SITEDIR=$(
  952.                     "${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
  953.                         import sys, sysconfig
  954.                         print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
  955.                     EOF
  956.                 );
  957.                 export PYTHON_SITEDIR;
  958.                 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  959.             ;;
  960.             PYTHON_INCLUDEDIR)
  961.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  962.                 PYTHON_INCLUDEDIR=$(
  963.                     "${PYTHON}" - "${ESYSROOT}/usr" <<-EOF || die
  964.                         import sys, sysconfig
  965.                         print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
  966.                     EOF
  967.                 );
  968.                 export PYTHON_INCLUDEDIR;
  969.                 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  970.                 if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  971.                     die "${impl} does not install any header files!";
  972.                 fi
  973.             ;;
  974.             PYTHON_LIBPATH)
  975.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  976.                 PYTHON_LIBPATH=$(
  977.                     "${PYTHON}" - <<-EOF || die
  978.                         import os.path, sysconfig
  979.                         print(
  980.                             os.path.join(
  981.                                 sysconfig.get_config_var("LIBDIR"),
  982.                                 sysconfig.get_config_var("LDLIBRARY"))
  983.                             if sysconfig.get_config_var("LDLIBRARY")
  984.                             else "")
  985.                     EOF
  986.                 );
  987.                 export PYTHON_LIBPATH;
  988.                 debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  989.                 if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  990.                     die "${impl} lacks a (usable) dynamic library";
  991.                 fi
  992.             ;;
  993.             PYTHON_CFLAGS)
  994.                 local val;
  995.                 case "${impl}" in
  996.                     python*)
  997.                         val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  998.                     ;;
  999.                     *)
  1000.                         die "${impl}: obtaining ${var} not supported"
  1001.                     ;;
  1002.                 esac;
  1003.                 export PYTHON_CFLAGS=${val};
  1004.                 debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  1005.             ;;
  1006.             PYTHON_LIBS)
  1007.                 local val;
  1008.                 case "${impl}" in
  1009.                     python*)
  1010.                         val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}-embed) || die
  1011.                     ;;
  1012.                     *)
  1013.                         die "${impl}: obtaining ${var} not supported"
  1014.                     ;;
  1015.                 esac;
  1016.                 export PYTHON_LIBS=${val};
  1017.                 debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  1018.             ;;
  1019.             PYTHON_CONFIG)
  1020.                 local flags val;
  1021.                 case "${impl}" in
  1022.                     python*)
  1023.                         [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  1024.                         flags=$(
  1025.                             "${PYTHON}" - <<-EOF || die
  1026.                                 import sysconfig
  1027.                                 print(sysconfig.get_config_var("ABIFLAGS")
  1028.                                     or "")
  1029.                             EOF
  1030.                         );
  1031.                         val=${PYTHON}${flags}-config
  1032.                     ;;
  1033.                     *)
  1034.                         die "${impl}: obtaining ${var} not supported"
  1035.                     ;;
  1036.                 esac;
  1037.                 export PYTHON_CONFIG=${val};
  1038.                 debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  1039.             ;;
  1040.             PYTHON_PKG_DEP)
  1041.                 local d;
  1042.                 case ${impl} in
  1043.                     python*)
  1044.                         PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  1045.                     ;;
  1046.                     pypy3)
  1047.                         PYTHON_PKG_DEP="dev-python/${impl}:="
  1048.                     ;;
  1049.                     *)
  1050.                         die "Invalid implementation: ${impl}"
  1051.                     ;;
  1052.                 esac;
  1053.                 if [[ -n ${PYTHON_REQ_USE} ]]; then
  1054.                     PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  1055.                 fi;
  1056.                 export PYTHON_PKG_DEP;
  1057.                 debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  1058.             ;;
  1059.             PYTHON_SCRIPTDIR)
  1060.                 local dir;
  1061.                 export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  1062.                 debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  1063.             ;;
  1064.             *)
  1065.                 die "_python_export: unknown variable ${var}"
  1066.             ;;
  1067.         esac;
  1068.     done
  1069. }
  1070. _python_impl_matches ()
  1071. {
  1072.     [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter";
  1073.     [[ ${#} -eq 1 ]] && return 0;
  1074.     local impl=${1/./_} pattern;
  1075.     shift;
  1076.     for pattern in "$@";
  1077.     do
  1078.         case ${pattern} in
  1079.             -2 | python2* | pypy)
  1080.                 if [[ ${EAPI} != 7 ]]; then
  1081.                     eerror;
  1082.                     eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  1083.                     eerror "${FUNCNAME[1]} calls.";
  1084.                     die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  1085.                 fi
  1086.             ;;
  1087.             -3)
  1088.                 if [[ ${EAPI} != 7 ]]; then
  1089.                     eerror;
  1090.                     eerror "Python 2 is no longer supported in Gentoo, please remove Python 2";
  1091.                     eerror "${FUNCNAME[1]} calls.";
  1092.                     die "Passing ${pattern} to ${FUNCNAME[1]} is banned in EAPI ${EAPI}";
  1093.                 fi;
  1094.                 return 0
  1095.             ;;
  1096.             3.10)
  1097.                 [[ ${impl} == python${pattern/./_} || ${impl} == pypy3 ]] && return 0
  1098.             ;;
  1099.             3.8 | 3.9 | 3.1[1-3])
  1100.                 [[ ${impl} == python${pattern/./_} ]] && return 0
  1101.             ;;
  1102.             *)
  1103.                 [[ ${impl} == ${pattern/./_} ]] && return 0
  1104.             ;;
  1105.         esac;
  1106.     done;
  1107.     return 1
  1108. }
  1109. _python_run_check_deps ()
  1110. {
  1111.     debug-print-function ${FUNCNAME} "${@}";
  1112.     local impl=${1};
  1113.     einfo "Checking whether ${impl} is suitable ...";
  1114.     local PYTHON_PKG_DEP;
  1115.     _python_export "${impl}" PYTHON_PKG_DEP;
  1116.     ebegin "  ${PYTHON_PKG_DEP}";
  1117.     has_version -b "${PYTHON_PKG_DEP}";
  1118.     eend ${?} || return 1;
  1119.     declare -f python_check_deps > /dev/null || return 0;
  1120.     local PYTHON_USEDEP="python_targets_${impl}(-)";
  1121.     local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)";
  1122.     ebegin "  python_check_deps";
  1123.     python_check_deps;
  1124.     eend ${?}
  1125. }
  1126. _python_set_impls ()
  1127. {
  1128.     local i;
  1129.     if [[ ${BASH_VERSINFO[0]} -ge 5 ]]; then
  1130.         [[ ${PYTHON_COMPAT@a} == *a* ]];
  1131.     else
  1132.         [[ $(declare -p PYTHON_COMPAT) == "declare -a"* ]];
  1133.     fi;
  1134.     if [[ ${?} -ne 0 ]]; then
  1135.         if ! declare -p PYTHON_COMPAT &> /dev/null; then
  1136.             die 'PYTHON_COMPAT not declared.';
  1137.         else
  1138.             die 'PYTHON_COMPAT must be an array.';
  1139.         fi;
  1140.     fi;
  1141.     local obsolete=();
  1142.     if [[ ! -n ${PYTHON_COMPAT_NO_STRICT} ]]; then
  1143.         for i in "${PYTHON_COMPAT[@]}";
  1144.         do
  1145.             case ${i} in
  1146.                 pypy3 | python3_9 | python3_1[0-3])
  1147.  
  1148.                 ;;
  1149.                 jython2_7 | pypy | pypy1_[89] | pypy2_0 | python2_[5-7] | python3_[1-9])
  1150.                     obsolete+=("${i}")
  1151.                 ;;
  1152.                 *)
  1153.                     if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}"; then
  1154.                         die "Mis-synced patterns in _python_set_impls: missing ${i}";
  1155.                     else
  1156.                         die "Invalid implementation in PYTHON_COMPAT: ${i}";
  1157.                     fi
  1158.                 ;;
  1159.             esac;
  1160.         done;
  1161.     fi;
  1162.     local supp=() unsupp=();
  1163.     for i in "${_PYTHON_ALL_IMPLS[@]}";
  1164.     do
  1165.         if has "${i}" "${PYTHON_COMPAT[@]}"; then
  1166.             supp+=("${i}");
  1167.         else
  1168.             unsupp+=("${i}");
  1169.         fi;
  1170.     done;
  1171.     if [[ ! -n ${supp[@]} ]]; then
  1172.         die "No supported implementation in PYTHON_COMPAT.";
  1173.     fi;
  1174.     if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  1175.         if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  1176.             eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  1177.             eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  1178.             eerror "Now   : ${supp[*]}";
  1179.             die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  1180.         fi;
  1181.         if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  1182.             eerror "Unsupported impls changed between inherits!";
  1183.             eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  1184.             eerror "Now   : ${unsupp[*]}";
  1185.             die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  1186.         fi;
  1187.     else
  1188.         _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  1189.         _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  1190.         readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  1191.     fi
  1192. }
  1193. _python_verify_patterns ()
  1194. {
  1195.     debug-print-function ${FUNCNAME} "${@}";
  1196.     local impl pattern;
  1197.     for pattern in "$@";
  1198.     do
  1199.         case ${pattern} in
  1200.             -[23] | 3.[89] | 3.1[0-3])
  1201.                 continue
  1202.             ;;
  1203.         esac;
  1204.         for impl in "${_PYTHON_ALL_IMPLS[@]}" "${_PYTHON_HISTORICAL_IMPLS[@]}";
  1205.         do
  1206.             [[ ${impl} == ${pattern/./_} ]] && continue 2;
  1207.         done;
  1208.         die "Invalid implementation pattern: ${pattern}";
  1209.     done
  1210. }
  1211. _python_wrapper_setup ()
  1212. {
  1213.     debug-print-function ${FUNCNAME} "${@}";
  1214.     local workdir=${1:-${T}/${EPYTHON}};
  1215.     local impl=${2:-${EPYTHON}};
  1216.     [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  1217.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  1218.     if [[ ! -x ${workdir}/bin/python ]]; then
  1219.         mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  1220.         rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  1221.         rm -f "${workdir}"/bin/2to3 || die;
  1222.         rm -f "${workdir}"/pkgconfig/python{2,3}{,-embed}.pc || die;
  1223.         local EPYTHON PYTHON;
  1224.         _python_export "${impl}" EPYTHON PYTHON;
  1225.         cat > "${workdir}/bin/python" <<-_EOF_ ||
  1226. #!/bin/sh
  1227. exec "${PYTHON}" "\${@}"
  1228. _EOF_
  1229.  die
  1230.         cp "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  1231.         chmod +x "${workdir}/bin/python" "${workdir}/bin/python3" || die;
  1232.         local nonsupp=(python2 python2-config);
  1233.         if [[ ${EPYTHON} == python* ]]; then
  1234.             cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  1235. #!/bin/sh
  1236. exec "${PYTHON}-config" "\${@}"
  1237. _EOF_
  1238.  die
  1239.             cp "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  1240.             chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python3-config" || die;
  1241.             ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  1242.             ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python3.pc || die;
  1243.             ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}-embed.pc "${workdir}"/pkgconfig/python3-embed.pc || die;
  1244.         else
  1245.             nonsupp+=(2to3 python-config python3-config);
  1246.         fi;
  1247.         local x;
  1248.         for x in "${nonsupp[@]}";
  1249.         do
  1250.             cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  1251. #!/bin/sh
  1252. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  1253. exit 127
  1254. _EOF_
  1255.  die
  1256.             chmod +x "${workdir}"/bin/${x} || die;
  1257.         done;
  1258.     fi;
  1259.     if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  1260.         PATH=${workdir}/bin${PATH:+:${PATH}};
  1261.     fi;
  1262.     if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  1263.         PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  1264.     fi;
  1265.     export PATH PKG_CONFIG_PATH
  1266. }
  1267. _ruby_implementation_depend ()
  1268. {
  1269.     local rubypn=;
  1270.     local rubyslot=;
  1271.     case $1 in
  1272.         ruby1[89] | ruby2[0-7] | ruby3[0-3])
  1273.             rubypn="dev-lang/ruby";
  1274.             rubyslot=":${1:4:1}.${1:5}"
  1275.         ;;
  1276.         ree18)
  1277.             rubypn="dev-lang/ruby-enterprise";
  1278.             rubyslot=":1.8"
  1279.         ;;
  1280.         jruby)
  1281.             rubypn="dev-java/jruby";
  1282.             rubyslot=""
  1283.         ;;
  1284.         rbx)
  1285.             rubypn="dev-lang/rubinius";
  1286.             rubyslot=""
  1287.         ;;
  1288.         *)
  1289.             die "$1: unknown Ruby implementation"
  1290.         ;;
  1291.     esac;
  1292.     echo "$2${rubypn}$3${rubyslot}"
  1293. }
  1294. _ruby_single_implementations_depend ()
  1295. {
  1296.     local _ruby_implementation depend;
  1297.     for _ruby_implementation in ${RUBY_TARGETS_PREFERENCE};
  1298.     do
  1299.         if [[ ${USE_RUBY} =~ ${_ruby_implementation} ]]; then
  1300.             depend+=" (";
  1301.             depend+=" $(_ruby_implementation_depend ${_ruby_implementation})";
  1302.             depend+=" virtual/rubygems[ruby_targets_${_ruby_implementation}(-)]";
  1303.             depend+=" )";
  1304.         fi;
  1305.     done;
  1306.     echo "|| ( ${depend} )"
  1307. }
  1308. _ruby_single_set_globals ()
  1309. {
  1310.     RUBY_DEPS=$(_ruby_single_implementations_depend)
  1311. }
  1312. _setup-allowed-flags ()
  1313. {
  1314.     ALLOWED_FLAGS=(-pipe -O '-O[123szg]' '-mcpu=*' '-march=*' '-mtune=*' '-mfpmath=*' -flto '-flto=*' -fno-lto '-fstack-protector*' -fstack-clash-protection '-fcf-protection=*' -fbounds-check -fbounds-checking -fno-PIE -fno-pie -nopie -no-pie -fharden-compares -fharden-conditional-branches -fharden-control-flow-redundancy -fno-harden-control-flow-redundancy -fhardcfr-skip-leaf -fhardcfr-check-exceptions -fhardcfr-check-returning-calls '-fhardcfr-check-noreturn-calls=*' '-mindirect-branch=*' -mindirect-branch-register '-mfunction-return=*' -mretpoline '-mharden-sls=*' '-mbranch-protection=*' -fno-unit-at-a-time -fno-strict-overflow '-fsanitize*' '-fno-sanitize*' -g '-g[0-9]' -ggdb '-ggdb[0-9]' -gdwarf '-gdwarf-*' -gstabs -gstabs+ -gz -glldb '-fdebug-default-version=*' -fno-diagnostics-color '-fmessage-length=*' -fno-ident -fpermissive -frecord-gcc-switches -frecord-command-line '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld=*');
  1315.     ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*' -mno-omit-leaf-frame-pointer);
  1316.     ALLOWED_FLAGS+=('-mregparm=*' -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float '-mfpu=*' -mieee -mieee-with-inexact '-mschedule=*' -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 '-mabi=*' -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 '-mcmodel=*' -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' '-mfloat-abi=*' '-mtls-dialect=*' -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 -mfix-r10000 -mno-fix-r10000 '-mr10k-cache-barrier=*' -mthumb -marm -ffixed-x18 -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha);
  1317.     ALLOWED_FLAGS+=(-mstackrealign '-mpreferred-stack-boundary=*' '-mincoming-stack-boundary=*');
  1318.     ALLOWED_FLAGS+=('--unwindlib=*' '--rtlib=*' '--stdlib=*')
  1319. }
  1320. _tc-getPROG ()
  1321. {
  1322.     local tuple=$1;
  1323.     local v var vars=$2;
  1324.     local prog=($3);
  1325.     var=${vars%% *};
  1326.     for v in ${vars};
  1327.     do
  1328.         if [[ -n ${!v} ]]; then
  1329.             export ${var}="${!v}";
  1330.             echo "${!v}";
  1331.             return 0;
  1332.         fi;
  1333.     done;
  1334.     local search=;
  1335.     [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  1336.     [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  1337.     [[ -n ${search} ]] && prog[0]=${search##*/};
  1338.     export ${var}="${prog[*]}";
  1339.     echo "${!var}"
  1340. }
  1341. _tc-has-openmp ()
  1342. {
  1343.     local base="${T}/test-tc-openmp";
  1344.     cat <<-EOF > "${base}.c"
  1345. #include <omp.h>
  1346. int main(void) {
  1347. int nthreads, tid, ret = 0;
  1348. #pragma omp parallel private(nthreads, tid)
  1349. {
  1350. tid = omp_get_thread_num();
  1351. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  1352. }
  1353. return ret;
  1354. }
  1355. EOF
  1356.  
  1357.     $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  1358.     local ret=$?;
  1359.     rm -f "${base}"*;
  1360.     return ${ret}
  1361. }
  1362. _test-flag-PROG ()
  1363. {
  1364.     local comp=$1;
  1365.     local lang=$2;
  1366.     shift 2;
  1367.     if [[ -z ${comp} ]]; then
  1368.         return 1;
  1369.     fi;
  1370.     if [[ -z $1 ]]; then
  1371.         return 1;
  1372.     fi;
  1373.     comp=($(tc-get${comp}));
  1374.     if ! type -p ${comp[0]} > /dev/null; then
  1375.         return 1;
  1376.     fi;
  1377.     local in_src in_ext cmdline_extra=();
  1378.     case "${lang}" in
  1379.         c)
  1380.             in_ext='c';
  1381.             in_src='int main(void) { return 0; }';
  1382.             cmdline_extra+=(-xc -c)
  1383.         ;;
  1384.         c++)
  1385.             in_ext='cc';
  1386.             in_src='int main(void) { return 0; }';
  1387.             cmdline_extra+=(-xc++ -c)
  1388.         ;;
  1389.         f77)
  1390.             in_ext='f';
  1391.             in_src='      end';
  1392.             cmdline_extra+=(-xf77 -c)
  1393.         ;;
  1394.         f95)
  1395.             in_ext='f90';
  1396.             in_src='end';
  1397.             cmdline_extra+=(-xf95 -c)
  1398.         ;;
  1399.         c+ld)
  1400.             in_ext='c';
  1401.             in_src='int main(void) { return 0; }';
  1402.             if is-ldflagq -fuse-ld=*; then
  1403.                 fuse_ld_value=$(get-flag -fuse-ld=*);
  1404.                 cmdline_extra+=(${fuse_ld_value});
  1405.             fi;
  1406.             cmdline_extra+=(-xc)
  1407.         ;;
  1408.     esac;
  1409.     local test_in=${T}/test-flag.${in_ext};
  1410.     local test_out=${T}/test-flag.exe;
  1411.     printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'";
  1412.     local cmdline=("${comp[@]}" -Werror "$@" "${cmdline_extra[@]}" "${test_in}" -o "${test_out}");
  1413.     "${cmdline[@]}" &> /dev/null
  1414. }
  1415. _test-flags-PROG ()
  1416. {
  1417.     local comp=$1;
  1418.     local flags=();
  1419.     local x;
  1420.     shift;
  1421.     [[ -z ${comp} ]] && return 1;
  1422.     while (( $# )); do
  1423.         case "$1" in
  1424.             --param | -B)
  1425.                 if test-flag-${comp} "$1" "$2"; then
  1426.                     flags+=("$1" "$2");
  1427.                 fi;
  1428.                 shift 2
  1429.             ;;
  1430.             *)
  1431.                 if test-flag-${comp} "$1"; then
  1432.                     flags+=("$1");
  1433.                 fi;
  1434.                 shift 1
  1435.             ;;
  1436.         esac;
  1437.     done;
  1438.     echo "${flags[*]}";
  1439.     [[ ${#flags[@]} -gt 0 ]]
  1440. }
  1441. all-flag-vars ()
  1442. {
  1443.     echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  1444. }
  1445. append-atomic-flags ()
  1446. {
  1447.     test-flags-CCLD "-latomic" &> /dev/null || return;
  1448.     append-libs "-Wl,--push-state,--as-needed,-latomic,--pop-state"
  1449. }
  1450. append-cflags ()
  1451. {
  1452.     [[ $# -eq 0 ]] && return 0;
  1453.     export CFLAGS+=" $*";
  1454.     return 0
  1455. }
  1456. append-cppflags ()
  1457. {
  1458.     [[ $# -eq 0 ]] && return 0;
  1459.     export CPPFLAGS+=" $*";
  1460.     return 0
  1461. }
  1462. append-cxxflags ()
  1463. {
  1464.     [[ $# -eq 0 ]] && return 0;
  1465.     export CXXFLAGS+=" $*";
  1466.     return 0
  1467. }
  1468. append-fflags ()
  1469. {
  1470.     [[ $# -eq 0 ]] && return 0;
  1471.     export FFLAGS+=" $*";
  1472.     export FCFLAGS+=" $*";
  1473.     return 0
  1474. }
  1475. append-flags ()
  1476. {
  1477.     [[ $# -eq 0 ]] && return 0;
  1478.     case " $* " in
  1479.         *' '-[DIU]*)
  1480.             eqawarn 'Please use append-cppflags for preprocessor flags'
  1481.         ;;
  1482.         *' '-L* | *' '-Wl,*)
  1483.             eqawarn 'Please use append-ldflags for linker flags'
  1484.         ;;
  1485.     esac;
  1486.     append-cflags "$@";
  1487.     append-cxxflags "$@";
  1488.     append-fflags "$@";
  1489.     return 0
  1490. }
  1491. append-ldflags ()
  1492. {
  1493.     [[ $# -eq 0 ]] && return 0;
  1494.     local flag;
  1495.     for flag in "$@";
  1496.     do
  1497.         [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1498.     done;
  1499.     export LDFLAGS="${LDFLAGS} $*";
  1500.     return 0
  1501. }
  1502. append-lfs-flags ()
  1503. {
  1504.     [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1505.     append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1506. }
  1507. append-libs ()
  1508. {
  1509.     [[ $# -eq 0 ]] && return 0;
  1510.     local flag;
  1511.     for flag in "$@";
  1512.     do
  1513.         if [[ -z "${flag// }" ]]; then
  1514.             eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1515.             continue;
  1516.         fi;
  1517.         case $flag in
  1518.             -[lL]*)
  1519.                 export LIBS="${LIBS} ${flag}"
  1520.             ;;
  1521.             -*)
  1522.                 eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1523.                 export LIBS="${LIBS} ${flag}"
  1524.             ;;
  1525.             *)
  1526.                 export LIBS="${LIBS} -l${flag}"
  1527.             ;;
  1528.         esac;
  1529.     done;
  1530.     return 0
  1531. }
  1532. build_sphinx ()
  1533. {
  1534.     debug-print-function ${FUNCNAME} "${@}";
  1535.     [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes 1 arg: <directory>";
  1536.     local dir=${1};
  1537.     sed -i -e 's:^intersphinx_mapping:disabled_&:' "${dir}"/conf.py || die;
  1538.     local command=("${EPYTHON}" -m sphinx.cmd.build);
  1539.     if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2> /dev/null; then
  1540.         command=(sphinx-build);
  1541.     fi;
  1542.     command+=(-b html -d "${dir}"/_build/doctrees "${dir}" "${dir}"/_build/html);
  1543.     echo "${command[@]}" 1>&2;
  1544.     "${command[@]}" || die;
  1545.     HTML_DOCS+=("${dir}/_build/html/.")
  1546. }
  1547. check-reqs_disk ()
  1548. {
  1549.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1550.     _check-reqs_disk "$@"
  1551. }
  1552. check-reqs_get_kibibytes ()
  1553. {
  1554.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1555.     _check-reqs_get_kibibytes "$@"
  1556. }
  1557. check-reqs_get_number ()
  1558. {
  1559.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1560.     _check-reqs_get_number "$@"
  1561. }
  1562. check-reqs_get_unit ()
  1563. {
  1564.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1565.     _check-reqs_get_unit "$@"
  1566. }
  1567. check-reqs_memory ()
  1568. {
  1569.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1570.     _check-reqs_memory "$@"
  1571. }
  1572. check-reqs_output ()
  1573. {
  1574.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1575.     _check-reqs_get_unit "$@"
  1576. }
  1577. check-reqs_pkg_pretend ()
  1578. {
  1579.     debug-print-function ${FUNCNAME} "$@";
  1580.     check-reqs_pkg_setup "$@"
  1581. }
  1582. check-reqs_pkg_setup ()
  1583. {
  1584.     debug-print-function ${FUNCNAME} "$@";
  1585.     _check-reqs_prepare;
  1586.     _check-reqs_run;
  1587.     _check-reqs_output
  1588. }
  1589. check-reqs_prepare ()
  1590. {
  1591.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1592.     _check-reqs_prepare "$@"
  1593. }
  1594. check-reqs_run ()
  1595. {
  1596.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1597.     _check-reqs_run "$@"
  1598. }
  1599. check-reqs_start_phase ()
  1600. {
  1601.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1602.     _check-reqs_start_phase "$@"
  1603. }
  1604. check-reqs_unsatisfied ()
  1605. {
  1606.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  1607.     _check-reqs_unsatisfied "$@"
  1608. }
  1609. clang-fullversion ()
  1610. {
  1611.     _clang_fullversion '$1.$2.$3' "$@"
  1612. }
  1613. clang-major-version ()
  1614. {
  1615.     _clang_fullversion '$1' "$@"
  1616. }
  1617. clang-micro-version ()
  1618. {
  1619.     _clang_fullversion '$3' "$@"
  1620. }
  1621. clang-minor-version ()
  1622. {
  1623.     _clang_fullversion '$2' "$@"
  1624. }
  1625. clang-version ()
  1626. {
  1627.     _clang_fullversion '$1.$2' "$@"
  1628. }
  1629. cmake-utils_src_make ()
  1630. {
  1631.     die "cmake-utils_src_make is banned. Use cmake_build instead"
  1632. }
  1633. cmake-utils_use ()
  1634. {
  1635.     _cmake_banned_func "" "$@"
  1636. }
  1637. cmake-utils_use_build ()
  1638. {
  1639.     _cmake_banned_func BUILD_ "$@"
  1640. }
  1641. cmake-utils_use_disable ()
  1642. {
  1643.     _cmake_banned_func DISABLE_ "$@"
  1644. }
  1645. cmake-utils_use_enable ()
  1646. {
  1647.     _cmake_banned_func ENABLE_ "$@"
  1648. }
  1649. cmake-utils_use_has ()
  1650. {
  1651.     _cmake_banned_func HAVE_ "$@"
  1652. }
  1653. cmake-utils_use_no ()
  1654. {
  1655.     _cmake_banned_func NO_ "$@"
  1656. }
  1657. cmake-utils_use_use ()
  1658. {
  1659.     _cmake_banned_func USE_ "$@"
  1660. }
  1661. cmake-utils_use_want ()
  1662. {
  1663.     _cmake_banned_func WANT_ "$@"
  1664. }
  1665. cmake-utils_use_with ()
  1666. {
  1667.     _cmake_banned_func WITH_ "$@"
  1668. }
  1669. cmake-utils_useno ()
  1670. {
  1671.     _cmake_banned_func "" "$@"
  1672. }
  1673. cmake_build ()
  1674. {
  1675.     debug-print-function ${FUNCNAME} "$@";
  1676.     _cmake_check_build_dir;
  1677.     pushd "${BUILD_DIR}" > /dev/null || die;
  1678.     case ${CMAKE_MAKEFILE_GENERATOR} in
  1679.         emake)
  1680.             [[ -e Makefile ]] || die "Makefile not found. Error during configure stage.";
  1681.             case ${CMAKE_VERBOSE} in
  1682.                 OFF)
  1683.                     emake "$@"
  1684.                 ;;
  1685.                 *)
  1686.                     emake VERBOSE=1 "$@"
  1687.                 ;;
  1688.             esac
  1689.         ;;
  1690.         ninja)
  1691.             [[ -e build.ninja ]] || die "build.ninja not found. Error during configure stage.";
  1692.             case ${CMAKE_VERBOSE} in
  1693.                 OFF)
  1694.                     NINJA_VERBOSE=OFF eninja "$@"
  1695.                 ;;
  1696.                 *)
  1697.                     eninja "$@"
  1698.                 ;;
  1699.             esac
  1700.         ;;
  1701.     esac;
  1702.     popd > /dev/null || die
  1703. }
  1704. cmake_comment_add_subdirectory ()
  1705. {
  1706.     if [[ -z ${1} ]]; then
  1707.         die "${FUNCNAME[0]} must be passed at least one directory name to comment";
  1708.     fi;
  1709.     [[ -e "CMakeLists.txt" ]] || return;
  1710.     local d;
  1711.     for d in $@;
  1712.     do
  1713.         d=${d//\//\\/};
  1714.         sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${d}[[:space:]]*)/I s/^/#DONOTCOMPILE /" -i CMakeLists.txt || die "failed to comment add_subdirectory(${d})";
  1715.     done
  1716. }
  1717. cmake_run_in ()
  1718. {
  1719.     if [[ -z ${2} ]]; then
  1720.         die "${FUNCNAME[0]} must be passed at least two arguments";
  1721.     fi;
  1722.     [[ -e ${1} ]] || die "${FUNCNAME[0]}: Nonexistent path: ${1}";
  1723.     pushd ${1} > /dev/null || die;
  1724.     "${@:2}";
  1725.     popd > /dev/null || die
  1726. }
  1727. cmake_src_compile ()
  1728. {
  1729.     debug-print-function ${FUNCNAME} "$@";
  1730.     cmake_build "$@"
  1731. }
  1732. cmake_src_configure ()
  1733. {
  1734.     debug-print-function ${FUNCNAME} "$@";
  1735.     [[ -n ${_CMAKE_SRC_PREPARE_HAS_RUN} ]] || die "FATAL: cmake_src_prepare has not been run";
  1736.     _cmake_check_build_dir;
  1737.     xdg_environment_reset;
  1738.     local build_rules=${BUILD_DIR}/gentoo_rules.cmake;
  1739.     cat > "${build_rules}" <<-_EOF_ ||
  1740. set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
  1741. set(CMAKE_ASM-ATT_COMPILE_OBJECT "<CMAKE_ASM-ATT_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c -x assembler <SOURCE>" CACHE STRING "ASM-ATT compile command" FORCE)
  1742. set(CMAKE_ASM-ATT_LINK_FLAGS "-nostdlib" CACHE STRING "ASM-ATT link flags" FORCE)
  1743. set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
  1744. set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
  1745. set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> ${FCFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "Fortran compile command" FORCE)
  1746. _EOF_
  1747.  die
  1748.     local myCC=$(tc-getCC) myCXX=$(tc-getCXX) myFC=$(tc-getFC);
  1749.     local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake;
  1750.     cat > ${toolchain_file} <<-_EOF_ ||
  1751. set(CMAKE_ASM_COMPILER "${myCC/ /;}")
  1752. set(CMAKE_ASM-ATT_COMPILER "${myCC/ /;}")
  1753. set(CMAKE_C_COMPILER "${myCC/ /;}")
  1754. set(CMAKE_CXX_COMPILER "${myCXX/ /;}")
  1755. set(CMAKE_Fortran_COMPILER "${myFC/ /;}")
  1756. set(CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
  1757. set(CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
  1758. set(CMAKE_SYSTEM_PROCESSOR "${CHOST%%-*}")
  1759. _EOF_
  1760.  die
  1761.     local -x ASMFLAGS=${CFLAGS};
  1762.     local -x PKG_CONFIG=$(tc-getPKG_CONFIG);
  1763.     if tc-is-cross-compiler; then
  1764.         local sysname;
  1765.         case "${KERNEL:-linux}" in
  1766.             Cygwin)
  1767.                 sysname="CYGWIN_NT-5.1"
  1768.             ;;
  1769.             HPUX)
  1770.                 sysname="HP-UX"
  1771.             ;;
  1772.             linux)
  1773.                 sysname="Linux"
  1774.             ;;
  1775.             Winnt)
  1776.                 sysname="Windows";
  1777.                 cat >> "${toolchain_file}" <<-_EOF_ ||
  1778. set(CMAKE_RC_COMPILER $(tc-getRC))
  1779. _EOF_
  1780.  die
  1781.             ;;
  1782.             *)
  1783.                 sysname="${KERNEL}"
  1784.             ;;
  1785.         esac
  1786.         cat >> "${toolchain_file}" <<-_EOF_ ||
  1787. set(CMAKE_SYSTEM_NAME "${sysname}")
  1788. _EOF_
  1789.  die;
  1790.     fi
  1791.     if [[ ${SYSROOT:-/} != / ]]; then
  1792.         cat >> "${toolchain_file}" <<-_EOF_ ||
  1793. set(CMAKE_SYSROOT "${ESYSROOT}")
  1794. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  1795. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  1796. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  1797. _EOF_
  1798.  die;
  1799.     fi
  1800.     if use prefix-guest; then
  1801.         cat >> "${build_rules}" <<-_EOF_ ||
  1802. # in Prefix we need rpath and must ensure cmake gets our default linker path
  1803. # right ... except for Darwin hosts
  1804. if(NOT APPLE)
  1805. set(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1806. set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
  1807. else()
  1808. set(CMAKE_PREFIX_PATH "${EPREFIX}/usr" CACHE STRING "" FORCE)
  1809. set(CMAKE_MACOSX_RPATH ON CACHE BOOL "" FORCE)
  1810. set(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
  1811. set(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1812. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
  1813. endif()
  1814. _EOF_
  1815.  die;
  1816.     fi
  1817.     local common_config=${BUILD_DIR}/gentoo_common_config.cmake;
  1818.     local libdir=$(get_libdir);
  1819.     cat > "${common_config}" <<-_EOF_ ||
  1820. set(CMAKE_GENTOO_BUILD ON CACHE BOOL "Indicate Gentoo package build")
  1821. set(LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
  1822. set(CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
  1823. set(CMAKE_INSTALL_INFODIR "${EPREFIX}/usr/share/info" CACHE PATH "")
  1824. set(CMAKE_INSTALL_MANDIR "${EPREFIX}/usr/share/man" CACHE PATH "")
  1825. set(CMAKE_USER_MAKE_RULES_OVERRIDE "${build_rules}" CACHE FILEPATH "Gentoo override rules")
  1826. set(CMAKE_INSTALL_DOCDIR "${EPREFIX}/usr/share/doc/${PF}" CACHE PATH "")
  1827. set(BUILD_SHARED_LIBS ON CACHE BOOL "")
  1828. set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
  1829. set(FETCHCONTENT_FULLY_DISCONNECTED ON CACHE BOOL "")
  1830. set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON CACHE BOOL "")
  1831. _EOF_
  1832.  die
  1833.     if [[ -n ${_ECM_ECLASS} ]]; then
  1834.         echo 'set(ECM_DISABLE_QMLPLUGINDUMP ON CACHE BOOL "")' >> "${common_config}" || die;
  1835.     fi;
  1836.     if [[ "${ARCH}" == riscv ]]; then
  1837.         echo 'set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX '"${libdir#lib}"' CACHE STRING "library search suffix" FORCE)' >> "${common_config}" || die;
  1838.     fi;
  1839.     if [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]]; then
  1840.         echo 'set(CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}" || die;
  1841.     fi;
  1842.     if [[ ${EAPI} != 7 ]]; then
  1843.         echo 'set(CMAKE_INSTALL_ALWAYS 1)' >> "${common_config}" || die;
  1844.     fi;
  1845.     if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]]; then
  1846.         cat >> ${common_config} <<-_EOF_ ||
  1847. set(CMAKE_ASM_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1848. set(CMAKE_ASM-ATT_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1849. set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1850. set(CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1851. set(CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1852. set(CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1853. set(CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1854. set(CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1855. set(CMAKE_STATIC_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
  1856. _EOF_
  1857.  die;
  1858.     fi
  1859.     [[ -z ${mycmakeargs} ]] && declare -a mycmakeargs=();
  1860.     local mycmakeargstype=$(declare -p mycmakeargs 2>&-);
  1861.     if [[ "${mycmakeargstype}" != "declare -a mycmakeargs="* ]]; then
  1862.         die "mycmakeargs must be declared as array";
  1863.     fi;
  1864.     local mycmakeargs_local=("${mycmakeargs[@]}");
  1865.     local warn_unused_cli="";
  1866.     if [[ ${CMAKE_WARN_UNUSED_CLI} == no ]]; then
  1867.         warn_unused_cli="--no-warn-unused-cli";
  1868.     fi;
  1869.     local generator_name;
  1870.     case ${CMAKE_MAKEFILE_GENERATOR} in
  1871.         ninja)
  1872.             generator_name="Ninja"
  1873.         ;;
  1874.         emake)
  1875.             generator_name="Unix Makefiles"
  1876.         ;;
  1877.     esac;
  1878.     local cmakeargs=(${warn_unused_cli} -C "${common_config}" -G "${generator_name}" -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" "${mycmakeargs_local[@]}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}");
  1879.     eval "local -a MYCMAKEARGS=( ${MYCMAKEARGS} )";
  1880.     cmakeargs+=("${MYCMAKEARGS[@]}");
  1881.     if [[ -n "${CMAKE_EXTRA_CACHE_FILE}" ]]; then
  1882.         cmakeargs+=(-C "${CMAKE_EXTRA_CACHE_FILE}");
  1883.     fi;
  1884.     pushd "${BUILD_DIR}" > /dev/null || die;
  1885.     debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}";
  1886.     echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}";
  1887.     "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
  1888.     popd > /dev/null || die
  1889. }
  1890. cmake_src_install ()
  1891. {
  1892.     debug-print-function ${FUNCNAME} "$@";
  1893.     DESTDIR="${D}" cmake_build install "$@";
  1894.     if [[ ${EAPI} == 7 ]]; then
  1895.         pushd "${S}" > /dev/null || die;
  1896.         einstalldocs;
  1897.         popd > /dev/null || die;
  1898.     else
  1899.         pushd "${CMAKE_USE_DIR}" > /dev/null || die;
  1900.         einstalldocs;
  1901.         popd > /dev/null || die;
  1902.     fi
  1903. }
  1904. cmake_src_prepare ()
  1905. {
  1906.     debug-print-function ${FUNCNAME} "$@";
  1907.     if [[ ${EAPI} == 7 ]]; then
  1908.         pushd "${S}" > /dev/null || die;
  1909.     fi;
  1910.     _cmake_check_build_dir;
  1911.     default_src_prepare;
  1912.     if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]]; then
  1913.         eerror "Unable to locate CMakeLists.txt under:";
  1914.         eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"";
  1915.         eerror "Consider not inheriting the cmake eclass.";
  1916.         die "FATAL: Unable to find CMakeLists.txt";
  1917.     fi;
  1918.     local modules_list;
  1919.     if [[ ${EAPI} == 7 && $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then
  1920.         modules_list=(${CMAKE_REMOVE_MODULES_LIST});
  1921.     else
  1922.         modules_list=("${CMAKE_REMOVE_MODULES_LIST[@]}");
  1923.     fi;
  1924.     local name;
  1925.     for name in "${modules_list[@]}";
  1926.     do
  1927.         if [[ ${EAPI} == 7 ]]; then
  1928.             find "${S}" -name ${name}.cmake -exec rm -v {} + || die;
  1929.         else
  1930.             find -name "${name}.cmake" -exec rm -v {} + || die;
  1931.         fi;
  1932.     done;
  1933.     _cmake_modify-cmakelists;
  1934.     if [[ ${EAPI} == 7 ]]; then
  1935.         popd > /dev/null || die;
  1936.     fi;
  1937.     if [[ -n ${CMAKE_QA_SRC_DIR_READONLY} && ! -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  1938.         if [[ ${EAPI} == 7 ]]; then
  1939.             chmod -R a-w "${S}";
  1940.         else
  1941.             chmod -R a-w "${CMAKE_USE_DIR}";
  1942.         fi;
  1943.     fi;
  1944.     _CMAKE_SRC_PREPARE_HAS_RUN=1
  1945. }
  1946. cmake_src_test ()
  1947. {
  1948.     debug-print-function ${FUNCNAME} "$@";
  1949.     _cmake_check_build_dir;
  1950.     pushd "${BUILD_DIR}" > /dev/null || die;
  1951.     [[ -e CTestTestfile.cmake ]] || {
  1952.         echo "No tests found. Skipping.";
  1953.         return 0
  1954.     };
  1955.     [[ -n ${TEST_VERBOSE} ]] && myctestargs+=(--extra-verbose --output-on-failure);
  1956.     [[ -n ${CMAKE_SKIP_TESTS} ]] && myctestargs+=(-E '('$( IFS='|'; echo "${CMAKE_SKIP_TESTS[*]}")')');
  1957.     set -- ctest -j "$(makeopts_jobs "${MAKEOPTS}" 999)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@";
  1958.     echo "$@" 1>&2;
  1959.     if "$@"; then
  1960.         einfo "Tests succeeded.";
  1961.         popd > /dev/null || die;
  1962.         return 0;
  1963.     else
  1964.         if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]]; then
  1965.             eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:";
  1966.             eerror "--START TEST LOG--------------------------------------------------------------";
  1967.             cat "${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1968.             eerror "--END TEST LOG----------------------------------------------------------------";
  1969.             die "Tests failed.";
  1970.         else
  1971.             die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log";
  1972.         fi;
  1973.         popd > /dev/null || die;
  1974.         return 1;
  1975.     fi
  1976. }
  1977. cmake_use_find_package ()
  1978. {
  1979.     debug-print-function ${FUNCNAME} "$@";
  1980.     if [[ "$#" != 2 || -z $1 ]]; then
  1981.         die "Usage: cmake_use_find_package <USE flag> <package name>";
  1982.     fi;
  1983.     echo "-DCMAKE_DISABLE_FIND_PACKAGE_$2=$(use $1 && echo OFF || echo ON)"
  1984. }
  1985. comment_add_subdirectory ()
  1986. {
  1987.     die "comment_add_subdirectory is banned. Use cmake_comment_add_subdirectory instead"
  1988. }
  1989. eapply ()
  1990. {
  1991.     local failed patch_cmd=patch;
  1992.     local -x LC_COLLATE=POSIX;
  1993.     type -P gpatch > /dev/null && patch_cmd=gpatch;
  1994.     function _eapply_patch ()
  1995.     {
  1996.         local f=${1};
  1997.         local prefix=${2};
  1998.         ebegin "${prefix:-Applying }${f##*/}";
  1999.         local all_opts=(-p1 -f -g0 --no-backup-if-mismatch "${patch_options[@]}");
  2000.         if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 < "${f}" &> /dev/null; then
  2001.             all_opts+=(-s -F0);
  2002.         fi;
  2003.         ${patch_cmd} "${all_opts[@]}" < "${f}";
  2004.         failed=${?};
  2005.         if ! eend "${failed}"; then
  2006.             __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  2007.         fi
  2008.     };
  2009.     local patch_options=() files=();
  2010.     local i found_doublehyphen;
  2011.     for ((i = 1; i <= ${#@}; ++i ))
  2012.     do
  2013.         if [[ ${@:i:1} == -- ]]; then
  2014.             patch_options=("${@:1:i-1}");
  2015.             files=("${@:i+1}");
  2016.             found_doublehyphen=1;
  2017.             break;
  2018.         fi;
  2019.     done;
  2020.     if [[ -z ${found_doublehyphen} ]]; then
  2021.         for ((i = 1; i <= ${#@}; ++i ))
  2022.         do
  2023.             if [[ ${@:i:1} != -* ]]; then
  2024.                 patch_options=("${@:1:i-1}");
  2025.                 files=("${@:i}");
  2026.                 break;
  2027.             fi;
  2028.         done;
  2029.         for i in "${files[@]}";
  2030.         do
  2031.             if [[ ${i} == -* ]]; then
  2032.                 die "eapply: all options must be passed before non-options";
  2033.             fi;
  2034.         done;
  2035.     fi;
  2036.     if [[ ${#files[@]} -eq 0 ]]; then
  2037.         die "eapply: no files specified";
  2038.     fi;
  2039.     local f;
  2040.     for f in "${files[@]}";
  2041.     do
  2042.         if [[ -d ${f} ]]; then
  2043.             function _eapply_get_files ()
  2044.             {
  2045.                 local LC_ALL=POSIX;
  2046.                 local prev_shopt=$(shopt -p nullglob);
  2047.                 shopt -s nullglob;
  2048.                 local f;
  2049.                 for f in "${1}"/*;
  2050.                 do
  2051.                     if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  2052.                         files+=("${f}");
  2053.                     fi;
  2054.                 done;
  2055.                 ${prev_shopt}
  2056.             };
  2057.             local files=();
  2058.             _eapply_get_files "${f}";
  2059.             [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  2060.             einfo "Applying patches from ${f} ...";
  2061.             local f2;
  2062.             for f2 in "${files[@]}";
  2063.             do
  2064.                 _eapply_patch "${f2}" '  ';
  2065.                 [[ ${failed} -ne 0 ]] && return "${failed}";
  2066.             done;
  2067.         else
  2068.             _eapply_patch "${f}";
  2069.             [[ ${failed} -ne 0 ]] && return "${failed}";
  2070.         fi;
  2071.     done;
  2072.     return 0
  2073. }
  2074. eapply_user ()
  2075. {
  2076.     [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  2077.     local tagfile=${T}/.portage_user_patches_applied;
  2078.     [[ -f ${tagfile} ]] && return;
  2079.      >> "${tagfile}";
  2080.     local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  2081.     local columns=${COLUMNS:-0};
  2082.     [[ ${columns} == 0 ]] && columns=$(set -- $( ( stty size </dev/tty ) 2>/dev/null || echo 24 80 ) ; echo $2);
  2083.     (( columns > 0 )) || (( columns = 80 ));
  2084.     local applied d f;
  2085.     local -A _eapply_user_patches;
  2086.     local prev_shopt=$(shopt -p nullglob);
  2087.     shopt -s nullglob;
  2088.     for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  2089.     do
  2090.         for f in "${d}"/*;
  2091.         do
  2092.             if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  2093.                 _eapply_user_patches[${f##*/}]=${f};
  2094.             fi;
  2095.         done;
  2096.     done;
  2097.     if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  2098.         while read -r -d '' f; do
  2099.             f=${_eapply_user_patches[${f}]};
  2100.             if [[ -s ${f} ]]; then
  2101.                 if [[ -z ${applied} ]]; then
  2102.                     einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++)); do echo -n =; done)${PORTAGE_COLOR_NORMAL}";
  2103.                     einfo "Applying user patches from ${basedir} ...";
  2104.                 fi;
  2105.                 eapply "${f}";
  2106.                 applied=1;
  2107.             fi;
  2108.         done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  2109.                 LC_ALL=C sort -z);
  2110.     fi;
  2111.     ${prev_shopt};
  2112.     if [[ -n ${applied} ]]; then
  2113.         einfo "User patches applied.";
  2114.         einfo "${PORTAGE_COLOR_INFO}$(for ((column = 0; column < ${columns} - 3; column++)); do echo -n =; done)${PORTAGE_COLOR_NORMAL}";
  2115.     fi
  2116. }
  2117. econf_build ()
  2118. {
  2119.     local CBUILD=${CBUILD:-${CHOST}};
  2120.     function econf_env ()
  2121.     {
  2122.         CHOST=${CBUILD} econf "$@"
  2123.     };
  2124.     tc-env_build econf_env "$@"
  2125. }
  2126. einstalldocs ()
  2127. {
  2128.     ( if [[ $(declare -p DOCS 2>/dev/null) != *=* ]]; then
  2129.         local d;
  2130.         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  2131.         do
  2132.             [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  2133.         done;
  2134.     else
  2135.         if ___is_indexed_array_var DOCS; then
  2136.             [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  2137.         else
  2138.             [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  2139.         fi;
  2140.     fi );
  2141.     ( if ___is_indexed_array_var HTML_DOCS; then
  2142.         [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  2143.     else
  2144.         [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  2145.     fi )
  2146. }
  2147. elibtoolize ()
  2148. {
  2149.     type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  2150.     ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  2151. }
  2152. eninja ()
  2153. {
  2154.     case "${NINJA}" in
  2155.         ninja | samu)
  2156.  
  2157.         ;;
  2158.         *)
  2159.             ewarn "Unknown value '${NINJA}' for \${NINJA}"
  2160.         ;;
  2161.     esac;
  2162.     local v;
  2163.     case "${NINJA_VERBOSE}" in
  2164.         OFF)
  2165.  
  2166.         ;;
  2167.         *)
  2168.             v="-v"
  2169.         ;;
  2170.     esac;
  2171.     set -- "${NINJA}" ${v} $(get_NINJAOPTS) "$@";
  2172.     echo "$@" 1>&2;
  2173.     "$@" || die -n "${*} failed"
  2174. }
  2175. epytest ()
  2176. {
  2177.     debug-print-function ${FUNCNAME} "${@}";
  2178.     _python_check_EPYTHON;
  2179.     _python_check_occluded_packages;
  2180.     local color=yes;
  2181.     [[ -n ${NO_COLOR} ]] && color=no;
  2182.     local args=(-vv -ra -l -Wdefault -Werror::pytest.PytestUnhandledCoroutineWarning "--color=${color}" -o console_output_style=count -o tmp_path_retention_count=0 -o tmp_path_retention_policy=failed);
  2183.     if [[ ! -n ${PYTEST_DISABLE_PLUGIN_AUTOLOAD} ]]; then
  2184.         args+=(-p no:cov -p no:flake8 -p no:flakes -p no:pylint -p no:markdown -p no:sugar -p no:xvfb -p no:pytest-describe -p no:plus -p no:tavern -p no:salt-factories);
  2185.     fi;
  2186.     if [[ -n ${EPYTEST_TIMEOUT} ]]; then
  2187.         if [[ ${PYTEST_PLUGINS} != *pytest_timeout* ]]; then
  2188.             args+=(-p timeout);
  2189.         fi;
  2190.         args+=("--timeout=${EPYTEST_TIMEOUT}");
  2191.     fi;
  2192.     if [[ -n ${EPYTEST_XDIST} ]]; then
  2193.         local jobs=${EPYTEST_JOBS:-$(makeopts_jobs)};
  2194.         if [[ ${jobs} -gt 1 ]]; then
  2195.             if [[ ${PYTEST_PLUGINS} != *xdist.plugin* ]]; then
  2196.                 args+=(-p xdist);
  2197.             fi;
  2198.             args+=(-n "${jobs}" --dist=worksteal);
  2199.         fi;
  2200.     fi;
  2201.     local x;
  2202.     for x in "${EPYTEST_DESELECT[@]}";
  2203.     do
  2204.         args+=(--deselect "${x}");
  2205.     done;
  2206.     for x in "${EPYTEST_IGNORE[@]}";
  2207.     do
  2208.         args+=(--ignore "${x}");
  2209.     done;
  2210.     set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}";
  2211.     echo "${@}" 1>&2;
  2212.     "${@}" || die -n "pytest failed with ${EPYTHON}";
  2213.     local ret=${?};
  2214.     rm -rf .hypothesis .pytest_cache || die;
  2215.     if [[ -n ${BUILD_DIR} && -d ${BUILD_DIR} ]]; then
  2216.         find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die;
  2217.     fi;
  2218.     return ${ret}
  2219. }
  2220. eunittest ()
  2221. {
  2222.     debug-print-function ${FUNCNAME} "${@}";
  2223.     _python_check_EPYTHON;
  2224.     _python_check_occluded_packages;
  2225.     local runner=unittest;
  2226.     if _python_impl_matches "${EPYTHON}" 3.{9..11}; then
  2227.         runner=unittest_or_fail;
  2228.     fi;
  2229.     set -- "${EPYTHON}" -m "${runner}" discover -v "${@}";
  2230.     echo "${@}" 1>&2;
  2231.     "${@}" || die -n "Tests failed with ${EPYTHON}";
  2232.     return ${?}
  2233. }
  2234. filter-flags ()
  2235. {
  2236.     _filter-hardened "$@";
  2237.     local v;
  2238.     for v in $(all-flag-vars);
  2239.     do
  2240.         _filter-var ${v} "$@";
  2241.     done;
  2242.     return 0
  2243. }
  2244. filter-ldflags ()
  2245. {
  2246.     _filter-var LDFLAGS "$@";
  2247.     return 0
  2248. }
  2249. filter-lfs-flags ()
  2250. {
  2251.     [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2252.     filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64
  2253. }
  2254. filter-lto ()
  2255. {
  2256.     [[ $# -ne 0 ]] && die "filter-lto takes no arguments";
  2257.     filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*'
  2258. }
  2259. filter-mfpmath ()
  2260. {
  2261.     local orig_mfpmath new_math prune_math;
  2262.     orig_mfpmath=$(get-flag -mfpmath);
  2263.     new_math=$(get-flag mfpmath);
  2264.     new_math=${new_math/both/387,sse};
  2265.     new_math=" ${new_math//[,+]/ } ";
  2266.     prune_math="";
  2267.     for prune_math in "$@";
  2268.     do
  2269.         new_math=${new_math/ ${prune_math} / };
  2270.     done;
  2271.     new_math=$(echo ${new_math});
  2272.     new_math=${new_math// /,};
  2273.     if [[ -z ${new_math} ]]; then
  2274.         filter-flags ${orig_mfpmath};
  2275.     else
  2276.         replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2277.     fi;
  2278.     return 0
  2279. }
  2280. gcc-fullversion ()
  2281. {
  2282.     _gcc_fullversion '$1.$2.$3' "$@"
  2283. }
  2284. gcc-major-version ()
  2285. {
  2286.     _gcc_fullversion '$1' "$@"
  2287. }
  2288. gcc-micro-version ()
  2289. {
  2290.     _gcc_fullversion '$3' "$@"
  2291. }
  2292. gcc-minor-version ()
  2293. {
  2294.     _gcc_fullversion '$2' "$@"
  2295. }
  2296. gcc-specs-directive ()
  2297. {
  2298.     local directive subdname subdirective;
  2299.     directive="$(_gcc-specs-directive_raw $1)";
  2300.     while [[ ${directive} == *%\(*\)* ]]; do
  2301.         subdname=${directive/*%\(};
  2302.         subdname=${subdname/\)*};
  2303.         subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2304.         directive="${directive//\%(${subdname})/${subdirective}}";
  2305.     done;
  2306.     echo "${directive}";
  2307.     return 0
  2308. }
  2309. gcc-specs-nostrict ()
  2310. {
  2311.     local directive;
  2312.     directive=$(gcc-specs-directive cc1);
  2313.     [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2314. }
  2315. gcc-specs-now ()
  2316. {
  2317.     local directive;
  2318.     directive=$(gcc-specs-directive link_command);
  2319.     [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2320. }
  2321. gcc-specs-pie ()
  2322. {
  2323.     local directive;
  2324.     directive=$(gcc-specs-directive cc1);
  2325.     [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2326. }
  2327. gcc-specs-relro ()
  2328. {
  2329.     local directive;
  2330.     directive=$(gcc-specs-directive link_command);
  2331.     [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2332. }
  2333. gcc-specs-ssp ()
  2334. {
  2335.     local directive;
  2336.     directive=$(gcc-specs-directive cc1);
  2337.     [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2338. }
  2339. gcc-specs-ssp-to-all ()
  2340. {
  2341.     local directive;
  2342.     directive=$(gcc-specs-directive cc1);
  2343.     [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2344. }
  2345. gcc-specs-stack-check ()
  2346. {
  2347.     local directive;
  2348.     directive=$(gcc-specs-directive cc1);
  2349.     [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2350. }
  2351. gcc-version ()
  2352. {
  2353.     _gcc_fullversion '$1.$2' "$@"
  2354. }
  2355. gen_usr_ldscript ()
  2356. {
  2357.     ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  2358.     local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2359.     [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2360.     tc-is-static-only && return;
  2361.     if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2362.         multilib_is_native_abi || return 0;
  2363.     fi;
  2364.     case ${CTARGET:-${CHOST}} in
  2365.         *-darwin*)
  2366.  
  2367.         ;;
  2368.         *-android*)
  2369.             return 0
  2370.         ;;
  2371.         *linux*)
  2372.             use prefix && return 0
  2373.         ;;
  2374.         *)
  2375.             return 0
  2376.         ;;
  2377.     esac;
  2378.     dodir /usr/${libdir};
  2379.     if [[ $1 == "-a" ]]; then
  2380.         auto=true;
  2381.         shift;
  2382.         dodir /${libdir};
  2383.     fi;
  2384.     local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2385.     if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2386.         local d="${T}/bfd-linker";
  2387.         mkdir -p "${d}";
  2388.         ln -sf $(type -P ${CHOST}-ld.bfd) "${d}"/ld;
  2389.         flags+=(-B"${d}");
  2390.     fi;
  2391.     output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2392.     [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2393.     for lib in "$@";
  2394.     do
  2395.         local tlib;
  2396.         if ${auto}; then
  2397.             lib="lib${lib}${suffix}";
  2398.         else
  2399.             [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2400.         fi;
  2401.         case ${CTARGET:-${CHOST}} in
  2402.             *-darwin*)
  2403.                 if ${auto}; then
  2404.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2405.                 else
  2406.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2407.                 fi;
  2408.                 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2409.                 tlib=${tlib##*/};
  2410.                 if ${auto}; then
  2411.                     mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2412.                     if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2413.                         mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2414.                     fi;
  2415.                     rm -f "${ED}"/${libdir}/${lib};
  2416.                 fi;
  2417.                 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2418.                     chmod u+w "${ED}${libdir}/${tlib}";
  2419.                     local nowrite=yes;
  2420.                 fi;
  2421.                 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2422.                 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2423.                 pushd "${ED}/usr/${libdir}" > /dev/null;
  2424.                 ln -snf "../../${libdir}/${tlib}" "${lib}";
  2425.                 popd > /dev/null
  2426.             ;;
  2427.             *)
  2428.                 if ${auto}; then
  2429.                     tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2430.                     [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2431.                     mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2432.                     if [[ ${tlib} != ${lib}* ]]; then
  2433.                         mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2434.                     fi;
  2435.                     rm -f "${ED}"/${libdir}/${lib};
  2436.                 else
  2437.                     tlib=${lib};
  2438.                 fi;
  2439.                 cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2440. /* GNU ld script
  2441.    Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2442.    in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2443.    run into linking problems.  This "fake" dynamic lib is a linker script that
  2444.    redirects the linker to the real lib.  And yes, this works in the cross-
  2445.    compiling scenario as the sysroot-ed linker will prepend the real path.
  2446.  
  2447.    See bug https://bugs.gentoo.org/4411 for more info.
  2448.  */
  2449. ${output_format}
  2450. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2451. END_LDSCRIPT
  2452.  
  2453.             ;;
  2454.         esac
  2455.         fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2456.     done
  2457. }
  2458. get-flag ()
  2459. {
  2460.     [[ $# -ne 1 ]] && die "usage: <flag>";
  2461.     local f var findflag="$1";
  2462.     for var in $(all-flag-vars);
  2463.     do
  2464.         for f in ${!var};
  2465.         do
  2466.             if [ "${f/${findflag}}" != "${f}" ]; then
  2467.                 printf "%s\n" "${f/-${findflag}=}";
  2468.                 return 0;
  2469.             fi;
  2470.         done;
  2471.     done;
  2472.     return 1
  2473. }
  2474. get_NINJAOPTS ()
  2475. {
  2476.     if [[ -z ${NINJAOPTS+set} ]]; then
  2477.         NINJAOPTS="-j$(get_makeopts_jobs 999) -l$(get_makeopts_loadavg 0)";
  2478.     fi;
  2479.     echo "${NINJAOPTS}"
  2480. }
  2481. get_abi_CFLAGS ()
  2482. {
  2483.     get_abi_var CFLAGS "$@"
  2484. }
  2485. get_abi_CHOST ()
  2486. {
  2487.     get_abi_var CHOST "$@"
  2488. }
  2489. get_abi_CTARGET ()
  2490. {
  2491.     get_abi_var CTARGET "$@"
  2492. }
  2493. get_abi_FAKE_TARGETS ()
  2494. {
  2495.     get_abi_var FAKE_TARGETS "$@"
  2496. }
  2497. get_abi_LDFLAGS ()
  2498. {
  2499.     get_abi_var LDFLAGS "$@"
  2500. }
  2501. get_abi_LIBDIR ()
  2502. {
  2503.     get_abi_var LIBDIR "$@"
  2504. }
  2505. get_abi_var ()
  2506. {
  2507.     local flag=$1;
  2508.     local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2509.     local var="${flag}_${abi}";
  2510.     echo ${!var}
  2511. }
  2512. get_all_abis ()
  2513. {
  2514.     local x order="" mvar dvar;
  2515.     mvar="MULTILIB_ABIS";
  2516.     dvar="DEFAULT_ABI";
  2517.     if [[ -n $1 ]]; then
  2518.         mvar="$1_${mvar}";
  2519.         dvar="$1_${dvar}";
  2520.     fi;
  2521.     if [[ -z ${!mvar} ]]; then
  2522.         echo "default";
  2523.         return 0;
  2524.     fi;
  2525.     for x in ${!mvar};
  2526.     do
  2527.         if [[ ${x} != ${!dvar} ]]; then
  2528.             order="${order:+${order} }${x}";
  2529.         fi;
  2530.     done;
  2531.     order="${order:+${order} }${!dvar}";
  2532.     echo ${order};
  2533.     return 0
  2534. }
  2535. get_all_libdirs ()
  2536. {
  2537.     local libdirs abi;
  2538.     for abi in ${MULTILIB_ABIS};
  2539.     do
  2540.         libdirs+=" $(get_abi_LIBDIR ${abi})";
  2541.     done;
  2542.     [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2543.     echo "${libdirs}"
  2544. }
  2545. get_exeext ()
  2546. {
  2547.     case ${CHOST} in
  2548.         mingw* | *-mingw*)
  2549.             echo ".exe"
  2550.         ;;
  2551.     esac
  2552. }
  2553. get_install_abis ()
  2554. {
  2555.     local x order="";
  2556.     if [[ -z ${MULTILIB_ABIS} ]]; then
  2557.         echo "default";
  2558.         return 0;
  2559.     fi;
  2560.     if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2561.         for x in ${MULTILIB_ABIS};
  2562.         do
  2563.             if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2564.                 has ${x} ${ABI_DENY} || order="${order} ${x}";
  2565.             fi;
  2566.         done;
  2567.         has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2568.         if [[ -n ${ABI_ALLOW} ]]; then
  2569.             local ordera="";
  2570.             for x in ${order};
  2571.             do
  2572.                 if has ${x} ${ABI_ALLOW}; then
  2573.                     ordera="${ordera} ${x}";
  2574.                 fi;
  2575.             done;
  2576.             order=${ordera};
  2577.         fi;
  2578.     else
  2579.         order=${DEFAULT_ABI};
  2580.     fi;
  2581.     if [[ -z ${order} ]]; then
  2582.         die "The ABI list is empty.  Are you using a proper multilib profile?  Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
  2583.     fi;
  2584.     echo ${order};
  2585.     return 0
  2586. }
  2587. get_libdir ()
  2588. {
  2589.     local libdir_var="LIBDIR_${ABI}";
  2590.     local libdir="lib";
  2591.     [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2592.     echo "${libdir}"
  2593. }
  2594. get_libname ()
  2595. {
  2596.     local libname;
  2597.     local ver=$1;
  2598.     case ${CHOST} in
  2599.         mingw* | *-mingw*)
  2600.             libname="dll"
  2601.         ;;
  2602.         *-darwin*)
  2603.             libname="dylib"
  2604.         ;;
  2605.         *)
  2606.             libname="so"
  2607.         ;;
  2608.     esac;
  2609.     if [[ -z $* ]]; then
  2610.         echo ".${libname}";
  2611.     else
  2612.         for ver in "$@";
  2613.         do
  2614.             case ${CHOST} in
  2615.                 *-darwin*)
  2616.                     echo ".${ver}.${libname}"
  2617.                 ;;
  2618.                 *)
  2619.                     echo ".${libname}.${ver}"
  2620.                 ;;
  2621.             esac;
  2622.         done;
  2623.     fi
  2624. }
  2625. get_makeopts_jobs ()
  2626. {
  2627.     makeopts_jobs "$(_get_all_makeopts)" "${1:-1}"
  2628. }
  2629. get_makeopts_loadavg ()
  2630. {
  2631.     makeopts_loadavg "$(_get_all_makeopts)" "${1:-999}"
  2632. }
  2633. get_modname ()
  2634. {
  2635.     local modname;
  2636.     local ver=$1;
  2637.     case ${CHOST} in
  2638.         *-darwin*)
  2639.             modname="bundle"
  2640.         ;;
  2641.         *)
  2642.             modname="so"
  2643.         ;;
  2644.     esac;
  2645.     echo ".${modname}"
  2646. }
  2647. get_nproc ()
  2648. {
  2649.     local nproc;
  2650.     if type -P nproc &> /dev/null; then
  2651.         nproc=$(nproc);
  2652.     fi;
  2653.     if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  2654.         nproc=$(sysctl -n hw.ncpu 2>/dev/null);
  2655.     fi;
  2656.     if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  2657.         nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null);
  2658.     fi;
  2659.     if [[ -n ${nproc} ]]; then
  2660.         echo "${nproc}";
  2661.     else
  2662.         echo "${1:-1}";
  2663.     fi
  2664. }
  2665. gnome2_disable_deprecation_warning ()
  2666. {
  2667.     local retval=0;
  2668.     local fails=();
  2669.     local makefile;
  2670.     ebegin "Disabling deprecation warnings";
  2671.     while read makefile; do
  2672.         if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
  2673.             continue;
  2674.         fi;
  2675.         LC_ALL=C sed -r -i -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(/bin/true):g' -e 's:-DGSEAL_ENABLE(=[A-Za-z0-9_]*)?:$(/bin/true):g' -i "${makefile}";
  2676.         if [[ $? -ne 0 ]]; then
  2677.             fails+=("${makefile}");
  2678.             retval=2;
  2679.         fi;
  2680.     done < <(find "${S}" -name "Makefile.in"        -o -name "Makefile.am" -o -name "Makefile.decl"         | sort; [[ -f "${S}"/configure ]] && echo configure);
  2681.     eend ${retval};
  2682.     for makefile in "${fails[@]}";
  2683.     do
  2684.         ewarn "Failed to disable deprecation warnings in ${makefile}";
  2685.     done
  2686. }
  2687. gnome2_environment_reset ()
  2688. {
  2689.     xdg_environment_reset;
  2690.     export G_HOME="${T}";
  2691.     export GST_REGISTRY="${T}/registry.xml";
  2692.     export GSETTINGS_BACKEND="memory";
  2693.     if has ${EAPI} 6 7; then
  2694.         export GST_INSPECT="$(type -P true)";
  2695.         unset DISPLAY;
  2696.     fi
  2697. }
  2698. gnome2_gconf_install ()
  2699. {
  2700.     local updater="${EROOT%/}${GCONFTOOL_BIN}";
  2701.     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2702.         debug-print "No GNOME 2 GConf schemas found";
  2703.         return;
  2704.     fi;
  2705.     if tc-is-cross-compiler; then
  2706.         ewarn "Updating of GNOME 2 GConf schemas skipped due to cross-compilation.";
  2707.         ewarn "You might want to run gconftool-2 manually on the target for";
  2708.         ewarn "your final image and re-run it when packages installing";
  2709.         ewarn "GNOME 2 GConf schemas get upgraded or added to the image.";
  2710.         return;
  2711.     fi;
  2712.     if [[ ! -x "${updater}" ]]; then
  2713.         debug-print "${updater} is not executable";
  2714.         return;
  2715.     fi;
  2716.     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2717.     export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")";
  2718.     einfo "Installing GNOME 2 GConf schemas";
  2719.     local F;
  2720.     for F in ${GNOME2_ECLASS_SCHEMAS};
  2721.     do
  2722.         if [[ -e "${EROOT%/}/${F}" ]]; then
  2723.             debug-print "Installing schema: ${F}";
  2724.             "${updater}" --makefile-install-rule "${EROOT%/}/${F}" > /dev/null;
  2725.         fi;
  2726.     done;
  2727.     pids=$(pgrep -x gconfd-2);
  2728.     if [[ $? == 0 ]]; then
  2729.         ebegin "Reloading GConf schemas";
  2730.         kill -HUP ${pids};
  2731.         eend $?;
  2732.     fi
  2733. }
  2734. gnome2_gconf_savelist ()
  2735. {
  2736.     pushd "${ED}" > /dev/null || die;
  2737.     export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null);
  2738.     popd > /dev/null || die
  2739. }
  2740. gnome2_gconf_uninstall ()
  2741. {
  2742.     local updater="${EROOT%/}${GCONFTOOL_BIN}";
  2743.     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2744.         debug-print "No GNOME 2 GConf schemas found";
  2745.         return;
  2746.     fi;
  2747.     if tc-is-cross-compiler; then
  2748.         ewarn "Removal of GNOME 2 GConf schemas skipped due to cross-compilation.";
  2749.         ewarn "You might want to run gconftool-2 manually on the target for";
  2750.         ewarn "your final image to uninstall this package's schemas.";
  2751.         return;
  2752.     fi;
  2753.     if [[ ! -x "${updater}" ]]; then
  2754.         debug-print "${updater} is not executable";
  2755.         return;
  2756.     fi;
  2757.     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2758.     export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT%/}/;")";
  2759.     einfo "Uninstalling GNOME 2 GConf schemas";
  2760.     local F;
  2761.     for F in ${GNOME2_ECLASS_SCHEMAS};
  2762.     do
  2763.         if [[ -e "${EROOT%/}/${F}" ]]; then
  2764.             debug-print "Uninstalling gconf schema: ${F}";
  2765.             "${updater}" --makefile-uninstall-rule "${EROOT%/}/${F}" > /dev/null;
  2766.         fi;
  2767.     done;
  2768.     pids=$(pgrep -x gconfd-2);
  2769.     if [[ $? == 0 ]]; then
  2770.         ebegin "Reloading GConf schemas";
  2771.         kill -HUP ${pids};
  2772.         eend $?;
  2773.     fi
  2774. }
  2775. gnome2_gdk_pixbuf_savelist ()
  2776. {
  2777.     pushd "${ED}" > /dev/null || die;
  2778.     export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null);
  2779.     popd > /dev/null || die
  2780. }
  2781. gnome2_gdk_pixbuf_update ()
  2782. {
  2783.     local updater="${EROOT%/}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders";
  2784.     [[ -x ${updater} ]] || updater="${EROOT%/}/usr/bin/gdk-pixbuf-query-loaders";
  2785.     if tc-is-cross-compiler; then
  2786.         ewarn "Updating of gdk-pixbuf loader cache skipped due to cross-compilation.";
  2787.         ewarn "You might want to run gdk-pixbuf-query-loaders manually on the target";
  2788.         ewarn "for your final image and re-run it when packages installing";
  2789.         ewarn "gdk-pixbuf loaders get upgraded or added to the image.";
  2790.         return;
  2791.     fi;
  2792.     if [[ ! -x ${updater} ]]; then
  2793.         debug-print "${updater} is not executable";
  2794.         return;
  2795.     fi;
  2796.     ebegin "Updating gdk-pixbuf loader cache";
  2797.     local tmp_file=$(mktemp "${T}"/tmp.XXXXXXXXXX) || die "Failed to create temporary file";
  2798.     ${updater} > "${tmp_file}" && chmod 0644 "${tmp_file}" && cp -f "${tmp_file}" "${EROOT%/}/usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" && rm "${tmp_file}";
  2799.     eend $?
  2800. }
  2801. gnome2_giomodule_cache_update ()
  2802. {
  2803.     local updater="${EROOT%/}/usr/bin/${CHOST}-gio-querymodules";
  2804.     [[ -x ${updater} ]] || updater="${EROOT%/}/usr/bin/gio-querymodules";
  2805.     if tc-is-cross-compiler; then
  2806.         ewarn "Updating of GIO modules cache skipped due to cross-compilation.";
  2807.         ewarn "You might want to run gio-querymodules manually on the target for";
  2808.         ewarn "your final image for performance reasons and re-run it when packages";
  2809.         ewarn "installing GIO modules get upgraded or added to the image.";
  2810.         return;
  2811.     fi;
  2812.     if [[ ! -x ${updater} ]]; then
  2813.         debug-print "${updater} is not executable";
  2814.         return;
  2815.     fi;
  2816.     ebegin "Updating GIO modules cache";
  2817.     ${updater} "${EROOT%/}"/usr/$(get_libdir)/gio/modules;
  2818.     eend $?
  2819. }
  2820. gnome2_omf_fix ()
  2821. {
  2822.     local omf_makefiles filename;
  2823.     omf_makefiles="$@";
  2824.     if [[ -f ${S}/omf.make ]]; then
  2825.         omf_makefiles="${omf_makefiles} ${S}/omf.make";
  2826.     fi;
  2827.     if [[ -f ${S}/gnome-doc-utils.make ]]; then
  2828.         omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make";
  2829.     fi;
  2830.     for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort);
  2831.     do
  2832.         omf_makefiles="${omf_makefiles} ${filename}";
  2833.     done;
  2834.     ebegin "Fixing OMF Makefiles";
  2835.     local retval=0;
  2836.     local fails=();
  2837.     for omf in ${omf_makefiles};
  2838.     do
  2839.         sed -i -e 's:scrollkeeper-update:true:' "${omf}";
  2840.         retval=$?;
  2841.         if [[ $retval -ne 0 ]]; then
  2842.             debug-print "updating of ${omf} failed";
  2843.             fails[$(( ${#fails[@]} + 1 ))]=$omf;
  2844.             retval=2;
  2845.         fi;
  2846.     done;
  2847.     eend $retval;
  2848.     for f in "${fails[@]}";
  2849.     do
  2850.         eerror "Failed to update OMF Makefile $f";
  2851.     done
  2852. }
  2853. gnome2_pkg_postinst ()
  2854. {
  2855.     xdg_pkg_postinst;
  2856.     gnome2_gconf_install;
  2857.     if [[ -n ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
  2858.         gnome2_schemas_update;
  2859.     fi;
  2860.     gnome2_scrollkeeper_update;
  2861.     if [[ -n ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
  2862.         gnome2_gdk_pixbuf_update;
  2863.     fi;
  2864.     if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  2865.         gnome2_giomodule_cache_update;
  2866.     fi
  2867. }
  2868. gnome2_pkg_postrm ()
  2869. {
  2870.     xdg_pkg_postrm;
  2871.     if [[ -n ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
  2872.         gnome2_schemas_update;
  2873.     fi;
  2874.     gnome2_scrollkeeper_update;
  2875.     if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  2876.         gnome2_giomodule_cache_update;
  2877.     fi
  2878. }
  2879. gnome2_pkg_preinst ()
  2880. {
  2881.     xdg_pkg_preinst;
  2882.     gnome2_gconf_savelist;
  2883.     gnome2_schemas_savelist;
  2884.     gnome2_scrollkeeper_savelist;
  2885.     gnome2_gdk_pixbuf_savelist;
  2886.     local f;
  2887.     GNOME2_ECLASS_GIO_MODULES=();
  2888.     while IFS= read -r -d '' f; do
  2889.         GNOME2_ECLASS_GIO_MODULES+=(${f});
  2890.     done < <(cd "${D}" && find usr/$(get_libdir)/gio/modules -type f -print0 2>/dev/null);
  2891.     export GNOME2_ECLASS_GIO_MODULES
  2892. }
  2893. gnome2_query_immodules_gtk2 ()
  2894. {
  2895.     local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-2.0;
  2896.     [[ -x ${updater} ]] || updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0;
  2897.     if [[ ! -x ${updater} ]]; then
  2898.         debug-print "${updater} is not executable";
  2899.         return;
  2900.     fi;
  2901.     ebegin "Updating gtk2 input method module cache";
  2902.     GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" "${updater}" --update-cache;
  2903.     eend $?
  2904. }
  2905. gnome2_query_immodules_gtk3 ()
  2906. {
  2907.     local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-3.0;
  2908.     [[ -x ${updater} ]] || updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0;
  2909.     if [[ ! -x ${updater} ]]; then
  2910.         debug-print "${updater} is not executable";
  2911.         return;
  2912.     fi;
  2913.     ebegin "Updating gtk3 input method module cache";
  2914.     GTK_IM_MODULE_FILE="${EROOT%/}/usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" "${updater}" --update-cache;
  2915.     eend $?
  2916. }
  2917. gnome2_schemas_savelist ()
  2918. {
  2919.     pushd "${ED}" > /dev/null || die;
  2920.     export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null);
  2921.     popd > /dev/null || die
  2922. }
  2923. gnome2_schemas_update ()
  2924. {
  2925.     local updater="${EROOT%/}${GLIB_COMPILE_SCHEMAS}";
  2926.     if tc-is-cross-compiler; then
  2927.         ewarn "Updating of GSettings schemas skipped due to cross-compilation.";
  2928.         ewarn "You might want to run glib-compile-schemas manually on the target";
  2929.         ewarn "for your final image and re-run it when packages installing";
  2930.         ewarn "GSettings schemas get upgraded or added to the image.";
  2931.         return;
  2932.     fi;
  2933.     if [[ ! -x ${updater} ]]; then
  2934.         debug-print "${updater} is not executable";
  2935.         return;
  2936.     fi;
  2937.     ebegin "Updating GSettings schemas";
  2938.     ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &> /dev/null;
  2939.     eend $?
  2940. }
  2941. gnome2_scrollkeeper_savelist ()
  2942. {
  2943.     pushd "${ED}" > /dev/null || die;
  2944.     export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null);
  2945.     popd > /dev/null || die
  2946. }
  2947. gnome2_scrollkeeper_update ()
  2948. {
  2949.     local updater="${EROOT%/}${SCROLLKEEPER_UPDATE_BIN}";
  2950.     if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
  2951.         debug-print "No scroll cache to update";
  2952.         return;
  2953.     fi;
  2954.     if tc-is-cross-compiler; then
  2955.         ewarn "Updating of scrollkeeper database skipped due to cross-compilation.";
  2956.         ewarn "You might want to run scrollkeeper-update manually on the target";
  2957.         ewarn "for your final image and re-run it when packages installing";
  2958.         ewarn "scrollkeeper OMF files get upgraded or added to the image.";
  2959.         return;
  2960.     fi;
  2961.     if [[ ! -x "${updater}" ]]; then
  2962.         debug-print "${updater} is not executable";
  2963.         return;
  2964.     fi;
  2965.     ebegin "Updating scrollkeeper database ...";
  2966.     "${updater}" -q -p "${EROOT%/}${SCROLLKEEPER_DIR}";
  2967.     eend $?
  2968. }
  2969. gnome2_src_compile ()
  2970. {
  2971.     default
  2972. }
  2973. gnome2_src_configure ()
  2974. {
  2975.     local g2conf=();
  2976.     if grep -q "enable-gtk-doc" "${ECONF_SOURCE:-.}"/configure; then
  2977.         g2conf+=(--disable-gtk-doc);
  2978.     fi;
  2979.     if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" "${ECONF_SOURCE:-.}"/configure.*; then
  2980.         g2conf+=(--disable-maintainer-mode);
  2981.     fi;
  2982.     if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then
  2983.         g2conf+=(--disable-scrollkeeper);
  2984.     fi;
  2985.     if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then
  2986.         g2conf+=(--disable-schemas-install);
  2987.     fi;
  2988.     if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then
  2989.         g2conf+=(--disable-schemas-compile);
  2990.     fi;
  2991.     if grep -q "disable-update-mimedb" "${ECONF_SOURCE:-.}"/configure; then
  2992.         g2conf+=(--disable-update-mimedb);
  2993.     fi;
  2994.     if grep -q "enable-compile-warnings" "${ECONF_SOURCE:-.}"/configure; then
  2995.         g2conf+=(--enable-compile-warnings=minimum);
  2996.     fi;
  2997.     addpredict "$(unset HOME; echo ~)/.gnome2";
  2998.     econf ${g2conf[@]} "$@"
  2999. }
  3000. gnome2_src_install ()
  3001. {
  3002.     export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1";
  3003.     local sk_tmp_dir="/var/lib/scrollkeeper";
  3004.     default;
  3005.     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  3006.     local d;
  3007.     for d in HACKING MAINTAINERS;
  3008.     do
  3009.         [[ -s ${d} ]] && dodoc "${d}";
  3010.     done;
  3011.     rm -rf "${ED}${sk_tmp_dir}" || die;
  3012.     rmdir "${ED}/var/lib" 2> /dev/null;
  3013.     rmdir "${ED}/var" 2> /dev/null;
  3014.     rm -rf "${ED}/usr/share/applications/mimeinfo.cache" || die;
  3015.     if has ${EAPI} 6; then
  3016.         case "${GNOME2_LA_PUNT}" in
  3017.             yes)
  3018.                 prune_libtool_files --modules
  3019.             ;;
  3020.             no)
  3021.  
  3022.             ;;
  3023.             *)
  3024.                 prune_libtool_files
  3025.             ;;
  3026.         esac;
  3027.     else
  3028.         if [[ ${GNOME2_LA_PUNT} != 'no' ]]; then
  3029.             find "${ED}" -name '*.la' -delete || die;
  3030.         fi;
  3031.     fi
  3032. }
  3033. gnome2_src_prepare ()
  3034. {
  3035.     default;
  3036.     gnome2_environment_reset;
  3037.     gnome2_disable_deprecation_warning;
  3038.     if [[ ${GNOME2_EAUTORECONF} == yes ]]; then
  3039.         eautoreconf;
  3040.     else
  3041.         elibtoolize ${ELTCONF};
  3042.     fi
  3043. }
  3044. has_multilib_profile ()
  3045. {
  3046.     [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  3047. }
  3048. in_iuse ()
  3049. {
  3050.     local use=${1};
  3051.     if [[ -z "${use}" ]]; then
  3052.         echo "!!! in_iuse() called without a parameter." 1>&2;
  3053.         echo "!!! in_iuse <USEFLAG>" 1>&2;
  3054.         die "in_iuse() called without a parameter";
  3055.     fi;
  3056.     local liuse=(${IUSE_EFFECTIVE});
  3057.     has "${use}" "${liuse[@]#[+-]}"
  3058. }
  3059. is-flag ()
  3060. {
  3061.     is-flagq "$@" && echo true
  3062. }
  3063. is-flagq ()
  3064. {
  3065.     [[ -n $2 ]] && die "Usage: is-flag <flag>";
  3066.     local var;
  3067.     for var in $(all-flag-vars);
  3068.     do
  3069.         _is_flagq ${var} "$1" && return 0;
  3070.     done;
  3071.     return 1
  3072. }
  3073. is-ldflag ()
  3074. {
  3075.     is-ldflagq "$@" && echo true
  3076. }
  3077. is-ldflagq ()
  3078. {
  3079.     [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  3080.     _is_flagq LDFLAGS $1
  3081. }
  3082. is_final_abi ()
  3083. {
  3084.     has_multilib_profile || return 0;
  3085.     set -- $(get_install_abis);
  3086.     local LAST_ABI=$#;
  3087.     [[ ${!LAST_ABI} == ${ABI} ]]
  3088. }
  3089. makeopts_jobs ()
  3090. {
  3091.     [[ $# -eq 0 ]] && set -- "$(_get_all_makeopts)";
  3092.     local jobs=$(echo " $* " | sed -r -n        -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p'        -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( $(get_nproc) + 1 ))}:p");
  3093.     echo ${jobs:-1}
  3094. }
  3095. makeopts_loadavg ()
  3096. {
  3097.     [[ $# -eq 0 ]] && set -- "$(_get_all_makeopts)";
  3098.     local lavg=$(echo " $* " | sed -r -n        -e 's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+(\.[0-9]+)?)[[:space:]].*:\3:p'       -e "s:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:${2:-999}:p");
  3099.     echo ${lavg:-${2:-999}}
  3100. }
  3101. multilib_env ()
  3102. {
  3103.     local CTARGET=${1:-${CTARGET}};
  3104.     local cpu=${CTARGET%%*-};
  3105.     if [[ ${CTARGET} = *-musl* ]]; then
  3106.         : "${MULTILIB_ABIS=default}";
  3107.         : "${DEFAULT_ABI=default}";
  3108.         export MULTILIB_ABIS DEFAULT_ABI;
  3109.         return;
  3110.     fi;
  3111.     case ${cpu} in
  3112.         aarch64*)
  3113.             export CFLAGS_arm=${CFLAGS_arm-};
  3114.             case ${cpu} in
  3115.                 aarch64*be)
  3116.                     export CHOST_arm="armv8b-${CTARGET#*-}"
  3117.                 ;;
  3118.                 *)
  3119.                     export CHOST_arm="armv8l-${CTARGET#*-}"
  3120.                 ;;
  3121.             esac;
  3122.             CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  3123.             export CTARGET_arm=${CHOST_arm};
  3124.             export LIBDIR_arm="lib";
  3125.             export CFLAGS_arm64=${CFLAGS_arm64-};
  3126.             export CHOST_arm64=${CTARGET};
  3127.             export CTARGET_arm64=${CHOST_arm64};
  3128.             export LIBDIR_arm64="lib64";
  3129.             : "${MULTILIB_ABIS=arm64}";
  3130.             : "${DEFAULT_ABI=arm64}"
  3131.         ;;
  3132.         x86_64*)
  3133.             export CFLAGS_x86=${CFLAGS_x86--m32};
  3134.             export CHOST_x86=${CTARGET/x86_64/i686};
  3135.             CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  3136.             export CTARGET_x86=${CHOST_x86};
  3137.             if [[ ${SYMLINK_LIB} == "yes" ]]; then
  3138.                 export LIBDIR_x86="lib32";
  3139.             else
  3140.                 export LIBDIR_x86="lib";
  3141.             fi;
  3142.             export CFLAGS_amd64=${CFLAGS_amd64--m64};
  3143.             export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  3144.             export CTARGET_amd64=${CHOST_amd64};
  3145.             export LIBDIR_amd64="lib64";
  3146.             export CFLAGS_x32=${CFLAGS_x32--mx32};
  3147.             export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  3148.             export CTARGET_x32=${CHOST_x32};
  3149.             export LIBDIR_x32="libx32";
  3150.             case ${CTARGET} in
  3151.                 *-gnux32)
  3152.                     : "${MULTILIB_ABIS=x32 amd64 x86}";
  3153.                     : "${DEFAULT_ABI=x32}"
  3154.                 ;;
  3155.                 *)
  3156.                     : "${MULTILIB_ABIS=amd64 x86}";
  3157.                     : "${DEFAULT_ABI=amd64}"
  3158.                 ;;
  3159.             esac
  3160.         ;;
  3161.         loongarch64*)
  3162.             export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  3163.             export CHOST_lp64d=${CTARGET};
  3164.             export CTARGET_lp64d=${CTARGET};
  3165.             export LIBDIR_lp64d=${LIBDIR_lp64d-lib64};
  3166.             : "${MULTILIB_ABIS=lp64d}";
  3167.             : "${DEFAULT_ABI=lp64d}"
  3168.         ;;
  3169.         mips64* | mipsisa64*)
  3170.             export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3171.             export CHOST_o32=${CTARGET/mips64/mips};
  3172.             export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  3173.             export CTARGET_o32=${CHOST_o32};
  3174.             export LIBDIR_o32="lib";
  3175.             export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3176.             export CHOST_n32=${CTARGET};
  3177.             export CTARGET_n32=${CHOST_n32};
  3178.             export LIBDIR_n32="lib32";
  3179.             export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3180.             export CHOST_n64=${CTARGET};
  3181.             export CTARGET_n64=${CHOST_n64};
  3182.             export LIBDIR_n64="lib64";
  3183.             : "${MULTILIB_ABIS=n64 n32 o32}";
  3184.             : "${DEFAULT_ABI=n32}"
  3185.         ;;
  3186.         powerpc64*)
  3187.             export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3188.             export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3189.             export CTARGET_ppc=${CHOST_ppc};
  3190.             export LIBDIR_ppc="lib";
  3191.             export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3192.             export CHOST_ppc64=${CTARGET};
  3193.             export CTARGET_ppc64=${CHOST_ppc64};
  3194.             export LIBDIR_ppc64="lib64";
  3195.             : "${MULTILIB_ABIS=ppc64 ppc}";
  3196.             : "${DEFAULT_ABI=ppc64}"
  3197.         ;;
  3198.         riscv64*)
  3199.             : "${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32}";
  3200.             : "${DEFAULT_ABI=lp64d}";
  3201.             local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  3202.             local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  3203.             export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib64};
  3204.             export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64gc};
  3205.             export CHOST_lp64d=${CTARGET};
  3206.             export CTARGET_lp64d=${CTARGET};
  3207.             export LIBDIR_lp64d=${LIBDIR_lp64d-lib64/lp64d};
  3208.             export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac};
  3209.             export CHOST_lp64=${CTARGET};
  3210.             export CTARGET_lp64=${CTARGET};
  3211.             export LIBDIR_lp64=${LIBDIR_lp64-lib64/lp64};
  3212.             export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  3213.             export CHOST_ilp32d=${CTARGET/riscv64/riscv32};
  3214.             export CTARGET_ilp32d=${CTARGET/riscv64/riscv32};
  3215.             export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  3216.             export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  3217.             export CHOST_ilp32=${CTARGET/riscv64/riscv32};
  3218.             export CTARGET_ilp32=${CTARGET/riscv64/riscv32};
  3219.             export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  3220.         ;;
  3221.         riscv32*)
  3222.             : "${MULTILIB_ABIS=ilp32d ilp32}";
  3223.             : "${DEFAULT_ABI=ilp32d}";
  3224.             local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}";
  3225.             local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable};
  3226.             export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib};
  3227.             export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc};
  3228.             export CHOST_ilp32d=${CTARGET};
  3229.             export CTARGET_ilp32d=${CTARGET};
  3230.             export LIBDIR_ilp32d=${LIBDIR_ilp32d-lib32/ilp32d};
  3231.             export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac};
  3232.             export CHOST_ilp32=${CTARGET};
  3233.             export CTARGET_ilp32=${CTARGET};
  3234.             export LIBDIR_ilp32=${LIBDIR_ilp32-lib32/ilp32}
  3235.         ;;
  3236.         s390x*)
  3237.             export CFLAGS_s390=${CFLAGS_s390--m31};
  3238.             export CHOST_s390=${CTARGET/s390x/s390};
  3239.             export CTARGET_s390=${CHOST_s390};
  3240.             export LIBDIR_s390="lib";
  3241.             export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3242.             export CHOST_s390x=${CTARGET};
  3243.             export CTARGET_s390x=${CHOST_s390x};
  3244.             export LIBDIR_s390x="lib64";
  3245.             : "${MULTILIB_ABIS=s390x s390}";
  3246.             : "${DEFAULT_ABI=s390x}"
  3247.         ;;
  3248.         sparc64*)
  3249.             export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  3250.             export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3251.             export CTARGET_sparc32=${CHOST_sparc32};
  3252.             export LIBDIR_sparc32="lib";
  3253.             export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3254.             export CHOST_sparc64=${CTARGET};
  3255.             export CTARGET_sparc64=${CHOST_sparc64};
  3256.             export LIBDIR_sparc64="lib64";
  3257.             : "${MULTILIB_ABIS=sparc64 sparc32}";
  3258.             : "${DEFAULT_ABI=sparc64}"
  3259.         ;;
  3260.         *)
  3261.             : "${MULTILIB_ABIS=default}";
  3262.             : "${DEFAULT_ABI=default}"
  3263.         ;;
  3264.     esac;
  3265.     export MULTILIB_ABIS DEFAULT_ABI
  3266. }
  3267. multilib_toolchain_setup ()
  3268. {
  3269.     local v vv;
  3270.     export ABI=$1;
  3271.     local save_restore_variables=(CBUILD CHOST AR CC CXX F77 FC LD NM OBJCOPY OBJDUMP PKG_CONFIG RANLIB READELF STRINGS STRIP PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH);
  3272.     if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  3273.         for v in "${save_restore_variables[@]}";
  3274.         do
  3275.             vv="_abi_saved_${v}";
  3276.             [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  3277.             unset ${vv};
  3278.         done;
  3279.         unset _DEFAULT_ABI_SAVED;
  3280.     fi;
  3281.     if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3282.         for v in "${save_restore_variables[@]}";
  3283.         do
  3284.             vv="_abi_saved_${v}";
  3285.             [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  3286.         done;
  3287.         export _DEFAULT_ABI_SAVED="true";
  3288.         if [[ ${CBUILD} == "${CHOST}" ]]; then
  3289.             export CBUILD=$(get_abi_CHOST $1);
  3290.         fi;
  3291.         export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3292.         export AR="$(tc-getAR)";
  3293.         export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3294.         export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3295.         export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  3296.         export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  3297.         export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3298.         export NM="$(tc-getNM)";
  3299.         export OBJCOPY="$(tc-getOBJCOPY)";
  3300.         export OBJDUMP="$(tc-getOBJDUMP)";
  3301.         export PKG_CONFIG="$(tc-getPKG_CONFIG)";
  3302.         export RANLIB="$(tc-getRANLIB)";
  3303.         export READELF="$(tc-getREADELF)";
  3304.         export STRINGS="$(tc-getSTRINGS)";
  3305.         export STRIP="$(tc-getSTRIP)";
  3306.         export CHOST=$(get_abi_CHOST $1);
  3307.         export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  3308.         export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  3309.         export PKG_CONFIG_SYSTEM_INCLUDE_PATH=${EPREFIX}/usr/include;
  3310.         export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir);
  3311.     fi
  3312. }
  3313. no-as-needed ()
  3314. {
  3315.     [[ $# -ne 0 ]] && die "no-as-needed takes no arguments";
  3316.     case $($(tc-getLD) -v 2>&1 </dev/null) in
  3317.         *GNU*)
  3318.             echo "-Wl,--no-as-needed"
  3319.         ;;
  3320.     esac
  3321. }
  3322. number_abis ()
  3323. {
  3324.     set -- `get_install_abis`;
  3325.     echo $#
  3326. }
  3327. optfeature ()
  3328. {
  3329.     debug-print-function ${FUNCNAME} "$@";
  3330.     local i j msg;
  3331.     local -a arr;
  3332.     local desc=$1;
  3333.     local flag=0;
  3334.     shift;
  3335.     for i in "$@";
  3336.     do
  3337.         read -r -d '' -a arr <<< "${i}";
  3338.         for j in "${arr[@]}";
  3339.         do
  3340.             if has_version "${j}"; then
  3341.                 flag=1;
  3342.             else
  3343.                 flag=0;
  3344.                 break;
  3345.             fi;
  3346.         done;
  3347.         if [[ ${flag} -eq 1 ]]; then
  3348.             break;
  3349.         fi;
  3350.     done;
  3351.     if [[ ${flag} -eq 0 ]]; then
  3352.         if [[ ${_OPTFEATURE_DOHEADER} == true ]]; then
  3353.             elog ${_OPTFEATURE_HEADER:-${_OPTFEATURE_DEFAULT_HEADER}};
  3354.             _OPTFEATURE_DOHEADER=false;
  3355.         fi;
  3356.         for i in "$@";
  3357.         do
  3358.             read -r -d '' -a arr <<< "${i}";
  3359.             msg=" ";
  3360.             for j in "${arr[@]}";
  3361.             do
  3362.                 msg+=" ${j} and";
  3363.             done;
  3364.             msg="${msg:0: -4} for ${desc}";
  3365.             elog "${msg}";
  3366.         done;
  3367.     fi
  3368. }
  3369. optfeature_header ()
  3370. {
  3371.     debug-print-function ${FUNCNAME} "$@";
  3372.     _OPTFEATURE_HEADER="${1}";
  3373.     _OPTFEATURE_DOHEADER=true
  3374. }
  3375. pkg_nofetch ()
  3376. {
  3377.     default
  3378. }
  3379. pkg_postinst ()
  3380. {
  3381.     optfeature "geolocation service (used at runtime if available)" "app-misc/geoclue";
  3382.     optfeature "Common Multimedia codecs" "media-plugins/gst-plugins-meta";
  3383.     optfeature "VAAPI encoding support" "media-libs/gst-plugins-bad[vaapi]";
  3384.     optfeature "MPEG-DASH support" "media-plugins/gst-plugins-dash";
  3385.     optfeature "HTTP live streaming (HLS) support" "media-plugins/gst-plugins-hls"
  3386. }
  3387. pkg_postrm ()
  3388. {
  3389.     gnome2_pkg_postrm "$@"
  3390. }
  3391. pkg_preinst ()
  3392. {
  3393.     gnome2_pkg_preinst "$@"
  3394. }
  3395. pkg_pretend ()
  3396. {
  3397.     if [[ ${MERGE_TYPE} != "binary" ]]; then
  3398.         if is-flagq "-g*" && ! is-flagq "-g*0"; then
  3399.             einfo "Checking for sufficient disk space to build ${PN} with debugging CFLAGS";
  3400.             check-reqs_pkg_pretend;
  3401.         fi;
  3402.         if ! test-flag-CXX -std=c++17; then
  3403.             die "You need at least GCC 7.3.x or Clang >= 5 for C++17-specific compiler flags";
  3404.         fi;
  3405.     fi
  3406. }
  3407. pkg_setup ()
  3408. {
  3409.     if [[ ${MERGE_TYPE} != "binary" ]] && is-flagq "-g*" && ! is-flagq "-g*0"; then
  3410.         check-reqs_pkg_setup;
  3411.     fi;
  3412.     python-any-r1_pkg_setup
  3413. }
  3414. python-any-r1_pkg_setup ()
  3415. {
  3416.     debug-print-function ${FUNCNAME} "${@}";
  3417.     [[ ${MERGE_TYPE} != binary ]] && python_setup
  3418. }
  3419. python_doexe ()
  3420. {
  3421.     debug-print-function ${FUNCNAME} "${@}";
  3422.     [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3423.     local f;
  3424.     for f in "$@";
  3425.     do
  3426.         python_newexe "${f}" "${f##*/}";
  3427.     done
  3428. }
  3429. python_doheader ()
  3430. {
  3431.     debug-print-function ${FUNCNAME} "${@}";
  3432.     [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3433.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3434.     local includedir=$(python_get_includedir);
  3435.     local d=${includedir#${ESYSROOT}};
  3436.     ( insopts -m 0644;
  3437.     insinto "${d}";
  3438.     doins -r "${@}" || return ${?} )
  3439. }
  3440. python_domodule ()
  3441. {
  3442.     debug-print-function ${FUNCNAME} "${@}";
  3443.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3444.     local d;
  3445.     if [[ ${_PYTHON_MODULEROOT} == /* ]]; then
  3446.         d=${_PYTHON_MODULEROOT};
  3447.     else
  3448.         local sitedir=$(python_get_sitedir);
  3449.         d=${sitedir#${EPREFIX}}/${_PYTHON_MODULEROOT//.//};
  3450.     fi;
  3451.     if [[ ${EBUILD_PHASE} == install ]]; then
  3452.         ( insopts -m 0644;
  3453.         insinto "${d}";
  3454.         doins -r "${@}" || return ${?} );
  3455.         python_optimize "${ED%/}/${d}";
  3456.     else
  3457.         if [[ -n ${BUILD_DIR} ]]; then
  3458.             local dest=${BUILD_DIR}/install${EPREFIX}/${d};
  3459.             mkdir -p "${dest}" || die;
  3460.             cp -pR "${@}" "${dest}/" || die;
  3461.             ( cd "${dest}" && chmod -R a+rX "${@##*/}" ) || die;
  3462.         else
  3463.             die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set";
  3464.         fi;
  3465.     fi
  3466. }
  3467. python_doscript ()
  3468. {
  3469.     debug-print-function ${FUNCNAME} "${@}";
  3470.     [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3471.     local _PYTHON_REWRITE_SHEBANG=1;
  3472.     python_doexe "${@}"
  3473. }
  3474. python_export_utf8_locale ()
  3475. {
  3476.     debug-print-function ${FUNCNAME} "${@}";
  3477.     type locale &> /dev/null || return 0;
  3478.     if [[ $(locale charmap) != UTF-8 ]]; then
  3479.         local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  3480.         for lang in ${locales};
  3481.         do
  3482.             if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  3483.                 if _python_check_locale_sanity "${lang}"; then
  3484.                     export LC_CTYPE=${lang};
  3485.                     if [[ -n ${LC_ALL} ]]; then
  3486.                         export LC_NUMERIC=${LC_ALL};
  3487.                         export LC_TIME=${LC_ALL};
  3488.                         export LC_COLLATE=${LC_ALL};
  3489.                         export LC_MONETARY=${LC_ALL};
  3490.                         export LC_MESSAGES=${LC_ALL};
  3491.                         export LC_PAPER=${LC_ALL};
  3492.                         export LC_NAME=${LC_ALL};
  3493.                         export LC_ADDRESS=${LC_ALL};
  3494.                         export LC_TELEPHONE=${LC_ALL};
  3495.                         export LC_MEASUREMENT=${LC_ALL};
  3496.                         export LC_IDENTIFICATION=${LC_ALL};
  3497.                         export LC_ALL=;
  3498.                     fi;
  3499.                     return 0;
  3500.                 fi;
  3501.             fi;
  3502.         done;
  3503.         ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  3504.         ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  3505.         ewarn "/etc/locale.gen and run locale-gen.";
  3506.         return 1;
  3507.     fi;
  3508.     return 0
  3509. }
  3510. python_fix_shebang ()
  3511. {
  3512.     debug-print-function ${FUNCNAME} "${@}";
  3513.     [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  3514.     local force quiet;
  3515.     while [[ -n ${@} ]]; do
  3516.         case "${1}" in
  3517.             -f | --force)
  3518.                 force=1;
  3519.                 shift
  3520.             ;;
  3521.             -q | --quiet)
  3522.                 quiet=1;
  3523.                 shift
  3524.             ;;
  3525.             --)
  3526.                 shift;
  3527.                 break
  3528.             ;;
  3529.             *)
  3530.                 break
  3531.             ;;
  3532.         esac;
  3533.     done;
  3534.     [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  3535.     local path f;
  3536.     for path in "$@";
  3537.     do
  3538.         local any_fixed is_recursive;
  3539.         [[ -d ${path} ]] && is_recursive=1;
  3540.         while IFS= read -r -d '' f; do
  3541.             local shebang i;
  3542.             local error= match=;
  3543.             IFS= read -r shebang < "${f}";
  3544.             if [[ ${shebang} == '#!'* ]]; then
  3545.                 local split_shebang=();
  3546.                 read -r -a split_shebang <<< ${shebang#"#!"} || die;
  3547.                 local in_path=${split_shebang[0]};
  3548.                 local from='^#! *[^ ]*';
  3549.                 if [[ ${in_path} == */env ]]; then
  3550.                     in_path=${split_shebang[1]};
  3551.                     from+=' *[^ ]*';
  3552.                 fi;
  3553.                 case ${in_path##*/} in
  3554.                     "${EPYTHON}")
  3555.                         match=1
  3556.                     ;;
  3557.                     python | python3)
  3558.                         match=1
  3559.                     ;;
  3560.                     python2 | python[23].[0-9] | python3.[1-9][0-9] | pypy | pypy3 | jython[23].[0-9])
  3561.                         match=1;
  3562.                         error=1
  3563.                     ;;
  3564.                 esac;
  3565.             fi;
  3566.             [[ -n ${force} ]] && error=;
  3567.             if [[ ! -n ${match} ]]; then
  3568.                 [[ -n ${is_recursive} ]] && continue;
  3569.                 error=1;
  3570.             fi;
  3571.             if [[ ! -n ${quiet} ]]; then
  3572.                 einfo "Fixing shebang in ${f#${D%/}}.";
  3573.             fi;
  3574.             if [[ ! -n ${error} ]]; then
  3575.                 debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3576.                 debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  3577.                 sed -i -e "1s@${from}@#!${EPREFIX}/usr/bin/${EPYTHON}@" "${f}" || die;
  3578.                 any_fixed=1;
  3579.             else
  3580.                 eerror "The file has incompatible shebang:";
  3581.                 eerror "  file: ${f#${D%/}}";
  3582.                 eerror "  current shebang: ${shebang}";
  3583.                 eerror "  requested impl: ${EPYTHON}";
  3584.                 die "${FUNCNAME}: conversion of incompatible shebang requested";
  3585.             fi;
  3586.         done < <(find -H "${path}" -type f -print0 || die);
  3587.         if [[ ! -n ${any_fixed} ]]; then
  3588.             eerror "QA error: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  3589.             eerror "There are no Python files in specified directory.";
  3590.             die "${FUNCNAME} did not match any fixable files";
  3591.         fi;
  3592.     done
  3593. }
  3594. python_gen_any_dep ()
  3595. {
  3596.     debug-print-function ${FUNCNAME} "${@}";
  3597.     local depstr=${1};
  3598.     [[ -n ${depstr} ]] || die "No dependency string provided";
  3599.     local i PYTHON_PKG_DEP out=;
  3600.     for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3601.     do
  3602.         local PYTHON_USEDEP="python_targets_${i}(-)";
  3603.         local PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)";
  3604.         _python_export "${i}" PYTHON_PKG_DEP;
  3605.         local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  3606.         i_depstr=${i_depstr//\$\{PYTHON_SINGLE_USEDEP\}/${PYTHON_SINGLE_USEDEP}};
  3607.         out="( ${PYTHON_PKG_DEP%:=} ${i_depstr} ) ${out}";
  3608.     done;
  3609.     echo "|| ( ${out})"
  3610. }
  3611. python_get_CFLAGS ()
  3612. {
  3613.     debug-print-function ${FUNCNAME} "${@}";
  3614.     _python_export "${@}" PYTHON_CFLAGS;
  3615.     echo "${PYTHON_CFLAGS}"
  3616. }
  3617. python_get_LIBS ()
  3618. {
  3619.     debug-print-function ${FUNCNAME} "${@}";
  3620.     _python_export "${@}" PYTHON_LIBS;
  3621.     echo "${PYTHON_LIBS}"
  3622. }
  3623. python_get_PYTHON_CONFIG ()
  3624. {
  3625.     debug-print-function ${FUNCNAME} "${@}";
  3626.     _python_export "${@}" PYTHON_CONFIG;
  3627.     echo "${PYTHON_CONFIG}"
  3628. }
  3629. python_get_includedir ()
  3630. {
  3631.     debug-print-function ${FUNCNAME} "${@}";
  3632.     _python_export "${@}" PYTHON_INCLUDEDIR;
  3633.     echo "${PYTHON_INCLUDEDIR}"
  3634. }
  3635. python_get_library_path ()
  3636. {
  3637.     debug-print-function ${FUNCNAME} "${@}";
  3638.     _python_export "${@}" PYTHON_LIBPATH;
  3639.     echo "${PYTHON_LIBPATH}"
  3640. }
  3641. python_get_scriptdir ()
  3642. {
  3643.     debug-print-function ${FUNCNAME} "${@}";
  3644.     _python_export "${@}" PYTHON_SCRIPTDIR;
  3645.     echo "${PYTHON_SCRIPTDIR}"
  3646. }
  3647. python_get_sitedir ()
  3648. {
  3649.     debug-print-function ${FUNCNAME} "${@}";
  3650.     _python_export "${@}" PYTHON_SITEDIR;
  3651.     echo "${PYTHON_SITEDIR}"
  3652. }
  3653. python_has_version ()
  3654. {
  3655.     debug-print-function ${FUNCNAME} "${@}";
  3656.     local root_arg=(-b);
  3657.     case ${1} in
  3658.         -b | -d | -r)
  3659.             root_arg=("${1}");
  3660.             shift
  3661.         ;;
  3662.     esac;
  3663.     local pkg;
  3664.     for pkg in "$@";
  3665.     do
  3666.         ebegin "    ${pkg}";
  3667.         has_version "${root_arg[@]}" "${pkg}";
  3668.         eend ${?} || return;
  3669.     done;
  3670.     return 0
  3671. }
  3672. python_moduleinto ()
  3673. {
  3674.     debug-print-function ${FUNCNAME} "${@}";
  3675.     _PYTHON_MODULEROOT=${1}
  3676. }
  3677. python_newexe ()
  3678. {
  3679.     debug-print-function ${FUNCNAME} "${@}";
  3680.     [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3681.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3682.     [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3683.     local wrapd=${_PYTHON_SCRIPTROOT:-/usr/bin};
  3684.     local f=${1};
  3685.     local newfn=${2};
  3686.     local scriptdir=$(python_get_scriptdir);
  3687.     local d=${scriptdir#${EPREFIX}};
  3688.     ( dodir "${wrapd}";
  3689.     exeopts -m 0755;
  3690.     exeinto "${d}";
  3691.     newexe "${f}" "${newfn}" || return ${?} );
  3692.     local dosym=dosym;
  3693.     [[ ${EAPI} == 7 ]] && dosym=dosym8;
  3694.     "${dosym}" -r /usr/lib/python-exec/python-exec2 "${wrapd}/${newfn}";
  3695.     if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3696.         python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3697.     fi
  3698. }
  3699. python_newscript ()
  3700. {
  3701.     debug-print-function ${FUNCNAME} "${@}";
  3702.     [[ ${EBUILD_PHASE} != install ]] && die "${FUNCNAME} can only be used in src_install";
  3703.     local _PYTHON_REWRITE_SHEBANG=1;
  3704.     python_newexe "${@}"
  3705. }
  3706. python_optimize ()
  3707. {
  3708.     debug-print-function ${FUNCNAME} "${@}";
  3709.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3710.     local PYTHON=${PYTHON};
  3711.     [[ -n ${PYTHON} ]] || _python_export PYTHON;
  3712.     [[ -x ${PYTHON} ]] || die "PYTHON (${PYTHON}) is not executable";
  3713.     if [[ ${#} -eq 0 ]]; then
  3714.         local f;
  3715.         while IFS= read -r -d '' f; do
  3716.             if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  3717.                 set -- "${D%/}${f}" "${@}";
  3718.             fi;
  3719.         done < <(
  3720.             "${PYTHON}" - <<-EOF || die
  3721.                 import sys
  3722.                 print("".join(x + "\0" for x in sys.path))
  3723.             EOF
  3724.         );
  3725.         debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  3726.     fi;
  3727.     local jobs=$(makeopts_jobs);
  3728.     local d;
  3729.     for d in "$@";
  3730.     do
  3731.         local instpath=${d#${D%/}};
  3732.         instpath=/${instpath##/};
  3733.         einfo "Optimize Python modules for ${instpath}";
  3734.         case "${EPYTHON}" in
  3735.             python3.8)
  3736.                 "${PYTHON}" -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  3737.                 "${PYTHON}" -O -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}";
  3738.                 "${PYTHON}" -OO -m compileall -j "${jobs}" -q -f -d "${instpath}" "${d}"
  3739.             ;;
  3740.             python* | pypy3)
  3741.                 "${PYTHON}" -m compileall -j "${jobs}" -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}"
  3742.             ;;
  3743.             pypy | jython2.7)
  3744.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  3745.             ;;
  3746.             *)
  3747.                 die "${FUNCNAME}: unexpected EPYTHON=${EPYTHON}"
  3748.             ;;
  3749.         esac;
  3750.     done
  3751. }
  3752. python_scriptinto ()
  3753. {
  3754.     debug-print-function ${FUNCNAME} "${@}";
  3755.     _PYTHON_SCRIPTROOT=${1}
  3756. }
  3757. python_setup ()
  3758. {
  3759.     debug-print-function ${FUNCNAME} "${@}";
  3760.     if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  3761.         local impls=(${PYTHON_COMPAT_OVERRIDE});
  3762.         [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-any-r1";
  3763.         ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  3764.         ewarn "implementation will be used:";
  3765.         ewarn;
  3766.         ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  3767.         ewarn;
  3768.         ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored.";
  3769.         _python_export "${impls[0]}" EPYTHON PYTHON;
  3770.         _python_wrapper_setup;
  3771.         einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT_OVERRIDE)";
  3772.         return;
  3773.     fi;
  3774.     local epython_impl=${EPYTHON/./_};
  3775.     if [[ -n ${epython_impl} ]]; then
  3776.         if ! has "${epython_impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
  3777.             if ! has "${epython_impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
  3778.                 ewarn "Invalid EPYTHON: ${EPYTHON}";
  3779.             else
  3780.                 einfo "EPYTHON (${EPYTHON}) not supported by the package";
  3781.             fi;
  3782.         else
  3783.             if _python_run_check_deps "${epython_impl}"; then
  3784.                 _python_export EPYTHON PYTHON;
  3785.                 _python_wrapper_setup;
  3786.                 einfo "Using ${EPYTHON} to build (via EPYTHON)";
  3787.                 return;
  3788.             fi;
  3789.         fi;
  3790.     fi;
  3791.     local i;
  3792.     for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  3793.     do
  3794.         local impl=${_PYTHON_SUPPORTED_IMPLS[i]};
  3795.         [[ ${impl} == ${epython_impl} ]] && continue;
  3796.         _python_export "${impl}" EPYTHON PYTHON;
  3797.         if _python_run_check_deps "${impl}"; then
  3798.             _python_wrapper_setup;
  3799.             einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT iteration)";
  3800.             return;
  3801.         fi;
  3802.     done;
  3803.     eerror "No Python implementation found for the build. This is usually";
  3804.     eerror "a bug in the ebuild. Please report it to bugs.gentoo.org";
  3805.     eerror "along with the build log.";
  3806.     echo;
  3807.     die "No supported Python implementation installed."
  3808. }
  3809. raw-ldflags ()
  3810. {
  3811.     local x input="$@";
  3812.     [[ -z ${input} ]] && input=${LDFLAGS};
  3813.     set --;
  3814.     for x in ${input};
  3815.     do
  3816.         case ${x} in
  3817.             -Wl,*)
  3818.                 x=${x#-Wl,};
  3819.                 set -- "$@" ${x//,/ }
  3820.             ;;
  3821.             *)
  3822.  
  3823.             ;;
  3824.         esac;
  3825.     done;
  3826.     echo "$@"
  3827. }
  3828. replace-cpu-flags ()
  3829. {
  3830.     local newcpu="$#";
  3831.     newcpu="${!newcpu}";
  3832.     while [ $# -gt 1 ]; do
  3833.         replace-flags "-march=${1}" "-march=${newcpu}";
  3834.         replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3835.         replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3836.         shift;
  3837.     done;
  3838.     return 0
  3839. }
  3840. replace-flags ()
  3841. {
  3842.     [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3843.     local f var new;
  3844.     for var in $(all-flag-vars);
  3845.     do
  3846.         new=();
  3847.         for f in ${!var};
  3848.         do
  3849.             [[ ${f} == ${1} ]] && f=${2};
  3850.             new+=("${f}");
  3851.         done;
  3852.         export ${var}="${new[*]}";
  3853.     done;
  3854.     return 0
  3855. }
  3856. replace-sparc64-flags ()
  3857. {
  3858.     [[ $# -ne 0 ]] && die "replace-sparc64-flags takes no arguments";
  3859.     local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3860.     if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3861.         for x in ${SPARC64_CPUS};
  3862.         do
  3863.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3864.         done;
  3865.     else
  3866.         for x in ${SPARC64_CPUS};
  3867.         do
  3868.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3869.         done;
  3870.     fi;
  3871.     if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3872.         for x in ${SPARC64_CPUS};
  3873.         do
  3874.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3875.         done;
  3876.     else
  3877.         for x in ${SPARC64_CPUS};
  3878.         do
  3879.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3880.         done;
  3881.     fi;
  3882.     export CFLAGS CXXFLAGS
  3883. }
  3884. setup-allowed-flags ()
  3885. {
  3886.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  3887.     _setup-allowed-flags "$@"
  3888. }
  3889. src_compile ()
  3890. {
  3891.     cmake_src_compile "$@"
  3892. }
  3893. src_configure ()
  3894. {
  3895.     tc-export CC;
  3896.     filter-lto;
  3897.     use alpha && append-ldflags "-Wl,--no-relax";
  3898.     use ia64 && append-ldflags "-Wl,--no-as-needed";
  3899.     use sparc && filter-flags "-mvis";
  3900.     use ppc64 && append-flags "-mminimal-toc";
  3901.     if ! use ia64; then
  3902.         append-ldflags $(test-flags-CCLD "-Wl,--no-keep-memory");
  3903.     fi;
  3904.     local rubyimpl;
  3905.     local ruby_interpreter="";
  3906.     local RUBY;
  3907.     for rubyimpl in ${USE_RUBY};
  3908.     do
  3909.         if has_version -b "virtual/rubygems[ruby_targets_${rubyimpl}(-)]"; then
  3910.             RUBY="$(type -P ${rubyimpl})";
  3911.             ruby_interpreter="-DRUBY_EXECUTABLE=${RUBY}";
  3912.         fi;
  3913.     done;
  3914.     [[ -z ${ruby_interpreter} ]] && die "No suitable ruby interpreter found";
  3915.     sed -i -e "s:#!/usr/bin/env ruby:#!${RUBY}:" $(grep -rl "/usr/bin/env ruby" Source/JavaScriptCore || die) || die;
  3916.     local mycmakeargs=(-DPython_EXECUTABLE="${PYTHON}" ${ruby_interpreter} -DBWRAP_EXECUTABLE:FILEPATH="${EPREFIX}"/usr/bin/bwrap -DDBUS_PROXY_EXECUTABLE:FILEPATH="${EPREFIX}"/usr/bin/xdg-dbus-proxy -DPORT=GTK -DENABLE_API_TESTS=OFF -DENABLE_BUBBLEWRAP_SANDBOX=$(usex seccomp) -DENABLE_GAMEPAD=$(usex gamepad) -DENABLE_MINIBROWSER=$(usex examples) -DENABLE_PDFJS=$(usex pdf) -DENABLE_GEOLOCATION=ON -DENABLE_SPELLCHECK=$(usex spell) -DENABLE_UNIFIED_BUILDS=$(usex jumbo-build) -DENABLE_VIDEO=$(usex gstreamer) -DUSE_GSTREAMER_WEBRTC=$(usex gstreamer) -DUSE_GSTREAMER_TRANSCODER=$(usex gstreamer) -DENABLE_WEB_CODECS=$(usex gstreamer) -DENABLE_WEBDRIVER=OFF -DENABLE_WEBGL=ON -DENABLE_WEB_AUDIO=$(usex gstreamer) -DUSE_AVIF=$(usex avif) -DENABLE_DOCUMENTATION=OFF -DENABLE_INTROSPECTION=$(usex introspection) -DENABLE_JOURNALD_LOG=$(usex systemd) -DENABLE_QUARTZ_TARGET=$(usex aqua) -DENABLE_WAYLAND_TARGET=$(usex wayland) -DENABLE_X11_TARGET=$(usex X) -DUSE_GBM=ON -DUSE_GTK4=OFF -DUSE_JPEGXL=$(usex jpegxl) -DUSE_LCMS=$(usex lcms) -DUSE_LIBBACKTRACE=OFF -DUSE_LIBDRM=ON -DUSE_LIBHYPHEN=ON -DUSE_LIBSECRET=$(usex keyring) -DUSE_SOUP2=OFF -DUSE_WOFF2=ON);
  3917.     append-cppflags -DNDEBUG;
  3918.     WK_USE_CCACHE=NO cmake_src_configure
  3919. }
  3920. src_install ()
  3921. {
  3922.     cmake_src_install "$@"
  3923. }
  3924. src_prepare ()
  3925. {
  3926.     cmake_src_prepare;
  3927.     gnome2_src_prepare;
  3928.     eapply "${FILESDIR}"/${PV}-branch-patchset.patch;
  3929.     eapply "${FILESDIR}"/2.42.3-arm64-non-jumbo-fix-925621.patch;
  3930.     eapply "${FILESDIR}"/${PV}-non-unified-build-fixes.patch
  3931. }
  3932. src_test ()
  3933. {
  3934.     cmake_src_test "$@"
  3935. }
  3936. src_unpack ()
  3937. {
  3938.     default
  3939. }
  3940. strip-flags ()
  3941. {
  3942.     [[ $# -ne 0 ]] && die "strip-flags takes no arguments";
  3943.     local x y var;
  3944.     local ALLOWED_FLAGS;
  3945.     _setup-allowed-flags;
  3946.     set -f;
  3947.     for var in $(all-flag-vars);
  3948.     do
  3949.         local new=();
  3950.         for x in ${!var};
  3951.         do
  3952.             for y in "${ALLOWED_FLAGS[@]}";
  3953.             do
  3954.                 if [[ ${x} == ${y} ]]; then
  3955.                     new+=("${x}");
  3956.                     break;
  3957.                 fi;
  3958.             done;
  3959.         done;
  3960.         if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  3961.             new+=(-O2);
  3962.         fi;
  3963.         if [[ ${!var} != "${new[*]}" ]]; then
  3964.             einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  3965.         fi;
  3966.         export ${var}="${new[*]}";
  3967.     done;
  3968.     set +f;
  3969.     return 0
  3970. }
  3971. strip-unsupported-flags ()
  3972. {
  3973.     [[ $# -ne 0 ]] && die "strip-unsupported-flags takes no arguments";
  3974.     export CFLAGS=$(test-flags-CC ${CFLAGS});
  3975.     export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3976.     export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3977.     export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  3978.     export LDFLAGS=$(test-flags-CCLD ${LDFLAGS})
  3979. }
  3980. tc-arch ()
  3981. {
  3982.     tc-ninja_magic_to_arch portage "$@"
  3983. }
  3984. tc-arch-kernel ()
  3985. {
  3986.     tc-ninja_magic_to_arch kern "$@"
  3987. }
  3988. tc-check-openmp ()
  3989. {
  3990.     if ! _tc-has-openmp; then
  3991.         eerror "Your current compiler does not support OpenMP!";
  3992.         if tc-is-gcc; then
  3993.             eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  3994.         else
  3995.             if tc-is-clang; then
  3996.                 eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  3997.             fi;
  3998.         fi;
  3999.         die "Active compiler does not have required support for OpenMP";
  4000.     fi
  4001. }
  4002. tc-cpp-is-true ()
  4003. {
  4004.     local CONDITION=${1};
  4005.     shift;
  4006.     $(tc-getTARGET_CPP) "${@}" -P - <<-EOF > /dev/null 2>&1
  4007. #if ${CONDITION}
  4008. true
  4009. #else
  4010. #error false
  4011. #endif
  4012. EOF
  4013.  
  4014. }
  4015. tc-detect-is-softfloat ()
  4016. {
  4017.     [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  4018.     case ${CTARGET:-${CHOST}} in
  4019.         *-newlib | *-elf | *-eabi)
  4020.             return 1
  4021.         ;;
  4022.         arm*)
  4023.             if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  4024.                 echo "no";
  4025.             else
  4026.                 if tc-cpp-is-true "defined(__SOFTFP__)"; then
  4027.                     echo "yes";
  4028.                 else
  4029.                     echo "softfp";
  4030.                 fi;
  4031.             fi;
  4032.             return 0
  4033.         ;;
  4034.         *)
  4035.             return 1
  4036.         ;;
  4037.     esac
  4038. }
  4039. tc-enables-cxx-assertions ()
  4040. {
  4041.     tc-cpp-is-true "defined(_GLIBCXX_ASSERTIONS) || defined(_LIBCPP_ENABLE_ASSERTIONS) || defined(_LIBCPP_ENABLE_HARDENED_MODE)" ${CPPFLAGS} ${CXXFLAGS}
  4042. }
  4043. tc-enables-fortify-source ()
  4044. {
  4045.     tc-cpp-is-true "defined(_FORTIFY_SOURCE)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4046. }
  4047. tc-enables-pie ()
  4048. {
  4049.     tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4050. }
  4051. tc-enables-ssp ()
  4052. {
  4053.     tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4054. }
  4055. tc-enables-ssp-all ()
  4056. {
  4057.     tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4058. }
  4059. tc-enables-ssp-strong ()
  4060. {
  4061.     tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS}
  4062. }
  4063. tc-endian ()
  4064. {
  4065.     local host=$1;
  4066.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4067.     host=${host%%-*};
  4068.     case ${host} in
  4069.         aarch64*be)
  4070.             echo big
  4071.         ;;
  4072.         aarch64)
  4073.             echo little
  4074.         ;;
  4075.         alpha*)
  4076.             echo little
  4077.         ;;
  4078.         arc*b*)
  4079.             echo big
  4080.         ;;
  4081.         arc*)
  4082.             echo little
  4083.         ;;
  4084.         arm*b*)
  4085.             echo big
  4086.         ;;
  4087.         arm*)
  4088.             echo little
  4089.         ;;
  4090.         cris*)
  4091.             echo little
  4092.         ;;
  4093.         hppa*)
  4094.             echo big
  4095.         ;;
  4096.         i?86*)
  4097.             echo little
  4098.         ;;
  4099.         ia64*)
  4100.             echo little
  4101.         ;;
  4102.         loongarch*)
  4103.             echo little
  4104.         ;;
  4105.         m68*)
  4106.             echo big
  4107.         ;;
  4108.         mips*l*)
  4109.             echo little
  4110.         ;;
  4111.         mips*)
  4112.             echo big
  4113.         ;;
  4114.         powerpc*le)
  4115.             echo little
  4116.         ;;
  4117.         powerpc*)
  4118.             echo big
  4119.         ;;
  4120.         riscv*)
  4121.             echo little
  4122.         ;;
  4123.         s390*)
  4124.             echo big
  4125.         ;;
  4126.         sh*b*)
  4127.             echo big
  4128.         ;;
  4129.         sh*)
  4130.             echo little
  4131.         ;;
  4132.         sparc*)
  4133.             echo big
  4134.         ;;
  4135.         x86_64*)
  4136.             echo little
  4137.         ;;
  4138.         *)
  4139.             echo wtf
  4140.         ;;
  4141.     esac
  4142. }
  4143. tc-env_build ()
  4144. {
  4145.     tc-export_build_env;
  4146.     CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) READELF=$(tc-getBUILD_READELF) "$@"
  4147. }
  4148. tc-export ()
  4149. {
  4150.     local var;
  4151.     for var in "$@";
  4152.     do
  4153.         [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4154.         "tc-get${var}" > /dev/null;
  4155.     done
  4156. }
  4157. tc-export_build_env ()
  4158. {
  4159.     tc-export "$@";
  4160.     if tc-is-cross-compiler; then
  4161.         : "${BUILD_CFLAGS:=-O1 -pipe}";
  4162.         : "${BUILD_CXXFLAGS:=-O1 -pipe}";
  4163.         : "${BUILD_CPPFLAGS:= }";
  4164.         : "${BUILD_LDFLAGS:= }";
  4165.     else
  4166.         : "${BUILD_CFLAGS:=${CFLAGS}}";
  4167.         : "${BUILD_CXXFLAGS:=${CXXFLAGS}}";
  4168.         : "${BUILD_CPPFLAGS:=${CPPFLAGS}}";
  4169.         : "${BUILD_LDFLAGS:=${LDFLAGS}}";
  4170.     fi;
  4171.     export BUILD_{C,CXX,CPP,LD}FLAGS;
  4172.     local v;
  4173.     for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4174.     do
  4175.         export ${v#BUILD_}_FOR_BUILD="${!v}";
  4176.     done
  4177. }
  4178. tc-get-build-ptr-size ()
  4179. {
  4180.     $(tc-getBUILD_CPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CBUILD pointer size"
  4181. }
  4182. tc-get-c-rtlib ()
  4183. {
  4184.     local res=$(
  4185.         $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}            -print-libgcc-file-name 2>/dev/null
  4186.     );
  4187.     case ${res} in
  4188.         *libclang_rt*)
  4189.             echo compiler-rt
  4190.         ;;
  4191.         *libgcc*)
  4192.             echo libgcc
  4193.         ;;
  4194.         *)
  4195.             return 1
  4196.         ;;
  4197.     esac;
  4198.     return 0
  4199. }
  4200. tc-get-compiler-type ()
  4201. {
  4202.     local code='
  4203. #if defined(__PATHSCALE__)
  4204.     HAVE_PATHCC
  4205. #elif defined(__clang__)
  4206.     HAVE_CLANG
  4207. #elif defined(__GNUC__)
  4208.     HAVE_GCC
  4209. #endif
  4210. ';
  4211.     local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4212.     case ${res} in
  4213.         *HAVE_PATHCC*)
  4214.             echo pathcc
  4215.         ;;
  4216.         *HAVE_CLANG*)
  4217.             echo clang
  4218.         ;;
  4219.         *HAVE_GCC*)
  4220.             echo gcc
  4221.         ;;
  4222.         *)
  4223.             echo unknown
  4224.         ;;
  4225.     esac
  4226. }
  4227. tc-get-cxx-stdlib ()
  4228. {
  4229.     local code='#include <ciso646>
  4230.  
  4231. #if defined(_LIBCPP_VERSION)
  4232.     HAVE_LIBCXX
  4233. #elif defined(__GLIBCXX__)
  4234.     HAVE_LIBSTDCPP
  4235. #endif
  4236. ';
  4237.     local res=$(
  4238.         $(tc-getCXX) ${CPPFLAGS} ${CXXFLAGS} -x c++ -E -P -             <<<"${code}" 2>/dev/null
  4239.     );
  4240.     case ${res} in
  4241.         *HAVE_LIBCXX*)
  4242.             echo libc++
  4243.         ;;
  4244.         *HAVE_LIBSTDCPP*)
  4245.             echo libstdc++
  4246.         ;;
  4247.         *)
  4248.             return 1
  4249.         ;;
  4250.     esac;
  4251.     return 0
  4252. }
  4253. tc-get-ptr-size ()
  4254. {
  4255.     $(tc-getCPP) -P - <<< __SIZEOF_POINTER__ || die "Could not determine CHOST pointer size"
  4256. }
  4257. tc-getAR ()
  4258. {
  4259.     tc-getPROG AR ar "$@"
  4260. }
  4261. tc-getAS ()
  4262. {
  4263.     tc-getPROG AS as "$@"
  4264. }
  4265. tc-getBUILD_AR ()
  4266. {
  4267.     tc-getBUILD_PROG AR ar "$@"
  4268. }
  4269. tc-getBUILD_AS ()
  4270. {
  4271.     tc-getBUILD_PROG AS as "$@"
  4272. }
  4273. tc-getBUILD_CC ()
  4274. {
  4275.     tc-getBUILD_PROG CC gcc "$@"
  4276. }
  4277. tc-getBUILD_CPP ()
  4278. {
  4279.     tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4280. }
  4281. tc-getBUILD_CXX ()
  4282. {
  4283.     tc-getBUILD_PROG CXX g++ "$@"
  4284. }
  4285. tc-getBUILD_LD ()
  4286. {
  4287.     tc-getBUILD_PROG LD ld "$@"
  4288. }
  4289. tc-getBUILD_NM ()
  4290. {
  4291.     tc-getBUILD_PROG NM nm "$@"
  4292. }
  4293. tc-getBUILD_OBJCOPY ()
  4294. {
  4295.     tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4296. }
  4297. tc-getBUILD_PKG_CONFIG ()
  4298. {
  4299.     tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4300. }
  4301. tc-getBUILD_PROG ()
  4302. {
  4303.     local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4304.     tc-is-cross-compiler || vars+=" $1";
  4305.     _tc-getPROG CBUILD "${vars}" "${@:2}"
  4306. }
  4307. tc-getBUILD_RANLIB ()
  4308. {
  4309.     tc-getBUILD_PROG RANLIB ranlib "$@"
  4310. }
  4311. tc-getBUILD_READELF ()
  4312. {
  4313.     tc-getBUILD_PROG READELF readelf "$@"
  4314. }
  4315. tc-getBUILD_STRINGS ()
  4316. {
  4317.     tc-getBUILD_PROG STRINGS strings "$@"
  4318. }
  4319. tc-getBUILD_STRIP ()
  4320. {
  4321.     tc-getBUILD_PROG STRIP strip "$@"
  4322. }
  4323. tc-getCC ()
  4324. {
  4325.     tc-getPROG CC gcc "$@"
  4326. }
  4327. tc-getCPP ()
  4328. {
  4329.     tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4330. }
  4331. tc-getCXX ()
  4332. {
  4333.     tc-getPROG CXX g++ "$@"
  4334. }
  4335. tc-getDLLWRAP ()
  4336. {
  4337.     tc-getPROG DLLWRAP dllwrap "$@"
  4338. }
  4339. tc-getF77 ()
  4340. {
  4341.     tc-getPROG F77 gfortran "$@"
  4342. }
  4343. tc-getFC ()
  4344. {
  4345.     tc-getPROG FC gfortran "$@"
  4346. }
  4347. tc-getGCJ ()
  4348. {
  4349.     tc-getPROG GCJ gcj "$@"
  4350. }
  4351. tc-getGO ()
  4352. {
  4353.     tc-getPROG GO gccgo "$@"
  4354. }
  4355. tc-getLD ()
  4356. {
  4357.     tc-getPROG LD ld "$@"
  4358. }
  4359. tc-getNM ()
  4360. {
  4361.     tc-getPROG NM nm "$@"
  4362. }
  4363. tc-getOBJCOPY ()
  4364. {
  4365.     tc-getPROG OBJCOPY objcopy "$@"
  4366. }
  4367. tc-getOBJDUMP ()
  4368. {
  4369.     tc-getPROG OBJDUMP objdump "$@"
  4370. }
  4371. tc-getPKG_CONFIG ()
  4372. {
  4373.     tc-getPROG PKG_CONFIG pkg-config "$@"
  4374. }
  4375. tc-getPROG ()
  4376. {
  4377.     _tc-getPROG CHOST "$@"
  4378. }
  4379. tc-getRANLIB ()
  4380. {
  4381.     tc-getPROG RANLIB ranlib "$@"
  4382. }
  4383. tc-getRC ()
  4384. {
  4385.     tc-getPROG RC windres "$@"
  4386. }
  4387. tc-getREADELF ()
  4388. {
  4389.     tc-getPROG READELF readelf "$@"
  4390. }
  4391. tc-getSTRINGS ()
  4392. {
  4393.     tc-getPROG STRINGS strings "$@"
  4394. }
  4395. tc-getSTRIP ()
  4396. {
  4397.     tc-getPROG STRIP strip "$@"
  4398. }
  4399. tc-getTARGET_CPP ()
  4400. {
  4401.     if [[ -n ${CTARGET} ]]; then
  4402.         _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4403.     else
  4404.         tc-getCPP "$@";
  4405.     fi
  4406. }
  4407. tc-has-tls ()
  4408. {
  4409.     local base="${T}/test-tc-tls";
  4410.     cat <<-EOF > "${base}.c"
  4411. int foo(int *i) {
  4412. static __thread int j = 0;
  4413. return *i ? j : *i;
  4414. }
  4415. EOF
  4416.  
  4417.     local flags;
  4418.     case $1 in
  4419.         -s)
  4420.             flags="-S"
  4421.         ;;
  4422.         -c)
  4423.             flags="-c"
  4424.         ;;
  4425.         -l)
  4426.  
  4427.         ;;
  4428.         -*)
  4429.             die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4430.         ;;
  4431.     esac;
  4432.     : "${flags:=-fPIC -shared -Wl,-z,defs}";
  4433.     [[ $1 == -* ]] && shift;
  4434.     $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4435.     local ret=$?;
  4436.     rm -f "${base}"*;
  4437.     return ${ret}
  4438. }
  4439. tc-is-clang ()
  4440. {
  4441.     [[ $(tc-get-compiler-type) == clang ]]
  4442. }
  4443. tc-is-cross-compiler ()
  4444. {
  4445.     [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4446. }
  4447. tc-is-gcc ()
  4448. {
  4449.     [[ $(tc-get-compiler-type) == gcc ]]
  4450. }
  4451. tc-is-lto ()
  4452. {
  4453.     local f="${T}/test-lto.o";
  4454.     case $(tc-get-compiler-type) in
  4455.         clang)
  4456.             $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  4457.             llvm-bcanalyzer "${f}" &> /dev/null && return 0
  4458.         ;;
  4459.         gcc)
  4460.             $(tc-getCC) ${CFLAGS} -c -o "${f}" -x c - <<< "" || die;
  4461.             [[ $($(tc-getREADELF) -S "${f}") == *.gnu.lto* ]] && return 0
  4462.         ;;
  4463.     esac;
  4464.     return 1
  4465. }
  4466. tc-is-softfloat ()
  4467. {
  4468.     tc-detect-is-softfloat || tc-tuple-is-softfloat
  4469. }
  4470. tc-is-static-only ()
  4471. {
  4472.     local host=${CTARGET:-${CHOST}};
  4473.     [[ ${host} == *-mint* ]]
  4474. }
  4475. tc-ld-disable-gold ()
  4476. {
  4477.     tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
  4478. }
  4479. tc-ld-force-bfd ()
  4480. {
  4481.     if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@"; then
  4482.         return;
  4483.     fi;
  4484.     ewarn "Forcing usage of the BFD linker";
  4485.     local ld=$(unset LD; tc-getLD "$@");
  4486.     local bfd_ld="${ld}.bfd";
  4487.     local path_ld=$(type -P "${bfd_ld}" 2>/dev/null);
  4488.     [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  4489.     if tc-is-gcc || tc-is-clang; then
  4490.         export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4491.     fi
  4492. }
  4493. tc-ld-is-gold ()
  4494. {
  4495.     local out;
  4496.     local -x LC_ALL=C;
  4497.     out=$($(tc-getLD "$@") --version 2>&1);
  4498.     if [[ ${out} == *"GNU gold"* ]]; then
  4499.         return 0;
  4500.     fi;
  4501.     local base="${T}/test-tc-gold";
  4502.     cat <<-EOF > "${base}.c"
  4503. int main(void) { return 0; }
  4504. EOF
  4505.  
  4506.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4507.     rm -f "${base}"*;
  4508.     if [[ ${out} == *"GNU gold"* ]]; then
  4509.         return 0;
  4510.     fi;
  4511.     return 1
  4512. }
  4513. tc-ld-is-lld ()
  4514. {
  4515.     local out;
  4516.     local -x LC_ALL=C;
  4517.     out=$($(tc-getLD "$@") --version 2>&1);
  4518.     if [[ ${out} == *"LLD"* ]]; then
  4519.         return 0;
  4520.     fi;
  4521.     local base="${T}/test-tc-lld";
  4522.     cat <<-EOF > "${base}.c"
  4523. int main(void) { return 0; }
  4524. EOF
  4525.  
  4526.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4527.     rm -f "${base}"*;
  4528.     if [[ ${out} == *"LLD"* ]]; then
  4529.         return 0;
  4530.     fi;
  4531.     return 1
  4532. }
  4533. tc-ninja_magic_to_arch ()
  4534. {
  4535.     function _tc_echo_kernel_alias ()
  4536.     {
  4537.         [[ ${type} == "kern" ]] && echo $1 || echo $2
  4538.     };
  4539.     local type=$1;
  4540.     local host=$2;
  4541.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4542.     case ${host} in
  4543.         aarch64*)
  4544.             echo arm64
  4545.         ;;
  4546.         alpha*)
  4547.             echo alpha
  4548.         ;;
  4549.         arc*)
  4550.             echo arc
  4551.         ;;
  4552.         arm*)
  4553.             echo arm
  4554.         ;;
  4555.         avr*)
  4556.             _tc_echo_kernel_alias avr32 avr
  4557.         ;;
  4558.         bfin*)
  4559.             _tc_echo_kernel_alias blackfin bfin
  4560.         ;;
  4561.         c6x*)
  4562.             echo c6x
  4563.         ;;
  4564.         cris*)
  4565.             echo cris
  4566.         ;;
  4567.         frv*)
  4568.             echo frv
  4569.         ;;
  4570.         hexagon*)
  4571.             echo hexagon
  4572.         ;;
  4573.         hppa*)
  4574.             _tc_echo_kernel_alias parisc hppa
  4575.         ;;
  4576.         i?86*)
  4577.             echo x86
  4578.         ;;
  4579.         ia64*)
  4580.             echo ia64
  4581.         ;;
  4582.         loongarch*)
  4583.             _tc_echo_kernel_alias loongarch loong
  4584.         ;;
  4585.         m68*)
  4586.             echo m68k
  4587.         ;;
  4588.         metag*)
  4589.             echo metag
  4590.         ;;
  4591.         microblaze*)
  4592.             echo microblaze
  4593.         ;;
  4594.         mips*)
  4595.             echo mips
  4596.         ;;
  4597.         nios2*)
  4598.             echo nios2
  4599.         ;;
  4600.         nios*)
  4601.             echo nios
  4602.         ;;
  4603.         or1k* | or32*)
  4604.             echo openrisc
  4605.         ;;
  4606.         powerpc*)
  4607.             if [[ ${type} == "kern" ]]; then
  4608.                 echo powerpc;
  4609.             else
  4610.                 if [[ ${host} == powerpc64* ]]; then
  4611.                     echo ppc64;
  4612.                 else
  4613.                     echo ppc;
  4614.                 fi;
  4615.             fi
  4616.         ;;
  4617.         riscv*)
  4618.             echo riscv
  4619.         ;;
  4620.         s390*)
  4621.             echo s390
  4622.         ;;
  4623.         score*)
  4624.             echo score
  4625.         ;;
  4626.         sh64*)
  4627.             _tc_echo_kernel_alias sh64 sh
  4628.         ;;
  4629.         sh*)
  4630.             echo sh
  4631.         ;;
  4632.         sparc64*)
  4633.             _tc_echo_kernel_alias sparc64 sparc
  4634.         ;;
  4635.         sparc*)
  4636.             [[ ${PROFILE_ARCH} == "sparc64" ]] && _tc_echo_kernel_alias sparc64 sparc || echo sparc
  4637.         ;;
  4638.         tile*)
  4639.             echo tile
  4640.         ;;
  4641.         vax*)
  4642.             echo vax
  4643.         ;;
  4644.         x86_64*)
  4645.             if [[ ${type} == "kern" ]]; then
  4646.                 echo x86;
  4647.             else
  4648.                 echo amd64;
  4649.             fi
  4650.         ;;
  4651.         xtensa*)
  4652.             echo xtensa
  4653.         ;;
  4654.         *)
  4655.             echo unknown
  4656.         ;;
  4657.     esac
  4658. }
  4659. tc-stack-grows-down ()
  4660. {
  4661.     case ${ARCH} in
  4662.         hppa | metag)
  4663.             return 1
  4664.         ;;
  4665.     esac;
  4666.     return 0
  4667. }
  4668. tc-tuple-is-softfloat ()
  4669. {
  4670.     local CTARGET=${CTARGET:-${CHOST}};
  4671.     case ${CTARGET//_/-} in
  4672.         bfin* | h8300*)
  4673.             echo "only"
  4674.         ;;
  4675.         *-softfloat-*)
  4676.             echo "yes"
  4677.         ;;
  4678.         *-softfp-*)
  4679.             echo "softfp"
  4680.         ;;
  4681.         arm*-hardfloat-* | arm*eabihf)
  4682.             echo "no"
  4683.         ;;
  4684.         *-newlib | *-elf | *-eabi)
  4685.             echo "no"
  4686.         ;;
  4687.         arm*)
  4688.             echo "yes"
  4689.         ;;
  4690.         *)
  4691.             echo "no"
  4692.         ;;
  4693.     esac
  4694. }
  4695. test-compile ()
  4696. {
  4697.     local lang=$1;
  4698.     local code=$2;
  4699.     shift 2;
  4700.     [[ -z "${lang}" ]] && return 1;
  4701.     [[ -z "${code}" ]] && return 1;
  4702.     local compiler filename_in filename_out args=() libs=();
  4703.     case "${lang}" in
  4704.         c)
  4705.             compiler="$(tc-getCC)";
  4706.             filename_in="${T}/test.c";
  4707.             filename_out="${T}/test.o";
  4708.             args+=(${CFLAGS[@]} -xc -c)
  4709.         ;;
  4710.         c++)
  4711.             compiler="$(tc-getCXX)";
  4712.             filename_in="${T}/test.cc";
  4713.             filename_out="${T}/test.o";
  4714.             args+=(${CXXFLAGS[@]} -xc++ -c)
  4715.         ;;
  4716.         f77)
  4717.             compiler="$(tc-getF77)";
  4718.             filename_in="${T}/test.f";
  4719.             filename_out="${T}/test.o";
  4720.             args+=(${FFFLAGS[@]} -xf77 -c)
  4721.         ;;
  4722.         f95)
  4723.             compiler="$(tc-getFC)";
  4724.             filename_in="${T}/test.f90";
  4725.             filename_out="${T}/test.o";
  4726.             args+=(${FCFLAGS[@]} -xf95 -c)
  4727.         ;;
  4728.         c+ld)
  4729.             compiler="$(tc-getCC)";
  4730.             filename_in="${T}/test.c";
  4731.             filename_out="${T}/test.exe";
  4732.             args+=(${CFLAGS[@]} ${LDFLAGS[@]} -xc);
  4733.             libs+=(${LIBS[@]})
  4734.         ;;
  4735.         c+++ld)
  4736.             compiler="$(tc-getCXX)";
  4737.             filename_in="${T}/test.cc";
  4738.             filename_out="${T}/test.exe";
  4739.             args+=(${CXXFLAGS[@]} ${LDFLAGS[@]} -xc++);
  4740.             libs+=(${LIBS[@]})
  4741.         ;;
  4742.         f77+ld)
  4743.             compiler="$(tc-getF77)";
  4744.             filename_in="${T}/test.f";
  4745.             filename_out="${T}/test.exe";
  4746.             args+=(${FFLAGS[@]} ${LDFLAGS[@]} -xf77);
  4747.             libs+=(${LIBS[@]})
  4748.         ;;
  4749.         f95+ld)
  4750.             compiler="$(tc-getFC)";
  4751.             filename_in="${T}/test.f90";
  4752.             filename_out="${T}/test.exe";
  4753.             args+=(${FCFLAGS[@]} ${LDFLAGS[@]} -xf95);
  4754.             libs+=(${LIBS[@]})
  4755.         ;;
  4756.         *)
  4757.             die "Unknown compiled language ${lang}"
  4758.         ;;
  4759.     esac;
  4760.     printf "%s\n" "${code}" > "${filename_in}" || die "Failed to create '${test_in}'";
  4761.     "${compiler}" ${args[@]} "${filename_in}" -o "${filename_out}" ${libs[@]} &> /dev/null
  4762. }
  4763. test-flag-CC ()
  4764. {
  4765.     _test-flag-PROG CC c "$@"
  4766. }
  4767. test-flag-CCLD ()
  4768. {
  4769.     _test-flag-PROG CC c+ld "$@"
  4770. }
  4771. test-flag-CXX ()
  4772. {
  4773.     _test-flag-PROG CXX c++ "$@"
  4774. }
  4775. test-flag-F77 ()
  4776. {
  4777.     _test-flag-PROG F77 f77 "$@"
  4778. }
  4779. test-flag-FC ()
  4780. {
  4781.     _test-flag-PROG FC f95 "$@"
  4782. }
  4783. test-flag-PROG ()
  4784. {
  4785.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  4786.     _test-flag-PROG "$@"
  4787. }
  4788. test-flags ()
  4789. {
  4790.     test-flags-CC "$@"
  4791. }
  4792. test-flags-CC ()
  4793. {
  4794.     _test-flags-PROG CC "$@"
  4795. }
  4796. test-flags-CCLD ()
  4797. {
  4798.     _test-flags-PROG CCLD "$@"
  4799. }
  4800. test-flags-CXX ()
  4801. {
  4802.     _test-flags-PROG CXX "$@"
  4803. }
  4804. test-flags-F77 ()
  4805. {
  4806.     _test-flags-PROG F77 "$@"
  4807. }
  4808. test-flags-FC ()
  4809. {
  4810.     _test-flags-PROG FC "$@"
  4811. }
  4812. test-flags-PROG ()
  4813. {
  4814.     [[ ${EAPI} == [67] ]] || die "Internal function ${FUNCNAME} is not available in EAPI ${EAPI}.";
  4815.     _test-flags-PROG "$@"
  4816. }
  4817. test_version_info ()
  4818. {
  4819.     if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  4820.         return 0;
  4821.     else
  4822.         return 1;
  4823.     fi
  4824. }
  4825. ver_cut ()
  4826. {
  4827.     local range=${1};
  4828.     local v=${2:-${PV}};
  4829.     local start end;
  4830.     local -a comp;
  4831.     __eapi7_ver_split "${v}";
  4832.     local max=$((${#comp[@]}/2));
  4833.     __eapi7_ver_parse_range "${range}" "${max}";
  4834.     local IFS=;
  4835.     if [[ ${start} -gt 0 ]]; then
  4836.         start=$(( start*2 - 1 ));
  4837.     fi;
  4838.     echo "${comp[*]:start:end*2-start}"
  4839. }
  4840. ver_rs ()
  4841. {
  4842.     local v;
  4843.     (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  4844.     local start end i;
  4845.     local -a comp;
  4846.     __eapi7_ver_split "${v}";
  4847.     local max=$((${#comp[@]}/2 - 1));
  4848.     while [[ ${#} -ge 2 ]]; do
  4849.         __eapi7_ver_parse_range "${1}" "${max}";
  4850.         for ((i = start*2; i <= end*2; i+=2 ))
  4851.         do
  4852.             [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  4853.             comp[i]=${2};
  4854.         done;
  4855.         shift 2;
  4856.     done;
  4857.     local IFS=;
  4858.     echo "${comp[*]}"
  4859. }
  4860. ver_test ()
  4861. {
  4862.     local va op vb;
  4863.     if [[ $# -eq 3 ]]; then
  4864.         va=${1};
  4865.         shift;
  4866.     else
  4867.         va=${PVR};
  4868.     fi;
  4869.     [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  4870.     op=${1};
  4871.     vb=${2};
  4872.     case ${op} in
  4873.         -eq | -ne | -lt | -le | -gt | -ge)
  4874.  
  4875.         ;;
  4876.         *)
  4877.             die "${FUNCNAME}: invalid operator: ${op}"
  4878.         ;;
  4879.     esac;
  4880.     __eapi7_ver_compare "${va}" "${vb}";
  4881.     test $? "${op}" 2
  4882. }
  4883. xdg_desktop_database_update ()
  4884. {
  4885.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4886.         die "xdg_desktop_database_update must be used in pkg_post* phases.";
  4887.     fi;
  4888.     if ! type update-desktop-database &> /dev/null; then
  4889.         debug-print "update-desktop-database is not found";
  4890.         return;
  4891.     fi;
  4892.     ebegin "Updating .desktop files database";
  4893.     update-desktop-database -q "${EROOT%/}${DESKTOP_DATABASE_DIR}";
  4894.     eend $?
  4895. }
  4896. xdg_environment_reset ()
  4897. {
  4898.     export XDG_DATA_HOME="${HOME}/.local/share";
  4899.     export XDG_CONFIG_HOME="${HOME}/.config";
  4900.     export XDG_CACHE_HOME="${HOME}/.cache";
  4901.     export XDG_STATE_HOME="${HOME}/.local/state";
  4902.     export XDG_RUNTIME_DIR="${T}/run";
  4903.     mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_STATE_HOME}" "${XDG_RUNTIME_DIR}" || die;
  4904.     chmod 0700 "${XDG_RUNTIME_DIR}" || die;
  4905.     unset DBUS_SESSION_BUS_ADDRESS
  4906. }
  4907. xdg_icon_cache_update ()
  4908. {
  4909.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4910.         die "xdg_icon_cache_update must be used in pkg_post* phases.";
  4911.     fi;
  4912.     if ! type gtk-update-icon-cache &> /dev/null; then
  4913.         debug-print "gtk-update-icon-cache is not found";
  4914.         return;
  4915.     fi;
  4916.     ebegin "Updating icons cache";
  4917.     local dir retval=0;
  4918.     local fails=();
  4919.     for dir in "${EROOT%/}"/usr/share/icons/*;
  4920.     do
  4921.         if [[ -f ${dir}/index.theme ]]; then
  4922.             if ! gtk-update-icon-cache -qf "${dir}"; then
  4923.                 debug-print "Updating cache failed on ${dir}";
  4924.                 fails+=("${dir}");
  4925.                 retval=2;
  4926.             fi;
  4927.         else
  4928.             if [[ $(ls "${dir}") = icon-theme.cache ]]; then
  4929.                 rm "${dir}/icon-theme.cache";
  4930.             fi;
  4931.         fi;
  4932.         if [[ -z $(ls "${dir}") ]]; then
  4933.             rmdir "${dir}";
  4934.         fi;
  4935.     done;
  4936.     eend ${retval};
  4937.     for dir in "${fails[@]}";
  4938.     do
  4939.         eerror "Failed to update cache with icon ${dir}";
  4940.     done
  4941. }
  4942. xdg_mimeinfo_database_update ()
  4943. {
  4944.     if [[ ${EBUILD_PHASE} != post* ]]; then
  4945.         die "xdg_mimeinfo_database_update must be used in pkg_post* phases.";
  4946.     fi;
  4947.     if ! type update-mime-database &> /dev/null; then
  4948.         debug-print "update-mime-database is not found";
  4949.         return;
  4950.     fi;
  4951.     local -x PKGSYSTEM_ENABLE_FSYNC=0;
  4952.     ebegin "Updating shared mime info database";
  4953.     update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}";
  4954.     eend $?
  4955. }
  4956. xdg_pkg_postinst ()
  4957. {
  4958.     if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  4959.         xdg_desktop_database_update;
  4960.     else
  4961.         debug-print "No .desktop files to add to database";
  4962.     fi;
  4963.     if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
  4964.         xdg_icon_cache_update;
  4965.     else
  4966.         debug-print "No icon files to add to cache";
  4967.     fi;
  4968.     if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  4969.         xdg_mimeinfo_database_update;
  4970.     else
  4971.         debug-print "No mime info files to add to database";
  4972.     fi
  4973. }
  4974. xdg_pkg_postrm ()
  4975. {
  4976.     if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  4977.         xdg_desktop_database_update;
  4978.     else
  4979.         debug-print "No .desktop files to add to database";
  4980.     fi;
  4981.     if [[ ${#XDG_ECLASS_ICONFILES[@]} -gt 0 ]]; then
  4982.         xdg_icon_cache_update;
  4983.     else
  4984.         debug-print "No icon files to add to cache";
  4985.     fi;
  4986.     if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  4987.         xdg_mimeinfo_database_update;
  4988.     else
  4989.         debug-print "No mime info files to add to database";
  4990.     fi
  4991. }
  4992. xdg_pkg_preinst ()
  4993. {
  4994.     local f;
  4995.     XDG_ECLASS_DESKTOPFILES=();
  4996.     while IFS= read -r -d '' f; do
  4997.         XDG_ECLASS_DESKTOPFILES+=(${f});
  4998.     done < <(cd "${ED}" && find 'usr/share/applications' -type f -print0 2>/dev/null);
  4999.     XDG_ECLASS_ICONFILES=();
  5000.     while IFS= read -r -d '' f; do
  5001.         XDG_ECLASS_ICONFILES+=(${f});
  5002.     done < <(cd "${ED}" && find 'usr/share/icons' -type f -print0 2>/dev/null);
  5003.     XDG_ECLASS_MIMEINFOFILES=();
  5004.     while IFS= read -r -d '' f; do
  5005.         XDG_ECLASS_MIMEINFOFILES+=(${f});
  5006.     done < <(cd "${ED}" && find 'usr/share/mime' -type f -print0 2>/dev/null)
  5007. }
  5008. xdg_src_prepare ()
  5009. {
  5010.     die "Called xdg_src_prepare in EAPI >= 8"
  5011. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement