Guest User

environment

a guest
Nov 8th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 199.19 KB | None | 0 0
  1. declare -x ABI="x86"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_PPC=""
  4. declare -x ABI_S390=""
  5. declare -x ABI_X86="32"
  6. declare -x ADAFLAGS=""
  7. declare -x ALSA_CARDS=""
  8. declare -x ANT_HOME="/usr/share/ant"
  9. declare -x APACHE2_MODULES=""
  10. declare -x APACHE2_MPMS=""
  11. declare -x AR="i686-pc-linux-gnu-ar"
  12. declare -x ARCH="x86"
  13. declare BDEPEND=""
  14. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7"
  15. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  16. declare -x CALLIGRA_FEATURES=""
  17. declare -x CAMERAS=""
  18. declare -x CBUILD="i686-pc-linux-gnu"
  19. declare -x CC="i686-pc-linux-gnu-clang"
  20. declare -x CCASFLAGS=""
  21. declare -x CFLAGS=""
  22. declare -x CFLAGS_default
  23. declare -- CHECKREQS_DISK_BUILD="5G"
  24. declare -- CHECKREQS_FAILED="true"
  25. declare -- CHECKREQS_MEMORY="3G"
  26. declare -x CHOST="i686-pc-linux-gnu"
  27. declare -x CHOST_default="i686-pc-linux-gnu"
  28. declare -x CHOST_x86="i686-pc-linux-gnu"
  29. declare -- CHROMIUM_FORCE_CLANG="yes"
  30. declare -- CHROMIUM_LANGS="am ar bg bn ca cs da de el en-GB es es-419 et fa fi fil fr gu he
  31.     hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt-BR pt-PT ro ru sk sl sr
  32.     sv sw ta te th tr uk vi zh-CN zh-TW"
  33. declare -x COLLECTD_PLUGINS=""
  34. declare -- COMMON_DEPEND="
  35.     app-accessibility/at-spi2-atk:2
  36.     app-arch/bzip2:=
  37.     cups? ( >=net-print/cups-1.3.11:= )
  38.     dev-libs/atk
  39.     dev-libs/expat:=
  40.     dev-libs/glib:2
  41.     system-icu? ( >=dev-libs/icu-59:= )
  42.     >=dev-libs/libxml2-2.9.4-r3:=[icu]
  43.     dev-libs/libxslt:=
  44.     dev-libs/nspr:=
  45.     >=dev-libs/nss-3.26:=
  46.     >=dev-libs/re2-0.2016.05.01:=
  47.     gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
  48.     >=media-libs/alsa-lib-1.0.19:=
  49.     media-libs/fontconfig:=
  50.     media-libs/freetype:=
  51.     >=media-libs/harfbuzz-1.8.8:0=[icu(-)]
  52.     <media-libs/harfbuzz-2.0.0:0
  53.     media-libs/libjpeg-turbo:=
  54.     media-libs/libpng:=
  55.     system-libvpx? ( media-libs/libvpx:=[postproc,svc] )
  56.     >=media-libs/openh264-1.6.0:=
  57.     pulseaudio? ( media-sound/pulseaudio:= )
  58.     system-ffmpeg? (
  59.         >=media-video/ffmpeg-4:=
  60.         || (
  61.             media-video/ffmpeg[-samba]
  62.             >=net-fs/samba-4.5.10-r1[-debug(-)]
  63.         )
  64.         !=net-fs/samba-4.5.12-r0
  65.         media-libs/opus:=
  66.     )
  67.     sys-apps/dbus:=
  68.     sys-apps/pciutils:=
  69.     virtual/udev
  70.     x11-libs/cairo:=
  71.     x11-libs/gdk-pixbuf:2
  72.     x11-libs/gtk+:3[X]
  73.     x11-libs/libX11:=
  74.     x11-libs/libXcomposite:=
  75.     x11-libs/libXcursor:=
  76.     x11-libs/libXdamage:=
  77.     x11-libs/libXext:=
  78.     x11-libs/libXfixes:=
  79.     >=x11-libs/libXi-1.6.0:=
  80.     x11-libs/libXrandr:=
  81.     x11-libs/libXrender:=
  82.     x11-libs/libXScrnSaver:=
  83.     x11-libs/libXtst:=
  84.     x11-libs/pango:=
  85.     app-arch/snappy:=
  86.     media-libs/flac:=
  87.     >=media-libs/libwebp-0.4.0:=
  88.     sys-libs/zlib:=[minizip]
  89.     kerberos? ( virtual/krb5 )
  90. "
  91. declare -- CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO ~!GRKERNSEC"
  92. declare -x CPPFLAGS=""
  93. declare -x CPU_FLAGS_ARM=""
  94. declare -x CPU_FLAGS_X86=""
  95. declare -x CTARGET_default="i686-pc-linux-gnu"
  96. declare -x CURL_SSL=""
  97. declare -x CXX="i686-pc-linux-gnu-clang++"
  98. declare -x CXXFLAGS="-O2 -march=i686 -pipe"
  99. declare -x DEFAULT_ABI="x86"
  100. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare pretend setup"
  101. declare DEPEND="
  102.     app-accessibility/at-spi2-atk:2
  103.     app-arch/bzip2:=
  104.     cups? ( >=net-print/cups-1.3.11:= )
  105.     dev-libs/atk
  106.     dev-libs/expat:=
  107.     dev-libs/glib:2
  108.     system-icu? ( >=dev-libs/icu-59:= )
  109.     >=dev-libs/libxml2-2.9.4-r3:=[icu]
  110.     dev-libs/libxslt:=
  111.     dev-libs/nspr:=
  112.     >=dev-libs/nss-3.26:=
  113.     >=dev-libs/re2-0.2016.05.01:=
  114.     gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
  115.     >=media-libs/alsa-lib-1.0.19:=
  116.     media-libs/fontconfig:=
  117.     media-libs/freetype:=
  118.     >=media-libs/harfbuzz-1.8.8:0=[icu(-)]
  119.     <media-libs/harfbuzz-2.0.0:0
  120.     media-libs/libjpeg-turbo:=
  121.     media-libs/libpng:=
  122.     system-libvpx? ( media-libs/libvpx:=[postproc,svc] )
  123.     >=media-libs/openh264-1.6.0:=
  124.     pulseaudio? ( media-sound/pulseaudio:= )
  125.     system-ffmpeg? (
  126.         >=media-video/ffmpeg-4:=
  127.         || (
  128.             media-video/ffmpeg[-samba]
  129.             >=net-fs/samba-4.5.10-r1[-debug(-)]
  130.         )
  131.         !=net-fs/samba-4.5.12-r0
  132.         media-libs/opus:=
  133.     )
  134.     sys-apps/dbus:=
  135.     sys-apps/pciutils:=
  136.     virtual/udev
  137.     x11-libs/cairo:=
  138.     x11-libs/gdk-pixbuf:2
  139.     x11-libs/gtk+:3[X]
  140.     x11-libs/libX11:=
  141.     x11-libs/libXcomposite:=
  142.     x11-libs/libXcursor:=
  143.     x11-libs/libXdamage:=
  144.     x11-libs/libXext:=
  145.     x11-libs/libXfixes:=
  146.     >=x11-libs/libXi-1.6.0:=
  147.     x11-libs/libXrandr:=
  148.     x11-libs/libXrender:=
  149.     x11-libs/libXScrnSaver:=
  150.     x11-libs/libXtst:=
  151.     x11-libs/pango:=
  152.     app-arch/snappy:=
  153.     media-libs/flac:=
  154.     >=media-libs/libwebp-0.4.0:=
  155.     sys-libs/zlib:=[minizip]
  156.     kerberos? ( virtual/krb5 )
  157.  
  158.     >=app-arch/gzip-1.7
  159.     !arm? (
  160.         dev-lang/yasm
  161.     )
  162.     dev-lang/perl
  163.     dev-util/gn
  164.     >=dev-util/gperf-3.0.3
  165.     >=dev-util/ninja-1.7.2
  166.     >=net-libs/nodejs-7.6.0[inspector]
  167.     sys-apps/hwids[usb(+)]
  168.     >=sys-devel/bison-2.4.3
  169.     sys-devel/flex
  170.     virtual/pkgconfig
  171.     dev-vcs/git
  172. >=sys-devel/clang-5 >=sys-apps/sed-4"
  173. declare DESCRIPTION="Open-source version of Google Chrome web browser"
  174. declare -- DESKTOP_DATABASE_DIR="/usr/share/applications"
  175. declare -- DESKTOP_DATABASE_UPDATE_BIN="/usr/bin/update-desktop-database"
  176. declare -x DESTTREE="/usr"
  177. declare -x DIROPTIONS="-m0755"
  178. declare -- DISABLE_AUTOFORMATTING="yes"
  179. declare -- DOC_CONTENTS="
  180. Some web pages may require additional fonts to display properly.
  181. Try installing some of the following packages if some characters
  182. are not displayed properly:
  183. - media-fonts/arphicfonts
  184. - media-fonts/droid
  185. - media-fonts/ipamonafont
  186. - media-fonts/noto
  187. - media-fonts/ja-ipafonts
  188. - media-fonts/takao-fonts
  189. - media-fonts/wqy-microhei
  190. - media-fonts/wqy-zenhei
  191.  
  192. To fix broken icons on the Downloads page, you should install an icon
  193. theme that covers the appropriate MIME types, and configure this as your
  194. GTK+ icon theme.
  195. "
  196. declare -x EAPI="6"
  197. declare -- EBUILD_DEATH_HOOKS=" chromium_pkg_die"
  198. declare -- EGYP_CHROMIUM_COMMAND="build/gyp_chromium"
  199. declare -- EGYP_CHROMIUM_DEPTH="."
  200. declare -x ELIBC="glibc"
  201. declare -x ENLIGHTENMENT_MODULES=""
  202. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  203. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  204. declare -- EPATCH_EXCLUDE=""
  205. declare -- EPATCH_FORCE="no"
  206. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  207. declare -- EPATCH_OPTS=""
  208. declare -- EPATCH_SINGLE_MSG=""
  209. declare -- EPATCH_SOURCE="/var/tmp/portage/www-client/chromium-70.0.3538.67/work/patch"
  210. declare -- EPATCH_SUFFIX="patch.bz2"
  211. declare -x EPYTHON="python2.7"
  212. declare -- ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)"
  213. declare -- ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)"
  214. declare -- ERROR_GRKERNSEC="CONFIG_GRKERNSEC breaks sandbox (bug #613668)"
  215. declare -- ERROR_NET_NS="NET_NS is required for sandbox to work"
  216. declare -- ERROR_PID_NS="PID_NS is required for sandbox to work"
  217. declare -- ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work"
  218. declare -- ERROR_USER_NS="USER_NS is required for sandbox to work"
  219. declare -x EXEOPTIONS="-m0755"
  220. declare -x FCFLAGS="-O2 -march=i686 -pipe"
  221. 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}\""
  222. declare -x FFLAGS="-O2 -march=i686 -pipe"
  223. declare -x FFTOOLS=""
  224. declare -x GCC_SPECS=""
  225. declare -- GCONFTOOL_BIN="/usr/bin/gconftool-2"
  226. declare -- GLIB_COMPILE_SCHEMAS="/usr/bin/glib-compile-schemas"
  227. declare -x GPSD_PROTOCOLS=""
  228. declare -x GRUB_PLATFORMS=""
  229. declare -x GSETTINGS_BACKEND="dconf"
  230. declare -- GTK_UPDATE_ICON_CACHE="/usr/bin/gtk-update-icon-cache"
  231. declare HDEPEND=""
  232. declare HOMEPAGE="http://chromium.org/"
  233. declare -x INHERITED=" check-reqs desktop epatch estack toolchain-funcs multilib ltprune preserve-libs vcs-clean eutils eapi7-ver linux-info chromium-2 xdg-utils gnome2-utils flag-o-matic multiprocessing ninja-utils pax-utils portability python-utils-r1 python-any-r1 readme.gentoo-r1"
  234. declare -x INPUT_DEVICES=""
  235. declare -x INSDESTTREE=""
  236. declare -x INSOPTIONS="-m0644"
  237. declare IUSE="component-build cups gnome-keyring +hangouts jumbo-build kerberos neon pic +proprietary-codecs pulseaudio selinux +suid +system-ffmpeg +system-icu +system-libvpx +tcmalloc widevine kernel_linux  custom-cflags +l10n_am +l10n_ar +l10n_bg +l10n_bn +l10n_ca +l10n_cs +l10n_da +l10n_de +l10n_el +l10n_en-GB +l10n_es +l10n_es-419 +l10n_et +l10n_fa +l10n_fi +l10n_fil +l10n_fr +l10n_gu +l10n_he +l10n_hi +l10n_hr +l10n_hu +l10n_id +l10n_it +l10n_ja +l10n_kn +l10n_ko +l10n_lt +l10n_lv +l10n_ml +l10n_mr +l10n_ms +l10n_nb +l10n_nl +l10n_pl +l10n_pt-BR +l10n_pt-PT +l10n_ro +l10n_ru +l10n_sk +l10n_sl +l10n_sr +l10n_sv +l10n_sw +l10n_ta +l10n_te +l10n_th +l10n_tr +l10n_uk +l10n_vi +l10n_zh-CN +l10n_zh-TW"
  238. declare -x IUSE_EFFECTIVE="abi_x86_32 alpha amd64 amd64-fbsd amd64-linux arm arm64 component-build cups custom-cflags elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc gnome-keyring hangouts hppa ia64 jumbo-build kerberos kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux l10n_am l10n_ar l10n_bg l10n_bn l10n_ca l10n_cs l10n_da l10n_de l10n_el l10n_en-GB l10n_es l10n_es-419 l10n_et l10n_fa l10n_fi l10n_fil l10n_fr l10n_gu l10n_he l10n_hi l10n_hr l10n_hu l10n_id l10n_it l10n_ja l10n_kn l10n_ko l10n_lt l10n_lv l10n_ml l10n_mr l10n_ms l10n_nb l10n_nl l10n_pl l10n_pt-BR l10n_pt-PT l10n_ro l10n_ru l10n_sk l10n_sl l10n_sr l10n_sv l10n_sw l10n_ta l10n_te l10n_th l10n_tr l10n_uk l10n_vi l10n_zh-CN l10n_zh-TW m68k m68k-mint mips neon pic ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest proprietary-codecs pulseaudio s390 selinux sh sparc sparc-solaris sparc64-solaris suid system-ffmpeg system-icu system-libvpx tcmalloc userland_BSD userland_GNU widevine x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  239. declare -x IUSE_IMPLICIT="abi_x86_32 prefix prefix-chain prefix-guest"
  240. declare -x I_KNOW_WHAT_I_AM_DOING="1"
  241. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  242. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  243. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  244. declare -x KERNEL="linux"
  245. declare -x KERNEL_ABI="x86"
  246. declare -- KERNEL_DIR="/usr/src/linux"
  247. declare -- KERNEL_MAKEFILE="/usr/src/linux/Makefile"
  248. declare -x KEYWORDS="amd64 ~x86"
  249. declare -- KV_DIR="/usr/src/linux"
  250. declare -- KV_EXTRA="-gentoo"
  251. declare -- KV_FULL="4.14.78-gentoo"
  252. declare -- KV_LOCAL=""
  253. declare -- KV_MAJOR="4"
  254. declare -- KV_MINOR="14"
  255. declare -- KV_OUT_DIR="/usr/src/linux"
  256. declare -- KV_PATCH="78"
  257. declare -x L10N="de"
  258. declare -x LANG="de_DE.utf8"
  259. declare -x LCD_DEVICES=""
  260. declare -x LC_COLLATE="C"
  261. declare -x LC_MESSAGES="C"
  262. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  263. declare -x LDFLAGS_default
  264. declare -x LIBDIR_default="lib"
  265. declare -x LIBDIR_x86="lib"
  266. declare -x LIBOPTIONS="-m0644"
  267. declare -x LIBREOFFICE_EXTENSIONS=""
  268. declare -x LICENSE="BSD"
  269. declare -x LINGUAS="de en"
  270. declare -x LINUX_CONFIG_EXISTS_DONE=""
  271. declare -x LIRC_DEVICES=""
  272. declare -x LLVM_TARGETS=""
  273. declare -x MAIL="/var/mail/rsu"
  274. declare -x MAKEOPTS="-j1"
  275. declare -x MANPAGER="manpager"
  276. declare -- MIMEINFO_DATABASE_DIR="/usr/share/mime"
  277. declare -- MIMEINFO_DATABASE_UPDATE_BIN="/usr/bin/update-mime-database"
  278. declare -x MONKEYD_PLUGINS=""
  279. declare -x MOZ_GMP_PATH="/usr/lib/nsbrowser/plugins/gmp-gmpopenh264/system-installed"
  280. declare -x MULTILIB_ABIS="x86"
  281. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  282. declare -x NETBEANS_MODULES=""
  283. declare -x NGINX_MODULES_HTTP=""
  284. declare -x NGINX_MODULES_MAIL=""
  285. declare -x NGINX_MODULES_STREAM=""
  286. declare -x NM="i686-pc-linux-gnu-nm"
  287. declare -x OFED_DRIVERS=""
  288. declare -x OFFICE_IMPLEMENTATION=""
  289. declare -x OPENGL_PROFILE="xorg-x11"
  290. declare -x OPENMPI_FABRICS=""
  291. declare -x OPENMPI_OFED_FEATURES=""
  292. declare -x OPENMPI_RM=""
  293. declare -a PATCHES=([0]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-compiler-r4.patch" [1]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-widevine-r2.patch" [2]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-webrtc-r0.patch" [3]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-memcpy-r0.patch" [4]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-math.h-r0.patch" [5]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-stdint.patch" [6]="/var/tmp/portage/www-client/chromium-70.0.3538.67/files/chromium-pdfium-stdlib-r0.patch")
  294. declare -x PATH="/var/tmp/portage/www-client/chromium-70.0.3538.67/temp/python2.7/bin:/var/tmp/portage/www-client/chromium-70.0.3538.67/temp/python2.7/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/i686-pc-linux-gnu/gcc-bin/7.3.0:/usr/lib/llvm/6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  295. declare -- PAX_MARKINGS="PT XT"
  296. declare PDEPEND=""
  297. declare -x PHP_TARGETS=""
  298. declare -x PKG_CONFIG_PATH="/var/tmp/portage/www-client/chromium-70.0.3538.67/temp/python2.7/pkgconfig"
  299. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  300. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  301. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  302. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/chromium-70.0.3538.67/html")
  303. declare -a PORTAGE_DOSTRIP=([0]="/")
  304. declare -a PORTAGE_DOSTRIP_SKIP=()
  305. declare -x POSTGRES_TARGETS=""
  306. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  307. declare -x PROPERTIES=""
  308. declare -x PYTHON="/usr/bin/python2.7"
  309. declare -x PYTHONDONTWRITEBYTECODE="1"
  310. declare -a PYTHON_COMPAT=([0]="python2_7")
  311. declare -- PYTHON_DEPS="|| ( >=dev-lang/python-2.7.5-r2:2.7 )"
  312. declare -x PYTHON_SINGLE_TARGET=""
  313. declare -x PYTHON_TARGETS=""
  314. declare -x QEMU_SOFTMMU_TARGETS=""
  315. declare -x QEMU_USER_TARGETS=""
  316. declare RDEPEND="
  317.     app-accessibility/at-spi2-atk:2
  318.     app-arch/bzip2:=
  319.     cups? ( >=net-print/cups-1.3.11:= )
  320.     dev-libs/atk
  321.     dev-libs/expat:=
  322.     dev-libs/glib:2
  323.     system-icu? ( >=dev-libs/icu-59:= )
  324.     >=dev-libs/libxml2-2.9.4-r3:=[icu]
  325.     dev-libs/libxslt:=
  326.     dev-libs/nspr:=
  327.     >=dev-libs/nss-3.26:=
  328.     >=dev-libs/re2-0.2016.05.01:=
  329.     gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
  330.     >=media-libs/alsa-lib-1.0.19:=
  331.     media-libs/fontconfig:=
  332.     media-libs/freetype:=
  333.     >=media-libs/harfbuzz-1.8.8:0=[icu(-)]
  334.     <media-libs/harfbuzz-2.0.0:0
  335.     media-libs/libjpeg-turbo:=
  336.     media-libs/libpng:=
  337.     system-libvpx? ( media-libs/libvpx:=[postproc,svc] )
  338.     >=media-libs/openh264-1.6.0:=
  339.     pulseaudio? ( media-sound/pulseaudio:= )
  340.     system-ffmpeg? (
  341.         >=media-video/ffmpeg-4:=
  342.         || (
  343.             media-video/ffmpeg[-samba]
  344.             >=net-fs/samba-4.5.10-r1[-debug(-)]
  345.         )
  346.         !=net-fs/samba-4.5.12-r0
  347.         media-libs/opus:=
  348.     )
  349.     sys-apps/dbus:=
  350.     sys-apps/pciutils:=
  351.     virtual/udev
  352.     x11-libs/cairo:=
  353.     x11-libs/gdk-pixbuf:2
  354.     x11-libs/gtk+:3[X]
  355.     x11-libs/libX11:=
  356.     x11-libs/libXcomposite:=
  357.     x11-libs/libXcursor:=
  358.     x11-libs/libXdamage:=
  359.     x11-libs/libXext:=
  360.     x11-libs/libXfixes:=
  361.     >=x11-libs/libXi-1.6.0:=
  362.     x11-libs/libXrandr:=
  363.     x11-libs/libXrender:=
  364.     x11-libs/libXScrnSaver:=
  365.     x11-libs/libXtst:=
  366.     x11-libs/pango:=
  367.     app-arch/snappy:=
  368.     media-libs/flac:=
  369.     >=media-libs/libwebp-0.4.0:=
  370.     sys-libs/zlib:=[minizip]
  371.     kerberos? ( virtual/krb5 )
  372.  
  373.     !<www-plugins/chrome-binary-plugins-57
  374.     x11-misc/xdg-utils
  375.     virtual/opengl
  376.     virtual/ttf-fonts
  377.     selinux? ( sec-policy/selinux-chromium )
  378.     tcmalloc? ( !<x11-drivers/nvidia-drivers-331.20 )
  379.     widevine? ( www-plugins/chrome-binary-plugins[widevine(-)] )
  380. "
  381. declare -- README_GENTOO_SUFFIX=""
  382. declare REPOSITORY
  383. declare REQUIRED_USE=""
  384. declare -x RESTRICT="bindist"
  385. 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}\""
  386. declare -x ROS_MESSAGES=""
  387. declare -x RUBY_TARGETS=""
  388. declare -x S="/var/tmp/portage/www-client/chromium-70.0.3538.67/work/chromium-70.0.3538.67"
  389. declare -x SANDBOX_DEBUG="0"
  390. declare -x SANDBOX_DENY=""
  391. declare -x SANDBOX_PREDICT="/var/tmp/portage/www-client/chromium-70.0.3538.67/homedir:/dev/crypto:/proc/self/coredump_filter:/var/cache/fontconfig:/dev/dri/"
  392. declare -x SANDBOX_READ="/:/var/tmp"
  393. declare -x SANDBOX_VERBOSE="1"
  394. 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/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/www-client/chromium-70.0.3538.67/homedir/.bash_history"
  395. declare -x SANE_BACKENDS=""
  396. declare -- SCROLLKEEPER_DIR="/var/lib/scrollkeeper"
  397. declare -- SCROLLKEEPER_UPDATE_BIN="/usr/bin/scrollkeeper-update"
  398. declare -x SHELL="/bin/bash"
  399. declare -x SLOT="0"
  400. declare SRC_URI="https://commondatastorage.googleapis.com/chromium-browser-official/chromium-70.0.3538.67.tar.xz"
  401. declare -x SSH_TTY="/dev/pts/1"
  402. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  403. declare -x USE="abi_x86_32 cups elibc_glibc kernel_linux l10n_de proprietary-codecs pulseaudio userland_GNU x86"
  404. declare -x USERLAND="GNU"
  405. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  406. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  407. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  408. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  409. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  410. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  411. declare -x UWSGI_PLUGINS=""
  412. declare -x VIDEO_CARDS=""
  413. declare -x VOICEMAIL_STORAGE=""
  414. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  415. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  416. declare -x XDG_RUNTIME_DIR="/var/run/user/1001"
  417. declare -x XFCE_PLUGINS=""
  418. declare -x XSESSION="icewm-session"
  419. declare -x XTABLES_ADDONS=""
  420. declare -- _CHECK_REQS_ECLASS_="1"
  421. declare -- _DESKTOP_ECLASS="1"
  422. declare -- _EPATCH_ECLASS="1"
  423. declare -- _ESTACK_ECLASS="1"
  424. declare -a _ESTACK_eshopts_=()
  425. declare -- _EUTILS_ECLASS="1"
  426. declare -x _E_DOCDESTTREE_=""
  427. declare -x _E_EXEDESTTREE_=""
  428. declare -- _FLAG_O_MATIC_ECLASS="1"
  429. declare -x _LINUX_CONFIG_EXISTS_DONE="1"
  430. declare -- _LTPRUNE_ECLASS="1"
  431. declare -- _MULTILIB_ECLASS="1"
  432. declare -- _MULTIPROCESSING_ECLASS="1"
  433. declare -- _NINJA_UTILS_ECLASS="1"
  434. declare -- _PAX_UTILS_ECLASS="1"
  435. declare -- _PORTABILITY_ECLASS="1"
  436. declare -- _PRESERVE_LIBS_ECLASS="1"
  437. declare -a _PYTHON_ALL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_4" [5]="python3_5" [6]="python3_6" [7]="python3_7")
  438. declare -- _PYTHON_ANY_R1="1"
  439. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python2_7")
  440. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python3_4" [4]="python3_5" [5]="python3_6" [6]="python3_7")
  441. declare -- _PYTHON_UTILS_R1="1"
  442. declare -- _README_GENTOO_ECLASS="1"
  443. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  444. declare -- ffmpeg_branding="Chrome"
  445. declare -- ffmpeg_target_arch="ia32"
  446. declare -- get_version_warning_done=""
  447. declare -- phase_func
  448. declare -- started_applying="1"
  449. PYTHON ()
  450. {
  451.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#.24.28PYTHON.29.2C_.24.7BEPYTHON.7D"
  452. }
  453. __eapi6_src_install ()
  454. {
  455.     if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  456.         emake DESTDIR="${D}" install;
  457.     fi;
  458.     einstalldocs
  459. }
  460. __eapi6_src_prepare ()
  461. {
  462.     if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  463.         [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  464.     else
  465.         if [[ -n ${PATCHES} ]]; then
  466.             eapply ${PATCHES};
  467.         fi;
  468.     fi;
  469.     eapply_user
  470. }
  471. _chromium_set_l10n_IUSE ()
  472. {
  473.     [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported";
  474.     local lang;
  475.     for lang in ${CHROMIUM_LANGS};
  476.     do
  477.         IUSE+=" +l10n_${lang}";
  478.     done
  479. }
  480. _clang_fullversion ()
  481. {
  482.     local ver="$1";
  483.     shift;
  484.     set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  485.     eval echo "$ver"
  486. }
  487. _dead_portability_user_funcs ()
  488. {
  489.     die "if you really need this, please file a bug for base-system@gentoo.org"
  490. }
  491. _eapply_patch ()
  492. {
  493.     local f=${1};
  494.     local prefix=${2};
  495.     started_applying=1;
  496.     ebegin "${prefix:-Applying }${f##*/}";
  497.     ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  498.     failed=${?};
  499.     if ! eend "${failed}"; then
  500.         __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  501.     fi
  502. }
  503. _filter-hardened ()
  504. {
  505.     local f;
  506.     for f in "$@";
  507.     do
  508.         case "${f}" in
  509.             -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  510.                 gcc-specs-pie || continue;
  511.                 if ! is-flagq -nopie && ! is-flagq -no-pie; then
  512.                     if test-flags -nopie > /dev/null; then
  513.                         append-flags -nopie;
  514.                     else
  515.                         append-flags -no-pie;
  516.                     fi;
  517.                 fi
  518.             ;;
  519.             -fstack-protector)
  520.                 gcc-specs-ssp || continue;
  521.                 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  522.             ;;
  523.             -fstack-protector-all)
  524.                 gcc-specs-ssp-to-all || continue;
  525.                 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  526.             ;;
  527.             -fno-strict-overflow)
  528.                 gcc-specs-nostrict || continue;
  529.                 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  530.             ;;
  531.         esac;
  532.     done
  533. }
  534. _filter-var ()
  535. {
  536.     local f x var=$1 new=();
  537.     shift;
  538.     for f in ${!var};
  539.     do
  540.         for x in "$@";
  541.         do
  542.             [[ ${f} == ${x} ]] && continue 2;
  543.         done;
  544.         new+=("${f}");
  545.     done;
  546.     export ${var}="${new[*]}"
  547. }
  548. _gcc-install-dir ()
  549. {
  550.     echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |      awk '$1=="install:" {print $2}')"
  551. }
  552. _gcc-specs-directive_raw ()
  553. {
  554.     local cc=$(tc-getCC);
  555.     local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  556.     ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  557. $1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
  558.     outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  559.     spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  560.     { spec=spec $0 }
  561. END { print spec }';
  562.     return 0
  563. }
  564. _gcc-specs-exists ()
  565. {
  566.     [[ -f $(_gcc-install-dir)/$1 ]]
  567. }
  568. _gcc_fullversion ()
  569. {
  570.     local ver="$1";
  571.     shift;
  572.     set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  573.     eval echo "$ver"
  574. }
  575. _iconins ()
  576. {
  577.     ( insopts -m 0644;
  578.     local funcname=$1;
  579.     shift;
  580.     local size dir;
  581.     local context=apps;
  582.     local theme=hicolor;
  583.     while [[ $# -gt 0 ]]; do
  584.         case $1 in
  585.             -s | --size)
  586.                 if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  587.                     size=${2%%x*};
  588.                 else
  589.                     size=${2};
  590.                 fi;
  591.                 case ${size} in
  592.                     16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  593.                         size=${size}x${size}
  594.                     ;;
  595.                     scalable)
  596.  
  597.                     ;;
  598.                     *)
  599.                         eerror "${size} is an unsupported icon size!";
  600.                         exit 1
  601.                     ;;
  602.                 esac;
  603.                 shift 2
  604.             ;;
  605.             -t | --theme)
  606.                 theme=${2};
  607.                 shift 2
  608.             ;;
  609.             -c | --context)
  610.                 context=${2};
  611.                 shift 2
  612.             ;;
  613.             *)
  614.                 if [[ -z ${size} ]]; then
  615.                     insinto /usr/share/pixmaps;
  616.                 else
  617.                     insinto /usr/share/icons/${theme}/${size}/${context};
  618.                 fi;
  619.                 if [[ ${funcname} == doicon ]]; then
  620.                     if [[ -f $1 ]]; then
  621.                         doins "${1}";
  622.                     else
  623.                         if [[ -d $1 ]]; then
  624.                             shopt -s nullglob;
  625.                             doins "${1}"/*.{png,svg};
  626.                             shopt -u nullglob;
  627.                         else
  628.                             eerror "${1} is not a valid file/directory!";
  629.                             exit 1;
  630.                         fi;
  631.                     fi;
  632.                 else
  633.                     break;
  634.                 fi;
  635.                 shift 1
  636.             ;;
  637.         esac;
  638.     done;
  639.     if [[ ${funcname} == newicon ]]; then
  640.         newins "$@";
  641.     fi ) || die
  642. }
  643. _is_flagq ()
  644. {
  645.     local x var="$1[*]";
  646.     for x in ${!var};
  647.     do
  648.         [[ ${x} == $2 ]] && return 0;
  649.     done;
  650.     return 1
  651. }
  652. _pax_list_files ()
  653. {
  654.     local f cmd;
  655.     cmd=$1;
  656.     shift;
  657.     for f in "$@";
  658.     do
  659.         ${cmd} "     ${f}";
  660.     done
  661. }
  662. _python_EPYTHON_supported ()
  663. {
  664.     debug-print-function ${FUNCNAME} "${@}";
  665.     local EPYTHON=${1};
  666.     local i=${EPYTHON/./_};
  667.     case "${i}" in
  668.         python* | jython* | pypy*)
  669.  
  670.         ;;
  671.         *)
  672.             ewarn "Invalid EPYTHON: ${EPYTHON}";
  673.             return 1
  674.         ;;
  675.     esac;
  676.     if has "${i}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
  677.         if python_is_installed "${i}"; then
  678.             if declare -f python_check_deps > /dev/null; then
  679.                 local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  680.                 python_check_deps;
  681.                 return ${?};
  682.             fi;
  683.             return 0;
  684.         fi;
  685.     else
  686.         if ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
  687.             ewarn "Invalid EPYTHON: ${EPYTHON}";
  688.         fi;
  689.     fi;
  690.     return 1
  691. }
  692. _python_check_dead_variables ()
  693. {
  694.     local v;
  695.     for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  696.     do
  697.         if [[ -n ${!v} ]]; then
  698.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  699.         fi;
  700.     done;
  701.     for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  702.     do
  703.         if [[ -n ${!v} ]]; then
  704.             die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  705.         fi;
  706.     done;
  707.     for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  708.     do
  709.         if [[ -n ${!v} ]]; then
  710.             die "${v} is invalid for python-r1 suite";
  711.         fi;
  712.     done;
  713.     for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  714.     do
  715.         if [[ -n ${!v} ]]; then
  716.             die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  717.         fi;
  718.     done;
  719.     if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  720.         die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  721.     fi;
  722.     for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  723.     do
  724.         if [[ -n ${!v} ]]; then
  725.             die "${v} is invalid for python-r1 suite";
  726.         fi;
  727.     done
  728. }
  729. _python_check_locale_sanity ()
  730. {
  731.     local -x LC_ALL=${1};
  732.     local IFS=;
  733.     local lc=({a..z});
  734.     local uc=({A..Z});
  735.     local input="${lc[*]}${uc[*]}";
  736.     local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  737.     [[ ${output} == "${uc[*]}${lc[*]}" ]]
  738. }
  739. _python_impl_matches ()
  740. {
  741.     [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  742.     local impl=${1} pattern;
  743.     shift;
  744.     for pattern in "$@";
  745.     do
  746.         if [[ ${pattern} == -2 ]]; then
  747.             ! python_is_python3 "${impl}";
  748.             return;
  749.         else
  750.             if [[ ${pattern} == -3 ]]; then
  751.                 python_is_python3 "${impl}";
  752.                 return;
  753.             else
  754.                 if [[ ${impl/./_} == ${pattern/./_} ]]; then
  755.                     return 0;
  756.                 fi;
  757.             fi;
  758.         fi;
  759.     done;
  760.     return 1
  761. }
  762. _python_impl_supported ()
  763. {
  764.     debug-print-function ${FUNCNAME} "${@}";
  765.     [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  766.     local impl=${1};
  767.     case "${impl}" in
  768.         python2_7 | python3_[4567] | jython2_7)
  769.             return 0
  770.         ;;
  771.         pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  772.             return 1
  773.         ;;
  774.         pypy | pypy3)
  775.             if [[ ${EAPI:-0} == [01234] ]]; then
  776.                 die "PyPy is supported in EAPI 5 and newer only.";
  777.             fi
  778.         ;;
  779.         *)
  780.             [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  781.             die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  782.         ;;
  783.     esac
  784. }
  785. _python_ln_rel ()
  786. {
  787.     debug-print-function ${FUNCNAME} "${@}";
  788.     local target=${1};
  789.     local symname=${2};
  790.     local tgpath=${target%/*}/;
  791.     local sympath=${symname%/*}/;
  792.     local rel_target=;
  793.     while [[ -n ${sympath} ]]; do
  794.         local tgseg= symseg=;
  795.         while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  796.             tgseg=${tgpath%%/*};
  797.             tgpath=${tgpath#${tgseg}/};
  798.         done;
  799.         while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  800.             symseg=${sympath%%/*};
  801.             sympath=${sympath#${symseg}/};
  802.         done;
  803.         if [[ ${tgseg} != ${symseg} ]]; then
  804.             rel_target=../${rel_target}${tgseg:+${tgseg}/};
  805.         fi;
  806.     done;
  807.     rel_target+=${tgpath}${target##*/};
  808.     debug-print "${FUNCNAME}: ${symname} -> ${target}";
  809.     debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  810.     ln -fs "${rel_target}" "${symname}"
  811. }
  812. _python_set_impls ()
  813. {
  814.     local i;
  815.     if ! declare -p PYTHON_COMPAT &> /dev/null; then
  816.         die 'PYTHON_COMPAT not declared.';
  817.     fi;
  818.     if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  819.         die 'PYTHON_COMPAT must be an array.';
  820.     fi;
  821.     for i in "${PYTHON_COMPAT[@]}";
  822.     do
  823.         _python_impl_supported "${i}";
  824.     done;
  825.     local supp=() unsupp=();
  826.     for i in "${_PYTHON_ALL_IMPLS[@]}";
  827.     do
  828.         if has "${i}" "${PYTHON_COMPAT[@]}"; then
  829.             supp+=("${i}");
  830.         else
  831.             unsupp+=("${i}");
  832.         fi;
  833.     done;
  834.     if [[ ! -n ${supp[@]} ]]; then
  835.         die "No supported implementation in PYTHON_COMPAT.";
  836.     fi;
  837.     if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  838.         if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  839.             eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  840.             eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  841.             eerror "Now   : ${supp[*]}";
  842.             die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  843.         fi;
  844.         if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  845.             eerror "Unsupported impls changed between inherits!";
  846.             eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  847.             eerror "Now   : ${unsupp[*]}";
  848.             die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  849.         fi;
  850.     else
  851.         _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  852.         _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  853.         readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  854.     fi
  855. }
  856. _tc-getPROG ()
  857. {
  858.     local tuple=$1;
  859.     local v var vars=$2;
  860.     local prog=($3);
  861.     var=${vars%% *};
  862.     for v in ${vars};
  863.     do
  864.         if [[ -n ${!v} ]]; then
  865.             export ${var}="${!v}";
  866.             echo "${!v}";
  867.             return 0;
  868.         fi;
  869.     done;
  870.     local search=;
  871.     [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  872.     [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  873.     [[ -n ${search} ]] && prog[0]=${search##*/};
  874.     export ${var}="${prog[*]}";
  875.     echo "${!var}"
  876. }
  877. _ver_compare ()
  878. {
  879.     local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  880.     re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  881.     [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  882.     an=${BASH_REMATCH[1]};
  883.     al=${BASH_REMATCH[3]};
  884.     as=${BASH_REMATCH[4]};
  885.     ar=${BASH_REMATCH[7]};
  886.     [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  887.     bn=${BASH_REMATCH[1]};
  888.     bl=${BASH_REMATCH[3]};
  889.     bs=${BASH_REMATCH[4]};
  890.     br=${BASH_REMATCH[7]};
  891.     _ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  892.     while [[ ${an} == *.* && ${bn} == *.* ]]; do
  893.         an=${an#*.};
  894.         bn=${bn#*.};
  895.         a=${an%%.*};
  896.         b=${bn%%.*};
  897.         if [[ ${a} == 0* || ${b} == 0* ]]; then
  898.             [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  899.            [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  900.             [[ ${a} > ${b} ]] && return 3;
  901.             [[ ${a} < ${b} ]] && return 1;
  902.         else
  903.             _ver_compare_int "${a}" "${b}" || return;
  904.         fi;
  905.     done;
  906.     [[ ${an} == *.* ]] && return 3;
  907.     [[ ${bn} == *.* ]] && return 1;
  908.     [[ ${al} > ${bl} ]] && return 3;
  909.     [[ ${al} < ${bl} ]] && return 1;
  910.     as=${as#_}${as:+_};
  911.     bs=${bs#_}${bs:+_};
  912.     while [[ -n ${as} && -n ${bs} ]]; do
  913.         a=${as%%_*};
  914.         b=${bs%%_*};
  915.         if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  916.             _ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  917.         else
  918.             [[ ${a%%[0-9]*} == p ]] && return 3;
  919.             [[ ${b%%[0-9]*} == p ]] && return 1;
  920.             [[ ${a} > ${b} ]] && return 3 || return 1;
  921.         fi;
  922.         as=${as#*_};
  923.         bs=${bs#*_};
  924.     done;
  925.     if [[ -n ${as} ]]; then
  926.         [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  927.     else
  928.         if [[ -n ${bs} ]]; then
  929.             [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  930.         fi;
  931.     fi;
  932.     _ver_compare_int "${ar#-r}" "${br#-r}" || return;
  933.     return 2
  934. }
  935. _ver_compare_int ()
  936. {
  937.     local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  938.     if [[ ${d} -gt 0 ]]; then
  939.         printf -v b "%0${d}d%s" 0 "${b}";
  940.     else
  941.         if [[ ${d} -lt 0 ]]; then
  942.             printf -v a "%0$(( -d ))d%s" 0 "${a}";
  943.         fi;
  944.     fi;
  945.     [[ ${a} > ${b} ]] && return 3;
  946.     [[ ${a} == "${b}" ]]
  947. }
  948. _ver_parse_range ()
  949. {
  950.     local range=${1};
  951.     local max=${2};
  952.     [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  953.     start=${range%-*};
  954.     [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  955.     if [[ -n ${end} ]]; then
  956.         [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  957.         [[ ${end} -le ${max} ]] || end=${max};
  958.     else
  959.         end=${max};
  960.     fi
  961. }
  962. _ver_split ()
  963. {
  964.     local v=${1} LC_ALL=C;
  965.     comp=();
  966.     local s c;
  967.     while [[ -n ${v} ]]; do
  968.         s=${v%%[a-zA-Z0-9]*};
  969.         v=${v:${#s}};
  970.         [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  971.         v=${v:${#c}};
  972.         comp+=("${s}" "${c}");
  973.     done
  974. }
  975. all-flag-vars ()
  976. {
  977.     echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  978. }
  979. append-cflags ()
  980. {
  981.     [[ $# -eq 0 ]] && return 0;
  982.     export CFLAGS+=" $*";
  983.     return 0
  984. }
  985. append-cppflags ()
  986. {
  987.     [[ $# -eq 0 ]] && return 0;
  988.     export CPPFLAGS+=" $*";
  989.     return 0
  990. }
  991. append-cxxflags ()
  992. {
  993.     [[ $# -eq 0 ]] && return 0;
  994.     export CXXFLAGS+=" $*";
  995.     return 0
  996. }
  997. append-fflags ()
  998. {
  999.     [[ $# -eq 0 ]] && return 0;
  1000.     export FFLAGS+=" $*";
  1001.     export FCFLAGS+=" $*";
  1002.     return 0
  1003. }
  1004. append-flags ()
  1005. {
  1006.     [[ $# -eq 0 ]] && return 0;
  1007.     case " $* " in
  1008.         *' '-[DIU]*)
  1009.             eqawarn 'please use append-cppflags for preprocessor flags'
  1010.         ;;
  1011.         *' '-L* | *' '-Wl,*)
  1012.             eqawarn 'please use append-ldflags for linker flags'
  1013.         ;;
  1014.     esac;
  1015.     append-cflags "$@";
  1016.     append-cxxflags "$@";
  1017.     append-fflags "$@";
  1018.     return 0
  1019. }
  1020. append-ldflags ()
  1021. {
  1022.     [[ $# -eq 0 ]] && return 0;
  1023.     local flag;
  1024.     for flag in "$@";
  1025.     do
  1026.         [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  1027.     done;
  1028.     export LDFLAGS="${LDFLAGS} $*";
  1029.     return 0
  1030. }
  1031. append-lfs-flags ()
  1032. {
  1033.     [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  1034.     append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1035. }
  1036. append-libs ()
  1037. {
  1038.     [[ $# -eq 0 ]] && return 0;
  1039.     local flag;
  1040.     for flag in "$@";
  1041.     do
  1042.         if [[ -z "${flag// }" ]]; then
  1043.             eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  1044.             continue;
  1045.         fi;
  1046.         case $flag in
  1047.             -[lL]*)
  1048.                 export LIBS="${LIBS} ${flag}"
  1049.             ;;
  1050.             -*)
  1051.                 eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  1052.                 export LIBS="${LIBS} ${flag}"
  1053.             ;;
  1054.             *)
  1055.                 export LIBS="${LIBS} -l${flag}"
  1056.             ;;
  1057.         esac;
  1058.     done;
  1059.     return 0
  1060. }
  1061. check-reqs_disk ()
  1062. {
  1063.     debug-print-function ${FUNCNAME} "$@";
  1064.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [path] [size]";
  1065.     local path=${1};
  1066.     local size=${2};
  1067.     local space_kbi;
  1068.     check-reqs_start_phase ${size} "disk space at \"${path}\"";
  1069.     space_kbi=$(df -Pk "${1}" 2>/dev/null | awk 'FNR == 2 {print $4}');
  1070.     if [[ $? == 0 && -n ${space_kbi} ]]; then
  1071.         if [[ ${space_kbi} -lt $(check-reqs_get_kibibytes ${size}) ]]; then
  1072.             eend 1;
  1073.             check-reqs_unsatisfied ${size} "disk space at \"${path}\"";
  1074.         else
  1075.             eend 0;
  1076.         fi;
  1077.     else
  1078.         eend 1;
  1079.         ewarn "Couldn't determine disk space, skipping...";
  1080.     fi
  1081. }
  1082. check-reqs_get_kibibytes ()
  1083. {
  1084.     debug-print-function ${FUNCNAME} "$@";
  1085.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  1086.     local unit=${1:(-1)};
  1087.     local size=${1%[GMT]};
  1088.     case ${unit} in
  1089.         M)
  1090.             echo $((1024 * size))
  1091.         ;;
  1092.         G)
  1093.             echo $((1024 * 1024 * size))
  1094.         ;;
  1095.         T)
  1096.             echo $((1024 * 1024 * 1024 * size))
  1097.         ;;
  1098.         *)
  1099.             die "${FUNCNAME}: Unknown unit: ${unit}"
  1100.         ;;
  1101.     esac
  1102. }
  1103. check-reqs_get_number ()
  1104. {
  1105.     debug-print-function ${FUNCNAME} "$@";
  1106.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  1107.     local size=${1%[GMT]};
  1108.     [[ ${size} == ${1} ]] && die "${FUNCNAME}: Missing unit: ${1}";
  1109.     echo ${size}
  1110. }
  1111. check-reqs_get_unit ()
  1112. {
  1113.     debug-print-function ${FUNCNAME} "$@";
  1114.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  1115.     local unit=${1:(-1)};
  1116.     case ${unit} in
  1117.         M)
  1118.             echo "MiB"
  1119.         ;;
  1120.         G)
  1121.             echo "GiB"
  1122.         ;;
  1123.         T)
  1124.             echo "TiB"
  1125.         ;;
  1126.         *)
  1127.             die "${FUNCNAME}: Unknown unit: ${unit}"
  1128.         ;;
  1129.     esac
  1130. }
  1131. check-reqs_memory ()
  1132. {
  1133.     debug-print-function ${FUNCNAME} "$@";
  1134.     [[ -z ${1} ]] && die "Usage: ${FUNCNAME} [size]";
  1135.     local size=${1};
  1136.     local actual_memory;
  1137.     check-reqs_start_phase ${size} "RAM";
  1138.     if [[ -r /proc/meminfo ]]; then
  1139.         actual_memory=$(awk '/MemTotal/ { print $2 }' /proc/meminfo);
  1140.     else
  1141.         actual_memory=$(sysctl hw.physmem 2>/dev/null );
  1142.         [[ "$?" == "0" ]] && actual_memory=$(echo $actual_memory | sed -e 's/^[^:=]*[:=]//' );
  1143.     fi;
  1144.     if [[ -n ${actual_memory} ]]; then
  1145.         if [[ ${actual_memory} -lt $(check-reqs_get_kibibytes ${size}) ]]; then
  1146.             eend 1;
  1147.             check-reqs_unsatisfied ${size} "RAM";
  1148.         else
  1149.             eend 0;
  1150.         fi;
  1151.     else
  1152.         eend 1;
  1153.         ewarn "Couldn't determine amount of memory, skipping...";
  1154.     fi
  1155. }
  1156. check-reqs_output ()
  1157. {
  1158.     debug-print-function ${FUNCNAME} "$@";
  1159.     local msg="ewarn";
  1160.     [[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] && msg="eerror";
  1161.     if [[ -n ${CHECKREQS_FAILED} ]]; then
  1162.         ${msg};
  1163.         ${msg} "Space constraints set in the ebuild were not met!";
  1164.         ${msg} "The build will most probably fail, you should enhance the space";
  1165.         ${msg} "as per failed tests.";
  1166.         ${msg};
  1167.         [[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] && die "Build requirements not met!";
  1168.     fi
  1169. }
  1170. check-reqs_pkg_pretend ()
  1171. {
  1172.     debug-print-function ${FUNCNAME} "$@";
  1173.     check-reqs_pkg_setup "$@"
  1174. }
  1175. check-reqs_pkg_setup ()
  1176. {
  1177.     debug-print-function ${FUNCNAME} "$@";
  1178.     check-reqs_prepare;
  1179.     check-reqs_run;
  1180.     check-reqs_output
  1181. }
  1182. check-reqs_prepare ()
  1183. {
  1184.     debug-print-function ${FUNCNAME} "$@";
  1185.     if [[ -z ${CHECKREQS_MEMORY} && -z ${CHECKREQS_DISK_BUILD} && -z ${CHECKREQS_DISK_USR} && -z ${CHECKREQS_DISK_VAR} ]]; then
  1186.         eerror "Set some check-reqs eclass variables if you want to use it.";
  1187.         eerror "If you are user and see this message file a bug against the package.";
  1188.         die "${FUNCNAME}: check-reqs eclass called but not actualy used!";
  1189.     fi
  1190. }
  1191. check-reqs_run ()
  1192. {
  1193.     debug-print-function ${FUNCNAME} "$@";
  1194.     unset CHECKREQS_FAILED;
  1195.     [[ ${EAPI:-0} == [0123] ]] && local MERGE_TYPE="";
  1196.     if [[ ${MERGE_TYPE} != binary ]]; then
  1197.         [[ -n ${CHECKREQS_MEMORY} ]] && check-reqs_memory ${CHECKREQS_MEMORY};
  1198.         [[ -n ${CHECKREQS_DISK_BUILD} ]] && check-reqs_disk "${T}" "${CHECKREQS_DISK_BUILD}";
  1199.     fi;
  1200.     if [[ ${MERGE_TYPE} != buildonly ]]; then
  1201.         [[ -n ${CHECKREQS_DISK_USR} ]] && check-reqs_disk "${EROOT}/usr" "${CHECKREQS_DISK_USR}";
  1202.         [[ -n ${CHECKREQS_DISK_VAR} ]] && check-reqs_disk "${EROOT}/var" "${CHECKREQS_DISK_VAR}";
  1203.     fi
  1204. }
  1205. check-reqs_start_phase ()
  1206. {
  1207.     debug-print-function ${FUNCNAME} "$@";
  1208.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]";
  1209.     local size=${1};
  1210.     local location=${2};
  1211.     local sizeunit="$(check-reqs_get_number ${size}) $(check-reqs_get_unit ${size})";
  1212.     ebegin "Checking for at least ${sizeunit} ${location}"
  1213. }
  1214. check-reqs_unsatisfied ()
  1215. {
  1216.     debug-print-function ${FUNCNAME} "$@";
  1217.     [[ -z ${2} ]] && die "Usage: ${FUNCNAME} [size] [location]";
  1218.     local msg="ewarn";
  1219.     local size=${1};
  1220.     local location=${2};
  1221.     local sizeunit="$(check-reqs_get_number ${size}) $(check-reqs_get_unit ${size})";
  1222.     [[ ${EBUILD_PHASE} == "pretend" && -z ${I_KNOW_WHAT_I_AM_DOING} ]] && msg="eerror";
  1223.     ${msg} "There is NOT at least ${sizeunit} ${location}";
  1224.     CHECKREQS_FAILED="true"
  1225. }
  1226. check_extra_config ()
  1227. {
  1228.     use kernel_linux || return;
  1229.     local config negate die error reworkmodulenames;
  1230.     local soft_errors_count=0 hard_errors_count=0 config_required=0;
  1231.     local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  1232.     linux-info_get_any_version;
  1233.     for config in ${CONFIG_CHECK};
  1234.     do
  1235.         if [[ "${config:0:1}" != "~" ]]; then
  1236.             config_required=1;
  1237.             break;
  1238.         fi;
  1239.     done;
  1240.     if [[ ${config_required} == 0 ]]; then
  1241.         if ! linux_config_exists; then
  1242.             ewarn "Unable to check for the following kernel config options due";
  1243.             ewarn "to absence of any configured kernel sources or compiled";
  1244.             ewarn "config:";
  1245.             for config in ${CONFIG_CHECK};
  1246.             do
  1247.                 config=${config#\~};
  1248.                 config=${config#\!};
  1249.                 local_error="ERROR_${config}";
  1250.                 msg="${!local_error}";
  1251.                 if [[ -z ${msg} ]]; then
  1252.                     local_error="WARNING_${config}";
  1253.                     msg="${!local_error}";
  1254.                 fi;
  1255.                 ewarn " - ${config}${msg:+ - }${msg}";
  1256.             done;
  1257.             ewarn "You're on your own to make sure they are set if needed.";
  1258.             export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1259.             return 0;
  1260.         fi;
  1261.     else
  1262.         require_configured_kernel;
  1263.     fi;
  1264.     einfo "Checking for suitable kernel configuration options...";
  1265.     for config in ${CONFIG_CHECK};
  1266.     do
  1267.         die=1;
  1268.         error=0;
  1269.         negate=0;
  1270.         reworkmodulenames=0;
  1271.         if [[ ${config:0:1} == "~" ]]; then
  1272.             die=0;
  1273.             config=${config:1};
  1274.         else
  1275.             if [[ ${config:0:1} == "@" ]]; then
  1276.                 die=0;
  1277.                 reworkmodulenames=1;
  1278.                 config=${config:1};
  1279.             fi;
  1280.         fi;
  1281.         if [[ ${config:0:1} == "!" ]]; then
  1282.             negate=1;
  1283.             config=${config:1};
  1284.         fi;
  1285.         if [[ ${negate} == 1 ]]; then
  1286.             linux_chkconfig_present ${config} && error=2;
  1287.         else
  1288.             if [[ ${reworkmodulenames} == 1 ]]; then
  1289.                 local temp_config="${config//*:}" i n;
  1290.                 config="${config//:*}";
  1291.                 if linux_chkconfig_present ${config}; then
  1292.                     for i in ${MODULE_NAMES};
  1293.                     do
  1294.                         n="${i//${temp_config}}";
  1295.                         [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  1296.                     done;
  1297.                     error=2;
  1298.                 fi;
  1299.             else
  1300.                 linux_chkconfig_present ${config} || error=1;
  1301.             fi;
  1302.         fi;
  1303.         if [[ ${error} > 0 ]]; then
  1304.             local report_func="eerror" local_error;
  1305.             local_error="ERROR_${config}";
  1306.             local_error="${!local_error}";
  1307.             if [[ -z "${local_error}" ]]; then
  1308.                 local_error="${config}_ERROR";
  1309.                 local_error="${!local_error}";
  1310.             fi;
  1311.             if [[ ${die} == 0 && -z "${local_error}" ]]; then
  1312.                 local_error="WARNING_${config}";
  1313.                 local_error="${!local_error}";
  1314.                 if [[ -n "${local_error}" ]]; then
  1315.                     report_func="ewarn";
  1316.                 fi;
  1317.             fi;
  1318.             if [[ -z "${local_error}" ]]; then
  1319.                 [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  1320.                 local_error="CONFIG_${config}:\t ${local_error}";
  1321.             fi;
  1322.             if [[ ${die} == 0 ]]; then
  1323.                 ${report_func} "  ${local_error}";
  1324.                 soft_errors_count=$[soft_errors_count + 1];
  1325.             else
  1326.                 ${report_func} "  ${local_error}";
  1327.                 hard_errors_count=$[hard_errors_count + 1];
  1328.             fi;
  1329.         fi;
  1330.     done;
  1331.     if [[ ${hard_errors_count} > 0 ]]; then
  1332.         eerror "Please check to make sure these options are set correctly.";
  1333.         eerror "Failure to do so may cause unexpected problems.";
  1334.         eerror "Once you have satisfied these options, please try merging";
  1335.         eerror "this package again.";
  1336.         export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1337.         die "Incorrect kernel configuration options";
  1338.     else
  1339.         if [[ ${soft_errors_count} > 0 ]]; then
  1340.             ewarn "Please check to make sure these options are set correctly.";
  1341.             ewarn "Failure to do so may cause unexpected problems.";
  1342.         else
  1343.             eend 0;
  1344.         fi;
  1345.     fi;
  1346.     export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  1347. }
  1348. check_kernel_built ()
  1349. {
  1350.     if ! use kernel_linux; then
  1351.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1352.     fi;
  1353.     require_configured_kernel;
  1354.     local versionh_path;
  1355.     if kernel_is -ge 3 7; then
  1356.         versionh_path="include/generated/uapi/linux/version.h";
  1357.     else
  1358.         versionh_path="include/linux/version.h";
  1359.     fi;
  1360.     if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]; then
  1361.         eerror "These sources have not yet been prepared.";
  1362.         eerror "We cannot build against an unprepared tree.";
  1363.         eerror "To resolve this, please type the following:";
  1364.         eerror;
  1365.         eerror "# cd ${KV_DIR}";
  1366.         eerror "# make oldconfig";
  1367.         eerror "# make modules_prepare";
  1368.         eerror;
  1369.         eerror "Then please try merging this module again.";
  1370.         die "Kernel sources need compiling first";
  1371.     fi
  1372. }
  1373. check_modules_supported ()
  1374. {
  1375.     if ! use kernel_linux; then
  1376.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1377.     fi;
  1378.     require_configured_kernel;
  1379.     if ! linux_chkconfig_builtin "MODULES"; then
  1380.         eerror "These sources do not support loading external modules.";
  1381.         eerror "to be able to use this module please enable \"Loadable modules support\"";
  1382.         eerror "in your kernel, recompile and then try merging this module again.";
  1383.         die "No support for external modules in ${KV_FULL} config";
  1384.     fi
  1385. }
  1386. check_reqs ()
  1387. {
  1388.     eerror "Package calling old ${FUNCNAME} function.";
  1389.     eerror "It should call check-reqs_pkg_pretend and check-reqs_pkg_setup.";
  1390.     die "${FUNCNAME} is banned"
  1391. }
  1392. check_zlibinflate ()
  1393. {
  1394.     if ! use kernel_linux; then
  1395.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1396.     fi;
  1397.     require_configured_kernel;
  1398.     local INFLATE;
  1399.     local DEFLATE;
  1400.     einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  1401.     ebegin "checking ZLIB_INFLATE";
  1402.     linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  1403.     eend $? || die;
  1404.     ebegin "checking ZLIB_DEFLATE";
  1405.     linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  1406.     eend $? || die;
  1407.     local LINENO_START;
  1408.     local LINENO_END;
  1409.     local SYMBOLS;
  1410.     local x;
  1411.     LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  1412.     LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  1413.     (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ));
  1414.     (( LINENO_END = $LINENO_END - 1 ));
  1415.     SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  1416.     for x in $SYMBOLS;
  1417.     do
  1418.         if [ "${!x}" = "y" ]; then
  1419.             einfo "${x} ensures zlib is linked into your kernel - excellent";
  1420.             return 0;
  1421.         fi;
  1422.     done;
  1423.     eerror;
  1424.     eerror "This kernel module requires ZLIB library support.";
  1425.     eerror "You have enabled zlib support in your kernel, but haven't enabled";
  1426.     eerror "enabled any option that will ensure that zlib is linked into your";
  1427.     eerror "kernel.";
  1428.     eerror;
  1429.     eerror "Please ensure that you enable at least one of these options:";
  1430.     eerror;
  1431.     for x in $SYMBOLS;
  1432.     do
  1433.         eerror "  * $x";
  1434.     done;
  1435.     eerror;
  1436.     eerror "Please remember to recompile and install your kernel, and reboot";
  1437.     eerror "into your new kernel before attempting to load this kernel module.";
  1438.     die "Kernel doesn't include zlib support"
  1439. }
  1440. chromium_pkg_die ()
  1441. {
  1442.     if [[ "${EBUILD_PHASE}" != "compile" ]]; then
  1443.         return;
  1444.     fi;
  1445.     if ( shopt -s extglob;
  1446.     is-flagq '-g?(gdb)?([1-9])' ); then
  1447.         ewarn;
  1448.         ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS).";
  1449.         ewarn "This produces very large build files causes the linker to consume large";
  1450.         ewarn "amounts of memory.";
  1451.         ewarn;
  1452.         ewarn "Please try removing -g{,gdb} before reporting a bug.";
  1453.         ewarn;
  1454.     fi;
  1455.     if has ccache ${FEATURES}; then
  1456.         ewarn;
  1457.         ewarn "You have enabled ccache. Please try disabling ccache";
  1458.         ewarn "before reporting a bug.";
  1459.         ewarn;
  1460.     fi;
  1461.     if use_if_iuse custom-cflags; then
  1462.         ewarn;
  1463.         ewarn "You have enabled the custom-cflags USE flag.";
  1464.         ewarn "Please disable it before reporting a bug.";
  1465.         ewarn;
  1466.     fi;
  1467.     einfo;
  1468.     einfo "$(grep MemTotal /proc/meminfo)";
  1469.     einfo "$(grep SwapTotal /proc/meminfo)";
  1470.     einfo
  1471. }
  1472. chromium_remove_language_paks ()
  1473. {
  1474.     local lang pak;
  1475.     for lang in ${CHROMIUM_LANGS};
  1476.     do
  1477.         if [[ ! -e ${lang}.pak ]]; then
  1478.             eqawarn "L10N warning: no .pak file for ${lang} (${lang}.pak not found)";
  1479.         fi;
  1480.     done;
  1481.     rm -f fake-bidi.pak || die;
  1482.     rm -f fake-bidi.pak.info || die;
  1483.     for pak in *.pak;
  1484.     do
  1485.         lang=${pak%.pak};
  1486.         if [[ ${lang} == en-US ]]; then
  1487.             continue;
  1488.         fi;
  1489.         if ! has ${lang} ${CHROMIUM_LANGS}; then
  1490.             eqawarn "L10N warning: no ${lang} in LANGS";
  1491.             continue;
  1492.         fi;
  1493.         if ! use l10n_${lang}; then
  1494.             rm "${pak}" || die;
  1495.             rm -f "${pak}.info" || die;
  1496.         fi;
  1497.     done
  1498. }
  1499. chromium_suid_sandbox_check_kernel_config ()
  1500. {
  1501.     has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported";
  1502.     if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
  1503.         ERROR_PID_NS="PID_NS is required for sandbox to work";
  1504.         ERROR_NET_NS="NET_NS is required for sandbox to work";
  1505.         ERROR_USER_NS="USER_NS is required for sandbox to work";
  1506.         ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work";
  1507.         ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)";
  1508.         ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)";
  1509.         ERROR_GRKERNSEC="CONFIG_GRKERNSEC breaks sandbox (bug #613668)";
  1510.         CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO ~!GRKERNSEC";
  1511.         check_extra_config;
  1512.     fi
  1513. }
  1514. clang-fullversion ()
  1515. {
  1516.     _clang_fullversion '$1.$2.$3' "$@"
  1517. }
  1518. clang-major-version ()
  1519. {
  1520.     _clang_fullversion '$1' "$@"
  1521. }
  1522. clang-micro-version ()
  1523. {
  1524.     _clang_fullversion '$3' "$@"
  1525. }
  1526. clang-minor-version ()
  1527. {
  1528.     _clang_fullversion '$2' "$@"
  1529. }
  1530. clang-version ()
  1531. {
  1532.     _clang_fullversion '$1.$2' "$@"
  1533. }
  1534. dlopen_lib ()
  1535. {
  1536.     case "${CHOST}" in
  1537.         *-linux-gnu* | *-linux-uclibc | *-interix*)
  1538.             echo "-ldl"
  1539.         ;;
  1540.     esac
  1541. }
  1542. doicon ()
  1543. {
  1544.     _iconins ${FUNCNAME} "$@"
  1545. }
  1546. domenu ()
  1547. {
  1548.     ( local i ret=0;
  1549.     insopts -m 0644;
  1550.     insinto /usr/share/applications;
  1551.     for i in "$@";
  1552.     do
  1553.         if [[ -d ${i} ]]; then
  1554.             doins "${i}"/*.desktop;
  1555.             ((ret|=$?));
  1556.         else
  1557.             doins "${i}";
  1558.             ((ret|=$?));
  1559.         fi;
  1560.     done;
  1561.     exit ${ret} )
  1562. }
  1563. eapply ()
  1564. {
  1565.     local failed patch_cmd=patch;
  1566.     local -x LC_COLLATE=POSIX;
  1567.     type -P gpatch > /dev/null && patch_cmd=gpatch;
  1568.     function _eapply_patch ()
  1569.     {
  1570.         local f=${1};
  1571.         local prefix=${2};
  1572.         started_applying=1;
  1573.         ebegin "${prefix:-Applying }${f##*/}";
  1574.         ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1575.         failed=${?};
  1576.         if ! eend "${failed}"; then
  1577.             __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1578.         fi
  1579.     };
  1580.     local patch_options=() files=();
  1581.     local i found_doublehyphen;
  1582.     for ((i = 1; i <= ${#@}; ++i ))
  1583.     do
  1584.         if [[ ${@:i:1} == -- ]]; then
  1585.             patch_options=("${@:1:i-1}");
  1586.             files=("${@:i+1}");
  1587.             found_doublehyphen=1;
  1588.             break;
  1589.         fi;
  1590.     done;
  1591.     if [[ -z ${found_doublehyphen} ]]; then
  1592.         for ((i = 1; i <= ${#@}; ++i ))
  1593.         do
  1594.             if [[ ${@:i:1} != -* ]]; then
  1595.                 patch_options=("${@:1:i-1}");
  1596.                 files=("${@:i}");
  1597.                 break;
  1598.             fi;
  1599.         done;
  1600.         for i in "${files[@]}";
  1601.         do
  1602.             if [[ ${i} == -* ]]; then
  1603.                 die "eapply: all options must be passed before non-options";
  1604.             fi;
  1605.         done;
  1606.     fi;
  1607.     if [[ ${#files[@]} -eq 0 ]]; then
  1608.         die "eapply: no files specified";
  1609.     fi;
  1610.     local f;
  1611.     for f in "${files[@]}";
  1612.     do
  1613.         if [[ -d ${f} ]]; then
  1614.             function _eapply_get_files ()
  1615.             {
  1616.                 local LC_ALL=POSIX;
  1617.                 local prev_shopt=$(shopt -p nullglob);
  1618.                 shopt -s nullglob;
  1619.                 local f;
  1620.                 for f in "${1}"/*;
  1621.                 do
  1622.                     if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1623.                         files+=("${f}");
  1624.                     fi;
  1625.                 done;
  1626.                 ${prev_shopt}
  1627.             };
  1628.             local files=();
  1629.             _eapply_get_files "${f}";
  1630.             [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1631.             einfo "Applying patches from ${f} ...";
  1632.             local f2;
  1633.             for f2 in "${files[@]}";
  1634.             do
  1635.                 _eapply_patch "${f2}" '  ';
  1636.                 [[ ${failed} -ne 0 ]] && return "${failed}";
  1637.             done;
  1638.         else
  1639.             _eapply_patch "${f}";
  1640.             [[ ${failed} -ne 0 ]] && return "${failed}";
  1641.         fi;
  1642.     done;
  1643.     return 0
  1644. }
  1645. eapply_user ()
  1646. {
  1647.     [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1648.     local tagfile=${T}/.portage_user_patches_applied;
  1649.     [[ -f ${tagfile} ]] && return;
  1650.      >> "${tagfile}";
  1651.     local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1652.     local applied d f;
  1653.     local -A _eapply_user_patches;
  1654.     local prev_shopt=$(shopt -p nullglob);
  1655.     shopt -s nullglob;
  1656.     for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1657.     do
  1658.         for f in "${d}"/*;
  1659.         do
  1660.             if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1661.                 _eapply_user_patches[${f##*/}]=${f};
  1662.             fi;
  1663.         done;
  1664.     done;
  1665.     if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1666.         while read -r -d '' f; do
  1667.             f=${_eapply_user_patches[${f}]};
  1668.             if [[ -s ${f} ]]; then
  1669.                 eapply "${f}";
  1670.                 applied=1;
  1671.             fi;
  1672.         done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1673.                 LC_ALL=C sort -z);
  1674.     fi;
  1675.     ${prev_shopt};
  1676.     [[ -n ${applied} ]] && ewarn "User patches applied."
  1677. }
  1678. ebeep ()
  1679. {
  1680.     ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1681. }
  1682. econf_build ()
  1683. {
  1684.     local CBUILD=${CBUILD:-${CHOST}};
  1685.     tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1686. }
  1687. ecvs_clean ()
  1688. {
  1689.     [[ $# -eq 0 ]] && set -- .;
  1690.     find "$@" '(' -type d -name 'CVS' -prune -o -type f -name '.cvs*' ')' -exec rm -rf '{}' +
  1691. }
  1692. edos2unix ()
  1693. {
  1694.     [[ $# -eq 0 ]] && return 0;
  1695.     sed -i 's/\r$//' -- "$@" || die
  1696. }
  1697. egit_clean ()
  1698. {
  1699.     [[ $# -eq 0 ]] && set -- .;
  1700.     find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' +
  1701. }
  1702. egyp_chromium ()
  1703. {
  1704.     set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@";
  1705.     echo "$@";
  1706.     "$@"
  1707. }
  1708. einstalldocs ()
  1709. {
  1710.     ( if ! declare -p DOCS &> /dev/null; then
  1711.         local d;
  1712.         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1713.         do
  1714.             [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1715.         done;
  1716.     else
  1717.         if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1718.             [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1719.         else
  1720.             [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1721.         fi;
  1722.     fi );
  1723.     ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1724.         [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1725.     else
  1726.         [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1727.     fi )
  1728. }
  1729. emktemp ()
  1730. {
  1731.     local exe="touch";
  1732.     [[ $1 == -d ]] && exe="mkdir" && shift;
  1733.     local topdir=$1;
  1734.     if [[ -z ${topdir} ]]; then
  1735.         [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1736.     fi;
  1737.     if ! type -P mktemp > /dev/null; then
  1738.         local tmp=/;
  1739.         while [[ -e ${tmp} ]]; do
  1740.             tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1741.         done;
  1742.         ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1743.         echo "${tmp}";
  1744.     else
  1745.         if [[ ${exe} == "touch" ]]; then
  1746.             TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1747.         else
  1748.             TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1749.         fi;
  1750.     fi
  1751. }
  1752. eninja ()
  1753. {
  1754.     local nonfatal_args=();
  1755.     [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=(-n);
  1756.     if [[ -z ${NINJAOPTS+set} ]]; then
  1757.         NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)";
  1758.     fi;
  1759.     set -- ninja -v ${NINJAOPTS} "$@";
  1760.     echo "$@" 1>&2;
  1761.     "$@" || die "${nonfatal_args[@]}" "${*} failed"
  1762. }
  1763. epatch ()
  1764. {
  1765.     function _epatch_draw_line ()
  1766.     {
  1767.         [[ -z $1 ]] && set "$(printf "%65s" '')";
  1768.         echo "${1//?/=}"
  1769.     };
  1770.     unset P4CONFIG P4PORT P4USER;
  1771.     local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1772.     while [[ $# -gt 0 ]]; do
  1773.         case $1 in
  1774.             -*)
  1775.                 EPATCH_OPTS+=("$1")
  1776.             ;;
  1777.             *)
  1778.                 break
  1779.             ;;
  1780.         esac;
  1781.         shift;
  1782.     done;
  1783.     if [[ $# -gt 1 ]]; then
  1784.         local m;
  1785.         for m in "$@";
  1786.         do
  1787.             epatch "${m}";
  1788.         done;
  1789.         return 0;
  1790.     fi;
  1791.     local SINGLE_PATCH="no";
  1792.     [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1793.     if [[ -f $1 ]]; then
  1794.         SINGLE_PATCH="yes";
  1795.         set -- "$1";
  1796.         local EPATCH_SUFFIX=$1;
  1797.     else
  1798.         if [[ -d $1 ]]; then
  1799.             evar_push_set LC_COLLATE C;
  1800.             set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1801.            evar_pop;
  1802.        else
  1803.            if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1804.                epatch "${EPATCH_SOURCE}/$1";
  1805.                return $?;
  1806.            else
  1807.                [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1808.                echo;
  1809.                eerror "Cannot find \$EPATCH_SOURCE!  Value for \$EPATCH_SOURCE is:";
  1810.                eerror;
  1811.                eerror "  ${EPATCH_SOURCE}";
  1812.                eerror "  ( ${EPATCH_SOURCE##*/} )";
  1813.                echo;
  1814.                die "Cannot find \$EPATCH_SOURCE!";
  1815.            fi;
  1816.        fi;
  1817.    fi;
  1818.    EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1819.    local PIPE_CMD;
  1820.    case ${EPATCH_SUFFIX##*\.} in
  1821.        xz)
  1822.            PIPE_CMD="xz -dc"
  1823.        ;;
  1824.        lzma)
  1825.            PIPE_CMD="lzma -dc"
  1826.        ;;
  1827.        bz2)
  1828.            PIPE_CMD="bzip2 -dc"
  1829.        ;;
  1830.        gz | Z | z)
  1831.            PIPE_CMD="gzip -dc"
  1832.        ;;
  1833.        ZIP | zip)
  1834.            PIPE_CMD="unzip -p"
  1835.        ;;
  1836.        *)
  1837.  
  1838.        ;;
  1839.    esac;
  1840.    [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1841.    local x;
  1842.    for x in "$@";
  1843.    do
  1844.        [[ ! -f ${x} ]] && continue;
  1845.        local patchname=${x##*/};
  1846.        local a=${patchname#*_};
  1847.        a=${a%%_*};
  1848.        if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1849.            continue;
  1850.        fi;
  1851.        if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  1852.            local prev_noglob=$(shopt -p -o noglob);
  1853.            set -o noglob;
  1854.            local ex;
  1855.            for ex in ${EPATCH_EXCLUDE};
  1856.            do
  1857.                if [[ ${patchname} == ${ex} ]]; then
  1858.                    einfo "  Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  1859.                    ${prev_noglob};
  1860.                    continue 2;
  1861.                fi;
  1862.            done;
  1863.            for ex in ${EPATCH_USER_EXCLUDE};
  1864.            do
  1865.                if [[ ${patchname} == ${ex} ]]; then
  1866.                    einfo "  Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  1867.                    ${prev_noglob};
  1868.                    continue 2;
  1869.                fi;
  1870.            done;
  1871.            ${prev_noglob};
  1872.        fi;
  1873.        if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1874.            if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1875.                einfo "${EPATCH_SINGLE_MSG}";
  1876.            else
  1877.                einfo "Applying ${patchname} ...";
  1878.            fi;
  1879.        else
  1880.            einfo "  ${patchname} ...";
  1881.        fi;
  1882.        local patch="patch";
  1883.        eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  1884.        local STDERR_TARGET="${T}/${patchname}.out";
  1885.        if [[ -e ${STDERR_TARGET} ]]; then
  1886.            STDERR_TARGET="${T}/${patchname}-$$.out";
  1887.        fi;
  1888.        printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  1889.        local count=0;
  1890.        local PATCH_TARGET;
  1891.        if [[ -n ${PIPE_CMD} ]]; then
  1892.            PATCH_TARGET="${T}/$$.patch";
  1893.            echo "PIPE_COMMAND:  ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1894.            if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1895.                echo;
  1896.                eerror "Could not extract patch!";
  1897.                count=5;
  1898.                break;
  1899.            fi;
  1900.        else
  1901.            PATCH_TARGET=${x};
  1902.        fi;
  1903.        local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1904.        if [[ -n ${abs_paths} ]]; then
  1905.            count=1;
  1906.            printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1907.        fi;
  1908.         local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1909.        if [[ -n ${rel_paths} ]]; then
  1910.            echo;
  1911.            eerror "Rejected Patch: ${patchname} !";
  1912.            eerror " ( ${PATCH_TARGET} )";
  1913.            eerror;
  1914.            eerror "Your patch uses relative paths '../':";
  1915.            eerror "${rel_paths}";
  1916.            echo;
  1917.            die "you need to fix the relative paths in patch";
  1918.        fi;
  1919.        local patch_cmd;
  1920.        while [[ ${count} -lt 5 ]]; do
  1921.            patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  1922.            ( _epatch_draw_line "***** ${patchname} *****";
  1923.            echo;
  1924.            echo "PATCH COMMAND:  ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  1925.            echo;
  1926.            _epatch_draw_line "***** ${patchname} *****";
  1927.            ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1928.            ret=$?;
  1929.            echo;
  1930.            echo "patch program exited with status ${ret}";
  1931.            exit ${ret} ) >> "${STDERR_TARGET}";
  1932.            if [ $? -eq 0 ]; then
  1933.                ( _epatch_draw_line "***** ${patchname} *****";
  1934.                echo;
  1935.                echo "ACTUALLY APPLYING ${patchname} ...";
  1936.                echo "PATCH COMMAND:  ${patch_cmd} < '${PATCH_TARGET}'";
  1937.                echo;
  1938.                _epatch_draw_line "***** ${patchname} *****";
  1939.                ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1940.                ret=$?;
  1941.                echo;
  1942.                echo "patch program exited with status ${ret}";
  1943.                exit ${ret} ) >> "${STDERR_TARGET}";
  1944.                if [ $? -ne 0 ]; then
  1945.                    echo;
  1946.                    eerror "A dry-run of patch command succeeded, but actually";
  1947.                    eerror "applying the patch failed!";
  1948.                    count=5;
  1949.                fi;
  1950.                break;
  1951.            fi;
  1952.            : $(( count++ ));
  1953.        done;
  1954.        (( EPATCH_N_APPLIED_PATCHES++ ));
  1955.        if [[ -n ${PIPE_CMD} ]]; then
  1956.            rm -f "${PATCH_TARGET}";
  1957.        fi;
  1958.        if [[ ${count} -ge 5 ]]; then
  1959.            echo;
  1960.            eerror "Failed Patch: ${patchname} !";
  1961.            eerror " ( ${PATCH_TARGET} )";
  1962.            eerror;
  1963.            eerror "Include in your bugreport the contents of:";
  1964.            eerror;
  1965.            eerror "  ${STDERR_TARGET}";
  1966.            echo;
  1967.            die "Failed Patch: ${patchname}!";
  1968.        fi;
  1969.        rm -f "${STDERR_TARGET}";
  1970.        cat >> "${T}/epatch.log"  <<-EOF
  1971. PATCH: ${x}
  1972. CMD: ${patch_cmd}
  1973. PWD: ${PWD}
  1974.  
  1975. EOF
  1976.  
  1977.        eend 0;
  1978.    done;
  1979.    [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1980.    :
  1981. }
  1982. epause ()
  1983. {
  1984.    ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1985. }
  1986. eshopts_pop ()
  1987. {
  1988.    local s;
  1989.    estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1990.    eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  1991. }
  1992. eshopts_push ()
  1993. {
  1994.    if [[ $1 == -[su] ]]; then
  1995.        estack_push eshopts "$(shopt -p)";
  1996.        [[ $# -eq 0 ]] && return 0;
  1997.        shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1998.    else
  1999.        estack_push eshopts "$(shopt -p -o)";
  2000.        [[ $# -eq 0 ]] && return 0;
  2001.        set "$@" || die "${FUNCNAME}: bad options to set: $*";
  2002.    fi
  2003. }
  2004. estack_pop ()
  2005. {
  2006.    [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  2007.     local _estack_name="_ESTACK_$1_";
  2008.     shift;
  2009.     local _estack_retvar=$1;
  2010.     shift;
  2011.     eval local _estack_i=\${#${_estack_name}\[@\]};
  2012.     [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  2013.     if [[ -n ${_estack_retvar} ]]; then
  2014.         eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  2015.     fi;
  2016.     eval unset \"${_estack_name}\[${_estack_i}\]\"
  2017. }
  2018. estack_push ()
  2019. {
  2020.     [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  2021.     local stack_name="_ESTACK_$1_";
  2022.     shift;
  2023.     eval ${stack_name}+=\( \"\$@\" \)
  2024. }
  2025. esvn_clean ()
  2026. {
  2027.     [[ $# -eq 0 ]] && set -- .;
  2028.     find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' +
  2029. }
  2030. eumask_pop ()
  2031. {
  2032.     [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  2033.     local s;
  2034.     estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  2035.     umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  2036. }
  2037. eumask_push ()
  2038. {
  2039.     estack_push eumask "$(umask)";
  2040.     umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  2041. }
  2042. evar_pop ()
  2043. {
  2044.     local cnt=${1:-bad};
  2045.     case $# in
  2046.         0)
  2047.             cnt=1
  2048.         ;;
  2049.         1)
  2050.             isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  2051.         ;;
  2052.         *)
  2053.             die "${FUNCNAME}: only accepts one arg: $*"
  2054.         ;;
  2055.     esac;
  2056.     local var val;
  2057.     while (( cnt-- )); do
  2058.         estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  2059.         estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  2060.         [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  2061.     done
  2062. }
  2063. evar_push ()
  2064. {
  2065.     local var val;
  2066.     for var in "$@";
  2067.     do
  2068.         [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  2069.         estack_push evar "${var}" "${val}";
  2070.     done
  2071. }
  2072. evar_push_set ()
  2073. {
  2074.     local var=$1;
  2075.     evar_push ${var};
  2076.     case $# in
  2077.         1)
  2078.             unset ${var}
  2079.         ;;
  2080.         2)
  2081.             printf -v "${var}" '%s' "$2"
  2082.         ;;
  2083.         *)
  2084.             die "${FUNCNAME}: incorrect # of args: $*"
  2085.         ;;
  2086.     esac
  2087. }
  2088. filter-flags ()
  2089. {
  2090.     _filter-hardened "$@";
  2091.     local v;
  2092.     for v in $(all-flag-vars);
  2093.     do
  2094.         _filter-var ${v} "$@";
  2095.     done;
  2096.     return 0
  2097. }
  2098. filter-ldflags ()
  2099. {
  2100.     _filter-var LDFLAGS "$@";
  2101.     return 0
  2102. }
  2103. filter-lfs-flags ()
  2104. {
  2105.     [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2106.     filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  2107. }
  2108. filter-mfpmath ()
  2109. {
  2110.     local orig_mfpmath new_math prune_math;
  2111.     orig_mfpmath=$(get-flag -mfpmath);
  2112.     new_math=$(get-flag mfpmath);
  2113.     new_math=${new_math/both/387,sse};
  2114.     new_math=" ${new_math//[,+]/ } ";
  2115.     prune_math="";
  2116.     for prune_math in "$@";
  2117.     do
  2118.         new_math=${new_math/ ${prune_math} / };
  2119.     done;
  2120.     new_math=$(echo ${new_math});
  2121.     new_math=${new_math// /,};
  2122.     if [[ -z ${new_math} ]]; then
  2123.         filter-flags ${orig_mfpmath};
  2124.     else
  2125.         replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2126.     fi;
  2127.     return 0
  2128. }
  2129. gcc-fullversion ()
  2130. {
  2131.     _gcc_fullversion '$1.$2.$3' "$@"
  2132. }
  2133. gcc-major-version ()
  2134. {
  2135.     _gcc_fullversion '$1' "$@"
  2136. }
  2137. gcc-micro-version ()
  2138. {
  2139.     _gcc_fullversion '$3' "$@"
  2140. }
  2141. gcc-minor-version ()
  2142. {
  2143.     _gcc_fullversion '$2' "$@"
  2144. }
  2145. gcc-specs-directive ()
  2146. {
  2147.     local directive subdname subdirective;
  2148.     directive="$(_gcc-specs-directive_raw $1)";
  2149.     while [[ ${directive} == *%\(*\)* ]]; do
  2150.         subdname=${directive/*%\(};
  2151.         subdname=${subdname/\)*};
  2152.         subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2153.         directive="${directive//\%(${subdname})/${subdirective}}";
  2154.     done;
  2155.     echo "${directive}";
  2156.     return 0
  2157. }
  2158. gcc-specs-nostrict ()
  2159. {
  2160.     local directive;
  2161.     directive=$(gcc-specs-directive cc1);
  2162.     [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2163. }
  2164. gcc-specs-now ()
  2165. {
  2166.     local directive;
  2167.     directive=$(gcc-specs-directive link_command);
  2168.     [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2169. }
  2170. gcc-specs-pie ()
  2171. {
  2172.     local directive;
  2173.     directive=$(gcc-specs-directive cc1);
  2174.     [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2175. }
  2176. gcc-specs-relro ()
  2177. {
  2178.     local directive;
  2179.     directive=$(gcc-specs-directive link_command);
  2180.     [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2181. }
  2182. gcc-specs-ssp ()
  2183. {
  2184.     local directive;
  2185.     directive=$(gcc-specs-directive cc1);
  2186.     [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2187. }
  2188. gcc-specs-ssp-to-all ()
  2189. {
  2190.     local directive;
  2191.     directive=$(gcc-specs-directive cc1);
  2192.     [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2193. }
  2194. gcc-specs-stack-check ()
  2195. {
  2196.     local directive;
  2197.     directive=$(gcc-specs-directive cc1);
  2198.     [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2199. }
  2200. gcc-version ()
  2201. {
  2202.     _gcc_fullversion '$1.$2' "$@"
  2203. }
  2204. gen_usr_ldscript ()
  2205. {
  2206.     local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2207.     [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2208.     tc-is-static-only && return;
  2209.     if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2210.         multilib_is_native_abi || return 0;
  2211.     fi;
  2212.     case ${CTARGET:-${CHOST}} in
  2213.         *-darwin*)
  2214.  
  2215.         ;;
  2216.         *-android*)
  2217.             return 0
  2218.         ;;
  2219.         *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  2220.             use prefix && return 0
  2221.         ;;
  2222.         *)
  2223.             return 0
  2224.         ;;
  2225.     esac;
  2226.     dodir /usr/${libdir};
  2227.     if [[ $1 == "-a" ]]; then
  2228.         auto=true;
  2229.         shift;
  2230.         dodir /${libdir};
  2231.     fi;
  2232.     local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2233.     if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2234.         local d="${T}/bfd-linker";
  2235.         mkdir -p "${d}";
  2236.         ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  2237.         flags+=(-B"${d}");
  2238.     fi;
  2239.     output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2240.     [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2241.     for lib in "$@";
  2242.     do
  2243.         local tlib;
  2244.         if ${auto}; then
  2245.             lib="lib${lib}${suffix}";
  2246.         else
  2247.             [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2248.         fi;
  2249.         case ${CTARGET:-${CHOST}} in
  2250.             *-darwin*)
  2251.                 if ${auto}; then
  2252.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2253.                 else
  2254.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2255.                 fi;
  2256.                 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2257.                 tlib=${tlib##*/};
  2258.                 if ${auto}; then
  2259.                     mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2260.                     if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2261.                         mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2262.                     fi;
  2263.                     rm -f "${ED}"/${libdir}/${lib};
  2264.                 fi;
  2265.                 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2266.                     chmod u+w "${ED}${libdir}/${tlib}";
  2267.                     local nowrite=yes;
  2268.                 fi;
  2269.                 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2270.                 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2271.                 pushd "${ED}/usr/${libdir}" > /dev/null;
  2272.                 ln -snf "../../${libdir}/${tlib}" "${lib}";
  2273.                 popd > /dev/null
  2274.             ;;
  2275.             *)
  2276.                 if ${auto}; then
  2277.                     tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2278.                     [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2279.                     mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2280.                     if [[ ${tlib} != ${lib}* ]]; then
  2281.                         mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2282.                     fi;
  2283.                     rm -f "${ED}"/${libdir}/${lib};
  2284.                 else
  2285.                     tlib=${lib};
  2286.                 fi;
  2287.                 cat > "${ED}/usr/${libdir}/${lib}"  <<-END_LDSCRIPT
  2288. /* GNU ld script
  2289.    Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2290.    in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2291.    run into linking problems.  This "fake" dynamic lib is a linker script that
  2292.    redirects the linker to the real lib.  And yes, this works in the cross-
  2293.    compiling scenario as the sysroot-ed linker will prepend the real path.
  2294.  
  2295.    See bug https://bugs.gentoo.org/4411 for more info.
  2296.  */
  2297. ${output_format}
  2298. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2299. END_LDSCRIPT
  2300.  
  2301.             ;;
  2302.         esac
  2303.         fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2304.     done
  2305. }
  2306. get-flag ()
  2307. {
  2308.     local f var findflag="$1";
  2309.     for var in $(all-flag-vars);
  2310.     do
  2311.         for f in ${!var};
  2312.         do
  2313.             if [ "${f/${findflag}}" != "${f}" ]; then
  2314.                 printf "%s\n" "${f/-${findflag}=}";
  2315.                 return 0;
  2316.             fi;
  2317.         done;
  2318.     done;
  2319.     return 1
  2320. }
  2321. get_abi_CFLAGS ()
  2322. {
  2323.     get_abi_var CFLAGS "$@"
  2324. }
  2325. get_abi_CHOST ()
  2326. {
  2327.     get_abi_var CHOST "$@"
  2328. }
  2329. get_abi_CTARGET ()
  2330. {
  2331.     get_abi_var CTARGET "$@"
  2332. }
  2333. get_abi_FAKE_TARGETS ()
  2334. {
  2335.     get_abi_var FAKE_TARGETS "$@"
  2336. }
  2337. get_abi_LDFLAGS ()
  2338. {
  2339.     get_abi_var LDFLAGS "$@"
  2340. }
  2341. get_abi_LIBDIR ()
  2342. {
  2343.     get_abi_var LIBDIR "$@"
  2344. }
  2345. get_abi_var ()
  2346. {
  2347.     local flag=$1;
  2348.     local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2349.     local var="${flag}_${abi}";
  2350.     echo ${!var}
  2351. }
  2352. get_all_abis ()
  2353. {
  2354.     local x order="" mvar dvar;
  2355.     mvar="MULTILIB_ABIS";
  2356.     dvar="DEFAULT_ABI";
  2357.     if [[ -n $1 ]]; then
  2358.         mvar="$1_${mvar}";
  2359.         dvar="$1_${dvar}";
  2360.     fi;
  2361.     if [[ -z ${!mvar} ]]; then
  2362.         echo "default";
  2363.         return 0;
  2364.     fi;
  2365.     for x in ${!mvar};
  2366.     do
  2367.         if [[ ${x} != ${!dvar} ]]; then
  2368.             order="${order:+${order} }${x}";
  2369.         fi;
  2370.     done;
  2371.     order="${order:+${order} }${!dvar}";
  2372.     echo ${order};
  2373.     return 0
  2374. }
  2375. get_all_libdirs ()
  2376. {
  2377.     local libdirs abi;
  2378.     for abi in ${MULTILIB_ABIS};
  2379.     do
  2380.         libdirs+=" $(get_abi_LIBDIR ${abi})";
  2381.     done;
  2382.     [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2383.     echo "${libdirs}"
  2384. }
  2385. get_bmake ()
  2386. {
  2387.     if [[ ${CBUILD:-${CHOST}} == *bsd* ]]; then
  2388.         echo make;
  2389.     else
  2390.         if [[ ${CBUILD:-${CHOST}} == *darwin* ]]; then
  2391.             echo bsdmake;
  2392.         else
  2393.             echo bmake;
  2394.         fi;
  2395.     fi
  2396. }
  2397. get_exeext ()
  2398. {
  2399.     case ${CHOST} in
  2400.         *-cygwin* | mingw* | *-mingw*)
  2401.             echo ".exe"
  2402.         ;;
  2403.     esac
  2404. }
  2405. get_install_abis ()
  2406. {
  2407.     local x order="";
  2408.     if [[ -z ${MULTILIB_ABIS} ]]; then
  2409.         echo "default";
  2410.         return 0;
  2411.     fi;
  2412.     if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2413.         for x in ${MULTILIB_ABIS};
  2414.         do
  2415.             if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2416.                 has ${x} ${ABI_DENY} || order="${order} ${x}";
  2417.             fi;
  2418.         done;
  2419.         has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2420.         if [[ -n ${ABI_ALLOW} ]]; then
  2421.             local ordera="";
  2422.             for x in ${order};
  2423.             do
  2424.                 if has ${x} ${ABI_ALLOW}; then
  2425.                     ordera="${ordera} ${x}";
  2426.                 fi;
  2427.             done;
  2428.             order=${ordera};
  2429.         fi;
  2430.     else
  2431.         order=${DEFAULT_ABI};
  2432.     fi;
  2433.     if [[ -z ${order} ]]; then
  2434.         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.";
  2435.     fi;
  2436.     echo ${order};
  2437.     return 0
  2438. }
  2439. get_libdir ()
  2440. {
  2441.     local libdir_var="LIBDIR_${ABI}";
  2442.     local libdir="lib";
  2443.     [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2444.     echo "${libdir}"
  2445. }
  2446. get_libname ()
  2447. {
  2448.     local libname;
  2449.     local ver=$1;
  2450.     case ${CHOST} in
  2451.         *-cygwin*)
  2452.             libname="dll.a"
  2453.         ;;
  2454.         mingw* | *-mingw*)
  2455.             libname="dll"
  2456.         ;;
  2457.         *-darwin*)
  2458.             libname="dylib"
  2459.         ;;
  2460.         *-mint*)
  2461.             libname="irrelevant"
  2462.         ;;
  2463.         hppa*-hpux*)
  2464.             libname="sl"
  2465.         ;;
  2466.         *)
  2467.             libname="so"
  2468.         ;;
  2469.     esac;
  2470.     if [[ -z $* ]]; then
  2471.         echo ".${libname}";
  2472.     else
  2473.         for ver in "$@";
  2474.         do
  2475.             case ${CHOST} in
  2476.                 *-cygwin*)
  2477.                     echo ".${ver}.${libname}"
  2478.                 ;;
  2479.                 *-darwin*)
  2480.                     echo ".${ver}.${libname}"
  2481.                 ;;
  2482.                 *-mint*)
  2483.                     echo ".${libname}"
  2484.                 ;;
  2485.                 *)
  2486.                     echo ".${libname}.${ver}"
  2487.                 ;;
  2488.             esac;
  2489.         done;
  2490.     fi
  2491. }
  2492. get_localversion ()
  2493. {
  2494.     local lv_list i x;
  2495.     local shopt_save=$(shopt -p nullglob);
  2496.     shopt -s nullglob;
  2497.     local files=(${1}/localversion*);
  2498.     ${shopt_save};
  2499.     for i in "${files[@]}";
  2500.     do
  2501.         [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}";
  2502.     done;
  2503.     for i in ${lv_list};
  2504.     do
  2505.         x="${x}$(<${i})";
  2506.     done;
  2507.     x=${x/ /};
  2508.     echo ${x}
  2509. }
  2510. get_makefile_extract_function ()
  2511. {
  2512.     local a='' b='' mkfunc='getfilevar';
  2513.     a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  2514.     b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  2515.     [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  2516.     echo "${mkfunc}"
  2517. }
  2518. get_modname ()
  2519. {
  2520.     local modname;
  2521.     local ver=$1;
  2522.     case ${CHOST} in
  2523.         *-darwin*)
  2524.             modname="bundle"
  2525.         ;;
  2526.         *)
  2527.             modname="so"
  2528.         ;;
  2529.     esac;
  2530.     echo ".${modname}"
  2531. }
  2532. get_mounts ()
  2533. {
  2534.     local point= node= fs= opts= foo=;
  2535.     if [[ $(uname -s) == "Linux" ]]; then
  2536.         while read node point fs opts foo; do
  2537.             echo "${point} ${node} ${fs} ${opts}";
  2538.         done < /proc/mounts;
  2539.         return;
  2540.     fi;
  2541.     local IFS=' ';
  2542.     LC_ALL=C mount -p | while read node point fs foo; do
  2543.         opts=${fs#* };
  2544.         fs=${fs%% *};
  2545.         echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}";
  2546.     done
  2547. }
  2548. get_nproc ()
  2549. {
  2550.     local nproc;
  2551.     if type -P nproc &> /dev/null; then
  2552.         nproc=$(nproc);
  2553.     fi;
  2554.     if [[ -z ${nproc} ]] && type -P sysctl &> /dev/null; then
  2555.         nproc=$(sysctl -n hw.ncpu 2>/dev/null);
  2556.     fi;
  2557.     if [[ -z ${nproc} ]] && type -P python &> /dev/null; then
  2558.         nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null);
  2559.     fi;
  2560.     if [[ -n ${nproc} ]]; then
  2561.         echo "${nproc}";
  2562.     else
  2563.         echo "${1:-1}";
  2564.     fi
  2565. }
  2566. get_running_version ()
  2567. {
  2568.     if ! use kernel_linux; then
  2569.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2570.     fi;
  2571.     KV_FULL=$(uname -r);
  2572.     if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2573.         KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source);
  2574.         KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build);
  2575.         unset KV_FULL;
  2576.         get_version;
  2577.         return $?;
  2578.     else
  2579.         if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
  2580.             KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source);
  2581.             unset KV_FULL;
  2582.             get_version;
  2583.             return $?;
  2584.         else
  2585.             if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2586.                 KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build);
  2587.                 unset KV_FULL;
  2588.                 get_version;
  2589.                 return $?;
  2590.             else
  2591.                 local kv_full=${KV_FULL//[-+_]*};
  2592.                 KV_MAJOR=$(ver_cut 1 ${kv_full});
  2593.                 KV_MINOR=$(ver_cut 2 ${kv_full});
  2594.                 KV_PATCH=$(ver_cut 3 ${kv_full});
  2595.                 KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}";
  2596.                 : ${KV_PATCH:=0};
  2597.             fi;
  2598.         fi;
  2599.     fi;
  2600.     return 0
  2601. }
  2602. get_version ()
  2603. {
  2604.     if ! use kernel_linux; then
  2605.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2606.     fi;
  2607.     local tmplocal;
  2608.     [ -n "${KV_FULL}" ] && return 0;
  2609.     unset KV_DIR;
  2610.     [ -z "${get_version_warning_done}" ] && qeinfo "Determining the location of the kernel source code";
  2611.     [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}";
  2612.     if [ -z "${KV_DIR}" ]; then
  2613.         if [ -z "${get_version_warning_done}" ]; then
  2614.             get_version_warning_done=1;
  2615.             qewarn "Unable to find kernel sources at ${KERNEL_DIR}";
  2616.             if [ "${KERNEL_DIR}" == "/usr/src/linux" ]; then
  2617.                 qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  2618.                 qeinfo "(or the kernel you wish to build against).";
  2619.                 qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  2620.             else
  2621.                 qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  2622.             fi;
  2623.         fi;
  2624.         return 1;
  2625.     fi;
  2626.     if [ -z "${KBUILD_OUTPUT}" -a -L "${KERNEL_DIR}/source" ]; then
  2627.         KBUILD_OUTPUT=${KERNEL_DIR};
  2628.         KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source");
  2629.         KV_DIR=${KERNEL_DIR};
  2630.     fi;
  2631.     if [ -z "${get_version_warning_done}" ]; then
  2632.         qeinfo "Found kernel source directory:";
  2633.         qeinfo "    ${KV_DIR}";
  2634.     fi;
  2635.     if [ ! -s "${KV_DIR}/Makefile" ]; then
  2636.         if [ -z "${get_version_warning_done}" ]; then
  2637.             get_version_warning_done=1;
  2638.             qeerror "Could not find a Makefile in the kernel source directory.";
  2639.             qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  2640.         fi;
  2641.         return 1;
  2642.     fi;
  2643.     local OUTPUT_DIR=${KBUILD_OUTPUT};
  2644.     KERNEL_MAKEFILE="${KV_DIR}/Makefile";
  2645.     if [[ -z ${OUTPUT_DIR} ]]; then
  2646.         local mkfunc=$(get_makefile_extract_function "${KERNEL_MAKEFILE}");
  2647.         OUTPUT_DIR=$(${mkfunc} KBUILD_OUTPUT "${KERNEL_MAKEFILE}");
  2648.     fi;
  2649.     KV_MAJOR=$(getfilevar_noexec VERSION "${KERNEL_MAKEFILE}");
  2650.     KV_MINOR=$(getfilevar_noexec PATCHLEVEL "${KERNEL_MAKEFILE}");
  2651.     KV_PATCH=$(getfilevar_noexec SUBLEVEL "${KERNEL_MAKEFILE}");
  2652.     KV_EXTRA=$(getfilevar_noexec EXTRAVERSION "${KERNEL_MAKEFILE}");
  2653.     if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then
  2654.         if [ -z "${get_version_warning_done}" ]; then
  2655.             get_version_warning_done=1;
  2656.             qeerror "Could not detect kernel version.";
  2657.             qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  2658.         fi;
  2659.         return 1;
  2660.     fi;
  2661.     [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}";
  2662.     if [ -n "${KV_OUT_DIR}" ]; then
  2663.         qeinfo "Found kernel object directory:";
  2664.         qeinfo "    ${KV_OUT_DIR}";
  2665.     fi;
  2666.     KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  2667.     if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
  2668.         KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  2669.     else
  2670.         if [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
  2671.             KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  2672.         else
  2673.             KV_LOCAL=;
  2674.         fi;
  2675.     fi;
  2676.     tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  2677.     if [ "$KV_LOCAL" = "$tmplocal" ]; then
  2678.         KV_LOCAL=;
  2679.     else
  2680.         KV_LOCAL=$tmplocal;
  2681.     fi;
  2682.     if [[ -z ${OUTPUT_DIR} ]]; then
  2683.         for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "";
  2684.         do
  2685.             OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build";
  2686.             if [[ -e ${OUTPUT_DIR} ]]; then
  2687.                 break;
  2688.             fi;
  2689.         done;
  2690.     fi;
  2691.     KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  2692.     qeinfo "Found sources for kernel version:";
  2693.     qeinfo "    ${KV_FULL}";
  2694.     return 0
  2695. }
  2696. getfilevar ()
  2697. {
  2698.     local ERROR basefname basedname myARCH="${ARCH}" M="${S}";
  2699.     ERROR=0;
  2700.     [ -z "${1}" ] && ERROR=1;
  2701.     [ ! -f "${2}" ] && ERROR=1;
  2702.     if [ "${ERROR}" = 1 ]; then
  2703.         echo -e "\n";
  2704.         eerror "getfilevar requires 2 variables, with the second a valid file.";
  2705.         eerror "   getfilevar <VARIABLE> <CONFIGFILE>";
  2706.     else
  2707.         basefname="$(basename ${2})";
  2708.         basedname="$(dirname ${2})";
  2709.         unset ARCH;
  2710.         [[ ${EAPI:-0} == [0123] ]] && function nonfatal ()
  2711.         {
  2712.             "$@"
  2713.         };
  2714.         case ${EBUILD_PHASE_FUNC} in
  2715.             pkg_info | pkg_nofetch | pkg_pretend)
  2716.                 M="${T}"
  2717.             ;;
  2718.         esac;
  2719.         echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | nonfatal emake -C "${basedname}" M="${M}" ${BUILD_FIXES} -s -f - 2> /dev/null;
  2720.         ARCH=${myARCH};
  2721.     fi
  2722. }
  2723. getfilevar_noexec ()
  2724. {
  2725.     local ERROR basefname basedname mycat myARCH="${ARCH}";
  2726.     ERROR=0;
  2727.     mycat='cat';
  2728.     [ -z "${1}" ] && ERROR=1;
  2729.     [ ! -f "${2}" ] && ERROR=1;
  2730.     [ "${2%.gz}" != "${2}" ] && mycat='zcat';
  2731.     if [ "${ERROR}" = 1 ]; then
  2732.         echo -e "\n";
  2733.         eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  2734.         eerror "   getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  2735.     else
  2736.         ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  2737.             s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  2738.             s,[[:space:]]*\$,,g ;
  2739.             p
  2740.         }";
  2741.     fi
  2742. }
  2743. gnome2_disable_deprecation_warning ()
  2744. {
  2745.     local retval=0;
  2746.     local fails=();
  2747.     local makefile;
  2748.     ebegin "Disabling deprecation warnings";
  2749.     while read makefile; do
  2750.         if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
  2751.             continue;
  2752.         fi;
  2753.         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}";
  2754.         if [[ $? -ne 0 ]]; then
  2755.             fails+=("${makefile}");
  2756.             retval=2;
  2757.         fi;
  2758.     done < <(find "${S}" -name "Makefile.in"        -o -name "Makefile.am" -o -name "Makefile.decl"         | sort; [[ -f "${S}"/configure ]] && echo configure);
  2759.     eend ${retval};
  2760.     for makefile in "${fails[@]}";
  2761.     do
  2762.         ewarn "Failed to disable deprecation warnings in ${makefile}";
  2763.     done
  2764. }
  2765. gnome2_environment_reset ()
  2766. {
  2767.     xdg_environment_reset;
  2768.     export G_HOME="${T}";
  2769.     export GST_REGISTRY="${T}/registry.xml";
  2770.     export GSETTINGS_BACKEND="memory";
  2771.     if has ${EAPI:-0} 6; then
  2772.         export GST_INSPECT="$(type -P true)";
  2773.         unset DISPLAY;
  2774.     fi
  2775. }
  2776. gnome2_gconf_install ()
  2777. {
  2778.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2779.     local updater="${EROOT}${GCONFTOOL_BIN}";
  2780.     if [[ ! -x "${updater}" ]]; then
  2781.         debug-print "${updater} is not executable";
  2782.         return;
  2783.     fi;
  2784.     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2785.         debug-print "No GNOME 2 GConf schemas found";
  2786.         return;
  2787.     fi;
  2788.     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2789.     export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")";
  2790.     einfo "Installing GNOME 2 GConf schemas";
  2791.     local F;
  2792.     for F in ${GNOME2_ECLASS_SCHEMAS};
  2793.     do
  2794.         if [[ -e "${EROOT}${F}" ]]; then
  2795.             debug-print "Installing schema: ${F}";
  2796.             "${updater}" --makefile-install-rule "${EROOT}${F}" > /dev/null;
  2797.         fi;
  2798.     done;
  2799.     pids=$(pgrep -x gconfd-2);
  2800.     if [[ $? == 0 ]]; then
  2801.         ebegin "Reloading GConf schemas";
  2802.         kill -HUP ${pids};
  2803.         eend $?;
  2804.     fi
  2805. }
  2806. gnome2_gconf_savelist ()
  2807. {
  2808.     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2809.     pushd "${ED}" > /dev/null || die;
  2810.     export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null);
  2811.     popd > /dev/null || die
  2812. }
  2813. gnome2_gconf_uninstall ()
  2814. {
  2815.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2816.     local updater="${EROOT}${GCONFTOOL_BIN}";
  2817.     if [[ ! -x "${updater}" ]]; then
  2818.         debug-print "${updater} is not executable";
  2819.         return;
  2820.     fi;
  2821.     if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2822.         debug-print "No GNOME 2 GConf schemas found";
  2823.         return;
  2824.     fi;
  2825.     unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2826.     export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")";
  2827.     einfo "Uninstalling GNOME 2 GConf schemas";
  2828.     local F;
  2829.     for F in ${GNOME2_ECLASS_SCHEMAS};
  2830.     do
  2831.         if [[ -e "${EROOT}${F}" ]]; then
  2832.             debug-print "Uninstalling gconf schema: ${F}";
  2833.             "${updater}" --makefile-uninstall-rule "${EROOT}${F}" > /dev/null;
  2834.         fi;
  2835.     done;
  2836.     pids=$(pgrep -x gconfd-2);
  2837.     if [[ $? == 0 ]]; then
  2838.         ebegin "Reloading GConf schemas";
  2839.         kill -HUP ${pids};
  2840.         eend $?;
  2841.     fi
  2842. }
  2843. gnome2_gdk_pixbuf_savelist ()
  2844. {
  2845.     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2846.     pushd "${ED}" > /dev/null || die;
  2847.     export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null);
  2848.     popd > /dev/null || die
  2849. }
  2850. gnome2_gdk_pixbuf_update ()
  2851. {
  2852.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2853.     local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders";
  2854.     if [[ ! -x ${updater} ]]; then
  2855.         updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders";
  2856.     fi;
  2857.     if [[ ! -x ${updater} ]]; then
  2858.         debug-print "${updater} is not executable";
  2859.         return;
  2860.     fi;
  2861.     if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
  2862.         debug-print "gdk-pixbuf loader cache does not need an update";
  2863.         return;
  2864.     fi;
  2865.     ebegin "Updating gdk-pixbuf loader cache";
  2866.     local tmp_file=$(emktemp);
  2867.     ${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}";
  2868.     eend $?
  2869. }
  2870. gnome2_giomodule_cache_update ()
  2871. {
  2872.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2873.     local updater="${EROOT}/usr/bin/${CHOST}-gio-querymodules";
  2874.     if [[ ! -x ${updater} ]]; then
  2875.         updater="${EROOT}/usr/bin/gio-querymodules";
  2876.     fi;
  2877.     if [[ ! -x ${updater} ]]; then
  2878.         debug-print "${updater} is not executable";
  2879.         return;
  2880.     fi;
  2881.     ebegin "Updating GIO modules cache";
  2882.     ${updater} "${EROOT%/}"/usr/$(get_libdir)/gio/modules;
  2883.     eend $?
  2884. }
  2885. gnome2_icon_cache_update ()
  2886. {
  2887.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2888.     local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}";
  2889.     if [[ ! -x "${updater}" ]]; then
  2890.         debug-print "${updater} is not executable";
  2891.         return;
  2892.     fi;
  2893.     ebegin "Updating icons cache";
  2894.     local retval=0;
  2895.     local fails=();
  2896.     for dir in "${EROOT%/}"/usr/share/icons/*;
  2897.     do
  2898.         if [[ -f "${dir}/index.theme" ]]; then
  2899.             local rv=0;
  2900.             "${updater}" -qf "${dir}";
  2901.             rv=$?;
  2902.             if [[ ! $rv -eq 0 ]]; then
  2903.                 debug-print "Updating cache failed on ${dir}";
  2904.                 fails+=("${dir}");
  2905.                 retval=2;
  2906.             fi;
  2907.         else
  2908.             if [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
  2909.                 rm "${dir}/icon-theme.cache";
  2910.             fi;
  2911.         fi;
  2912.         if [[ -z $(ls "${dir}") ]]; then
  2913.             rmdir "${dir}";
  2914.         fi;
  2915.     done;
  2916.     eend ${retval};
  2917.     for f in "${fails[@]}";
  2918.     do
  2919.         eerror "Failed to update cache with icon $f";
  2920.     done
  2921. }
  2922. gnome2_icon_savelist ()
  2923. {
  2924.     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2925.     pushd "${ED}" > /dev/null || die;
  2926.     export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null);
  2927.     popd > /dev/null || die
  2928. }
  2929. gnome2_omf_fix ()
  2930. {
  2931.     local omf_makefiles filename;
  2932.     omf_makefiles="$@";
  2933.     if [[ -f ${S}/omf.make ]]; then
  2934.         omf_makefiles="${omf_makefiles} ${S}/omf.make";
  2935.     fi;
  2936.     if [[ -f ${S}/gnome-doc-utils.make ]]; then
  2937.         omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make";
  2938.     fi;
  2939.     for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort);
  2940.     do
  2941.         omf_makefiles="${omf_makefiles} ${filename}";
  2942.     done;
  2943.     ebegin "Fixing OMF Makefiles";
  2944.     local retval=0;
  2945.     local fails=();
  2946.     for omf in ${omf_makefiles};
  2947.     do
  2948.         sed -i -e 's:scrollkeeper-update:true:' "${omf}";
  2949.         retval=$?;
  2950.         if [[ $retval -ne 0 ]]; then
  2951.             debug-print "updating of ${omf} failed";
  2952.             fails[$(( ${#fails[@]} + 1 ))]=$omf;
  2953.             retval=2;
  2954.         fi;
  2955.     done;
  2956.     eend $retval;
  2957.     for f in "${fails[@]}";
  2958.     do
  2959.         eerror "Failed to update OMF Makefile $f";
  2960.     done
  2961. }
  2962. gnome2_query_immodules_gtk2 ()
  2963. {
  2964.     local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-2.0;
  2965.     [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0;
  2966.     ebegin "Updating gtk2 input method module cache";
  2967.     GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" "${updater}" --update-cache;
  2968.     eend $?
  2969. }
  2970. gnome2_query_immodules_gtk3 ()
  2971. {
  2972.     local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-3.0;
  2973.     [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0;
  2974.     ebegin "Updating gtk3 input method module cache";
  2975.     GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" "${updater}" --update-cache;
  2976.     eend $?
  2977. }
  2978. gnome2_schemas_savelist ()
  2979. {
  2980.     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2981.     pushd "${ED}" > /dev/null || die;
  2982.     export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null);
  2983.     popd > /dev/null || die
  2984. }
  2985. gnome2_schemas_update ()
  2986. {
  2987.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2988.     local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}";
  2989.     if [[ ! -x ${updater} ]]; then
  2990.         debug-print "${updater} is not executable";
  2991.         return;
  2992.     fi;
  2993.     ebegin "Updating GSettings schemas";
  2994.     ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &> /dev/null;
  2995.     eend $?
  2996. }
  2997. gnome2_scrollkeeper_savelist ()
  2998. {
  2999.     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  3000.     pushd "${ED}" > /dev/null || die;
  3001.     export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null);
  3002.     popd > /dev/null || die
  3003. }
  3004. gnome2_scrollkeeper_update ()
  3005. {
  3006.     has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  3007.     local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}";
  3008.     if [[ ! -x "${updater}" ]]; then
  3009.         debug-print "${updater} is not executable";
  3010.         return;
  3011.     fi;
  3012.     if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
  3013.         debug-print "No scroll cache to update";
  3014.         return;
  3015.     fi;
  3016.     ebegin "Updating scrollkeeper database ...";
  3017.     "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}";
  3018.     eend $?
  3019. }
  3020. gyp_use ()
  3021. {
  3022.     local gypflag="-D${2:-use_${1//-/_}}=";
  3023.     usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
  3024. }
  3025. has_m32 ()
  3026. {
  3027.     die "${FUNCNAME}: don't use this anymore"
  3028. }
  3029. has_m64 ()
  3030. {
  3031.     die "${FUNCNAME}: don't use this anymore"
  3032. }
  3033. has_multilib_profile ()
  3034. {
  3035.     [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  3036. }
  3037. host-is-pax ()
  3038. {
  3039.     grep -qs ^PaX: /proc/self/status
  3040. }
  3041. in_iuse ()
  3042. {
  3043.     local use=${1};
  3044.     if [[ -z "${use}" ]]; then
  3045.         echo "!!! in_iuse() called without a parameter." 1>&2;
  3046.         echo "!!! in_iuse <USEFLAG>" 1>&2;
  3047.         die "in_iuse() called without a parameter";
  3048.     fi;
  3049.     local liuse=(${IUSE_EFFECTIVE});
  3050.     has "${use}" "${liuse[@]#[+-]}"
  3051. }
  3052. is-flag ()
  3053. {
  3054.     is-flagq "$@" && echo true
  3055. }
  3056. is-flagq ()
  3057. {
  3058.     [[ -n $2 ]] && die "Usage: is-flag <flag>";
  3059.     local var;
  3060.     for var in $(all-flag-vars);
  3061.     do
  3062.         _is_flagq ${var} "$1" && return 0;
  3063.     done;
  3064.     return 1
  3065. }
  3066. is-ldflag ()
  3067. {
  3068.     is-ldflagq "$@" && echo true
  3069. }
  3070. is-ldflagq ()
  3071. {
  3072.     [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  3073.     _is_flagq LDFLAGS $1
  3074. }
  3075. is-login-disabled ()
  3076. {
  3077.     _dead_portability_user_funcs
  3078. }
  3079. is_final_abi ()
  3080. {
  3081.     has_multilib_profile || return 0;
  3082.     set -- $(get_install_abis);
  3083.     local LAST_ABI=$#;
  3084.     [[ ${!LAST_ABI} == ${ABI} ]]
  3085. }
  3086. isdigit ()
  3087. {
  3088.     local d;
  3089.     for d in "$@";
  3090.     do
  3091.         [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  3092.     done;
  3093.     return 0
  3094. }
  3095. kernel_is ()
  3096. {
  3097.     if ! use kernel_linux; then
  3098.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  3099.     fi;
  3100.     linux-info_get_any_version;
  3101.     local operator test value;
  3102.     case ${1#-} in
  3103.         lt)
  3104.             operator="-lt";
  3105.             shift
  3106.         ;;
  3107.         gt)
  3108.             operator="-gt";
  3109.             shift
  3110.         ;;
  3111.         le)
  3112.             operator="-le";
  3113.             shift
  3114.         ;;
  3115.         ge)
  3116.             operator="-ge";
  3117.             shift
  3118.         ;;
  3119.         eq)
  3120.             operator="-eq";
  3121.             shift
  3122.         ;;
  3123.         *)
  3124.             operator="-eq"
  3125.         ;;
  3126.     esac;
  3127.     [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters";
  3128.     : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ));
  3129.     : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ));
  3130.     [ ${test} ${operator} ${value} ]
  3131. }
  3132. linux-info_get_any_version ()
  3133. {
  3134.     if ! use kernel_linux; then
  3135.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  3136.     fi;
  3137.     if ! get_version; then
  3138.         ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  3139.         if ! get_running_version; then
  3140.             die "Unable to determine any Linux Kernel version, please report a bug";
  3141.         fi;
  3142.     fi
  3143. }
  3144. linux-info_pkg_setup ()
  3145. {
  3146.     use kernel_linux || return;
  3147.     linux-info_get_any_version;
  3148.     if kernel_is 2 4; then
  3149.         if [ "$( gcc-major-version )" -eq "4" ]; then
  3150.             echo;
  3151.             ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with";
  3152.             ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!";
  3153.             echo;
  3154.             ewarn "Either switch to another gcc-version (via gcc-config) or use a";
  3155.             ewarn "newer kernel that supports gcc-4.";
  3156.             echo;
  3157.             ewarn "Also be aware that bugreports about gcc-4 not working";
  3158.             ewarn "with linux-2.4 based ebuilds will be closed as INVALID!";
  3159.             echo;
  3160.         fi;
  3161.     fi;
  3162.     [ -n "${CONFIG_CHECK}" ] && check_extra_config
  3163. }
  3164. linux_chkconfig_builtin ()
  3165. {
  3166.     linux_config_qa_check linux_chkconfig_builtin;
  3167.     [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
  3168. }
  3169. linux_chkconfig_module ()
  3170. {
  3171.     linux_config_qa_check linux_chkconfig_module;
  3172.     [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
  3173. }
  3174. linux_chkconfig_present ()
  3175. {
  3176.     linux_config_qa_check linux_chkconfig_present;
  3177.     [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
  3178. }
  3179. linux_chkconfig_string ()
  3180. {
  3181.     linux_config_qa_check linux_chkconfig_string;
  3182.     getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
  3183. }
  3184. linux_config_bin_exists ()
  3185. {
  3186.     export _LINUX_CONFIG_EXISTS_DONE=1;
  3187.     use kernel_linux && [[ -s /proc/config.gz ]]
  3188. }
  3189. linux_config_exists ()
  3190. {
  3191.     linux_config_src_exists || linux_config_bin_exists
  3192. }
  3193. linux_config_path ()
  3194. {
  3195.     if linux_config_src_exists; then
  3196.         echo "${KV_OUT_DIR}/.config";
  3197.     else
  3198.         if linux_config_bin_exists; then
  3199.             echo "/proc/config.gz";
  3200.         else
  3201.             return 1;
  3202.         fi;
  3203.     fi
  3204. }
  3205. linux_config_qa_check ()
  3206. {
  3207.     local f="$1";
  3208.     if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
  3209.         ewarn "QA: You called $f before any linux_config_exists!";
  3210.         ewarn "QA: The return value of $f will NOT guaranteed later!";
  3211.     fi;
  3212.     if ! use kernel_linux; then
  3213.         die "$f called on non-Linux system, please fix the ebuild";
  3214.     fi
  3215. }
  3216. linux_config_src_exists ()
  3217. {
  3218.     export _LINUX_CONFIG_EXISTS_DONE=1;
  3219.     use kernel_linux && [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
  3220. }
  3221. list-paxables ()
  3222. {
  3223.     file "$@" 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//'
  3224. }
  3225. make_desktop_entry ()
  3226. {
  3227.     [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  3228.     local exec=${1};
  3229.     local name=${2:-${PN}};
  3230.     local icon=${3:-${PN}};
  3231.     local type=${4};
  3232.     local fields=${5};
  3233.     if [[ -z ${type} ]]; then
  3234.         local catmaj=${CATEGORY%%-*};
  3235.         local catmin=${CATEGORY##*-};
  3236.         case ${catmaj} in
  3237.             app)
  3238.                 case ${catmin} in
  3239.                     accessibility)
  3240.                         type="Utility;Accessibility"
  3241.                     ;;
  3242.                     admin)
  3243.                         type=System
  3244.                     ;;
  3245.                     antivirus)
  3246.                         type=System
  3247.                     ;;
  3248.                     arch)
  3249.                         type="Utility;Archiving"
  3250.                     ;;
  3251.                     backup)
  3252.                         type="Utility;Archiving"
  3253.                     ;;
  3254.                     cdr)
  3255.                         type="AudioVideo;DiscBurning"
  3256.                     ;;
  3257.                     dicts)
  3258.                         type="Office;Dictionary"
  3259.                     ;;
  3260.                     doc)
  3261.                         type=Documentation
  3262.                     ;;
  3263.                     editors)
  3264.                         type="Utility;TextEditor"
  3265.                     ;;
  3266.                     emacs)
  3267.                         type="Development;TextEditor"
  3268.                     ;;
  3269.                     emulation)
  3270.                         type="System;Emulator"
  3271.                     ;;
  3272.                     laptop)
  3273.                         type="Settings;HardwareSettings"
  3274.                     ;;
  3275.                     office)
  3276.                         type=Office
  3277.                     ;;
  3278.                     pda)
  3279.                         type="Office;PDA"
  3280.                     ;;
  3281.                     vim)
  3282.                         type="Development;TextEditor"
  3283.                     ;;
  3284.                     xemacs)
  3285.                         type="Development;TextEditor"
  3286.                     ;;
  3287.                 esac
  3288.             ;;
  3289.             dev)
  3290.                 type="Development"
  3291.             ;;
  3292.             games)
  3293.                 case ${catmin} in
  3294.                     action | fps)
  3295.                         type=ActionGame
  3296.                     ;;
  3297.                     arcade)
  3298.                         type=ArcadeGame
  3299.                     ;;
  3300.                     board)
  3301.                         type=BoardGame
  3302.                     ;;
  3303.                     emulation)
  3304.                         type=Emulator
  3305.                     ;;
  3306.                     kids)
  3307.                         type=KidsGame
  3308.                     ;;
  3309.                     puzzle)
  3310.                         type=LogicGame
  3311.                     ;;
  3312.                     roguelike)
  3313.                         type=RolePlaying
  3314.                     ;;
  3315.                     rpg)
  3316.                         type=RolePlaying
  3317.                     ;;
  3318.                     simulation)
  3319.                         type=Simulation
  3320.                     ;;
  3321.                     sports)
  3322.                         type=SportsGame
  3323.                     ;;
  3324.                     strategy)
  3325.                         type=StrategyGame
  3326.                     ;;
  3327.                 esac;
  3328.                 type="Game;${type}"
  3329.             ;;
  3330.             gnome)
  3331.                 type="Gnome;GTK"
  3332.             ;;
  3333.             kde)
  3334.                 type="KDE;Qt"
  3335.             ;;
  3336.             mail)
  3337.                 type="Network;Email"
  3338.             ;;
  3339.             media)
  3340.                 case ${catmin} in
  3341.                     gfx)
  3342.                         type=Graphics
  3343.                     ;;
  3344.                     *)
  3345.                         case ${catmin} in
  3346.                             radio)
  3347.                                 type=Tuner
  3348.                             ;;
  3349.                             sound)
  3350.                                 type=Audio
  3351.                             ;;
  3352.                             tv)
  3353.                                 type=TV
  3354.                             ;;
  3355.                             video)
  3356.                                 type=Video
  3357.                             ;;
  3358.                         esac;
  3359.                         type="AudioVideo;${type}"
  3360.                     ;;
  3361.                 esac
  3362.             ;;
  3363.             net)
  3364.                 case ${catmin} in
  3365.                     dialup)
  3366.                         type=Dialup
  3367.                     ;;
  3368.                     ftp)
  3369.                         type=FileTransfer
  3370.                     ;;
  3371.                     im)
  3372.                         type=InstantMessaging
  3373.                     ;;
  3374.                     irc)
  3375.                         type=IRCClient
  3376.                     ;;
  3377.                     mail)
  3378.                         type=Email
  3379.                     ;;
  3380.                     news)
  3381.                         type=News
  3382.                     ;;
  3383.                     nntp)
  3384.                         type=News
  3385.                     ;;
  3386.                     p2p)
  3387.                         type=FileTransfer
  3388.                     ;;
  3389.                     voip)
  3390.                         type=Telephony
  3391.                     ;;
  3392.                 esac;
  3393.                 type="Network;${type}"
  3394.             ;;
  3395.             sci)
  3396.                 case ${catmin} in
  3397.                     astro*)
  3398.                         type=Astronomy
  3399.                     ;;
  3400.                     bio*)
  3401.                         type=Biology
  3402.                     ;;
  3403.                     calc*)
  3404.                         type=Calculator
  3405.                     ;;
  3406.                     chem*)
  3407.                         type=Chemistry
  3408.                     ;;
  3409.                     elec*)
  3410.                         type=Electronics
  3411.                     ;;
  3412.                     geo*)
  3413.                         type=Geology
  3414.                     ;;
  3415.                     math*)
  3416.                         type=Math
  3417.                     ;;
  3418.                     physics)
  3419.                         type=Physics
  3420.                     ;;
  3421.                     visual*)
  3422.                         type=DataVisualization
  3423.                     ;;
  3424.                 esac;
  3425.                 type="Education;Science;${type}"
  3426.             ;;
  3427.             sys)
  3428.                 type="System"
  3429.             ;;
  3430.             www)
  3431.                 case ${catmin} in
  3432.                     client)
  3433.                         type=WebBrowser
  3434.                     ;;
  3435.                 esac;
  3436.                 type="Network;${type}"
  3437.             ;;
  3438.             *)
  3439.                 type=
  3440.             ;;
  3441.         esac;
  3442.     fi;
  3443.     local slot=${SLOT%/*};
  3444.     if [[ ${slot} == "0" ]]; then
  3445.         local desktop_name="${PN}";
  3446.     else
  3447.         local desktop_name="${PN}-${slot}";
  3448.     fi;
  3449.     local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  3450.     type=${type%;}${type:+;};
  3451.     if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  3452.         ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  3453.         ewarn "allowed in .desktop files if the value is not an absolute path.";
  3454.         icon=${icon%.*};
  3455.     fi;
  3456.     cat > "${desktop}"  <<-EOF ||
  3457. [Desktop Entry]
  3458. Name=${name}
  3459. Type=Application
  3460. Comment=${DESCRIPTION}
  3461. Exec=${exec}
  3462. TryExec=${exec%% *}
  3463. Icon=${icon}
  3464. Categories=${type}
  3465. EOF
  3466.  die
  3467.     if [[ ${fields:-=} != *=* ]]; then
  3468.         ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  3469.         fields="Path=${fields}";
  3470.     fi;
  3471.     if [[ -n ${fields} ]]; then
  3472.         printf '%b\n' "${fields}" >> "${desktop}" || die;
  3473.     fi;
  3474.     ( insopts -m 0644;
  3475.     insinto /usr/share/applications;
  3476.     doins "${desktop}" ) || die "installing desktop file failed"
  3477. }
  3478. make_session_desktop ()
  3479. {
  3480.     [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  3481.     [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  3482.     local title=$1;
  3483.     local command=$2;
  3484.     local desktop=${T}/${wm:-${PN}}.desktop;
  3485.     shift 2;
  3486.     cat > "${desktop}"  <<-EOF ||
  3487. [Desktop Entry]
  3488. Name=${title}
  3489. Comment=This session logs you into ${title}
  3490. Exec=${command} $*
  3491. TryExec=${command}
  3492. Type=XSession
  3493. EOF
  3494.  die
  3495.     ( insopts -m 0644;
  3496.     insinto /usr/share/xsessions;
  3497.     doins "${desktop}" )
  3498. }
  3499. make_wrapper ()
  3500. {
  3501.     local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  3502.     local tmpwrapper=$(emktemp);
  3503.     has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  3504.     ( echo '#!/bin/sh';
  3505.     if [[ -n ${libdir} ]]; then
  3506.         local var;
  3507.         if [[ ${CHOST} == *-darwin* ]]; then
  3508.             var=DYLD_LIBRARY_PATH;
  3509.         else
  3510.             var=LD_LIBRARY_PATH;
  3511.         fi;
  3512.         cat  <<-EOF
  3513. if [ "\${${var}+set}" = "set" ] ; then
  3514. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  3515. else
  3516. export ${var}="${EPREFIX}${libdir}"
  3517. fi
  3518. EOF
  3519.  
  3520.     fi
  3521.     [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  3522.     printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  3523.     chmod go+rx "${tmpwrapper}";
  3524.     if [[ -n ${path} ]]; then
  3525.         ( exeopts -m 0755;
  3526.         exeinto "${path}";
  3527.         newexe "${tmpwrapper}" "${wrapper}" ) || die;
  3528.     else
  3529.         newbin "${tmpwrapper}" "${wrapper}" || die;
  3530.     fi
  3531. }
  3532. makeopts_jobs ()
  3533. {
  3534.     [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  3535.     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:-999}:p");
  3536.     echo ${jobs:-1}
  3537. }
  3538. makeopts_loadavg ()
  3539. {
  3540.     [[ $# -eq 0 ]] && set -- "${MAKEOPTS}";
  3541.     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");
  3542.     echo ${lavg:-${2:-999}}
  3543. }
  3544. multilib_env ()
  3545. {
  3546.     local CTARGET=${1:-${CTARGET}};
  3547.     local cpu=${CTARGET%%*-};
  3548.     case ${cpu} in
  3549.         aarch64*)
  3550.             export CFLAGS_arm=${CFLAGS_arm-};
  3551.             case ${cpu} in
  3552.                 aarch64*be)
  3553.                     export CHOST_arm="armv8b-${CTARGET#*-}"
  3554.                 ;;
  3555.                 *)
  3556.                     export CHOST_arm="armv8l-${CTARGET#*-}"
  3557.                 ;;
  3558.             esac;
  3559.             CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  3560.             export CTARGET_arm=${CHOST_arm};
  3561.             export LIBDIR_arm="lib";
  3562.             export CFLAGS_arm64=${CFLAGS_arm64-};
  3563.             export CHOST_arm64=${CTARGET};
  3564.             export CTARGET_arm64=${CHOST_arm64};
  3565.             export LIBDIR_arm64="lib64";
  3566.             : ${MULTILIB_ABIS=arm64};
  3567.             : ${DEFAULT_ABI=arm64}
  3568.         ;;
  3569.         x86_64*)
  3570.             export CFLAGS_x86=${CFLAGS_x86--m32};
  3571.             export CHOST_x86=${CTARGET/x86_64/i686};
  3572.             CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  3573.             export CTARGET_x86=${CHOST_x86};
  3574.             if [[ ${SYMLINK_LIB} == "yes" ]]; then
  3575.                 export LIBDIR_x86="lib32";
  3576.             else
  3577.                 export LIBDIR_x86="lib";
  3578.             fi;
  3579.             export CFLAGS_amd64=${CFLAGS_amd64--m64};
  3580.             export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  3581.             export CTARGET_amd64=${CHOST_amd64};
  3582.             export LIBDIR_amd64="lib64";
  3583.             export CFLAGS_x32=${CFLAGS_x32--mx32};
  3584.             export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  3585.             export CTARGET_x32=${CHOST_x32};
  3586.             export LIBDIR_x32="libx32";
  3587.             case ${CTARGET} in
  3588.                 *-gnux32)
  3589.                     : ${MULTILIB_ABIS=x32 amd64 x86};
  3590.                     : ${DEFAULT_ABI=x32}
  3591.                 ;;
  3592.                 *)
  3593.                     : ${MULTILIB_ABIS=amd64 x86};
  3594.                     : ${DEFAULT_ABI=amd64}
  3595.                 ;;
  3596.             esac
  3597.         ;;
  3598.         mips64* | mipsisa64*)
  3599.             export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3600.             export CHOST_o32=${CTARGET/mips64/mips};
  3601.             export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  3602.             export CTARGET_o32=${CHOST_o32};
  3603.             export LIBDIR_o32="lib";
  3604.             export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3605.             export CHOST_n32=${CTARGET};
  3606.             export CTARGET_n32=${CHOST_n32};
  3607.             export LIBDIR_n32="lib32";
  3608.             export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3609.             export CHOST_n64=${CTARGET};
  3610.             export CTARGET_n64=${CHOST_n64};
  3611.             export LIBDIR_n64="lib64";
  3612.             : ${MULTILIB_ABIS=n64 n32 o32};
  3613.             : ${DEFAULT_ABI=n32}
  3614.         ;;
  3615.         powerpc64*)
  3616.             export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3617.             export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3618.             export CTARGET_ppc=${CHOST_ppc};
  3619.             export LIBDIR_ppc="lib";
  3620.             export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3621.             export CHOST_ppc64=${CTARGET};
  3622.             export CTARGET_ppc64=${CHOST_ppc64};
  3623.             export LIBDIR_ppc64="lib64";
  3624.             : ${MULTILIB_ABIS=ppc64 ppc};
  3625.             : ${DEFAULT_ABI=ppc64}
  3626.         ;;
  3627.         s390x*)
  3628.             export CFLAGS_s390=${CFLAGS_s390--m31};
  3629.             export CHOST_s390=${CTARGET/s390x/s390};
  3630.             export CTARGET_s390=${CHOST_s390};
  3631.             export LIBDIR_s390="lib";
  3632.             export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3633.             export CHOST_s390x=${CTARGET};
  3634.             export CTARGET_s390x=${CHOST_s390x};
  3635.             export LIBDIR_s390x="lib64";
  3636.             : ${MULTILIB_ABIS=s390x s390};
  3637.             : ${DEFAULT_ABI=s390x}
  3638.         ;;
  3639.         sparc64*)
  3640.             export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  3641.             export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3642.             export CTARGET_sparc32=${CHOST_sparc32};
  3643.             export LIBDIR_sparc32="lib";
  3644.             export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3645.             export CHOST_sparc64=${CTARGET};
  3646.             export CTARGET_sparc64=${CHOST_sparc64};
  3647.             export LIBDIR_sparc64="lib64";
  3648.             : ${MULTILIB_ABIS=sparc64 sparc32};
  3649.             : ${DEFAULT_ABI=sparc64}
  3650.         ;;
  3651.         *)
  3652.             : ${MULTILIB_ABIS=default};
  3653.             : ${DEFAULT_ABI=default}
  3654.         ;;
  3655.     esac;
  3656.     export MULTILIB_ABIS DEFAULT_ABI
  3657. }
  3658. multilib_toolchain_setup ()
  3659. {
  3660.     local v vv;
  3661.     export ABI=$1;
  3662.     if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  3663.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  3664.         do
  3665.             vv="_abi_saved_${v}";
  3666.             [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  3667.             unset ${vv};
  3668.         done;
  3669.         unset _DEFAULT_ABI_SAVED;
  3670.     fi;
  3671.     if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3672.         for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  3673.         do
  3674.             vv="_abi_saved_${v}";
  3675.             [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  3676.         done;
  3677.         export _DEFAULT_ABI_SAVED="true";
  3678.         if [[ ${CBUILD} == "${CHOST}" ]]; then
  3679.             export CBUILD=$(get_abi_CHOST $1);
  3680.         fi;
  3681.         export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3682.         export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3683.         export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3684.         export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  3685.         export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  3686.         export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3687.         export CHOST=$(get_abi_CHOST $1);
  3688.         export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  3689.         export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  3690.     fi
  3691. }
  3692. newicon ()
  3693. {
  3694.     _iconins ${FUNCNAME} "$@"
  3695. }
  3696. newmenu ()
  3697. {
  3698.     ( insopts -m 0644;
  3699.     insinto /usr/share/applications;
  3700.     newins "$@" )
  3701. }
  3702. no-as-needed ()
  3703. {
  3704.     case $($(tc-getLD) -v 2>&1 </dev/null) in
  3705.         *GNU*)
  3706.             echo "-Wl,--no-as-needed"
  3707.         ;;
  3708.     esac
  3709. }
  3710. number_abis ()
  3711. {
  3712.     set -- `get_install_abis`;
  3713.     echo $#
  3714. }
  3715. optfeature ()
  3716. {
  3717.     debug-print-function ${FUNCNAME} "$@";
  3718.     local i j msg;
  3719.     local desc=$1;
  3720.     local flag=0;
  3721.     shift;
  3722.     for i in "$@";
  3723.     do
  3724.         for j in ${i};
  3725.         do
  3726.             if has_version "${j}"; then
  3727.                 flag=1;
  3728.             else
  3729.                 flag=0;
  3730.                 break;
  3731.             fi;
  3732.         done;
  3733.         if [[ ${flag} -eq 1 ]]; then
  3734.             break;
  3735.         fi;
  3736.     done;
  3737.     if [[ ${flag} -eq 0 ]]; then
  3738.         for i in "$@";
  3739.         do
  3740.             msg=" ";
  3741.             for j in ${i};
  3742.             do
  3743.                 msg+=" ${j} and";
  3744.             done;
  3745.             msg="${msg:0: -4} for ${desc}";
  3746.             elog "${msg}";
  3747.         done;
  3748.     fi
  3749. }
  3750. path_exists ()
  3751. {
  3752.     eerror "path_exists has been removed.  Please see the following post";
  3753.     eerror "for a replacement snippet:";
  3754.     eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  3755.     die "path_exists is banned"
  3756. }
  3757. pax-mark ()
  3758. {
  3759.     local f;
  3760.     local flags;
  3761.     local ret=0;
  3762.     flags="${1//[!zPpEeMmRrSs]}";
  3763.     [[ -n "${flags}" ]] || return 0;
  3764.     shift;
  3765.     local dodefault="";
  3766.     [[ -n "${flags//[!z]}" ]] && dodefault="yes";
  3767.     if has PT ${PAX_MARKINGS}; then
  3768.         for f in "$@";
  3769.         do
  3770.             if type -p paxctl > /dev/null; then
  3771.                 einfo "PT_PAX marking -${flags} ${f} with paxctl";
  3772.                 paxctl -q${flags} "${f}" > /dev/null 2>&1 && continue;
  3773.             fi;
  3774.             if type -p paxctl-ng > /dev/null && paxctl-ng -L; then
  3775.                 einfo "PT_PAX marking -${flags} ${f} with paxctl-ng";
  3776.                 flags="${flags//z}";
  3777.                 [[ ${dodefault} == "yes" ]] && paxctl-ng -L -z "${f}" > /dev/null 2>&1;
  3778.                 [[ -n "${flags}" ]] || continue;
  3779.                 paxctl-ng -L -${flags} "${f}" > /dev/null 2>&1 && continue;
  3780.             fi;
  3781.             if type -p scanelf > /dev/null && [[ ${PAX_MARKINGS} != "none" ]]; then
  3782.                 einfo "PT_PAX marking -${flags} ${f} with scanelf";
  3783.                 scanelf -Xxz ${flags} "$f" > /dev/null 2>&1;
  3784.             else
  3785.                 if [[ ${PAX_MARKINGS} != "none" ]]; then
  3786.                     elog "Failed to set PT_PAX markings -${flags} ${f}.";
  3787.                     ret=1;
  3788.                 fi;
  3789.             fi;
  3790.         done;
  3791.     fi;
  3792.     if has XT ${PAX_MARKINGS}; then
  3793.         flags="${flags//z}";
  3794.         for f in "$@";
  3795.         do
  3796.             if type -p paxctl-ng > /dev/null && paxctl-ng -l; then
  3797.                 einfo "XATTR_PAX marking -${flags} ${f} with paxctl-ng";
  3798.                 [[ ${dodefault} == "yes" ]] && paxctl-ng -d "${f}" > /dev/null 2>&1;
  3799.                 [[ -n "${flags}" ]] || continue;
  3800.                 paxctl-ng -l -${flags} "${f}" > /dev/null 2>&1 && continue;
  3801.             fi;
  3802.             if type -p setfattr > /dev/null; then
  3803.                 [[ -n "${flags//[!Ee]}" ]] || flags+="e";
  3804.                 einfo "XATTR_PAX marking -${flags} ${f} with setfattr";
  3805.                 [[ ${dodefault} == "yes" ]] && setfattr -x "user.pax.flags" "${f}" > /dev/null 2>&1;
  3806.                 setfattr -n "user.pax.flags" -v "${flags}" "${f}" > /dev/null 2>&1 && continue;
  3807.             fi;
  3808.             if [[ ${PAX_MARKINGS} != "none" ]]; then
  3809.                 elog "Failed to set XATTR_PAX markings -${flags} ${f}.";
  3810.                 ret=1;
  3811.             fi;
  3812.         done;
  3813.     fi;
  3814.     return ${ret}
  3815. }
  3816. pkg_nofetch ()
  3817. {
  3818.     default
  3819. }
  3820. pkg_postinst ()
  3821. {
  3822.     gnome2_icon_cache_update;
  3823.     xdg_desktop_database_update;
  3824.     readme.gentoo_print_elog
  3825. }
  3826. pkg_postrm ()
  3827. {
  3828.     gnome2_icon_cache_update;
  3829.     xdg_desktop_database_update
  3830. }
  3831. pkg_preinst ()
  3832. {
  3833.     gnome2_icon_savelist
  3834. }
  3835. pkg_pretend ()
  3836. {
  3837.     pre_build_checks
  3838. }
  3839. pkg_setup ()
  3840. {
  3841.     pre_build_checks;
  3842.     chromium_suid_sandbox_check_kernel_config
  3843. }
  3844. pre_build_checks ()
  3845. {
  3846.     CHECKREQS_MEMORY="3G";
  3847.     CHECKREQS_DISK_BUILD="5G";
  3848.     eshopts_push -s extglob;
  3849.     if is-flagq '-g?(gdb)?([1-9])'; then
  3850.         CHECKREQS_DISK_BUILD="25G";
  3851.         if ! use component-build; then
  3852.             CHECKREQS_MEMORY="16G";
  3853.         fi;
  3854.     fi;
  3855.     eshopts_pop;
  3856.     check-reqs_pkg_setup
  3857. }
  3858. preserve_old_lib ()
  3859. {
  3860.     if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  3861.         eerror "preserve_old_lib() must be called from pkg_preinst() only";
  3862.         die "Invalid preserve_old_lib() usage";
  3863.     fi;
  3864.     [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  3865.     has preserve-libs ${FEATURES} && return 0;
  3866.     has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT};
  3867.     local lib dir;
  3868.     for lib in "$@";
  3869.     do
  3870.         [[ -e ${EROOT}/${lib} ]] || continue;
  3871.         dir=${lib%/*};
  3872.         dodir ${dir} || die "dodir ${dir} failed";
  3873.         cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  3874.         touch "${ED}"/${lib};
  3875.     done
  3876. }
  3877. preserve_old_lib_notify ()
  3878. {
  3879.     if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  3880.         eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  3881.         die "Invalid preserve_old_lib_notify() usage";
  3882.     fi;
  3883.     has preserve-libs ${FEATURES} && return 0;
  3884.     has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT};
  3885.     local lib notice=0;
  3886.     for lib in "$@";
  3887.     do
  3888.         [[ -e ${EROOT}/${lib} ]] || continue;
  3889.         if [[ ${notice} -eq 0 ]]; then
  3890.             notice=1;
  3891.             ewarn "Old versions of installed libraries were detected on your system.";
  3892.             ewarn "In order to avoid breaking packages that depend on these old libs,";
  3893.             ewarn "the libraries are not being removed.  You need to run revdep-rebuild";
  3894.             ewarn "in order to remove these old dependencies.  If you do not have this";
  3895.             ewarn "helper program, simply emerge the 'gentoolkit' package.";
  3896.             ewarn;
  3897.         fi;
  3898.         ewarn "  # revdep-rebuild --library '${lib}' && rm '${lib}'";
  3899.     done
  3900. }
  3901. prune_libtool_files ()
  3902. {
  3903.     debug-print-function ${FUNCNAME} "$@";
  3904.     local removing_all removing_modules opt;
  3905.     for opt in "$@";
  3906.     do
  3907.         case "${opt}" in
  3908.             --all)
  3909.                 removing_all=1;
  3910.                 removing_modules=1
  3911.             ;;
  3912.             --modules)
  3913.                 removing_modules=1
  3914.             ;;
  3915.             *)
  3916.                 die "Invalid argument to ${FUNCNAME}(): ${opt}"
  3917.             ;;
  3918.         esac;
  3919.     done;
  3920.     local f;
  3921.     local queue=();
  3922.     while IFS= read -r -d '' f; do
  3923.         local archivefile=${f/%.la/.a};
  3924.         if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  3925.             continue;
  3926.         fi;
  3927.         [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  3928.         local reason= pkgconfig_scanned=;
  3929.         local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  3930.         if [[ ${snotlink} == yes ]]; then
  3931.             if [[ -f ${archivefile} ]]; then
  3932.                 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  3933.                 queue+=("${archivefile}");
  3934.             fi;
  3935.             if [[ -n ${removing_modules} ]]; then
  3936.                 reason='module';
  3937.             fi;
  3938.         else
  3939.             if [[ -n ${removing_all} ]]; then
  3940.                 reason='requested';
  3941.             else
  3942.                 if [[ ! -f ${archivefile} ]]; then
  3943.                     reason='no static archive';
  3944.                 else
  3945.                     if [[ ! -n $(sed -nre                   "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p"      "${f}") ]]; then
  3946.                         reason='no libs & flags';
  3947.                     else
  3948.                         if [[ ! -n ${pkgconfig_scanned} ]]; then
  3949.                             local pc_libs=();
  3950.                             if [[ ! -n ${removing_all} ]]; then
  3951.                                 local pc;
  3952.                                 local tf=${T}/prune-lt-files.pc;
  3953.                                 local pkgconf=$(tc-getPKG_CONFIG);
  3954.                                 while IFS= read -r -d '' pc; do
  3955.                                     local arg libs;
  3956.                                     if ${pkgconf} --exists "${pc}" &> /dev/null; then
  3957.                                         sed -e '/^Requires:/d' "${pc}" > "${tf}";
  3958.                                         libs=$(${pkgconf} --libs "${tf}");
  3959.                                     else
  3960.                                         libs=$(sed -ne 's/^Libs://p' "${pc}");
  3961.                                     fi;
  3962.                                     for arg in ${libs};
  3963.                                     do
  3964.                                         if [[ ${arg} == -l* ]]; then
  3965.                                             if [[ ${arg} == '*$*' ]]; then
  3966.                                                 eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  3967.                                                 eerror "(arg: ${arg})";
  3968.                                                 eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  3969.                                                 die "${FUNCNAME}: unsubstituted variable found in .pc";
  3970.                                             fi;
  3971.                                             pc_libs+=(lib${arg#-l}.la);
  3972.                                         fi;
  3973.                                     done;
  3974.                                 done < <(find "${D}" -type f -name '*.pc' -print0);
  3975.                                 rm -f "${tf}";
  3976.                             fi;
  3977.                             pkgconfig_scanned=1;
  3978.                         fi;
  3979.                         has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  3980.                     fi;
  3981.                 fi;
  3982.             fi;
  3983.         fi;
  3984.         if [[ -n ${reason} ]]; then
  3985.             einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  3986.             queue+=("${f}");
  3987.         fi;
  3988.     done < <(find "${D}" -xtype f -name '*.la' -print0);
  3989.     if [[ -n ${queue[@]} ]]; then
  3990.         rm -f "${queue[@]}";
  3991.     fi
  3992. }
  3993. python-any-r1_pkg_setup ()
  3994. {
  3995.     debug-print-function ${FUNCNAME} "${@}";
  3996.     [[ ${MERGE_TYPE} != binary ]] && python_setup
  3997. }
  3998. python_abi_depend ()
  3999. {
  4000.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4001. }
  4002. python_byte-compile_modules ()
  4003. {
  4004.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4005. }
  4006. python_clean_byte-compiled_modules ()
  4007. {
  4008.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4009. }
  4010. python_clean_installation_image ()
  4011. {
  4012.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4013. }
  4014. python_clean_py-compile_files ()
  4015. {
  4016.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4017. }
  4018. python_convert_shebangs ()
  4019. {
  4020.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_convert_shebangs"
  4021. }
  4022. python_disable_pyc ()
  4023. {
  4024.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4025. }
  4026. python_doexe ()
  4027. {
  4028.     debug-print-function ${FUNCNAME} "${@}";
  4029.     local f;
  4030.     for f in "$@";
  4031.     do
  4032.         python_newexe "${f}" "${f##*/}";
  4033.     done
  4034. }
  4035. python_doheader ()
  4036. {
  4037.     debug-print-function ${FUNCNAME} "${@}";
  4038.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  4039.     if [[ ${EAPI:-0} == [0123] ]]; then
  4040.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  4041.     fi;
  4042.     local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  4043.     [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  4044.     d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  4045.     ( insopts -m 0644;
  4046.     insinto "${d}";
  4047.     doins -r "${@}" || return ${?} )
  4048. }
  4049. python_domodule ()
  4050. {
  4051.     debug-print-function ${FUNCNAME} "${@}";
  4052.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  4053.     if [[ ${EAPI:-0} == [0123] ]]; then
  4054.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  4055.     fi;
  4056.     local d;
  4057.     if [[ ${python_moduleroot} == /* ]]; then
  4058.         d=${python_moduleroot};
  4059.     else
  4060.         local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  4061.         [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  4062.         d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  4063.     fi;
  4064.     ( insopts -m 0644;
  4065.     insinto "${d}";
  4066.     doins -r "${@}" || return ${?} );
  4067.     python_optimize "${ED%/}/${d}"
  4068. }
  4069. python_doscript ()
  4070. {
  4071.     debug-print-function ${FUNCNAME} "${@}";
  4072.     local _PYTHON_REWRITE_SHEBANG=1;
  4073.     python_doexe "${@}"
  4074. }
  4075. python_enable_pyc ()
  4076. {
  4077.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4078. }
  4079. python_execute_function ()
  4080. {
  4081.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_execute_function"
  4082. }
  4083. python_execute_nosetests ()
  4084. {
  4085.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4086. }
  4087. python_execute_py.test ()
  4088. {
  4089.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4090. }
  4091. python_execute_trial ()
  4092. {
  4093.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4094. }
  4095. python_export ()
  4096. {
  4097.     debug-print-function ${FUNCNAME} "${@}";
  4098.     local impl var;
  4099.     case "${1}" in
  4100.         python* | jython*)
  4101.             impl=${1/_/.};
  4102.             shift
  4103.         ;;
  4104.         pypy | pypy3)
  4105.             impl=${1};
  4106.             shift
  4107.         ;;
  4108.         *)
  4109.             impl=${EPYTHON};
  4110.             if [[ -z ${impl} ]]; then
  4111.                 die "python_export called without a python implementation and EPYTHON is unset";
  4112.             fi
  4113.         ;;
  4114.     esac;
  4115.     debug-print "${FUNCNAME}: implementation: ${impl}";
  4116.     for var in "$@";
  4117.     do
  4118.         case "${var}" in
  4119.             EPYTHON)
  4120.                 export EPYTHON=${impl};
  4121.                 debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  4122.             ;;
  4123.             PYTHON)
  4124.                 export PYTHON=${EPREFIX}/usr/bin/${impl};
  4125.                 debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  4126.             ;;
  4127.             PYTHON_SITEDIR)
  4128.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  4129.                 PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  4130.                 export PYTHON_SITEDIR;
  4131.                 debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  4132.             ;;
  4133.             PYTHON_INCLUDEDIR)
  4134.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  4135.                 PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  4136.                 export PYTHON_INCLUDEDIR;
  4137.                 debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  4138.                 if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  4139.                     die "${impl} does not install any header files!";
  4140.                 fi
  4141.             ;;
  4142.             PYTHON_LIBPATH)
  4143.                 [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  4144.                 PYTHON_LIBPATH=$("${PYTHON}" -c 'import os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") else "")') || die;
  4145.                 export PYTHON_LIBPATH;
  4146.                 debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  4147.                 if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  4148.                     die "${impl} lacks a (usable) dynamic library";
  4149.                 fi
  4150.             ;;
  4151.             PYTHON_CFLAGS)
  4152.                 local val;
  4153.                 case "${impl}" in
  4154.                     python*)
  4155.                         val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  4156.                     ;;
  4157.                     *)
  4158.                         die "${impl}: obtaining ${var} not supported"
  4159.                     ;;
  4160.                 esac;
  4161.                 export PYTHON_CFLAGS=${val};
  4162.                 debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  4163.             ;;
  4164.             PYTHON_LIBS)
  4165.                 local val;
  4166.                 case "${impl}" in
  4167.                     python*)
  4168.                         val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  4169.                     ;;
  4170.                     *)
  4171.                         die "${impl}: obtaining ${var} not supported"
  4172.                     ;;
  4173.                 esac;
  4174.                 export PYTHON_LIBS=${val};
  4175.                 debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  4176.             ;;
  4177.             PYTHON_CONFIG)
  4178.                 local flags val;
  4179.                 case "${impl}" in
  4180.                     python*)
  4181.                         [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  4182.                         flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  4183.                         val=${PYTHON}${flags}-config
  4184.                     ;;
  4185.                     *)
  4186.                         die "${impl}: obtaining ${var} not supported"
  4187.                     ;;
  4188.                 esac;
  4189.                 export PYTHON_CONFIG=${val};
  4190.                 debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  4191.             ;;
  4192.             PYTHON_PKG_DEP)
  4193.                 local d;
  4194.                 case ${impl} in
  4195.                     python2.7)
  4196.                         PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  4197.                     ;;
  4198.                     python3.3)
  4199.                         PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  4200.                     ;;
  4201.                     python*)
  4202.                         PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  4203.                     ;;
  4204.                     pypy)
  4205.                         PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  4206.                     ;;
  4207.                     pypy3)
  4208.                         PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  4209.                     ;;
  4210.                     jython2.7)
  4211.                         PYTHON_PKG_DEP='dev-java/jython:2.7'
  4212.                     ;;
  4213.                     *)
  4214.                         die "Invalid implementation: ${impl}"
  4215.                     ;;
  4216.                 esac;
  4217.                 if [[ -n ${PYTHON_REQ_USE} ]]; then
  4218.                     PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  4219.                 fi;
  4220.                 export PYTHON_PKG_DEP;
  4221.                 debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  4222.             ;;
  4223.             PYTHON_SCRIPTDIR)
  4224.                 local dir;
  4225.                 export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  4226.                 debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  4227.             ;;
  4228.             *)
  4229.                 die "python_export: unknown variable ${var}"
  4230.             ;;
  4231.         esac;
  4232.     done
  4233. }
  4234. python_export_utf8_locale ()
  4235. {
  4236.     debug-print-function ${FUNCNAME} "${@}";
  4237.     type locale > /dev/null || return 0;
  4238.     if [[ $(locale charmap) != UTF-8 ]]; then
  4239.         local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  4240.         for lang in ${locales};
  4241.         do
  4242.             if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  4243.                 if _python_check_locale_sanity "${lang}"; then
  4244.                     export LC_CTYPE=${lang};
  4245.                     if [[ -n ${LC_ALL} ]]; then
  4246.                         export LC_NUMERIC=${LC_ALL};
  4247.                         export LC_TIME=${LC_ALL};
  4248.                         export LC_COLLATE=${LC_ALL};
  4249.                         export LC_MONETARY=${LC_ALL};
  4250.                         export LC_MESSAGES=${LC_ALL};
  4251.                         export LC_PAPER=${LC_ALL};
  4252.                         export LC_NAME=${LC_ALL};
  4253.                         export LC_ADDRESS=${LC_ALL};
  4254.                         export LC_TELEPHONE=${LC_ALL};
  4255.                         export LC_MEASUREMENT=${LC_ALL};
  4256.                         export LC_IDENTIFICATION=${LC_ALL};
  4257.                         export LC_ALL=;
  4258.                     fi;
  4259.                     return 0;
  4260.                 fi;
  4261.             fi;
  4262.         done;
  4263.         ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  4264.         ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  4265.         ewarn "/etc/locale.gen and run locale-gen.";
  4266.         return 1;
  4267.     fi;
  4268.     return 0
  4269. }
  4270. python_fix_shebang ()
  4271. {
  4272.     debug-print-function ${FUNCNAME} "${@}";
  4273.     [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  4274.     local force quiet;
  4275.     while [[ -n ${@} ]]; do
  4276.         case "${1}" in
  4277.             -f | --force)
  4278.                 force=1;
  4279.                 shift
  4280.             ;;
  4281.             -q | --quiet)
  4282.                 quiet=1;
  4283.                 shift
  4284.             ;;
  4285.             --)
  4286.                 shift;
  4287.                 break
  4288.             ;;
  4289.             *)
  4290.                 break
  4291.             ;;
  4292.         esac;
  4293.     done;
  4294.     [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  4295.     local path f;
  4296.     for path in "$@";
  4297.     do
  4298.         local any_correct any_fixed is_recursive;
  4299.         [[ -d ${path} ]] && is_recursive=1;
  4300.         while IFS= read -r -d '' f; do
  4301.             local shebang i;
  4302.             local error= from=;
  4303.             IFS= read -r shebang < "${f}";
  4304.             if [[ ${shebang} == '#!'* ]]; then
  4305.                 local split_shebang=();
  4306.                 read -r -a split_shebang <<< ${shebang} || die;
  4307.                 for i in "${split_shebang[@]}";
  4308.                 do
  4309.                     case "${i}" in
  4310.                         *"${EPYTHON}")
  4311.                             debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  4312.                             debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  4313.                             any_correct=1;
  4314.                             from=${EPYTHON};
  4315.                             break
  4316.                         ;;
  4317.                         *python | *python[23])
  4318.                             debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  4319.                             debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  4320.                             if [[ ${i} == *python2 ]]; then
  4321.                                 from=python2;
  4322.                                 if [[ ! -n ${force} ]]; then
  4323.                                     python_is_python3 "${EPYTHON}" && error=1;
  4324.                                 fi;
  4325.                             else
  4326.                                 if [[ ${i} == *python3 ]]; then
  4327.                                     from=python3;
  4328.                                     if [[ ! -n ${force} ]]; then
  4329.                                         python_is_python3 "${EPYTHON}" || error=1;
  4330.                                     fi;
  4331.                                 else
  4332.                                     from=python;
  4333.                                 fi;
  4334.                             fi;
  4335.                             break
  4336.                         ;;
  4337.                         *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  4338.                             if [[ ! -n ${force} ]]; then
  4339.                                 error=1;
  4340.                             else
  4341.                                 case "${i}" in
  4342.                                     *python[23].[0123456789])
  4343.                                         from="python[23].[0123456789]"
  4344.                                     ;;
  4345.                                     *pypy)
  4346.                                         from="pypy"
  4347.                                     ;;
  4348.                                     *pypy3)
  4349.                                         from="pypy3"
  4350.                                     ;;
  4351.                                     *jython[23].[0123456789])
  4352.                                         from="jython[23].[0123456789]"
  4353.                                     ;;
  4354.                                     *)
  4355.                                         die "${FUNCNAME}: internal error in 2nd pattern match"
  4356.                                     ;;
  4357.                                 esac;
  4358.                             fi;
  4359.                             break
  4360.                         ;;
  4361.                     esac;
  4362.                 done;
  4363.             fi;
  4364.             if [[ ! -n ${error} && ! -n ${from} ]]; then
  4365.                 [[ -n ${is_recursive} ]] && continue;
  4366.                 error=1;
  4367.             fi;
  4368.             if [[ ! -n ${quiet} ]]; then
  4369.                 einfo "Fixing shebang in ${f#${D%/}}.";
  4370.             fi;
  4371.             if [[ ! -n ${error} ]]; then
  4372.                 if [[ ${shebang} == *${from}" "* ]]; then
  4373.                     sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  4374.                 else
  4375.                     sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  4376.                 fi;
  4377.                 any_fixed=1;
  4378.             else
  4379.                 eerror "The file has incompatible shebang:";
  4380.                 eerror "  file: ${f#${D%/}}";
  4381.                 eerror "  current shebang: ${shebang}";
  4382.                 eerror "  requested impl: ${EPYTHON}";
  4383.                 die "${FUNCNAME}: conversion of incompatible shebang requested";
  4384.             fi;
  4385.         done < <(find -H "${path}" -type f -print0 || die);
  4386.         if [[ ! -n ${any_fixed} ]]; then
  4387.             local cmd=eerror;
  4388.             [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  4389.             "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  4390.             if [[ -n ${any_correct} ]]; then
  4391.                 "${cmd}" "All files have ${EPYTHON} shebang already.";
  4392.             else
  4393.                 "${cmd}" "There are no Python files in specified directory.";
  4394.             fi;
  4395.             [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  4396.         fi;
  4397.     done
  4398. }
  4399. python_gen_any_dep ()
  4400. {
  4401.     debug-print-function ${FUNCNAME} "${@}";
  4402.     local depstr=${1};
  4403.     [[ -n ${depstr} ]] || die "No dependency string provided";
  4404.     local i PYTHON_PKG_DEP out=;
  4405.     for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  4406.     do
  4407.         local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  4408.         python_export "${i}" PYTHON_PKG_DEP;
  4409.         local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  4410.         out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}";
  4411.     done;
  4412.     echo "|| ( ${out})"
  4413. }
  4414. python_generate_cffi_modules ()
  4415. {
  4416.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4417. }
  4418. python_generate_wrapper_scripts ()
  4419. {
  4420.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4421. }
  4422. python_get_CFLAGS ()
  4423. {
  4424.     debug-print-function ${FUNCNAME} "${@}";
  4425.     python_export "${@}" PYTHON_CFLAGS;
  4426.     echo "${PYTHON_CFLAGS}"
  4427. }
  4428. python_get_LIBS ()
  4429. {
  4430.     debug-print-function ${FUNCNAME} "${@}";
  4431.     python_export "${@}" PYTHON_LIBS;
  4432.     echo "${PYTHON_LIBS}"
  4433. }
  4434. python_get_PYTHON_CONFIG ()
  4435. {
  4436.     debug-print-function ${FUNCNAME} "${@}";
  4437.     python_export "${@}" PYTHON_CONFIG;
  4438.     echo "${PYTHON_CONFIG}"
  4439. }
  4440. python_get_extension_module_suffix ()
  4441. {
  4442.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4443. }
  4444. python_get_implementation ()
  4445. {
  4446.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4447. }
  4448. python_get_implementation_and_version ()
  4449. {
  4450.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4451. }
  4452. python_get_implementational_package ()
  4453. {
  4454.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4455. }
  4456. python_get_includedir ()
  4457. {
  4458.     debug-print-function ${FUNCNAME} "${@}";
  4459.     python_export "${@}" PYTHON_INCLUDEDIR;
  4460.     echo "${PYTHON_INCLUDEDIR}"
  4461. }
  4462. python_get_libdir ()
  4463. {
  4464.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4465. }
  4466. python_get_library ()
  4467. {
  4468.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4469. }
  4470. python_get_library_path ()
  4471. {
  4472.     debug-print-function ${FUNCNAME} "${@}";
  4473.     python_export "${@}" PYTHON_LIBPATH;
  4474.     echo "${PYTHON_LIBPATH}"
  4475. }
  4476. python_get_scriptdir ()
  4477. {
  4478.     debug-print-function ${FUNCNAME} "${@}";
  4479.     python_export "${@}" PYTHON_SCRIPTDIR;
  4480.     echo "${PYTHON_SCRIPTDIR}"
  4481. }
  4482. python_get_sitedir ()
  4483. {
  4484.     debug-print-function ${FUNCNAME} "${@}";
  4485.     python_export "${@}" PYTHON_SITEDIR;
  4486.     echo "${PYTHON_SITEDIR}"
  4487. }
  4488. python_get_version ()
  4489. {
  4490.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4491. }
  4492. python_install_executables ()
  4493. {
  4494.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4495. }
  4496. python_is_installed ()
  4497. {
  4498.     local impl=${1:-${EPYTHON}};
  4499.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  4500.     local hasv_args=();
  4501.     case ${EAPI:-0} in
  4502.         0 | 1 | 2 | 3 | 4)
  4503.             local -x ROOT=/
  4504.         ;;
  4505.         5 | 6)
  4506.             hasv_args+=(--host-root)
  4507.         ;;
  4508.         *)
  4509.             hasv_args+=(-b)
  4510.         ;;
  4511.     esac;
  4512.     case "${impl}" in
  4513.         pypy | pypy3)
  4514.             local append=;
  4515.             if [[ -n ${PYTHON_REQ_USE} ]]; then
  4516.                 append=[${PYTHON_REQ_USE}];
  4517.             fi;
  4518.             has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  4519.         ;;
  4520.         *)
  4521.             local PYTHON_PKG_DEP;
  4522.             python_export "${impl}" PYTHON_PKG_DEP;
  4523.             has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  4524.         ;;
  4525.     esac
  4526. }
  4527. python_is_python3 ()
  4528. {
  4529.     local impl=${1:-${EPYTHON}};
  4530.     [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  4531.     [[ ${impl} == python3* || ${impl} == pypy3 ]]
  4532. }
  4533. python_merge_intermediate_installation_images ()
  4534. {
  4535.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4536. }
  4537. python_mod_cleanup ()
  4538. {
  4539.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  4540. }
  4541. python_mod_optimize ()
  4542. {
  4543.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
  4544. }
  4545. python_moduleinto ()
  4546. {
  4547.     debug-print-function ${FUNCNAME} "${@}";
  4548.     python_moduleroot=${1}
  4549. }
  4550. python_need_rebuild ()
  4551. {
  4552.     die "${FUNCNAME}() is invalid for python-r1 suite"
  4553. }
  4554. python_newexe ()
  4555. {
  4556.     debug-print-function ${FUNCNAME} "${@}";
  4557.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  4558.     [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  4559.     if [[ ${EAPI:-0} == [0123] ]]; then
  4560.         die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  4561.     fi;
  4562.     local wrapd=${python_scriptroot:-/usr/bin};
  4563.     local f=${1};
  4564.     local newfn=${2};
  4565.     local PYTHON_SCRIPTDIR d;
  4566.     python_export PYTHON_SCRIPTDIR;
  4567.     d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  4568.     ( dodir "${wrapd}";
  4569.     exeopts -m 0755;
  4570.     exeinto "${d}";
  4571.     newexe "${f}" "${newfn}" || return ${?} );
  4572.     _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  4573.     if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  4574.         python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  4575.     fi
  4576. }
  4577. python_newscript ()
  4578. {
  4579.     debug-print-function ${FUNCNAME} "${@}";
  4580.     local _PYTHON_REWRITE_SHEBANG=1;
  4581.     python_newexe "${@}"
  4582. }
  4583. python_optimize ()
  4584. {
  4585.     debug-print-function ${FUNCNAME} "${@}";
  4586.     if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  4587.         eerror "The new Python eclasses expect the compiled Python files to";
  4588.         eerror "be controlled by the Package Manager. For this reason,";
  4589.         eerror "the python_optimize function can be used only during src_* phases";
  4590.         eerror "(src_install most commonly) and not during pkg_* phases.";
  4591.         echo;
  4592.         die "python_optimize is not to be used in pre/post* phases";
  4593.     fi;
  4594.     [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  4595.     local PYTHON=${PYTHON};
  4596.     [[ -n ${PYTHON} ]] || python_export PYTHON;
  4597.     if [[ ${#} -eq 0 ]]; then
  4598.         local f;
  4599.         while IFS= read -r -d '' f; do
  4600.             if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  4601.                 set -- "${D%/}${f}" "${@}";
  4602.             fi;
  4603.         done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  4604.         debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  4605.     fi;
  4606.     local d;
  4607.     for d in "$@";
  4608.     do
  4609.         local instpath=${d#${D%/}};
  4610.         instpath=/${instpath##/};
  4611.         case "${EPYTHON}" in
  4612.             python2.7 | python3.[34])
  4613.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  4614.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  4615.             ;;
  4616.             python* | pypy3)
  4617.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  4618.                 "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  4619.                 "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  4620.             ;;
  4621.             *)
  4622.                 "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  4623.             ;;
  4624.         esac;
  4625.     done
  4626. }
  4627. python_pkg_setup ()
  4628. {
  4629.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  4630. }
  4631. python_scriptinto ()
  4632. {
  4633.     debug-print-function ${FUNCNAME} "${@}";
  4634.     python_scriptroot=${1}
  4635. }
  4636. python_set_active_version ()
  4637. {
  4638.     die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  4639. }
  4640. python_setup ()
  4641. {
  4642.     debug-print-function ${FUNCNAME} "${@}";
  4643.     if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  4644.         local impls=(${PYTHON_COMPAT_OVERRIDE});
  4645.         [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-any-r1";
  4646.         ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  4647.         ewarn "implementation will be used:";
  4648.         ewarn;
  4649.         ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  4650.         ewarn;
  4651.         ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored.";
  4652.         python_export "${impls[0]}" EPYTHON PYTHON;
  4653.         python_wrapper_setup;
  4654.         return;
  4655.     fi;
  4656.     if [[ -n ${EPYTHON} ]]; then
  4657.         if _python_EPYTHON_supported "${EPYTHON}"; then
  4658.             python_export EPYTHON PYTHON;
  4659.             python_wrapper_setup;
  4660.             return;
  4661.         fi;
  4662.     fi;
  4663.     local variant i;
  4664.     for variant in '' '--python2' '--python3';
  4665.     do
  4666.         i=$(eselect python --show ${variant} 2>/dev/null);
  4667.         if [[ ! -n ${i} ]]; then
  4668.             break;
  4669.         else
  4670.             if _python_EPYTHON_supported "${i}"; then
  4671.                 python_export "${i}" EPYTHON PYTHON;
  4672.                 python_wrapper_setup;
  4673.                 return;
  4674.             fi;
  4675.         fi;
  4676.     done;
  4677.     for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  4678.     do
  4679.         python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON;
  4680.         if _python_EPYTHON_supported "${EPYTHON}"; then
  4681.             python_wrapper_setup;
  4682.             return;
  4683.         fi;
  4684.     done;
  4685.     eerror "No Python implementation found for the build. This is usually";
  4686.     eerror "a bug in the ebuild. Please report it to bugs.gentoo.org";
  4687.     eerror "along with the build log.";
  4688.     echo;
  4689.     die "No supported Python implementation installed."
  4690. }
  4691. python_wrapper_setup ()
  4692. {
  4693.     debug-print-function ${FUNCNAME} "${@}";
  4694.     local workdir=${1:-${T}/${EPYTHON}};
  4695.     local impl=${2:-${EPYTHON}};
  4696.     [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  4697.     [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  4698.     if [[ ! -x ${workdir}/bin/python ]]; then
  4699.         _python_check_dead_variables;
  4700.         mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  4701.         rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  4702.         rm -f "${workdir}"/bin/2to3 || die;
  4703.         rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  4704.         local EPYTHON PYTHON;
  4705.         python_export "${impl}" EPYTHON PYTHON;
  4706.         local pyver pyother;
  4707.         if python_is_python3; then
  4708.             pyver=3;
  4709.             pyother=2;
  4710.         else
  4711.             pyver=2;
  4712.             pyother=3;
  4713.         fi;
  4714.         cat > "${workdir}/bin/python"  <<-_EOF_ ||
  4715. #!/bin/sh
  4716. exec "${PYTHON}" "\${@}"
  4717. _EOF_
  4718.  die
  4719.         cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  4720.         chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  4721.         local nonsupp=("python${pyother}" "python${pyother}-config");
  4722.         if [[ ${EPYTHON} == python* ]]; then
  4723.             cat > "${workdir}/bin/python-config"  <<-_EOF_ ||
  4724. #!/bin/sh
  4725. exec "${PYTHON}-config" "\${@}"
  4726. _EOF_
  4727.  die
  4728.             cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  4729.             chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  4730.             ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  4731.             ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  4732.             ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  4733.         else
  4734.             nonsupp+=(2to3 python-config "python${pyver}-config");
  4735.         fi;
  4736.         local x;
  4737.         for x in "${nonsupp[@]}";
  4738.         do
  4739.             cat > "${workdir}"/bin/${x}  <<-_EOF_ ||
  4740. #!/bin/sh
  4741. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  4742. exit 127
  4743. _EOF_
  4744.  die
  4745.             chmod +x "${workdir}"/bin/${x} || die;
  4746.         done;
  4747.     fi;
  4748.     if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  4749.         PATH=${workdir}/bin${PATH:+:${PATH}};
  4750.     fi;
  4751.     if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  4752.         PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  4753.     fi;
  4754.     export PATH PKG_CONFIG_PATH
  4755. }
  4756. qeerror ()
  4757. {
  4758.     qout eerror "${@}"
  4759. }
  4760. qeinfo ()
  4761. {
  4762.     qout einfo "${@}"
  4763. }
  4764. qewarn ()
  4765. {
  4766.     qout ewarn "${@}"
  4767. }
  4768. qout ()
  4769. {
  4770.     local outputmsg type;
  4771.     type=${1};
  4772.     shift;
  4773.     outputmsg="${@}";
  4774.     case "${EBUILD_PHASE}" in
  4775.         depend)
  4776.             unset outputmsg
  4777.         ;;
  4778.         clean)
  4779.             unset outputmsg
  4780.         ;;
  4781.         preinst)
  4782.             unset outputmsg
  4783.         ;;
  4784.     esac;
  4785.     [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
  4786. }
  4787. raw-ldflags ()
  4788. {
  4789.     local x input="$@";
  4790.     [[ -z ${input} ]] && input=${LDFLAGS};
  4791.     set --;
  4792.     for x in ${input};
  4793.     do
  4794.         case ${x} in
  4795.             -Wl,*)
  4796.                 x=${x#-Wl,};
  4797.                 set -- "$@" ${x//,/ }
  4798.             ;;
  4799.             *)
  4800.  
  4801.             ;;
  4802.         esac;
  4803.     done;
  4804.     echo "$@"
  4805. }
  4806. readme.gentoo_create_doc ()
  4807. {
  4808.     debug-print-function ${FUNCNAME} "${@}";
  4809.     if [[ -n "${DOC_CONTENTS}" ]]; then
  4810.         if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
  4811.             echo "${DOC_CONTENTS}" > "${T}"/README.gentoo || die;
  4812.         else
  4813.             local saved_flags=$-;
  4814.             set -f;
  4815.             echo -e ${DOC_CONTENTS} | fold -s -w 70 | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo;
  4816.             assert;
  4817.             set +f -${saved_flags};
  4818.         fi;
  4819.     else
  4820.         if [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
  4821.             cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die;
  4822.         else
  4823.             if [[ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]]; then
  4824.                 cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die;
  4825.             else
  4826.                 die "You are not specifying README.gentoo contents!";
  4827.             fi;
  4828.         fi;
  4829.     fi;
  4830.     dodoc "${T}"/README.gentoo;
  4831.     README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
  4832. }
  4833. readme.gentoo_print_elog ()
  4834. {
  4835.     debug-print-function ${FUNCNAME} "${@}";
  4836.     if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
  4837.         die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!";
  4838.     else
  4839.         if ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
  4840.             echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do
  4841.                 elog "${ELINE}";
  4842.             done;
  4843.             elog "";
  4844.             elog "(Note: Above message is only printed the first time package is";
  4845.             elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*";
  4846.             elog "for future reference)";
  4847.         fi;
  4848.     fi
  4849. }
  4850. replace-cpu-flags ()
  4851. {
  4852.     local newcpu="$#";
  4853.     newcpu="${!newcpu}";
  4854.     while [ $# -gt 1 ]; do
  4855.         replace-flags "-march=${1}" "-march=${newcpu}";
  4856.         replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  4857.         replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  4858.         shift;
  4859.     done;
  4860.     return 0
  4861. }
  4862. replace-flags ()
  4863. {
  4864.     [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  4865.     local f var new;
  4866.     for var in $(all-flag-vars);
  4867.     do
  4868.         new=();
  4869.         for f in ${!var};
  4870.         do
  4871.             [[ ${f} == ${1} ]] && f=${2};
  4872.             new+=("${f}");
  4873.         done;
  4874.         export ${var}="${new[*]}";
  4875.     done;
  4876.     return 0
  4877. }
  4878. replace-sparc64-flags ()
  4879. {
  4880.     local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  4881.     if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  4882.         for x in ${SPARC64_CPUS};
  4883.         do
  4884.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  4885.         done;
  4886.     else
  4887.         for x in ${SPARC64_CPUS};
  4888.         do
  4889.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  4890.         done;
  4891.     fi;
  4892.     if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  4893.         for x in ${SPARC64_CPUS};
  4894.         do
  4895.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  4896.         done;
  4897.     else
  4898.         for x in ${SPARC64_CPUS};
  4899.         do
  4900.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  4901.         done;
  4902.     fi;
  4903.     export CFLAGS CXXFLAGS
  4904. }
  4905. require_configured_kernel ()
  4906. {
  4907.     if ! use kernel_linux; then
  4908.         die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  4909.     fi;
  4910.     if ! linux_config_src_exists; then
  4911.         qeerror "Could not find a usable .config in the kernel source directory.";
  4912.         qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  4913.         qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  4914.         qeerror "it points to the necessary object directory so that it might find .config.";
  4915.         die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  4916.     fi;
  4917.     get_version || die "Unable to determine configured kernel version"
  4918. }
  4919. seq ()
  4920. {
  4921.     local p=$(type -P seq);
  4922.     if [[ -n ${p} ]]; then
  4923.         "${p}" "$@" || die;
  4924.         return $?;
  4925.     fi;
  4926.     local min max step;
  4927.     case $# in
  4928.         1)
  4929.             min=1 max=$1 step=1
  4930.         ;;
  4931.         2)
  4932.             min=$1 max=$2 step=1
  4933.         ;;
  4934.         3)
  4935.             min=$1 max=$3 step=$2
  4936.         ;;
  4937.         *)
  4938.             die "seq called with wrong number of arguments"
  4939.         ;;
  4940.     esac;
  4941.     p=$(type -P jot);
  4942.     if [[ -n ${p} ]]; then
  4943.         local reps;
  4944.         if [[ ${step} != 0 ]]; then
  4945.             reps=$(( (max - min) / step + 1 ));
  4946.         else
  4947.             reps=0;
  4948.         fi;
  4949.         jot $reps $min $max $step || die;
  4950.         return $?;
  4951.     fi;
  4952.     while :; do
  4953.         [[ $max < $min && $step > 0 ]] && break;
  4954.         [[ $min < $max && $step < 0 ]] && break;
  4955.         echo $min;
  4956.         : $(( min += step ));
  4957.     done;
  4958.     return 0
  4959. }
  4960. set_arch_to_kernel ()
  4961. {
  4962.     export ARCH=$(tc-arch-kernel)
  4963. }
  4964. set_arch_to_portage ()
  4965. {
  4966.     export ARCH=$(tc-arch)
  4967. }
  4968. setup-allowed-flags ()
  4969. {
  4970.     ALLOWED_FLAGS=(-pipe -O '-O[12sg]' -mcpu -march -mtune '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check -fbounds-check -fbounds-checking -fno-strict-overflow -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -gz -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld');
  4971.     ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  4972.     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 -mfix-r10000 -mno-fix-r10000 -mthumb -marm -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)
  4973. }
  4974. src_compile ()
  4975. {
  4976.     python_setup;
  4977.     local x;
  4978.     for x in mksnapshot v8_context_snapshot_generator;
  4979.     do
  4980.         if tc-is-cross-compiler; then
  4981.             eninja -C out/Release "host/${x}";
  4982.             pax-mark m "out/Release/host/${x}";
  4983.         else
  4984.             eninja -C out/Release "${x}";
  4985.             pax-mark m "out/Release/${x}";
  4986.         fi;
  4987.     done;
  4988.     eninja -C out/Release gen/ui/accessibility/ax_enums.mojom.h;
  4989.     eninja -C out/Release gen/ui/accessibility/ax_enums.mojom-shared.h;
  4990.     eninja -C out/Release chrome chromedriver;
  4991.     use suid && eninja -C out/Release chrome_sandbox;
  4992.     pax-mark m out/Release/chrome
  4993. }
  4994. src_configure ()
  4995. {
  4996.     python_setup;
  4997.     local myconf_gn="";
  4998.     tc-export AR CC CXX NM;
  4999.     if [[ ${CHROMIUM_FORCE_CLANG} == yes ]] && ! tc-is-clang; then
  5000.         CC=${CHOST}-clang;
  5001.         CXX=${CHOST}-clang++;
  5002.         strip-unsupported-flags;
  5003.     fi;
  5004.     if tc-is-clang; then
  5005.         myconf_gn+=" is_clang=true clang_use_chrome_plugins=false";
  5006.     else
  5007.         myconf_gn+=" is_clang=false";
  5008.     fi;
  5009.     myconf_gn+=" custom_toolchain=\"//build/toolchain/linux/unbundle:default\"";
  5010.     if tc-is-cross-compiler; then
  5011.         tc-export BUILD_{AR,CC,CXX,NM};
  5012.         myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:host\"";
  5013.         myconf_gn+=" v8_snapshot_toolchain=\"//build/toolchain/linux/unbundle:host\"";
  5014.     else
  5015.         myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:default\"";
  5016.     fi;
  5017.     myconf_gn+=" is_debug=false";
  5018.     myconf_gn+=" is_component_build=$(usex component-build true false)";
  5019.     myconf_gn+=" use_jumbo_build=$(usex jumbo-build true false)";
  5020.     myconf_gn+=" use_allocator=$(usex tcmalloc \"tcmalloc\" \"none\")";
  5021.     myconf_gn+=" enable_nacl=false";
  5022.     local gn_system_libraries=(flac fontconfig freetype libdrm libjpeg libpng libwebp libxml libxslt openh264 re2 snappy yasm zlib);
  5023.     if use system-ffmpeg; then
  5024.         gn_system_libraries+=(ffmpeg opus);
  5025.     fi;
  5026.     if use system-icu; then
  5027.         gn_system_libraries+=(icu);
  5028.     fi;
  5029.     if use system-libvpx; then
  5030.         gn_system_libraries+=(libvpx);
  5031.     fi;
  5032.     build/linux/unbundle/replace_gn_files.py --system-libraries "${gn_system_libraries[@]}" || die;
  5033.     myconf_gn+=" use_system_harfbuzz=true";
  5034.     myconf_gn+=" enable_hangout_services_extension=$(usex hangouts true false)";
  5035.     myconf_gn+=" enable_widevine=$(usex widevine true false)";
  5036.     myconf_gn+=" use_cups=$(usex cups true false)";
  5037.     myconf_gn+=" use_gnome_keyring=$(usex gnome-keyring true false)";
  5038.     myconf_gn+=" use_kerberos=$(usex kerberos true false)";
  5039.     myconf_gn+=" use_pulseaudio=$(usex pulseaudio true false)";
  5040.     myconf_gn+=" fieldtrial_testing_like_official_build=true";
  5041.     myconf_gn+=" use_gold=false use_sysroot=false linux_use_bundled_binutils=false use_custom_libcxx=false";
  5042.     myconf_gn+=" use_lld=false";
  5043.     ffmpeg_branding="$(usex proprietary-codecs Chrome Chromium)";
  5044.     myconf_gn+=" proprietary_codecs=$(usex proprietary-codecs true false)";
  5045.     myconf_gn+=" ffmpeg_branding=\"${ffmpeg_branding}\"";
  5046.     local google_api_key="AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc";
  5047.     local google_default_client_id="329227923882.apps.googleusercontent.com";
  5048.     local google_default_client_secret="vgKG0NNv7GoDpbtoFNLxCUXu";
  5049.     myconf_gn+=" google_api_key=\"${google_api_key}\"";
  5050.     myconf_gn+=" google_default_client_id=\"${google_default_client_id}\"";
  5051.     myconf_gn+=" google_default_client_secret=\"${google_default_client_secret}\"";
  5052.     local myarch="$(tc-arch)";
  5053.     if [[ $myarch = amd64 ]]; then
  5054.         myconf_gn+=" target_cpu=\"x64\"";
  5055.         ffmpeg_target_arch=x64;
  5056.     else
  5057.         if [[ $myarch = x86 ]]; then
  5058.             myconf_gn+=" target_cpu=\"x86\"";
  5059.             ffmpeg_target_arch=ia32;
  5060.         else
  5061.             if [[ $myarch = arm64 ]]; then
  5062.                 myconf_gn+=" target_cpu=\"arm64\"";
  5063.                 ffmpeg_target_arch=arm64;
  5064.             else
  5065.                 if [[ $myarch = arm ]]; then
  5066.                     myconf_gn+=" target_cpu=\"arm\"";
  5067.                     ffmpeg_target_arch=$(usex neon arm-neon arm);
  5068.                 else
  5069.                     die "Failed to determine target arch, got '$myarch'.";
  5070.                 fi;
  5071.             fi;
  5072.         fi;
  5073.     fi;
  5074.     myconf_gn+=" treat_warnings_as_errors=false";
  5075.     myconf_gn+=" fatal_linker_warnings=false";
  5076.     if ! use custom-cflags; then
  5077.         replace-flags "-Os" "-O2";
  5078.         strip-flags;
  5079.         if use x86; then
  5080.             filter-flags "-g*";
  5081.         fi;
  5082.         if [[ ${myarch} == amd64 || ${myarch} == x86 ]]; then
  5083.             filter-flags -mno-mmx -mno-sse2 -mno-ssse3 -mno-sse4.1 -mno-avx -mno-avx2;
  5084.         fi;
  5085.     fi;
  5086.     export TMPDIR="${WORKDIR}/temp";
  5087.     mkdir -p -m 755 "${TMPDIR}" || die;
  5088.     addpredict /dev/dri/;
  5089.     if false; then
  5090.         local build_ffmpeg_args="";
  5091.         if use pic && [[ "${ffmpeg_target_arch}" == "ia32" ]]; then
  5092.             build_ffmpeg_args+=" --disable-asm";
  5093.         fi;
  5094.         einfo "Configuring bundled ffmpeg...";
  5095.         pushd third_party/ffmpeg > /dev/null || die;
  5096.         chromium/scripts/build_ffmpeg.py linux ${ffmpeg_target_arch} --branding ${ffmpeg_branding} -- ${build_ffmpeg_args} || die;
  5097.         chromium/scripts/copy_config.sh || die;
  5098.         chromium/scripts/generate_gn.py || die;
  5099.         popd > /dev/null || die;
  5100.     fi;
  5101.     einfo "Configuring Chromium...";
  5102.     set -- gn gen --args="${myconf_gn} ${EXTRA_GN}" out/Release;
  5103.     echo "$@";
  5104.     "$@" || die
  5105. }
  5106. src_install ()
  5107. {
  5108.     local CHROMIUM_HOME="/usr/$(get_libdir)/chromium-browser";
  5109.     exeinto "${CHROMIUM_HOME}";
  5110.     doexe out/Release/chrome;
  5111.     if use suid; then
  5112.         newexe out/Release/chrome_sandbox chrome-sandbox;
  5113.         fperms 4755 "${CHROMIUM_HOME}/chrome-sandbox";
  5114.     fi;
  5115.     doexe out/Release/chromedriver;
  5116.     local sedargs=(-e "s:/usr/lib/:/usr/$(get_libdir)/:g");
  5117.     sed "${sedargs[@]}" "${FILESDIR}/chromium-launcher-r3.sh" > chromium-launcher.sh || die;
  5118.     doexe chromium-launcher.sh;
  5119.     dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium-browser;
  5120.     dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium;
  5121.     dosym "${CHROMIUM_HOME}/chromedriver" /usr/bin/chromedriver;
  5122.     insinto /etc/chromium;
  5123.     newins "${FILESDIR}/chromium.default" "default";
  5124.     pushd out/Release/locales > /dev/null || die;
  5125.     chromium_remove_language_paks;
  5126.     popd;
  5127.     insinto "${CHROMIUM_HOME}";
  5128.     doins out/Release/*.bin;
  5129.     doins out/Release/*.pak;
  5130.     doins out/Release/*.so;
  5131.     if ! use system-icu; then
  5132.         doins out/Release/icudtl.dat;
  5133.     fi;
  5134.     doins -r out/Release/locales;
  5135.     doins -r out/Release/resources;
  5136.     if [[ -d out/Release/swiftshader ]]; then
  5137.         insinto "${CHROMIUM_HOME}/swiftshader";
  5138.         doins out/Release/swiftshader/*.so;
  5139.     fi;
  5140.     local branding size;
  5141.     for size in 16 22 24 32 48 64 128 256;
  5142.     do
  5143.         case ${size} in
  5144.             16 | 32)
  5145.                 branding="chrome/app/theme/default_100_percent/chromium"
  5146.             ;;
  5147.             *)
  5148.                 branding="chrome/app/theme/chromium"
  5149.             ;;
  5150.         esac;
  5151.         newicon -s ${size} "${branding}/product_logo_${size}.png" chromium-browser.png;
  5152.     done;
  5153.     local mime_types="text/html;text/xml;application/xhtml+xml;";
  5154.     mime_types+="x-scheme-handler/http;x-scheme-handler/https;";
  5155.     mime_types+="x-scheme-handler/ftp;";
  5156.     mime_types+="x-scheme-handler/mailto;x-scheme-handler/webcal;";
  5157.     make_desktop_entry chromium-browser "Chromium" chromium-browser "Network;WebBrowser" "MimeType=${mime_types}\nStartupWMClass=chromium-browser";
  5158.     sed -e "/^Exec/s/$/ %U/" -i "${ED}"/usr/share/applications/*.desktop || die;
  5159.     insinto /usr/share/gnome-control-center/default-apps;
  5160.     newins "${FILESDIR}"/chromium-browser.xml chromium-browser.xml;
  5161.     readme.gentoo_create_doc
  5162. }
  5163. src_prepare ()
  5164. {
  5165.     python_setup;
  5166.     default;
  5167.     mkdir -p third_party/node/linux/node-linux-x64/bin || die;
  5168.     ln -s "${EPREFIX}"/usr/bin/node third_party/node/linux/node-linux-x64/bin/node || die;
  5169.     local keeplibs=(base/third_party/dmg_fp base/third_party/dynamic_annotations base/third_party/icu base/third_party/nspr base/third_party/superfasthash base/third_party/symbolize base/third_party/valgrind base/third_party/xdg_mime base/third_party/xdg_user_dirs buildtools/third_party/libc++ buildtools/third_party/libc++abi chrome/third_party/mozilla_security_manager courgette/third_party net/third_party/http2 net/third_party/mozilla_security_manager net/third_party/nss net/third_party/quic net/third_party/spdy net/third_party/uri_template third_party/WebKit third_party/abseil-cpp third_party/analytics third_party/angle third_party/angle/src/common/third_party/base third_party/angle/src/common/third_party/smhasher third_party/angle/src/third_party/compiler third_party/angle/src/third_party/libXNVCtrl third_party/angle/src/third_party/trace_event third_party/angle/third_party/glslang third_party/angle/third_party/spirv-headers third_party/angle/third_party/spirv-tools third_party/angle/third_party/vulkan-headers third_party/angle/third_party/vulkan-loader third_party/angle/third_party/vulkan-tools third_party/angle/third_party/vulkan-validation-layers third_party/apple_apsl third_party/blink third_party/boringssl third_party/boringssl/src/third_party/fiat third_party/breakpad third_party/breakpad/breakpad/src/third_party/curl third_party/brotli third_party/cacheinvalidation third_party/catapult third_party/catapult/common/py_vulcanize/third_party/rcssmin third_party/catapult/common/py_vulcanize/third_party/rjsmin third_party/catapult/third_party/beautifulsoup4 third_party/catapult/third_party/html5lib-python third_party/catapult/third_party/polymer third_party/catapult/third_party/six third_party/catapult/tracing/third_party/d3 third_party/catapult/tracing/third_party/gl-matrix third_party/catapult/tracing/third_party/jszip third_party/catapult/tracing/third_party/mannwhitneyu third_party/catapult/tracing/third_party/oboe third_party/catapult/tracing/third_party/pako third_party/ced third_party/cld_3 third_party/crashpad third_party/crashpad/crashpad/third_party/zlib third_party/crc32c third_party/cros_system_api third_party/devscripts third_party/dom_distiller_js third_party/fips181 third_party/flatbuffers third_party/flot third_party/freetype third_party/glslang-angle third_party/google_input_tools third_party/google_input_tools/third_party/closure_library third_party/google_input_tools/third_party/closure_library/third_party/closure third_party/googletest third_party/hunspell third_party/iccjpeg third_party/inspector_protocol third_party/jinja2 third_party/jstemplate third_party/khronos third_party/leveldatabase third_party/libXNVCtrl third_party/libaddressinput third_party/libaom third_party/libaom/source/libaom/third_party/vector third_party/libaom/source/libaom/third_party/x86inc third_party/libjingle third_party/libphonenumber third_party/libsecret third_party/libsrtp third_party/libsync third_party/libudev third_party/libwebm third_party/libxml/chromium third_party/libyuv third_party/llvm third_party/lss third_party/lzma_sdk third_party/markupsafe third_party/mesa third_party/metrics_proto third_party/modp_b64 third_party/node third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2 third_party/openmax_dl third_party/ots third_party/pdfium third_party/pdfium/third_party/agg23 third_party/pdfium/third_party/base third_party/pdfium/third_party/bigint third_party/pdfium/third_party/freetype third_party/pdfium/third_party/lcms third_party/pdfium/third_party/libopenjpeg20 third_party/pdfium/third_party/libpng16 third_party/pdfium/third_party/libtiff third_party/pdfium/third_party/skia_shared third_party/perfetto third_party/ply third_party/polymer third_party/protobuf third_party/protobuf/third_party/six third_party/pyjson5 third_party/qcms third_party/rnnoise third_party/s2cellid third_party/sfntly third_party/simplejson third_party/skia third_party/skia/third_party/gif third_party/skia/third_party/skcms third_party/skia/third_party/vulkan third_party/smhasher third_party/spirv-headers third_party/spirv-tools-angle third_party/sqlite third_party/swiftshader third_party/swiftshader/third_party/llvm-subzero third_party/swiftshader/third_party/subzero third_party/unrar third_party/usrsctp third_party/vulkan third_party/vulkan-validation-layers third_party/web-animations-js third_party/webdriver third_party/webrtc third_party/webrtc/common_audio/third_party/fft4g third_party/webrtc/common_audio/third_party/spl_sqrt_floor third_party/webrtc/modules/third_party/fft third_party/webrtc/modules/third_party/g711 third_party/webrtc/modules/third_party/g722 third_party/webrtc/rtc_base/third_party/base64 third_party/webrtc/rtc_base/third_party/sigslot third_party/widevine third_party/woff2 third_party/zlib/google url/third_party/mozilla v8/src/third_party/valgrind v8/src/third_party/utf8-decoder v8/third_party/inspector_protocol v8/third_party/v8 base/third_party/libevent third_party/adobe third_party/speech-dispatcher third_party/usb_ids third_party/xdg-utils third_party/yasm/run_yasm.py);
  5170.     if ! use system-ffmpeg; then
  5171.         keeplibs+=(third_party/ffmpeg third_party/opus);
  5172.     fi;
  5173.     if ! use system-icu; then
  5174.         keeplibs+=(third_party/icu);
  5175.     fi;
  5176.     if ! use system-libvpx; then
  5177.         keeplibs+=(third_party/libvpx);
  5178.         keeplibs+=(third_party/libvpx/source/libvpx/third_party/x86inc);
  5179.     fi;
  5180.     if use tcmalloc; then
  5181.         keeplibs+=(third_party/tcmalloc);
  5182.     fi;
  5183.     build/linux/unbundle/remove_bundled_libraries.py "${keeplibs[@]}" --do-remove || die
  5184. }
  5185. src_test ()
  5186. {
  5187.     default
  5188. }
  5189. src_unpack ()
  5190. {
  5191.     default
  5192. }
  5193. strip-flags ()
  5194. {
  5195.     local x y var;
  5196.     local ALLOWED_FLAGS;
  5197.     setup-allowed-flags;
  5198.     set -f;
  5199.     for var in $(all-flag-vars);
  5200.     do
  5201.         local new=();
  5202.         for x in ${!var};
  5203.         do
  5204.             local flag=${x%%=*};
  5205.             for y in "${ALLOWED_FLAGS[@]}";
  5206.             do
  5207.                 if [[ -z ${flag%%${y}} ]]; then
  5208.                     new+=("${x}");
  5209.                     break;
  5210.                 fi;
  5211.             done;
  5212.         done;
  5213.         if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  5214.             new+=(-O2);
  5215.         fi;
  5216.         if [[ ${!var} != "${new[*]}" ]]; then
  5217.             einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  5218.         fi;
  5219.         export ${var}="${new[*]}";
  5220.     done;
  5221.     set +f;
  5222.     return 0
  5223. }
  5224. strip-linguas ()
  5225. {
  5226.     local ls newls nols;
  5227.     if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  5228.         local op=$1;
  5229.         shift;
  5230.         ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  5231.         shift;
  5232.         local d f;
  5233.         for d in "$@";
  5234.         do
  5235.             if [[ ${op} == "-u" ]]; then
  5236.                 newls=${ls};
  5237.             else
  5238.                 newls="";
  5239.             fi;
  5240.             for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  5241.             do
  5242.                 if [[ ${op} == "-i" ]]; then
  5243.                     has ${f} ${ls} && newls="${newls} ${f}";
  5244.                 else
  5245.                     has ${f} ${ls} || newls="${newls} ${f}";
  5246.                 fi;
  5247.             done;
  5248.             ls=${newls};
  5249.         done;
  5250.     else
  5251.         ls="$@";
  5252.     fi;
  5253.     nols="";
  5254.     newls="";
  5255.     for f in ${LINGUAS};
  5256.     do
  5257.         if has ${f} ${ls}; then
  5258.             newls="${newls} ${f}";
  5259.         else
  5260.             nols="${nols} ${f}";
  5261.         fi;
  5262.     done;
  5263.     [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  5264.     export LINGUAS=${newls:1}
  5265. }
  5266. strip-unsupported-flags ()
  5267. {
  5268.     export CFLAGS=$(test-flags-CC ${CFLAGS});
  5269.     export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  5270.     export FFLAGS=$(test-flags-F77 ${FFLAGS});
  5271.     export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  5272.     export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  5273. }
  5274. tc-arch ()
  5275. {
  5276.     tc-ninja_magic_to_arch portage "$@"
  5277. }
  5278. tc-arch-kernel ()
  5279. {
  5280.     tc-ninja_magic_to_arch kern "$@"
  5281. }
  5282. tc-check-openmp ()
  5283. {
  5284.     if ! tc-has-openmp; then
  5285.         eerror "Your current compiler does not support OpenMP!";
  5286.         if tc-is-gcc; then
  5287.             eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  5288.         else
  5289.             if tc-is-clang; then
  5290.                 eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  5291.             fi;
  5292.         fi;
  5293.         die "Active compiler does not have required support for OpenMP";
  5294.     fi
  5295. }
  5296. tc-cpp-is-true ()
  5297. {
  5298.     local CONDITION=${1};
  5299.     shift;
  5300.     local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  5301.             #if ${CONDITION}
  5302.             true
  5303.             #endif
  5304.         EOF
  5305.     );
  5306.     [[ ${RESULT} == true ]]
  5307. }
  5308. tc-detect-is-softfloat ()
  5309. {
  5310.     [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  5311.     case ${CTARGET:-${CHOST}} in
  5312.         *-newlib | *-elf | *-eabi)
  5313.             return 1
  5314.         ;;
  5315.         arm*)
  5316.             if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  5317.                 echo "no";
  5318.             else
  5319.                 if tc-cpp-is-true "defined(__SOFTFP__)"; then
  5320.                     echo "yes";
  5321.                 else
  5322.                     echo "softfp";
  5323.                 fi;
  5324.             fi;
  5325.             return 0
  5326.         ;;
  5327.         *)
  5328.             return 1
  5329.         ;;
  5330.     esac
  5331. }
  5332. tc-enables-pie ()
  5333. {
  5334.     tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  5335. }
  5336. tc-enables-ssp ()
  5337. {
  5338.     tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  5339. }
  5340. tc-enables-ssp-all ()
  5341. {
  5342.     tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  5343. }
  5344. tc-enables-ssp-strong ()
  5345. {
  5346.     tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  5347. }
  5348. tc-endian ()
  5349. {
  5350.     local host=$1;
  5351.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  5352.     host=${host%%-*};
  5353.     case ${host} in
  5354.         aarch64*be)
  5355.             echo big
  5356.         ;;
  5357.         aarch64)
  5358.             echo little
  5359.         ;;
  5360.         alpha*)
  5361.             echo little
  5362.         ;;
  5363.         arm*b*)
  5364.             echo big
  5365.         ;;
  5366.         arm*)
  5367.             echo little
  5368.         ;;
  5369.         cris*)
  5370.             echo little
  5371.         ;;
  5372.         hppa*)
  5373.             echo big
  5374.         ;;
  5375.         i?86*)
  5376.             echo little
  5377.         ;;
  5378.         ia64*)
  5379.             echo little
  5380.         ;;
  5381.         m68*)
  5382.             echo big
  5383.         ;;
  5384.         mips*l*)
  5385.             echo little
  5386.         ;;
  5387.         mips*)
  5388.             echo big
  5389.         ;;
  5390.         powerpc*le)
  5391.             echo little
  5392.         ;;
  5393.         powerpc*)
  5394.             echo big
  5395.         ;;
  5396.         s390*)
  5397.             echo big
  5398.         ;;
  5399.         sh*b*)
  5400.             echo big
  5401.         ;;
  5402.         sh*)
  5403.             echo little
  5404.         ;;
  5405.         sparc*)
  5406.             echo big
  5407.         ;;
  5408.         x86_64*)
  5409.             echo little
  5410.         ;;
  5411.         *)
  5412.             echo wtf
  5413.         ;;
  5414.     esac
  5415. }
  5416. tc-env_build ()
  5417. {
  5418.     tc-export_build_env;
  5419.     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) "$@"
  5420. }
  5421. tc-export ()
  5422. {
  5423.     local var;
  5424.     for var in "$@";
  5425.     do
  5426.         [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  5427.         "tc-get${var}" > /dev/null;
  5428.     done
  5429. }
  5430. tc-export_build_env ()
  5431. {
  5432.     tc-export "$@";
  5433.     if tc-is-cross-compiler; then
  5434.         : ${BUILD_CFLAGS:=-O1 -pipe};
  5435.         : ${BUILD_CXXFLAGS:=-O1 -pipe};
  5436.         : ${BUILD_CPPFLAGS:= };
  5437.         : ${BUILD_LDFLAGS:= };
  5438.     else
  5439.         : ${BUILD_CFLAGS:=${CFLAGS}};
  5440.         : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  5441.         : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  5442.         : ${BUILD_LDFLAGS:=${LDFLAGS}};
  5443.     fi;
  5444.     export BUILD_{C,CXX,CPP,LD}FLAGS;
  5445.     local v;
  5446.     for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  5447.     do
  5448.         export ${v#BUILD_}_FOR_BUILD="${!v}";
  5449.     done
  5450. }
  5451. tc-get-compiler-type ()
  5452. {
  5453.     local code='
  5454. #if defined(__PATHSCALE__)
  5455.     HAVE_PATHCC
  5456. #elif defined(__clang__)
  5457.     HAVE_CLANG
  5458. #elif defined(__GNUC__)
  5459.     HAVE_GCC
  5460. #endif
  5461. ';
  5462.     local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  5463.     case ${res} in
  5464.         *HAVE_PATHCC*)
  5465.             echo pathcc
  5466.         ;;
  5467.         *HAVE_CLANG*)
  5468.             echo clang
  5469.         ;;
  5470.         *HAVE_GCC*)
  5471.             echo gcc
  5472.         ;;
  5473.         *)
  5474.             echo unknown
  5475.         ;;
  5476.     esac
  5477. }
  5478. tc-getAR ()
  5479. {
  5480.     tc-getPROG AR ar "$@"
  5481. }
  5482. tc-getAS ()
  5483. {
  5484.     tc-getPROG AS as "$@"
  5485. }
  5486. tc-getBUILD_AR ()
  5487. {
  5488.     tc-getBUILD_PROG AR ar "$@"
  5489. }
  5490. tc-getBUILD_AS ()
  5491. {
  5492.     tc-getBUILD_PROG AS as "$@"
  5493. }
  5494. tc-getBUILD_CC ()
  5495. {
  5496.     tc-getBUILD_PROG CC gcc "$@"
  5497. }
  5498. tc-getBUILD_CPP ()
  5499. {
  5500.     tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  5501. }
  5502. tc-getBUILD_CXX ()
  5503. {
  5504.     tc-getBUILD_PROG CXX g++ "$@"
  5505. }
  5506. tc-getBUILD_LD ()
  5507. {
  5508.     tc-getBUILD_PROG LD ld "$@"
  5509. }
  5510. tc-getBUILD_NM ()
  5511. {
  5512.     tc-getBUILD_PROG NM nm "$@"
  5513. }
  5514. tc-getBUILD_OBJCOPY ()
  5515. {
  5516.     tc-getBUILD_PROG OBJCOPY objcopy "$@"
  5517. }
  5518. tc-getBUILD_PKG_CONFIG ()
  5519. {
  5520.     tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  5521. }
  5522. tc-getBUILD_PROG ()
  5523. {
  5524.     local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  5525.     tc-is-cross-compiler || vars+=" $1";
  5526.     _tc-getPROG CBUILD "${vars}" "${@:2}"
  5527. }
  5528. tc-getBUILD_RANLIB ()
  5529. {
  5530.     tc-getBUILD_PROG RANLIB ranlib "$@"
  5531. }
  5532. tc-getBUILD_STRIP ()
  5533. {
  5534.     tc-getBUILD_PROG STRIP strip "$@"
  5535. }
  5536. tc-getCC ()
  5537. {
  5538.     tc-getPROG CC gcc "$@"
  5539. }
  5540. tc-getCPP ()
  5541. {
  5542.     tc-getPROG CPP "${CC:-gcc} -E" "$@"
  5543. }
  5544. tc-getCXX ()
  5545. {
  5546.     tc-getPROG CXX g++ "$@"
  5547. }
  5548. tc-getDLLWRAP ()
  5549. {
  5550.     tc-getPROG DLLWRAP dllwrap "$@"
  5551. }
  5552. tc-getF77 ()
  5553. {
  5554.     tc-getPROG F77 gfortran "$@"
  5555. }
  5556. tc-getFC ()
  5557. {
  5558.     tc-getPROG FC gfortran "$@"
  5559. }
  5560. tc-getGCJ ()
  5561. {
  5562.     tc-getPROG GCJ gcj "$@"
  5563. }
  5564. tc-getGO ()
  5565. {
  5566.     tc-getPROG GO gccgo "$@"
  5567. }
  5568. tc-getLD ()
  5569. {
  5570.     tc-getPROG LD ld "$@"
  5571. }
  5572. tc-getNM ()
  5573. {
  5574.     tc-getPROG NM nm "$@"
  5575. }
  5576. tc-getOBJCOPY ()
  5577. {
  5578.     tc-getPROG OBJCOPY objcopy "$@"
  5579. }
  5580. tc-getOBJDUMP ()
  5581. {
  5582.     tc-getPROG OBJDUMP objdump "$@"
  5583. }
  5584. tc-getPKG_CONFIG ()
  5585. {
  5586.     tc-getPROG PKG_CONFIG pkg-config "$@"
  5587. }
  5588. tc-getPROG ()
  5589. {
  5590.     _tc-getPROG CHOST "$@"
  5591. }
  5592. tc-getRANLIB ()
  5593. {
  5594.     tc-getPROG RANLIB ranlib "$@"
  5595. }
  5596. tc-getRC ()
  5597. {
  5598.     tc-getPROG RC windres "$@"
  5599. }
  5600. tc-getSTRIP ()
  5601. {
  5602.     tc-getPROG STRIP strip "$@"
  5603. }
  5604. tc-getTARGET_CPP ()
  5605. {
  5606.     if [[ -n ${CTARGET} ]]; then
  5607.         _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  5608.     else
  5609.         tc-getCPP "$@";
  5610.     fi
  5611. }
  5612. tc-has-openmp ()
  5613. {
  5614.     local base="${T}/test-tc-openmp";
  5615.     cat > "${base}.c"  <<-EOF
  5616. #include <omp.h>
  5617. int main() {
  5618. int nthreads, tid, ret = 0;
  5619. #pragma omp parallel private(nthreads, tid)
  5620. {
  5621. tid = omp_get_thread_num();
  5622. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  5623. }
  5624. return ret;
  5625. }
  5626. EOF
  5627.  
  5628.     $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  5629.     local ret=$?;
  5630.     rm -f "${base}"*;
  5631.     return ${ret}
  5632. }
  5633. tc-has-tls ()
  5634. {
  5635.     local base="${T}/test-tc-tls";
  5636.     cat > "${base}.c"  <<-EOF
  5637. int foo(int *i) {
  5638. static __thread int j = 0;
  5639. return *i ? j : *i;
  5640. }
  5641. EOF
  5642.  
  5643.     local flags;
  5644.     case $1 in
  5645.         -s)
  5646.             flags="-S"
  5647.         ;;
  5648.         -c)
  5649.             flags="-c"
  5650.         ;;
  5651.         -l)
  5652.  
  5653.         ;;
  5654.         -*)
  5655.             die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  5656.         ;;
  5657.     esac;
  5658.     : ${flags:=-fPIC -shared -Wl,-z,defs};
  5659.     [[ $1 == -* ]] && shift;
  5660.     $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  5661.     local ret=$?;
  5662.     rm -f "${base}"*;
  5663.     return ${ret}
  5664. }
  5665. tc-is-clang ()
  5666. {
  5667.     [[ $(tc-get-compiler-type) == clang ]]
  5668. }
  5669. tc-is-cross-compiler ()
  5670. {
  5671.     [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  5672. }
  5673. tc-is-gcc ()
  5674. {
  5675.     [[ $(tc-get-compiler-type) == gcc ]]
  5676. }
  5677. tc-is-softfloat ()
  5678. {
  5679.     tc-detect-is-softfloat || tc-tuple-is-softfloat
  5680. }
  5681. tc-is-static-only ()
  5682. {
  5683.     local host=${CTARGET:-${CHOST}};
  5684.     [[ ${host} == *-mint* ]]
  5685. }
  5686. tc-ld-disable-gold ()
  5687. {
  5688.     if ! tc-ld-is-gold "$@"; then
  5689.         return;
  5690.     fi;
  5691.     ewarn "Forcing usage of the BFD linker instead of GOLD";
  5692.     local ld=$(tc-getLD "$@");
  5693.     local bfd_ld="${ld%% *}.bfd";
  5694.     local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  5695.     [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  5696.     local fallback="true";
  5697.     if tc-is-gcc; then
  5698.         local major=$(gcc-major-version "$@");
  5699.         local minor=$(gcc-minor-version "$@");
  5700.         if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  5701.             export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  5702.             fallback="false";
  5703.         fi;
  5704.     else
  5705.         if tc-is-clang; then
  5706.             local major=$(clang-major-version "$@");
  5707.             local minor=$(clang-minor-version "$@");
  5708.             if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  5709.                 export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  5710.                 fallback="false";
  5711.             fi;
  5712.         fi;
  5713.     fi;
  5714.     if [[ ${fallback} == "true" ]]; then
  5715.         if [[ -e ${path_ld} ]]; then
  5716.             local d="${T}/bfd-linker";
  5717.             mkdir -p "${d}";
  5718.             ln -sf "${path_ld}" "${d}"/ld;
  5719.             export LDFLAGS="${LDFLAGS} -B${d}";
  5720.         else
  5721.             die "unable to locate a BFD linker to bypass gold";
  5722.         fi;
  5723.     fi
  5724. }
  5725. tc-ld-is-gold ()
  5726. {
  5727.     local out;
  5728.     out=$($(tc-getLD "$@") --version 2>&1);
  5729.     if [[ ${out} == *"GNU gold"* ]]; then
  5730.         return 0;
  5731.     fi;
  5732.     local base="${T}/test-tc-gold";
  5733.     cat > "${base}.c"  <<-EOF
  5734. int main() { return 0; }
  5735. EOF
  5736.  
  5737.     out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  5738.     rm -f "${base}"*;
  5739.     if [[ ${out} == *"GNU gold"* ]]; then
  5740.         return 0;
  5741.     fi;
  5742.     return 1
  5743. }
  5744. tc-ninja_magic_to_arch ()
  5745. {
  5746.     function ninj ()
  5747.     {
  5748.         [[ ${type} == "kern" ]] && echo $1 || echo $2
  5749.     };
  5750.     local type=$1;
  5751.     local host=$2;
  5752.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  5753.     case ${host} in
  5754.         aarch64*)
  5755.             echo arm64
  5756.         ;;
  5757.         alpha*)
  5758.             echo alpha
  5759.         ;;
  5760.         arm*)
  5761.             echo arm
  5762.         ;;
  5763.         avr*)
  5764.             ninj avr32 avr
  5765.         ;;
  5766.         bfin*)
  5767.             ninj blackfin bfin
  5768.         ;;
  5769.         c6x*)
  5770.             echo c6x
  5771.         ;;
  5772.         cris*)
  5773.             echo cris
  5774.         ;;
  5775.         frv*)
  5776.             echo frv
  5777.         ;;
  5778.         hexagon*)
  5779.             echo hexagon
  5780.         ;;
  5781.         hppa*)
  5782.             ninj parisc hppa
  5783.         ;;
  5784.         i?86*)
  5785.             if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  5786.                 echo i386;
  5787.             else
  5788.                 echo x86;
  5789.             fi
  5790.         ;;
  5791.         ia64*)
  5792.             echo ia64
  5793.         ;;
  5794.         m68*)
  5795.             echo m68k
  5796.         ;;
  5797.         metag*)
  5798.             echo metag
  5799.         ;;
  5800.         microblaze*)
  5801.             echo microblaze
  5802.         ;;
  5803.         mips*)
  5804.             echo mips
  5805.         ;;
  5806.         nios2*)
  5807.             echo nios2
  5808.         ;;
  5809.         nios*)
  5810.             echo nios
  5811.         ;;
  5812.         or1k | or32*)
  5813.             echo openrisc
  5814.         ;;
  5815.         powerpc*)
  5816.             if [[ ${type} == "kern" ]]; then
  5817.                 echo powerpc;
  5818.             else
  5819.                 if [[ ${host} == powerpc64* ]]; then
  5820.                     echo ppc64;
  5821.                 else
  5822.                     echo ppc;
  5823.                 fi;
  5824.             fi
  5825.         ;;
  5826.         riscv*)
  5827.             echo riscv
  5828.         ;;
  5829.         s390*)
  5830.             echo s390
  5831.         ;;
  5832.         score*)
  5833.             echo score
  5834.         ;;
  5835.         sh64*)
  5836.             ninj sh64 sh
  5837.         ;;
  5838.         sh*)
  5839.             echo sh
  5840.         ;;
  5841.         sparc64*)
  5842.             ninj sparc64 sparc
  5843.         ;;
  5844.         sparc*)
  5845.             [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  5846.         ;;
  5847.         tile*)
  5848.             echo tile
  5849.         ;;
  5850.         vax*)
  5851.             echo vax
  5852.         ;;
  5853.         x86_64*freebsd*)
  5854.             echo amd64
  5855.         ;;
  5856.         x86_64*)
  5857.             if [[ ${type} == "kern" ]]; then
  5858.                 echo x86;
  5859.             else
  5860.                 echo amd64;
  5861.             fi
  5862.         ;;
  5863.         xtensa*)
  5864.             echo xtensa
  5865.         ;;
  5866.         *)
  5867.             echo unknown
  5868.         ;;
  5869.     esac
  5870. }
  5871. tc-stack-grows-down ()
  5872. {
  5873.     case ${ARCH} in
  5874.         hppa | metag)
  5875.             return 1
  5876.         ;;
  5877.     esac;
  5878.     return 0
  5879. }
  5880. tc-tuple-is-softfloat ()
  5881. {
  5882.     local CTARGET=${CTARGET:-${CHOST}};
  5883.     case ${CTARGET//_/-} in
  5884.         bfin* | h8300*)
  5885.             echo "only"
  5886.         ;;
  5887.         *-softfloat-*)
  5888.             echo "yes"
  5889.         ;;
  5890.         *-softfp-*)
  5891.             echo "softfp"
  5892.         ;;
  5893.         arm*-hardfloat-* | arm*eabihf)
  5894.             echo "no"
  5895.         ;;
  5896.         *-newlib | *-elf | *-eabi)
  5897.             echo "no"
  5898.         ;;
  5899.         arm*)
  5900.             echo "yes"
  5901.         ;;
  5902.         *)
  5903.             echo "no"
  5904.         ;;
  5905.     esac
  5906. }
  5907. test-flag-CC ()
  5908. {
  5909.     test-flag-PROG "CC" c "$@"
  5910. }
  5911. test-flag-CXX ()
  5912. {
  5913.     test-flag-PROG "CXX" c++ "$@"
  5914. }
  5915. test-flag-F77 ()
  5916. {
  5917.     test-flag-PROG "F77" f77 "$@"
  5918. }
  5919. test-flag-FC ()
  5920. {
  5921.     test-flag-PROG "FC" f95 "$@"
  5922. }
  5923. test-flag-PROG ()
  5924. {
  5925.     local comp=$1;
  5926.     local lang=$2;
  5927.     shift 2;
  5928.     [[ -z ${comp} || -z $1 ]] && return 1;
  5929.     local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  5930.     if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  5931.         cmdline+=("$@" -x${lang} -);
  5932.     else
  5933.         cmdline+=("$@" -c -o /dev/null /dev/null);
  5934.     fi;
  5935.     if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  5936.         cmdline+=(-Qunused-arguments);
  5937.         "${cmdline[@]}" < /dev/null &> /dev/null;
  5938.     fi
  5939. }
  5940. test-flags ()
  5941. {
  5942.     test-flags-CC "$@"
  5943. }
  5944. test-flags-CC ()
  5945. {
  5946.     test-flags-PROG "CC" "$@"
  5947. }
  5948. test-flags-CXX ()
  5949. {
  5950.     test-flags-PROG "CXX" "$@"
  5951. }
  5952. test-flags-F77 ()
  5953. {
  5954.     test-flags-PROG "F77" "$@"
  5955. }
  5956. test-flags-FC ()
  5957. {
  5958.     test-flags-PROG "FC" "$@"
  5959. }
  5960. test-flags-PROG ()
  5961. {
  5962.     local comp=$1;
  5963.     local flags=();
  5964.     local x;
  5965.     shift;
  5966.     [[ -z ${comp} ]] && return 1;
  5967.     while (( $# )); do
  5968.         case "$1" in
  5969.             --param)
  5970.                 if test-flag-${comp} "$1" "$2"; then
  5971.                     flags+=("$1" "$2");
  5972.                 fi;
  5973.                 shift 2
  5974.             ;;
  5975.             *)
  5976.                 if test-flag-${comp} "$1"; then
  5977.                     flags+=("$1");
  5978.                 fi;
  5979.                 shift 1
  5980.             ;;
  5981.         esac;
  5982.     done;
  5983.     echo "${flags[*]}";
  5984.     [[ ${#flags[@]} -gt 0 ]]
  5985. }
  5986. test_version_info ()
  5987. {
  5988.     if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  5989.         return 0;
  5990.     else
  5991.         return 1;
  5992.     fi
  5993. }
  5994. treecopy ()
  5995. {
  5996.     local dest=${!#};
  5997.     local files_count=$#;
  5998.     while (( $# > 1 )); do
  5999.         local dirstruct=$(dirname "$1");
  6000.         mkdir -p "${dest}/${dirstruct}" || die;
  6001.         cp -pPR "$1" "${dest}/${dirstruct}" || die;
  6002.         shift;
  6003.     done
  6004. }
  6005. use_if_iuse ()
  6006. {
  6007.     in_iuse $1 || return 1;
  6008.     use $1
  6009. }
  6010. ver_cut ()
  6011. {
  6012.     local range=${1};
  6013.     local v=${2:-${PV}};
  6014.     local start end;
  6015.     local -a comp;
  6016.     _ver_split "${v}";
  6017.     local max=$((${#comp[@]}/2));
  6018.     _ver_parse_range "${range}" "${max}";
  6019.     if [[ ${start} -gt 0 ]]; then
  6020.         start=$(( start*2 - 1 ));
  6021.     fi;
  6022.     printf "%s" "${comp[@]:start:end*2-start}" '
  6023. '
  6024. }
  6025. ver_rs ()
  6026. {
  6027.     local v;
  6028.     (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  6029.     local start end i;
  6030.     local -a comp;
  6031.     _ver_split "${v}";
  6032.     local max=$((${#comp[@]}/2 - 1));
  6033.     while [[ ${#} -ge 2 ]]; do
  6034.         _ver_parse_range "${1}" "${max}";
  6035.         for ((i = start*2; i <= end*2; i+=2 ))
  6036.         do
  6037.             [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  6038.             comp[i]=${2};
  6039.         done;
  6040.         shift 2;
  6041.     done;
  6042.     local IFS=;
  6043.     echo "${comp[*]}"
  6044. }
  6045. ver_test ()
  6046. {
  6047.     local va op vb;
  6048.     if [[ $# -eq 3 ]]; then
  6049.         va=${1};
  6050.         shift;
  6051.     else
  6052.         va=${PVR};
  6053.     fi;
  6054.     [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  6055.     op=${1};
  6056.     vb=${2};
  6057.     case ${op} in
  6058.         -eq | -ne | -lt | -le | -gt | -ge)
  6059.  
  6060.         ;;
  6061.         *)
  6062.             die "${FUNCNAME}: invalid operator: ${op}"
  6063.         ;;
  6064.     esac;
  6065.     _ver_compare "${va}" "${vb}";
  6066.     test $? "${op}" 2
  6067. }
  6068. xdg_desktop_database_update ()
  6069. {
  6070.     local updater="${EROOT%/}${DESKTOP_DATABASE_UPDATE_BIN}";
  6071.     if [[ ${EBUILD_PHASE} != post* ]]; then
  6072.         die "xdg_desktop_database_update must be used in pkg_post* phases.";
  6073.     fi;
  6074.     if [[ ! -x "${updater}" ]]; then
  6075.         debug-print "${updater} is not executable";
  6076.         return;
  6077.     fi;
  6078.     ebegin "Updating .desktop files database";
  6079.     "${updater}" -q "${EROOT%/}${DESKTOP_DATABASE_DIR}";
  6080.     eend $?
  6081. }
  6082. xdg_environment_reset ()
  6083. {
  6084.     export XDG_DATA_HOME="${HOME}/.local/share";
  6085.     export XDG_CONFIG_HOME="${HOME}/.config";
  6086.     export XDG_CACHE_HOME="${HOME}/.cache";
  6087.     export XDG_RUNTIME_DIR="${T}/run";
  6088.     mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_RUNTIME_DIR}" || die;
  6089.     chmod 0700 "${XDG_RUNTIME_DIR}" || die;
  6090.     unset DBUS_SESSION_BUS_ADDRESS
  6091. }
  6092. xdg_mimeinfo_database_update ()
  6093. {
  6094.     local updater="${EROOT%/}${MIMEINFO_DATABASE_UPDATE_BIN}";
  6095.     if [[ ${EBUILD_PHASE} != post* ]]; then
  6096.         die "xdg_mimeinfo_database_update must be used in pkg_post* phases.";
  6097.     fi;
  6098.     if [[ ! -x "${updater}" ]]; then
  6099.         debug-print "${updater} is not executable";
  6100.         return;
  6101.     fi;
  6102.     ebegin "Updating shared mime info database";
  6103.     "${updater}" "${EROOT%/}${MIMEINFO_DATABASE_DIR}";
  6104.     eend $?
  6105. }
Add Comment
Please, Sign In to add comment