Advertisement
Guest User

Untitled

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