Advertisement
Guest User

/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/enviro

a guest
Jan 6th, 2017
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 238.45 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_X86="64"
  3. declare -x ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci"
  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 -- BASE_EXPF="src_unpack src_compile src_install src_prepare src_configure"
  8. declare -x BLENDERDIR="/usr/local/blender1.70_Linux_i386_libc6-dyn/"
  9. declare -x BOOTSTRAP_USE="cxx unicode internal-glib python_targets_python3_4 python_targets_python2_7 multilib"
  10. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
  11. declare -x CAMERAS="ptp2"
  12. declare -x CBUILD="x86_64-pc-linux-gnu"
  13. declare -x CC="x86_64-pc-linux-gnu-gcc"
  14. declare -x CFLAGS="-march=native -O2"
  15. declare -x CFLAGS_amd64="-m64"
  16. declare -x CFLAGS_default
  17. declare -x CFLAGS_x32="-mx32"
  18. declare -x CFLAGS_x86="-m32"
  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 -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  25. declare -x COLORFGBG="15;0"
  26. declare -x CPU_FLAGS_X86="mmx sse sse2 mmxext"
  27. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  28. declare -x CVSROOT=":pserver:cvs@tor:/cvs"
  29. declare -x CXX="x86_64-pc-linux-gnu-g++"
  30. declare -x CXXFLAGS="-march=native -O2"
  31. declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-7CTG8bvbyW,guid=459d72670c1690d0de64cbc6586ebcf1"
  32. declare -x DEFAULT_ABI="amd64"
  33. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare setup unpack"
  34. declare DEPEND="!app-emulation/virtualbox-bin
  35. ~app-emulation/virtualbox-modules-4.3.38
  36. dev-libs/libIDL
  37. >=dev-libs/libxslt-1.1.19
  38. net-misc/curl
  39. !libressl? ( dev-libs/openssl:0= )
  40. libressl? ( dev-libs/libressl:= )
  41. dev-libs/libxml2
  42. media-libs/libpng:0=
  43. media-libs/libvpx:0=
  44. sys-libs/zlib
  45. !headless? (
  46. qt4? (
  47. dev-qt/qtgui:4
  48. dev-qt/qtcore:4
  49. opengl? ( dev-qt/qtopengl:4 )
  50. x11-libs/libXinerama
  51. )
  52. opengl? ( virtual/opengl media-libs/freeglut )
  53. x11-libs/libX11
  54. x11-libs/libXcursor
  55. x11-libs/libXext
  56. x11-libs/libXmu
  57. x11-libs/libXt
  58. media-libs/libsdl:0[X,video]
  59. )
  60.  
  61. java? ( >=virtual/jre-1.6:= )
  62. udev? ( >=virtual/udev-171 )
  63. vnc? ( >=net-libs/libvncserver-0.9.9 )
  64. >=dev-util/kbuild-0.1.9998_pre20131130
  65. >=dev-lang/yasm-0.6.2
  66. sys-devel/bin86
  67. sys-power/iasl
  68. pam? ( sys-libs/pam )
  69. sys-libs/libcap
  70. doc? (
  71. dev-texlive/texlive-basic
  72. dev-texlive/texlive-latex
  73. dev-texlive/texlive-latexrecommended
  74. dev-texlive/texlive-latexextra
  75. dev-texlive/texlive-fontsrecommended
  76. dev-texlive/texlive-fontsextra
  77. )
  78. java? ( >=virtual/jre-1.6:= )
  79. virtual/pkgconfig
  80. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  81. !headless? ( x11-libs/libXinerama )
  82. pulseaudio? ( media-sound/pulseaudio )
  83. vboxwebsrv? ( net-libs/gsoap[-gnutls(-)] )
  84. >=dev-lang/python-2.7.5-r2:2.7 >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),python_single_target_python2_7(+)] java? ( >=dev-java/java-config-2.2.0-r3 ) virtual/pkgconfig"
  85. declare DESCRIPTION="Family of powerful x86 virtualization products for enterprise and home use"
  86. declare -x DESKTOP_SESSION="/usr/share/xsessions/plasma"
  87. declare -x DESTTREE="/usr"
  88. declare -x DIROPTIONS="-m0755"
  89. declare -x EAPI="5"
  90. declare -- EBUILD_DEATH_HOOKS=" java-pkg_die"
  91. declare -x ELIBC="glibc"
  92. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  93. declare -- EPATCH_EXCLUDE="050_virtualbox-4.3.14-nopie.patch"
  94. declare -- EPATCH_FORCE="no"
  95. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  96. declare -- EPATCH_N_APPLIED_PATCHES="8"
  97. declare -- EPATCH_OPTS=""
  98. declare -- EPATCH_SINGLE_MSG=""
  99. declare -- EPATCH_SOURCE="/var/tmp/portage/app-emulation/virtualbox-4.3.38/work/patch"
  100. declare -- EPATCH_SUFFIX="patch.bz2"
  101. declare -- EPATCH_USER_SOURCE="/etc/portage/patches"
  102. declare -x EPYTHON="python2.7"
  103. declare -x EXEOPTIONS="-m0755"
  104. declare -x FCFLAGS="-O2 -pipe"
  105. 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}\""
  106. declare -x FFLAGS="-O2 -pipe"
  107. declare -x GCC_SPECS=""
  108. declare -x GIA_ARCH="linux"
  109. declare -x GIT_EDITOR="vim"
  110. 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"
  111. declare -x GRUB_PLATFORMS=""
  112. declare -x GSETTINGS_BACKEND="dconf"
  113. declare -x GS_LIB="/home/daf/.fonts"
  114. declare -x GTK2_RC_FILES="/etc/gtk-2.0/gtkrc:/home/daf/.gtkrc-2.0:/home/daf/.config/gtkrc-2.0"
  115. declare -x GTK_MODULES="canberra-gtk-module"
  116. declare -x GTK_RC_FILES="/etc/gtk/gtkrc:/home/daf/.gtkrc:/home/daf/.config/gtkrc"
  117. declare -x GUILE_LOAD_PATH="/usr/share/guile/1.8"
  118. declare HDEPEND=""
  119. declare HOMEPAGE="http://www.virtualbox.org/"
  120. declare -x HOST_CC="x86_64-pc-linux-gnu-gcc"
  121. declare -x INHERITED=" multilib toolchain-funcs eutils fdo-mime flag-o-matic versionator java-utils-2 java-pkg-opt-2 linux-info pax-utils python-utils-r1 python-single-r1 base qmake-utils qt4-r2 udev"
  122. declare -x INPUT_DEVICES="keyboard mouse evdev"
  123. declare -x INSDESTTREE=""
  124. declare -x INSOPTIONS="-m0644"
  125. declare IUSE="+additions alsa doc extensions headless java libressl pam pulseaudio +opengl python +qt4 +sdk +udev vboxwebsrv vnc elibc_FreeBSD java python_targets_python2_7"
  126. declare -x IUSE_EFFECTIVE="abi_x86_64 additions alpha alsa amd64 amd64-fbsd amd64-linux arm arm-linux arm64 doc 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 extensions headless hppa hppa-hpux ia64 ia64-hpux ia64-linux java kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_Interix kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux libressl m68k m68k-mint mips nios2 opengl pam ppc ppc-aix ppc-macos ppc-openbsd ppc64 ppc64-linux prefix prefix-guest pulseaudio python python_targets_python2_7 qt4 riscv s390 sdk sh sparc sparc-fbsd sparc-solaris sparc64-freebsd sparc64-solaris udev userland_BSD userland_GNU vboxwebsrv vnc 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"
  127. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest"
  128. declare -- JAVA_PKG_ALLOW_VM_CHANGE="yes"
  129. declare -- JAVA_PKG_BUILD_DEPEND_FILE="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/java-pkg-build-depend"
  130. declare -- JAVA_PKG_COMPILERS_CONF="/etc/java-config-2/build/compilers.conf"
  131. declare -- JAVA_PKG_COMPILER_DIR="/usr/share/java-config-2/compiler"
  132. declare -- JAVA_PKG_DEPEND_FILE="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/java-pkg-depend"
  133. declare -- JAVA_PKG_EXTRA_ENV="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/java-pkg-extra-env"
  134. declare -- JAVA_PKG_EXTRA_ENV_VARS=""
  135. declare -- JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3 "
  136. declare -- JAVA_PKG_OPTIONAL_DEPEND_FILE="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/java-pkg-optional-depend"
  137. declare -- JAVA_PKG_OPT_USE="java"
  138. declare -- JAVA_PKG_QA_VIOLATIONS="0"
  139. declare -x KDE_FULL_SESSION="true"
  140. declare -x KDE_MULTIHEAD="false"
  141. declare -x KDE_SESSION_UID="1000"
  142. declare -x KDE_SESSION_VERSION="5"
  143. declare -x KERNEL="linux"
  144. declare -x KERNEL_ABI="amd64"
  145. declare -- KERNEL_DIR="/usr/src/linux"
  146. declare -x KEYWORDS="amd64 x86"
  147. declare -x KONSOLE_DBUS_SERVICE=":1.58"
  148. declare -x KONSOLE_DBUS_SESSION="/Sessions/7"
  149. declare -x KONSOLE_DBUS_WINDOW="/Windows/6"
  150. declare -x KONSOLE_PROFILE_NAME="default"
  151. declare -x LADSPA_PATH="/usr/lib64/ladspa"
  152. declare -x LANG="en_US.utf8"
  153. declare -x LANGUAGE=""
  154. declare -x LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
  155. declare -x LC_ALL="C"
  156. declare -x LC_MESSAGES="C"
  157. declare -x LC_TIME="en_ZA.UTF-8"
  158. declare -x LD="x86_64-pc-linux-gnu-ld"
  159. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  160. declare -x LDFLAGS_amd64="-m elf_x86_64"
  161. declare -x LDFLAGS_default
  162. declare -x LDFLAGS_x32="-m elf32_x86_64"
  163. declare -x LDFLAGS_x86="-m elf_i386"
  164. declare -x LIBDIR_amd64="lib64"
  165. declare -x LIBDIR_amd64_fbsd="lib64"
  166. declare -x LIBDIR_arm="lib"
  167. declare -x LIBDIR_arm64="lib64"
  168. declare -x LIBDIR_default="lib"
  169. declare -x LIBDIR_n32="lib32"
  170. declare -x LIBDIR_n64="lib64"
  171. declare -x LIBDIR_o32="lib"
  172. declare -x LIBDIR_ppc="lib32"
  173. declare -x LIBDIR_ppc64="lib64"
  174. declare -x LIBDIR_s390="lib32"
  175. declare -x LIBDIR_s390x="lib64"
  176. declare -x LIBDIR_sparc32="lib32"
  177. declare -x LIBDIR_sparc64="lib64"
  178. declare -x LIBDIR_x32="libx32"
  179. declare -x LIBDIR_x86="lib32"
  180. declare -x LIBDIR_x86_fbsd="lib32"
  181. declare -x LIBOPTIONS="-m0644"
  182. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  183. declare -x LICENSE="GPL-2"
  184. declare -x LIGHTFLOWPATH="/root/dl/lightflow/Lightflow"
  185. declare -x MAIL="/var/mail/daf"
  186. declare -x MAKEOPTS="-j7"
  187. declare -x MANPAGER="manpager"
  188. declare -x MOZILLA_FIVE_HOME="/usr/lib/mozilla"
  189. declare -x MPEGTABLES="/root/lib/tables"
  190. declare -x MULTILIB_ABIS="amd64 x86"
  191. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  192. 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"
  193. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec)"
  194. declare -x MULTIOSDIRS="../lib64:../lib32"
  195. declare -- MY_P="VirtualBox-4.3.38"
  196. declare -- MY_PV="4.3.38"
  197. declare -x NDS_LDEV_DIR="/root/ldev"
  198. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  199. declare -x NODE_PATH="/usr/local/lib/node_modules"
  200. declare -x OFFICE_IMPLEMENTATION="libreoffice"
  201. declare -x OPENCL_PROFILE="nvidia"
  202. declare -x OPENGL_PROFILE="nvidia"
  203. declare -x PATH="/var/tmp/portage/app-emulation/virtualbox-4.3.38/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/4.9.4"
  204. declare -- PAX_MARKINGS="PT XT"
  205. declare PDEPEND="additions? ( ~app-emulation/virtualbox-additions-4.3.38 )
  206. extensions? ( =app-emulation/virtualbox-extpack-oracle-4.3.38* ) "
  207. declare -x PHP_TARGETS="php5-6"
  208. declare -x PILOTRATE="38400"
  209. declare -x PKG_CONFIG_PATH="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp/python2.7/pkgconfig"
  210. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  211. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  212. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/virtualbox-4.3.38/html")'
  213. declare -x PORTAGE_NICENESS="19"
  214. declare -x PROFILEHOME=""
  215. 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"
  216. declare -x PROPERTIES=""
  217. declare -x PROVIDE=""
  218. declare -x PYTHON="/usr/bin/python2.7"
  219. declare -x PYTHONDOCS_2_7="/usr/share/doc/python-docs-2.7.10/html/library"
  220. declare -x PYTHONDONTWRITEBYTECODE="1"
  221. declare -x PYTHONSTARTUP="/root/.pythonrc"
  222. declare -a PYTHON_COMPAT='([0]="python2_7")'
  223. declare -- PYTHON_DEPS=">=dev-lang/python-2.7.5-r2:2.7 >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),python_single_target_python2_7(+)]"
  224. declare -- PYTHON_REQUIRED_USE="python_targets_python2_7"
  225. declare -x PYTHON_SINGLE_TARGET="python2_7"
  226. declare -x PYTHON_TARGETS="python2_7"
  227. declare -- PYTHON_USEDEP="python_targets_python2_7(-)?,-python_single_target_jython2_7(-),-python_single_target_pypy(-),-python_single_target_pypy3(-),-python_single_target_python3_4(-),-python_single_target_python3_5(-),python_single_target_python2_7(+)"
  228. declare -- QA_TEXTRELS_x86="usr/lib/virtualbox-ose/VBoxGuestPropSvc.so
  229. usr/lib/virtualbox/VBoxSDL.so
  230. usr/lib/virtualbox/VBoxSharedFolders.so
  231. usr/lib/virtualbox/VBoxDD2.so
  232. usr/lib/virtualbox/VBoxOGLrenderspu.so
  233. usr/lib/virtualbox/VBoxPython.so
  234. usr/lib/virtualbox/VBoxDD.so
  235. usr/lib/virtualbox/VBoxDDU.so
  236. usr/lib/virtualbox/VBoxREM64.so
  237. usr/lib/virtualbox/VBoxSharedClipboard.so
  238. usr/lib/virtualbox/VBoxHeadless.so
  239. usr/lib/virtualbox/VBoxRT.so
  240. usr/lib/virtualbox/VBoxREM.so
  241. usr/lib/virtualbox/VBoxSettings.so
  242. usr/lib/virtualbox/VBoxKeyboard.so
  243. usr/lib/virtualbox/VBoxSharedCrOpenGL.so
  244. usr/lib/virtualbox/VBoxVMM.so
  245. usr/lib/virtualbox/VirtualBox.so
  246. usr/lib/virtualbox/VBoxOGLhosterrorspu.so
  247. usr/lib/virtualbox/components/VBoxC.so
  248. usr/lib/virtualbox/components/VBoxSVCM.so
  249. usr/lib/virtualbox/components/VBoxDDU.so
  250. usr/lib/virtualbox/components/VBoxRT.so
  251. usr/lib/virtualbox/components/VBoxREM.so
  252. usr/lib/virtualbox/components/VBoxVMM.so
  253. usr/lib/virtualbox/VBoxREM32.so
  254. usr/lib/virtualbox/VBoxPython2_4.so
  255. usr/lib/virtualbox/VBoxPython2_5.so
  256. usr/lib/virtualbox/VBoxPython2_6.so
  257. usr/lib/virtualbox/VBoxPython2_7.so
  258. usr/lib/virtualbox/VBoxXPCOMC.so
  259. usr/lib/virtualbox/VBoxOGLhostcrutil.so
  260. usr/lib/virtualbox/VBoxNetDHCP.so
  261. usr/lib/virtualbox/VBoxNetNAT.so"
  262. declare -x QT_AUTO_SCREEN_SCALE_FACTOR="0"
  263. declare -x QT_GRAPHICSSYSTEM="raster"
  264. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins"
  265. declare -x RANLIB="x86_64-pc-linux-gnu-ranlib"
  266. declare RDEPEND="!app-emulation/virtualbox-bin
  267. ~app-emulation/virtualbox-modules-4.3.38
  268. dev-libs/libIDL
  269. >=dev-libs/libxslt-1.1.19
  270. net-misc/curl
  271. !libressl? ( dev-libs/openssl:0= )
  272. libressl? ( dev-libs/libressl:= )
  273. dev-libs/libxml2
  274. media-libs/libpng:0=
  275. media-libs/libvpx:0=
  276. sys-libs/zlib
  277. !headless? (
  278. qt4? (
  279. dev-qt/qtgui:4
  280. dev-qt/qtcore:4
  281. opengl? ( dev-qt/qtopengl:4 )
  282. x11-libs/libXinerama
  283. )
  284. opengl? ( virtual/opengl media-libs/freeglut )
  285. x11-libs/libX11
  286. x11-libs/libXcursor
  287. x11-libs/libXext
  288. x11-libs/libXmu
  289. x11-libs/libXt
  290. media-libs/libsdl:0[X,video]
  291. )
  292.  
  293. java? ( >=virtual/jre-1.6:= )
  294. udev? ( >=virtual/udev-171 )
  295. vnc? ( >=net-libs/libvncserver-0.9.9 ) java? ( >=dev-java/java-config-2.2.0-r3 ) "
  296. declare REPOSITORY
  297. declare REQUIRED_USE="
  298. java? ( sdk )
  299. python? (
  300. ( sdk )
  301. )
  302. vboxwebsrv? ( java )
  303. python_targets_python2_7
  304. "
  305. declare -x RESTRICT=""
  306. 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}\""
  307. declare -x RUBY_TARGETS="ruby21"
  308. declare -x S="/var/tmp/portage/app-emulation/virtualbox-4.3.38/work/VirtualBox-4.3.38"
  309. declare -x SANDBOX_DEBUG="0"
  310. declare -x SANDBOX_DENY=""
  311. declare -x SANDBOX_PREDICT="/var/tmp/portage/app-emulation/virtualbox-4.3.38/homedir:/dev/crypto:/var/cache/fontconfig"
  312. declare -x SANDBOX_READ="/:/var/tmp"
  313. declare -x SANDBOX_VERBOSE="1"
  314. 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/app-emulation/virtualbox-4.3.38/homedir/.bash_history"
  315. declare -x SESSION_MANAGER="local/nea:@/tmp/.ICE-unix/4580,unix/nea:/tmp/.ICE-unix/4580"
  316. declare -x SHELL="/bin/zsh"
  317. declare -x SHELL_SESSION_ID="8ef954531753400093fe494c70fda1d4"
  318. declare -x SLOT="0"
  319. declare SRC_URI="http://download.virtualbox.org/virtualbox/4.3.38/VirtualBox-4.3.38.tar.bz2
  320. https://dev.gentoo.org/~polynomial-c/virtualbox/patchsets/virtualbox-4.3.16-patches-01.tar.xz"
  321. declare -x SSH_ASKPASS="/usr/bin/ksshaskpass"
  322. declare -x STEAM_FRAME_FORCE_CLOSE="1"
  323. declare -x SVN_EDITOR="vim"
  324. declare -x SYMLINK_LIB="yes"
  325. declare -x USE="abi_x86_64 amd64 elibc_glibc kernel_linux python_targets_python2_7 qt4 userland_GNU"
  326. declare -x USERLAND="GNU"
  327. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  328. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  329. 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"
  330. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  331. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
  332. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  333. declare -x VIDEO_CARDS="nvidia nouveau"
  334. declare -x WANT_JAVA_CONFIG="2"
  335. declare -x WINDOWID="79691837"
  336. declare -x X11HOME="/usr/X11R6"
  337. declare -x XCURSOR_THEME="breeze_cursors"
  338. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  339. declare -x XDG_CONFIG_HOME="/var/tmp/portage/app-emulation/virtualbox-4.3.38/temp"
  340. declare -x XDG_CURRENT_DESKTOP="KDE"
  341. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  342. declare -x XDG_RUNTIME_DIR="/var/run/user/1000"
  343. declare -x XDG_SEAT="seat0"
  344. declare -x XDG_SEAT_PATH="/org/freedesktop/DisplayManager/Seat0"
  345. declare -x XDG_SESSION_CLASS="user"
  346. declare -x XDG_SESSION_COOKIE="nea-1483652340.963238-601008492"
  347. declare -x XDG_SESSION_DESKTOP="KDE"
  348. declare -x XDG_SESSION_PATH="/org/freedesktop/DisplayManager/Session0"
  349. declare -x XDG_SESSION_TYPE="x11"
  350. declare -x XDG_VTNR="7"
  351. 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"
  352. declare -- _BASE_ECLASS="1"
  353. declare -a _ESTACK_eshopts_='()'
  354. declare -a _ESTACK_evar_='()'
  355. declare -- _EUTILS_ECLASS="1"
  356. declare -- _EUTILS_ECLASSDIR_LOCAL="/usr/portage/eclass"
  357. declare -x _E_DOCDESTTREE_=""
  358. declare -x _E_EXEDESTTREE_=""
  359. declare -- _FLAG_O_MATIC_ECLASS="1"
  360. declare -- _LINUX_CONFIG_EXISTS_DONE=""
  361. declare -- _MULTILIB_ECLASS="1"
  362. declare -- _PAX_UTILS_ECLASS="1"
  363. declare -a _PYTHON_ALL_IMPLS='([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_4" [5]="python3_5")'
  364. declare -- _PYTHON_SINGLE_R1="1"
  365. declare -a _PYTHON_SUPPORTED_IMPLS='([0]="python2_7")'
  366. declare -a _PYTHON_UNSUPPORTED_IMPLS='([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python3_4" [4]="python3_5")'
  367. declare -- _PYTHON_UTILS_R1="1"
  368. declare -- _QMAKE_UTILS_ECLASS="1"
  369. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  370. declare -- _VERSIONATOR_ECLASS="1"
  371. declare -- get_version_warning_done=""
  372. declare -- phase_func
  373. PYTHON ()
  374. {
  375. 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"
  376. }
  377. __eapi6_src_install ()
  378. {
  379. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  380. emake DESTDIR="${D}" install;
  381. fi;
  382. einstalldocs
  383. }
  384. __eapi6_src_prepare ()
  385. {
  386. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  387. [[ -n ${PATCHES[@]} ]] && eapply "${PATCHES[@]}";
  388. else
  389. if [[ -n ${PATCHES} ]]; then
  390. eapply ${PATCHES};
  391. fi;
  392. fi;
  393. eapply_user
  394. }
  395. _clang_fullversion ()
  396. {
  397. local ver="$1";
  398. shift;
  399. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  400. eval echo "$ver"
  401. }
  402. _epatch_draw_line ()
  403. {
  404. [[ -z $1 ]] && set "$(printf "%65s" '')";
  405. echo "${1//?/=}"
  406. }
  407. _eutils_eprefix_init ()
  408. {
  409. has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
  410. }
  411. _filter-hardened ()
  412. {
  413. local f;
  414. for f in "$@";
  415. do
  416. case "${f}" in
  417. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  418. gcc-specs-pie || continue;
  419. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  420. if test-flags -nopie > /dev/null; then
  421. append-flags -nopie;
  422. else
  423. append-flags -no-pie;
  424. fi;
  425. fi
  426. ;;
  427. -fstack-protector)
  428. gcc-specs-ssp || continue;
  429. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  430. ;;
  431. -fstack-protector-all)
  432. gcc-specs-ssp-to-all || continue;
  433. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  434. ;;
  435. -fno-strict-overflow)
  436. gcc-specs-nostrict || continue;
  437. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  438. ;;
  439. esac;
  440. done
  441. }
  442. _filter-var ()
  443. {
  444. local f x var=$1 new=();
  445. shift;
  446. for f in ${!var};
  447. do
  448. for x in "$@";
  449. do
  450. [[ ${f} == ${x} ]] && continue 2;
  451. done;
  452. new+=("${f}");
  453. done;
  454. eval export ${var}=\""${new[*]}"\"
  455. }
  456. _gcc-install-dir ()
  457. {
  458. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  459. }
  460. _gcc-specs-directive_raw ()
  461. {
  462. local cc=$(tc-getCC);
  463. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  464. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  465. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  466. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  467. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  468. { spec=spec $0 }
  469. END { print spec }';
  470. return 0
  471. }
  472. _gcc-specs-exists ()
  473. {
  474. [[ -f $(_gcc-install-dir)/$1 ]]
  475. }
  476. _gcc_fullversion ()
  477. {
  478. local ver="$1";
  479. shift;
  480. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  481. eval echo "$ver"
  482. }
  483. _iconins ()
  484. {
  485. ( local funcname=$1;
  486. shift;
  487. local size dir;
  488. local context=apps;
  489. local theme=hicolor;
  490. while [[ $# -gt 0 ]]; do
  491. case $1 in
  492. -s | --size)
  493. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  494. size=${2%%x*};
  495. else
  496. size=${2};
  497. fi;
  498. case ${size} in
  499. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  500. size=${size}x${size}
  501. ;;
  502. scalable)
  503.  
  504. ;;
  505. *)
  506. eerror "${size} is an unsupported icon size!";
  507. exit 1
  508. ;;
  509. esac;
  510. shift 2
  511. ;;
  512. -t | --theme)
  513. theme=${2};
  514. shift 2
  515. ;;
  516. -c | --context)
  517. context=${2};
  518. shift 2
  519. ;;
  520. *)
  521. if [[ -z ${size} ]]; then
  522. insinto /usr/share/pixmaps;
  523. else
  524. insinto /usr/share/icons/${theme}/${size}/${context};
  525. fi;
  526. if [[ ${funcname} == doicon ]]; then
  527. if [[ -f $1 ]]; then
  528. doins "${1}";
  529. else
  530. if [[ -d $1 ]]; then
  531. shopt -s nullglob;
  532. doins "${1}"/*.{png,svg};
  533. shopt -u nullglob;
  534. else
  535. eerror "${1} is not a valid file/directory!";
  536. exit 1;
  537. fi;
  538. fi;
  539. else
  540. break;
  541. fi;
  542. shift 1
  543. ;;
  544. esac;
  545. done;
  546. if [[ ${funcname} == newicon ]]; then
  547. newins "$@";
  548. fi ) || die
  549. }
  550. _is_flagq ()
  551. {
  552. local x var;
  553. eval var=\""\${$1[*]}"\";
  554. for x in ${var};
  555. do
  556. [[ ${x} == $2 ]] && return 0;
  557. done;
  558. return 1
  559. }
  560. _pax_list_files ()
  561. {
  562. local f cmd;
  563. cmd=$1;
  564. shift;
  565. for f in "$@";
  566. do
  567. ${cmd} " ${f}";
  568. done
  569. }
  570. _python_check_dead_variables ()
  571. {
  572. local v;
  573. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  574. do
  575. if [[ -n ${!v} ]]; then
  576. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  577. fi;
  578. done;
  579. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  580. do
  581. if [[ -n ${!v} ]]; then
  582. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  583. fi;
  584. done;
  585. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  586. do
  587. if [[ -n ${!v} ]]; then
  588. die "${v} is invalid for python-r1 suite";
  589. fi;
  590. done;
  591. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  592. do
  593. if [[ -n ${!v} ]]; then
  594. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  595. fi;
  596. done;
  597. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  598. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  599. fi;
  600. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  601. do
  602. if [[ -n ${!v} ]]; then
  603. die "${v} is invalid for python-r1 suite";
  604. fi;
  605. done
  606. }
  607. _python_check_locale_sanity ()
  608. {
  609. local -x LC_ALL=${1};
  610. local IFS=;
  611. local lc=({a..z});
  612. local uc=({A..Z});
  613. local input="${lc[*]}${uc[*]}";
  614. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  615. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  616. }
  617. _python_impl_supported ()
  618. {
  619. debug-print-function ${FUNCNAME} "${@}";
  620. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  621. local impl=${1};
  622. case "${impl}" in
  623. python2_7 | python3_[45] | jython2_7)
  624. return 0
  625. ;;
  626. pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  627. return 1
  628. ;;
  629. pypy | pypy3)
  630. if [[ ${EAPI:-0} == [01234] ]]; then
  631. die "PyPy is supported in EAPI 5 and newer only.";
  632. fi
  633. ;;
  634. *)
  635. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  636. ;;
  637. esac
  638. }
  639. _python_ln_rel ()
  640. {
  641. debug-print-function ${FUNCNAME} "${@}";
  642. local target=${1};
  643. local symname=${2};
  644. local tgpath=${target%/*}/;
  645. local sympath=${symname%/*}/;
  646. local rel_target=;
  647. while [[ -n ${sympath} ]]; do
  648. local tgseg= symseg=;
  649. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  650. tgseg=${tgpath%%/*};
  651. tgpath=${tgpath#${tgseg}/};
  652. done;
  653. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  654. symseg=${sympath%%/*};
  655. sympath=${sympath#${symseg}/};
  656. done;
  657. if [[ ${tgseg} != ${symseg} ]]; then
  658. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  659. fi;
  660. done;
  661. rel_target+=${tgpath}${target##*/};
  662. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  663. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  664. ln -fs "${rel_target}" "${symname}"
  665. }
  666. _python_set_impls ()
  667. {
  668. local i;
  669. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  670. die 'PYTHON_COMPAT not declared.';
  671. fi;
  672. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  673. die 'PYTHON_COMPAT must be an array.';
  674. fi;
  675. for i in "${PYTHON_COMPAT[@]}";
  676. do
  677. _python_impl_supported "${i}";
  678. done;
  679. _PYTHON_SUPPORTED_IMPLS=();
  680. _PYTHON_UNSUPPORTED_IMPLS=();
  681. for i in "${_PYTHON_ALL_IMPLS[@]}";
  682. do
  683. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  684. _PYTHON_SUPPORTED_IMPLS+=("${i}");
  685. else
  686. _PYTHON_UNSUPPORTED_IMPLS+=("${i}");
  687. fi;
  688. done;
  689. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 0 ]]; then
  690. die "No supported implementation in PYTHON_COMPAT.";
  691. fi;
  692. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS
  693. }
  694. _tc-getPROG ()
  695. {
  696. local tuple=$1;
  697. local v var vars=$2;
  698. local prog=($3);
  699. var=${vars%% *};
  700. for v in ${vars};
  701. do
  702. if [[ -n ${!v} ]]; then
  703. export ${var}="${!v}";
  704. echo "${!v}";
  705. return 0;
  706. fi;
  707. done;
  708. local search=;
  709. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  710. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  711. [[ -n ${search} ]] && prog[0]=${search##*/};
  712. export ${var}="${prog[*]}";
  713. echo "${!var}"
  714. }
  715. _udev_get_udevdir ()
  716. {
  717. if $($(tc-getPKG_CONFIG) --exists udev); then
  718. echo "$($(tc-getPKG_CONFIG) --variable=udevdir udev)";
  719. else
  720. echo /lib/udev;
  721. fi
  722. }
  723. all-flag-vars ()
  724. {
  725. echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  726. }
  727. append-cflags ()
  728. {
  729. [[ $# -eq 0 ]] && return 0;
  730. export CFLAGS+=" $*";
  731. return 0
  732. }
  733. append-cppflags ()
  734. {
  735. [[ $# -eq 0 ]] && return 0;
  736. export CPPFLAGS+=" $*";
  737. return 0
  738. }
  739. append-cxxflags ()
  740. {
  741. [[ $# -eq 0 ]] && return 0;
  742. export CXXFLAGS+=" $*";
  743. return 0
  744. }
  745. append-fflags ()
  746. {
  747. [[ $# -eq 0 ]] && return 0;
  748. export FFLAGS+=" $*";
  749. export FCFLAGS+=" $*";
  750. return 0
  751. }
  752. append-flags ()
  753. {
  754. [[ $# -eq 0 ]] && return 0;
  755. case " $* " in
  756. *' '-[DIU]*)
  757. eqawarn 'please use append-cppflags for preprocessor flags'
  758. ;;
  759. *' '-L* | *' '-Wl,*)
  760. eqawarn 'please use append-ldflags for linker flags'
  761. ;;
  762. esac;
  763. append-cflags "$@";
  764. append-cxxflags "$@";
  765. append-fflags "$@";
  766. return 0
  767. }
  768. append-ldflags ()
  769. {
  770. [[ $# -eq 0 ]] && return 0;
  771. local flag;
  772. for flag in "$@";
  773. do
  774. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  775. done;
  776. export LDFLAGS="${LDFLAGS} $*";
  777. return 0
  778. }
  779. append-lfs-flags ()
  780. {
  781. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  782. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  783. }
  784. append-libs ()
  785. {
  786. [[ $# -eq 0 ]] && return 0;
  787. local flag;
  788. for flag in "$@";
  789. do
  790. if [[ -z "${flag// }" ]]; then
  791. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  792. continue;
  793. fi;
  794. case $flag in
  795. -[lL]*)
  796. export LIBS="${LIBS} ${flag}"
  797. ;;
  798. -*)
  799. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  800. export LIBS="${LIBS} ${flag}"
  801. ;;
  802. *)
  803. export LIBS="${LIBS} -l${flag}"
  804. ;;
  805. esac;
  806. done;
  807. return 0
  808. }
  809. base_src_compile ()
  810. {
  811. debug-print-function $FUNCNAME "$@";
  812. has src_configure ${BASE_EXPF} || base_src_configure;
  813. base_src_make "$@"
  814. }
  815. base_src_configure ()
  816. {
  817. debug-print-function $FUNCNAME "$@";
  818. [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
  819. }
  820. base_src_install ()
  821. {
  822. debug-print-function $FUNCNAME "$@";
  823. emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME";
  824. base_src_install_docs
  825. }
  826. base_src_install_docs ()
  827. {
  828. debug-print-function $FUNCNAME "$@";
  829. local x;
  830. pushd "${S}" > /dev/null;
  831. if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  832. for x in "${DOCS[@]}";
  833. do
  834. debug-print "$FUNCNAME: docs: creating document from ${x}";
  835. dodoc "${x}" || die "dodoc failed";
  836. done;
  837. fi;
  838. if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  839. for x in "${HTML_DOCS[@]}";
  840. do
  841. debug-print "$FUNCNAME: docs: creating html document from ${x}";
  842. dohtml -r "${x}" || die "dohtml failed";
  843. done;
  844. fi;
  845. popd > /dev/null
  846. }
  847. base_src_make ()
  848. {
  849. debug-print-function $FUNCNAME "$@";
  850. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  851. emake "$@" || die "died running emake, $FUNCNAME";
  852. fi
  853. }
  854. base_src_prepare ()
  855. {
  856. debug-print-function $FUNCNAME "$@";
  857. debug-print "$FUNCNAME: PATCHES=$PATCHES";
  858. local patches_failed=0;
  859. pushd "${S}" > /dev/null;
  860. if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  861. for x in "${PATCHES[@]}";
  862. do
  863. debug-print "$FUNCNAME: applying patch from ${x}";
  864. if [[ -d "${x}" ]]; then
  865. EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch};
  866. oldval=${EPATCH_SOURCE};
  867. EPATCH_SOURCE=${x};
  868. EPATCH_FORCE=yes;
  869. epatch;
  870. EPATCH_SOURCE=${oldval};
  871. else
  872. if [[ -f "${x}" ]]; then
  873. epatch "${x}";
  874. else
  875. ewarn "QA: File or directory \"${x}\" does not exist.";
  876. ewarn "QA: Check your PATCHES array or add missing file/directory.";
  877. patches_failed=1;
  878. fi;
  879. fi;
  880. done;
  881. [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages.";
  882. else
  883. for x in ${PATCHES};
  884. do
  885. debug-print "$FUNCNAME: patching from ${x}";
  886. epatch "${x}";
  887. done;
  888. fi;
  889. debug-print "$FUNCNAME: applying user patches";
  890. epatch_user;
  891. popd > /dev/null
  892. }
  893. base_src_unpack ()
  894. {
  895. debug-print-function $FUNCNAME "$@";
  896. pushd "${WORKDIR}" > /dev/null;
  897. if [[ $(type -t unpacker_src_unpack) == "function" ]]; then
  898. unpacker_src_unpack;
  899. else
  900. if [[ -n ${A} ]]; then
  901. unpack ${A};
  902. fi;
  903. fi;
  904. has src_prepare ${BASE_EXPF} || base_src_prepare;
  905. popd > /dev/null
  906. }
  907. built_with_use ()
  908. {
  909. _eutils_eprefix_init;
  910. local hidden="no";
  911. if [[ $1 == "--hidden" ]]; then
  912. hidden="yes";
  913. shift;
  914. fi;
  915. local missing_action="die";
  916. if [[ $1 == "--missing" ]]; then
  917. missing_action=$2;
  918. shift;
  919. shift;
  920. case ${missing_action} in
  921. true | false | die)
  922.  
  923. ;;
  924. *)
  925. die "unknown action '${missing_action}'"
  926. ;;
  927. esac;
  928. fi;
  929. local opt=$1;
  930. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  931. local PKG=$(best_version $1);
  932. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  933. shift;
  934. local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE;
  935. local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE;
  936. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  937. case ${missing_action} in
  938. true)
  939. return 0
  940. ;;
  941. false)
  942. return 1
  943. ;;
  944. die)
  945. die "Unable to determine what USE flags $PKG was built with"
  946. ;;
  947. esac;
  948. fi;
  949. if [[ ${hidden} == "no" ]]; then
  950. local IUSE_BUILT=($(<"${IUSEFILE}"));
  951. local expand;
  952. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  953. do
  954. if [[ $1 == ${expand}_* ]]; then
  955. expand="";
  956. break;
  957. fi;
  958. done;
  959. if [[ -n ${expand} ]]; then
  960. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  961. case ${missing_action} in
  962. true)
  963. return 0
  964. ;;
  965. false)
  966. return 1
  967. ;;
  968. die)
  969. die "$PKG does not actually support the $1 USE flag!"
  970. ;;
  971. esac;
  972. fi;
  973. fi;
  974. fi;
  975. local USE_BUILT=$(<${USEFILE});
  976. while [[ $# -gt 0 ]]; do
  977. if [[ ${opt} = "-o" ]]; then
  978. has $1 ${USE_BUILT} && return 0;
  979. else
  980. has $1 ${USE_BUILT} || return 1;
  981. fi;
  982. shift;
  983. done;
  984. [[ ${opt} = "-a" ]]
  985. }
  986. check_extra_config ()
  987. {
  988. local config negate die error reworkmodulenames;
  989. local soft_errors_count=0 hard_errors_count=0 config_required=0;
  990. local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  991. linux-info_get_any_version;
  992. for config in ${CONFIG_CHECK};
  993. do
  994. if [[ "${config:0:1}" != "~" ]]; then
  995. config_required=1;
  996. break;
  997. fi;
  998. done;
  999. if [[ ${config_required} == 0 ]]; then
  1000. if ! linux_config_exists; then
  1001. ewarn "Unable to check for the following kernel config options due";
  1002. ewarn "to absence of any configured kernel sources or compiled";
  1003. ewarn "config:";
  1004. for config in ${CONFIG_CHECK};
  1005. do
  1006. config=${config#\~};
  1007. config=${config#\!};
  1008. local_error="ERROR_${config}";
  1009. msg="${!local_error}";
  1010. if [[ -z ${msg} ]]; then
  1011. local_error="WARNING_${config}";
  1012. msg="${!local_error}";
  1013. fi;
  1014. ewarn " - ${config}${msg:+ - }${msg}";
  1015. done;
  1016. ewarn "You're on your own to make sure they are set if needed.";
  1017. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1018. return 0;
  1019. fi;
  1020. else
  1021. require_configured_kernel;
  1022. fi;
  1023. einfo "Checking for suitable kernel configuration options...";
  1024. for config in ${CONFIG_CHECK};
  1025. do
  1026. die=1;
  1027. error=0;
  1028. negate=0;
  1029. reworkmodulenames=0;
  1030. if [[ ${config:0:1} == "~" ]]; then
  1031. die=0;
  1032. config=${config:1};
  1033. else
  1034. if [[ ${config:0:1} == "@" ]]; then
  1035. die=0;
  1036. reworkmodulenames=1;
  1037. config=${config:1};
  1038. fi;
  1039. fi;
  1040. if [[ ${config:0:1} == "!" ]]; then
  1041. negate=1;
  1042. config=${config:1};
  1043. fi;
  1044. if [[ ${negate} == 1 ]]; then
  1045. linux_chkconfig_present ${config} && error=2;
  1046. else
  1047. if [[ ${reworkmodulenames} == 1 ]]; then
  1048. local temp_config="${config//*:}" i n;
  1049. config="${config//:*}";
  1050. if linux_chkconfig_present ${config}; then
  1051. for i in ${MODULE_NAMES};
  1052. do
  1053. n="${i//${temp_config}}";
  1054. [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  1055. done;
  1056. error=2;
  1057. fi;
  1058. else
  1059. linux_chkconfig_present ${config} || error=1;
  1060. fi;
  1061. fi;
  1062. if [[ ${error} > 0 ]]; then
  1063. local report_func="eerror" local_error;
  1064. local_error="ERROR_${config}";
  1065. local_error="${!local_error}";
  1066. if [[ -z "${local_error}" ]]; then
  1067. local_error="${config}_ERROR";
  1068. local_error="${!local_error}";
  1069. fi;
  1070. if [[ ${die} == 0 && -z "${local_error}" ]]; then
  1071. local_error="WARNING_${config}";
  1072. local_error="${!local_error}";
  1073. if [[ -n "${local_error}" ]]; then
  1074. report_func="ewarn";
  1075. fi;
  1076. fi;
  1077. if [[ -z "${local_error}" ]]; then
  1078. [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  1079. local_error="CONFIG_${config}:\t ${local_error}";
  1080. fi;
  1081. if [[ ${die} == 0 ]]; then
  1082. ${report_func} " ${local_error}";
  1083. soft_errors_count=$[soft_errors_count + 1];
  1084. else
  1085. ${report_func} " ${local_error}";
  1086. hard_errors_count=$[hard_errors_count + 1];
  1087. fi;
  1088. fi;
  1089. done;
  1090. if [[ ${hard_errors_count} > 0 ]]; then
  1091. eerror "Please check to make sure these options are set correctly.";
  1092. eerror "Failure to do so may cause unexpected problems.";
  1093. eerror "Once you have satisfied these options, please try merging";
  1094. eerror "this package again.";
  1095. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1096. die "Incorrect kernel configuration options";
  1097. else
  1098. if [[ ${soft_errors_count} > 0 ]]; then
  1099. ewarn "Please check to make sure these options are set correctly.";
  1100. ewarn "Failure to do so may cause unexpected problems.";
  1101. else
  1102. eend 0;
  1103. fi;
  1104. fi;
  1105. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  1106. }
  1107. check_kernel_built ()
  1108. {
  1109. require_configured_kernel;
  1110. get_version;
  1111. local versionh_path;
  1112. if kernel_is -ge 3 7; then
  1113. versionh_path="include/generated/uapi/linux/version.h";
  1114. else
  1115. versionh_path="include/linux/version.h";
  1116. fi;
  1117. if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]; then
  1118. eerror "These sources have not yet been prepared.";
  1119. eerror "We cannot build against an unprepared tree.";
  1120. eerror "To resolve this, please type the following:";
  1121. eerror;
  1122. eerror "# cd ${KV_DIR}";
  1123. eerror "# make oldconfig";
  1124. eerror "# make modules_prepare";
  1125. eerror;
  1126. eerror "Then please try merging this module again.";
  1127. die "Kernel sources need compiling first";
  1128. fi
  1129. }
  1130. check_license ()
  1131. {
  1132. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  1133. }
  1134. check_modules_supported ()
  1135. {
  1136. require_configured_kernel;
  1137. get_version;
  1138. if ! linux_chkconfig_builtin "MODULES"; then
  1139. eerror "These sources do not support loading external modules.";
  1140. eerror "to be able to use this module please enable \"Loadable modules support\"";
  1141. eerror "in your kernel, recompile and then try merging this module again.";
  1142. die "No support for external modules in ${KV_FULL} config";
  1143. fi
  1144. }
  1145. check_zlibinflate ()
  1146. {
  1147. require_configured_kernel;
  1148. get_version;
  1149. local INFLATE;
  1150. local DEFLATE;
  1151. einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  1152. ebegin "checking ZLIB_INFLATE";
  1153. linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  1154. eend $?;
  1155. [ "$?" != 0 ] && die;
  1156. ebegin "checking ZLIB_DEFLATE";
  1157. linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  1158. eend $?;
  1159. [ "$?" != 0 ] && die;
  1160. local LINENO_START;
  1161. local LINENO_END;
  1162. local SYMBOLS;
  1163. local x;
  1164. LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  1165. LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  1166. (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ));
  1167. (( LINENO_END = $LINENO_END - 1 ));
  1168. SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  1169. for x in $SYMBOLS;
  1170. do
  1171. if [ "${!x}" = "y" ]; then
  1172. einfo "${x} ensures zlib is linked into your kernel - excellent";
  1173. return 0;
  1174. fi;
  1175. done;
  1176. eerror;
  1177. eerror "This kernel module requires ZLIB library support.";
  1178. eerror "You have enabled zlib support in your kernel, but haven't enabled";
  1179. eerror "enabled any option that will ensure that zlib is linked into your";
  1180. eerror "kernel.";
  1181. eerror;
  1182. eerror "Please ensure that you enable at least one of these options:";
  1183. eerror;
  1184. for x in $SYMBOLS;
  1185. do
  1186. eerror " * $x";
  1187. done;
  1188. eerror;
  1189. eerror "Please remember to recompile and install your kernel, and reboot";
  1190. eerror "into your new kernel before attempting to load this kernel module.";
  1191. die "Kernel doesn't include zlib support"
  1192. }
  1193. clang-fullversion ()
  1194. {
  1195. _clang_fullversion '$1.$2.$3' "$@"
  1196. }
  1197. clang-major-version ()
  1198. {
  1199. _clang_fullversion '$1' "$@"
  1200. }
  1201. clang-micro-version ()
  1202. {
  1203. _clang_fullversion '$3' "$@"
  1204. }
  1205. clang-minor-version ()
  1206. {
  1207. _clang_fullversion '$2' "$@"
  1208. }
  1209. clang-version ()
  1210. {
  1211. _clang_fullversion '$1.$2' "$@"
  1212. }
  1213. delete_all_version_separators ()
  1214. {
  1215. replace_all_version_separators "" "${1}"
  1216. }
  1217. delete_version_separator ()
  1218. {
  1219. replace_version_separator "${1}" "" "${2}"
  1220. }
  1221. doicon ()
  1222. {
  1223. _iconins ${FUNCNAME} "$@"
  1224. }
  1225. domenu ()
  1226. {
  1227. ( local i j ret=0;
  1228. insinto /usr/share/applications;
  1229. for i in "$@";
  1230. do
  1231. if [[ -f ${i} ]]; then
  1232. doins "${i}";
  1233. ((ret+=$?));
  1234. else
  1235. if [[ -d ${i} ]]; then
  1236. for j in "${i}"/*.desktop;
  1237. do
  1238. doins "${j}";
  1239. ((ret+=$?));
  1240. done;
  1241. else
  1242. ((++ret));
  1243. fi;
  1244. fi;
  1245. done;
  1246. exit ${ret} )
  1247. }
  1248. eant ()
  1249. {
  1250. debug-print-function ${FUNCNAME} $*;
  1251. if [[ ${EBUILD_PHASE} = compile ]]; then
  1252. java-ant-2_src_configure;
  1253. fi;
  1254. if ! has java-ant-2 ${INHERITED}; then
  1255. local msg="You should inherit java-ant-2 when using eant";
  1256. java-pkg_announce-qa-violation "${msg}";
  1257. fi;
  1258. local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore";
  1259. java-pkg_init-compiler_;
  1260. local compiler="${GENTOO_COMPILER}";
  1261. local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}";
  1262. local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})";
  1263. if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
  1264. die "ANT_BUILD_COMPILER undefined in ${compiler_env}";
  1265. fi;
  1266. if [[ ${compiler} != "javac" ]]; then
  1267. antflags="${antflags} -Dbuild.compiler=${build_compiler}";
  1268. local build_compiler_deps="$(source ${JAVA_PKG_COMPILER_DIR}/${compiler} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER_DEPS})";
  1269. if [[ -n ${build_compiler_deps} ]]; then
  1270. antflags="${antflags} -lib $(java-config -p ${build_compiler_deps})";
  1271. fi;
  1272. fi;
  1273. for arg in "${@}";
  1274. do
  1275. if [[ ${arg} = -lib ]]; then
  1276. if is-java-strict; then
  1277. eerror "You should not use the -lib argument to eant because it will fail";
  1278. eerror "with JAVA_PKG_STRICT. Please use for example java-pkg_jar-from";
  1279. eerror "or ant properties to make dependencies available.";
  1280. eerror "For ant tasks use WANT_ANT_TASKS or ANT_TASKS from.";
  1281. eerror "split ant (>=dev-java/ant-core-1.7).";
  1282. die "eant -lib is deprecated/forbidden";
  1283. else
  1284. echo "eant -lib is deprecated. Turn JAVA_PKG_STRICT on for";
  1285. echo "more info.";
  1286. fi;
  1287. fi;
  1288. done;
  1289. local want_ant_tasks;
  1290. for i in ${WANT_ANT_TASKS};
  1291. do
  1292. if [[ ${i} = */*:* ]]; then
  1293. i=${i#*/};
  1294. i=${i%:0};
  1295. want_ant_tasks+="${i/:/-} ";
  1296. else
  1297. want_ant_tasks+="${i} ";
  1298. fi;
  1299. done;
  1300. ANT_TASKS="${ANT_TASKS:-${want_ant_tasks% }}";
  1301. ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}";
  1302. ANT_TASKS="${ANT_TASKS:-none}";
  1303. if [[ "${ANT_TASKS}" == "all" ]]; then
  1304. einfo "Using all available ANT_TASKS";
  1305. else
  1306. if [[ "${ANT_TASKS}" == "none" ]]; then
  1307. einfo "Disabling all optional ANT_TASKS";
  1308. else
  1309. einfo "Using following ANT_TASKS: ${ANT_TASKS}";
  1310. fi;
  1311. fi;
  1312. export ANT_TASKS;
  1313. [[ -n ${JAVA_PKG_DEBUG} ]] && antflags="${antflags} --execdebug -debug";
  1314. [[ -n ${PORTAGE_QUIET} ]] && antflags="${antflags} -q";
  1315. local gcp="${EANT_GENTOO_CLASSPATH}";
  1316. local getjarsarg="";
  1317. if [[ ${EBUILD_PHASE} = "test" ]]; then
  1318. antflags="${antflags} -DJunit.present=true";
  1319. getjarsarg="--with-dependencies";
  1320. local re="\bant-junit4?([-:]\S+)?\b";
  1321. [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}";
  1322. else
  1323. antflags="${antflags} -Dmaven.test.skip=true";
  1324. fi;
  1325. local cp;
  1326. for atom in ${gcp};
  1327. do
  1328. cp+=":$(java-pkg_getjars ${getjarsarg} ${atom})";
  1329. done;
  1330. [[ -n ${EANT_NEEDS_TOOLS} ]] && cp+=":$(java-config --tools)";
  1331. [[ -n ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && cp+=":${EANT_GENTOO_CLASSPATH_EXTRA}";
  1332. if [[ -n ${cp#:} ]]; then
  1333. antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"";
  1334. fi;
  1335. [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}";
  1336. debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}";
  1337. ant ${antflags} "${@}" || die "eant failed"
  1338. }
  1339. ebeep ()
  1340. {
  1341. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1342. }
  1343. econf_build ()
  1344. {
  1345. local CBUILD=${CBUILD:-${CHOST}};
  1346. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1347. }
  1348. ecvs_clean ()
  1349. {
  1350. [[ $# -eq 0 ]] && set -- .;
  1351. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  1352. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  1353. }
  1354. edos2unix ()
  1355. {
  1356. [[ $# -eq 0 ]] && return 0;
  1357. sed -i 's/\r$//' -- "$@" || die
  1358. }
  1359. egit_clean ()
  1360. {
  1361. [[ $# -eq 0 ]] && set -- .;
  1362. find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
  1363. }
  1364. einstalldocs ()
  1365. {
  1366. debug-print-function ${FUNCNAME} "${@}";
  1367. local dodoc_opts=-r;
  1368. has ${EAPI} 0 1 2 3 && dodoc_opts=;
  1369. if ! declare -p DOCS &> /dev/null; then
  1370. local d;
  1371. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1372. do
  1373. if [[ -s ${d} ]]; then
  1374. dodoc "${d}" || die;
  1375. fi;
  1376. done;
  1377. else
  1378. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1379. if [[ -n ${DOCS[@]} ]]; then
  1380. dodoc ${dodoc_opts} "${DOCS[@]}" || die;
  1381. fi;
  1382. else
  1383. if [[ -n ${DOCS} ]]; then
  1384. dodoc ${dodoc_opts} ${DOCS} || die;
  1385. fi;
  1386. fi;
  1387. fi;
  1388. if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1389. if [[ -n ${HTML_DOCS[@]} ]]; then
  1390. dohtml -r "${HTML_DOCS[@]}" || die;
  1391. fi;
  1392. else
  1393. if [[ -n ${HTML_DOCS} ]]; then
  1394. dohtml -r ${HTML_DOCS} || die;
  1395. fi;
  1396. fi;
  1397. return 0
  1398. }
  1399. ejavac ()
  1400. {
  1401. debug-print-function ${FUNCNAME} $*;
  1402. local compiler_executable;
  1403. compiler_executable=$(java-pkg_get-javac);
  1404. local javac_args;
  1405. javac_args="$(java-pkg_javac-args)";
  1406. if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  1407. einfo "Verbose logging for \"${FUNCNAME}\" function";
  1408. einfo "Compiler executable: ${compiler_executable}";
  1409. einfo "Extra arguments: ${javac_args}";
  1410. einfo "Complete command:";
  1411. einfo "${compiler_executable} ${javac_args} ${@}";
  1412. fi;
  1413. ebegin "Compiling";
  1414. ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
  1415. }
  1416. ejavadoc ()
  1417. {
  1418. debug-print-function ${FUNCNAME} $*;
  1419. local javadoc_args="";
  1420. if java-pkg_is-vm-version-ge "1.8"; then
  1421. javadoc_args="-Xdoclint:none";
  1422. fi;
  1423. if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  1424. einfo "Verbose logging for \"${FUNCNAME}\" function";
  1425. einfo "Javadoc executable: javadoc";
  1426. einfo "Extra arguments: ${javadoc_args}";
  1427. einfo "Complete command:";
  1428. einfo "javadoc ${javadoc_args} ${@}";
  1429. fi;
  1430. ebegin "Generating JavaDoc";
  1431. javadoc ${javadoc_args} "${@}" || die "ejavadoc failed"
  1432. }
  1433. ejunit ()
  1434. {
  1435. debug-print-function ${FUNCNAME} $*;
  1436. ejunit_ "junit" "${@}"
  1437. }
  1438. ejunit4 ()
  1439. {
  1440. debug-print-function ${FUNCNAME} $*;
  1441. ejunit_ "junit-4" "${@}"
  1442. }
  1443. ejunit_ ()
  1444. {
  1445. debug-print-function ${FUNCNAME} $*;
  1446. local pkgs;
  1447. if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
  1448. for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' ');
  1449. do
  1450. pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//");
  1451. done;
  1452. fi;
  1453. local junit=${1};
  1454. shift 1;
  1455. local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs});
  1456. if [[ ${1} = -cp || ${1} = -classpath ]]; then
  1457. cp="${2}:${cp}";
  1458. shift 2;
  1459. else
  1460. cp=".:${cp}";
  1461. fi;
  1462. local runner=junit.textui.TestRunner;
  1463. if [[ "${junit}" == "junit-4" ]]; then
  1464. runner=org.junit.runner.JUnitCore;
  1465. fi;
  1466. debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}";
  1467. java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
  1468. }
  1469. emktemp ()
  1470. {
  1471. local exe="touch";
  1472. [[ $1 == -d ]] && exe="mkdir" && shift;
  1473. local topdir=$1;
  1474. if [[ -z ${topdir} ]]; then
  1475. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1476. fi;
  1477. if ! type -P mktemp > /dev/null; then
  1478. local tmp=/;
  1479. while [[ -e ${tmp} ]]; do
  1480. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1481. done;
  1482. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1483. echo "${tmp}";
  1484. else
  1485. if [[ ${exe} == "touch" ]]; then
  1486. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1487. else
  1488. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1489. fi;
  1490. fi
  1491. }
  1492. epatch ()
  1493. {
  1494. function _epatch_draw_line ()
  1495. {
  1496. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1497. echo "${1//?/=}"
  1498. };
  1499. unset P4CONFIG P4PORT P4USER;
  1500. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1501. while [[ $# -gt 0 ]]; do
  1502. case $1 in
  1503. -*)
  1504. EPATCH_OPTS+=("$1")
  1505. ;;
  1506. *)
  1507. break
  1508. ;;
  1509. esac;
  1510. shift;
  1511. done;
  1512. if [[ $# -gt 1 ]]; then
  1513. local m;
  1514. for m in "$@";
  1515. do
  1516. epatch "${m}";
  1517. done;
  1518. return 0;
  1519. fi;
  1520. local SINGLE_PATCH="no";
  1521. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1522. if [[ -f $1 ]]; then
  1523. SINGLE_PATCH="yes";
  1524. set -- "$1";
  1525. local EPATCH_SUFFIX=$1;
  1526. else
  1527. if [[ -d $1 ]]; then
  1528. evar_push_set LC_COLLATE C;
  1529. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1530. evar_pop;
  1531. else
  1532. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1533. epatch "${EPATCH_SOURCE}/$1";
  1534. return $?;
  1535. else
  1536. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1537. echo;
  1538. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1539. eerror;
  1540. eerror " ${EPATCH_SOURCE}";
  1541. eerror " ( ${EPATCH_SOURCE##*/} )";
  1542. echo;
  1543. die "Cannot find \$EPATCH_SOURCE!";
  1544. fi;
  1545. fi;
  1546. fi;
  1547. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1548. local PIPE_CMD;
  1549. case ${EPATCH_SUFFIX##*\.} in
  1550. xz)
  1551. PIPE_CMD="xz -dc"
  1552. ;;
  1553. lzma)
  1554. PIPE_CMD="lzma -dc"
  1555. ;;
  1556. bz2)
  1557. PIPE_CMD="bzip2 -dc"
  1558. ;;
  1559. gz | Z | z)
  1560. PIPE_CMD="gzip -dc"
  1561. ;;
  1562. ZIP | zip)
  1563. PIPE_CMD="unzip -p"
  1564. ;;
  1565. *)
  1566.  
  1567. ;;
  1568. esac;
  1569. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1570. local x;
  1571. for x in "$@";
  1572. do
  1573. [[ ! -f ${x} ]] && continue;
  1574. local patchname=${x##*/};
  1575. local a=${patchname#*_};
  1576. a=${a%%_*};
  1577. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1578. continue;
  1579. fi;
  1580. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  1581. eshopts_push -o noglob;
  1582. local ex;
  1583. for ex in ${EPATCH_EXCLUDE};
  1584. do
  1585. if [[ ${patchname} == ${ex} ]]; then
  1586. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  1587. eshopts_pop;
  1588. continue 2;
  1589. fi;
  1590. done;
  1591. for ex in ${EPATCH_USER_EXCLUDE};
  1592. do
  1593. if [[ ${patchname} == ${ex} ]]; then
  1594. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  1595. eshopts_pop;
  1596. continue 2;
  1597. fi;
  1598. done;
  1599. eshopts_pop;
  1600. fi;
  1601. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1602. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1603. einfo "${EPATCH_SINGLE_MSG}";
  1604. else
  1605. einfo "Applying ${patchname} ...";
  1606. fi;
  1607. else
  1608. einfo " ${patchname} ...";
  1609. fi;
  1610. local patch="patch";
  1611. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  1612. local STDERR_TARGET="${T}/${patchname}.out";
  1613. if [[ -e ${STDERR_TARGET} ]]; then
  1614. STDERR_TARGET="${T}/${patchname}-$$.out";
  1615. fi;
  1616. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  1617. local count=0;
  1618. local PATCH_TARGET;
  1619. if [[ -n ${PIPE_CMD} ]]; then
  1620. PATCH_TARGET="${T}/$$.patch";
  1621. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1622. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1623. echo;
  1624. eerror "Could not extract patch!";
  1625. count=5;
  1626. break;
  1627. fi;
  1628. else
  1629. PATCH_TARGET=${x};
  1630. fi;
  1631. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1632. if [[ -n ${abs_paths} ]]; then
  1633. count=1;
  1634. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1635. fi;
  1636. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1637. if [[ -n ${rel_paths} ]]; then
  1638. echo;
  1639. eerror "Rejected Patch: ${patchname} !";
  1640. eerror " ( ${PATCH_TARGET} )";
  1641. eerror;
  1642. eerror "Your patch uses relative paths '../':";
  1643. eerror "${rel_paths}";
  1644. echo;
  1645. die "you need to fix the relative paths in patch";
  1646. fi;
  1647. local patch_cmd;
  1648. while [[ ${count} -lt 5 ]]; do
  1649. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  1650. ( _epatch_draw_line "***** ${patchname} *****";
  1651. echo;
  1652. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  1653. echo;
  1654. _epatch_draw_line "***** ${patchname} *****";
  1655. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1656. ret=$?;
  1657. echo;
  1658. echo "patch program exited with status ${ret}";
  1659. exit ${ret} ) >> "${STDERR_TARGET}";
  1660. if [ $? -eq 0 ]; then
  1661. ( _epatch_draw_line "***** ${patchname} *****";
  1662. echo;
  1663. echo "ACTUALLY APPLYING ${patchname} ...";
  1664. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1665. echo;
  1666. _epatch_draw_line "***** ${patchname} *****";
  1667. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1668. ret=$?;
  1669. echo;
  1670. echo "patch program exited with status ${ret}";
  1671. exit ${ret} ) >> "${STDERR_TARGET}";
  1672. if [ $? -ne 0 ]; then
  1673. echo;
  1674. eerror "A dry-run of patch command succeeded, but actually";
  1675. eerror "applying the patch failed!";
  1676. count=5;
  1677. fi;
  1678. break;
  1679. fi;
  1680. : $(( count++ ));
  1681. done;
  1682. (( EPATCH_N_APPLIED_PATCHES++ ));
  1683. if [[ -n ${PIPE_CMD} ]]; then
  1684. rm -f "${PATCH_TARGET}";
  1685. fi;
  1686. if [[ ${count} -ge 5 ]]; then
  1687. echo;
  1688. eerror "Failed Patch: ${patchname} !";
  1689. eerror " ( ${PATCH_TARGET} )";
  1690. eerror;
  1691. eerror "Include in your bugreport the contents of:";
  1692. eerror;
  1693. eerror " ${STDERR_TARGET}";
  1694. echo;
  1695. die "Failed Patch: ${patchname}!";
  1696. fi;
  1697. rm -f "${STDERR_TARGET}";
  1698. cat >> "${T}/epatch.log" <<-EOF
  1699. PATCH: ${x}
  1700. CMD: ${patch_cmd}
  1701. PWD: ${PWD}
  1702.  
  1703. EOF
  1704.  
  1705. eend 0;
  1706. done;
  1707. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1708. :
  1709. }
  1710. epatch_user ()
  1711. {
  1712. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1713. local applied="${T}/epatch_user.log";
  1714. [[ -e ${applied} ]] && return 2;
  1715. local EPATCH_SOURCE check;
  1716. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}};
  1717. do
  1718. EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CTARGET}/${check};
  1719. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CHOST}/${check};
  1720. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${check};
  1721. if [[ -d ${EPATCH_SOURCE} ]]; then
  1722. local old_n_applied_patches=${EPATCH_N_APPLIED_PATCHES:-0};
  1723. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1724. echo "${EPATCH_SOURCE}" > "${applied}";
  1725. if [[ ${old_n_applied_patches} -lt ${EPATCH_N_APPLIED_PATCHES} ]]; then
  1726. has epatch_user_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" epatch_user_death_notice";
  1727. fi;
  1728. return 0;
  1729. fi;
  1730. done;
  1731. echo "none" > "${applied}";
  1732. return 1
  1733. }
  1734. epatch_user_death_notice ()
  1735. {
  1736. ewarn "!!! User patches were applied to this build!"
  1737. }
  1738. epause ()
  1739. {
  1740. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1741. }
  1742. epunt_cxx ()
  1743. {
  1744. local dir=$1;
  1745. [[ -z ${dir} ]] && dir=${S};
  1746. ebegin "Removing useless C++ checks";
  1747. local f p any_found;
  1748. while IFS= read -r -d '' f; do
  1749. for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch;
  1750. do
  1751. if patch --no-backup-if-mismatch -p1 "${f}" "${p}" > /dev/null; then
  1752. any_found=1;
  1753. break;
  1754. fi;
  1755. done;
  1756. done < <(find "${dir}" -name configure -print0);
  1757. if [[ -z ${any_found} ]]; then
  1758. eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt).";
  1759. fi;
  1760. eend 0
  1761. }
  1762. eqmake4 ()
  1763. {
  1764. debug-print-function ${FUNCNAME} "$@";
  1765. has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  1766. ebegin "Running qmake";
  1767. local qmake_args=("$@");
  1768. local regexp='.*\.pro';
  1769. if ! [[ ${1} =~ ${regexp} ]]; then
  1770. local project_file=$(qmake-utils_find_pro_file);
  1771. if [[ -z ${project_file} ]]; then
  1772. echo;
  1773. eerror "No project files found in '${PWD}'";
  1774. eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1775. echo;
  1776. die "eqmake4 failed";
  1777. fi;
  1778. qmake_args+=("${project_file}");
  1779. fi;
  1780. local config_add=release;
  1781. local config_remove=debug;
  1782. if use_if_iuse debug; then
  1783. config_add=debug;
  1784. config_remove=release;
  1785. fi;
  1786. local awkscript='BEGIN {
  1787. printf "### eqmake4 was here ###\n" > file;
  1788. printf "CONFIG -= debug_and_release %s\n", remove >> file;
  1789. printf "CONFIG += %s\n\n", add >> file;
  1790. fixed=0;
  1791. }
  1792. /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
  1793. if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
  1794. fixed=1;
  1795. }
  1796. }
  1797. /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
  1798. if (gsub("\\<" add "\\>", "") > 0) {
  1799. fixed=1;
  1800. }
  1801. }
  1802. {
  1803. print >> file;
  1804. }
  1805. END {
  1806. print fixed;
  1807. }';
  1808. [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob;
  1809. local file;
  1810. while read file; do
  1811. local excl;
  1812. for excl in ${EQMAKE4_EXCLUDE};
  1813. do
  1814. [[ ${file} == ${excl} ]] && continue 2;
  1815. done;
  1816. grep -q '^### eqmake4 was here ###$' "${file}" && continue;
  1817. local retval=$({
  1818. rm -f "${file}" || echo FAIL
  1819. awk -v file="${file}" -v add=${config_add} -v remove=${config_remove} -- "${awkscript}" || echo FAIL
  1820. } < "${file}");
  1821. if [[ ${retval} == 1 ]]; then
  1822. einfo " - fixed CONFIG in ${file}";
  1823. else
  1824. if [[ ${retval} != 0 ]]; then
  1825. eerror " - error while processing ${file}";
  1826. die "eqmake4 failed to process ${file}";
  1827. fi;
  1828. fi;
  1829. done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null);
  1830. [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop;
  1831. "$(qt4_get_bindir)"/qmake -makefile QMAKE_AR="$(tc-getAR) cqs" QMAKE_CC="$(tc-getCC)" QMAKE_CXX="$(tc-getCXX)" QMAKE_LINK="$(tc-getCXX)" QMAKE_LINK_C="$(tc-getCC)" QMAKE_OBJCOPY="$(tc-getOBJCOPY)" QMAKE_RANLIB= QMAKE_STRIP= QMAKE_CFLAGS="${CFLAGS}" QMAKE_CFLAGS_RELEASE= QMAKE_CFLAGS_DEBUG= QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_CXXFLAGS_RELEASE= QMAKE_CXXFLAGS_DEBUG= QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LFLAGS_RELEASE= QMAKE_LFLAGS_DEBUG= QMAKE_LIBDIR_QT="${EPREFIX}$(qt4_get_libdir)" QMAKE_LIBDIR_X11="${EPREFIX}/usr/$(get_libdir)" QMAKE_LIBDIR_OPENGL="${EPREFIX}/usr/$(get_libdir)" "${qmake_args[@]}";
  1832. if ! eend $?; then
  1833. echo;
  1834. eerror "Running qmake has failed! (see above for details)";
  1835. eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1836. echo;
  1837. die "eqmake4 failed";
  1838. fi
  1839. }
  1840. eqmake5 ()
  1841. {
  1842. debug-print-function ${FUNCNAME} "$@";
  1843. ebegin "Running qmake";
  1844. "$(qt5_get_bindir)"/qmake -makefile QMAKE_AR="$(tc-getAR) cqs" QMAKE_CC="$(tc-getCC)" QMAKE_LINK_C="$(tc-getCC)" QMAKE_LINK_C_SHLIB="$(tc-getCC)" QMAKE_CXX="$(tc-getCXX)" QMAKE_LINK="$(tc-getCXX)" QMAKE_LINK_SHLIB="$(tc-getCXX)" QMAKE_OBJCOPY="$(tc-getOBJCOPY)" QMAKE_RANLIB= QMAKE_STRIP= QMAKE_CFLAGS="${CFLAGS}" QMAKE_CFLAGS_RELEASE= QMAKE_CFLAGS_DEBUG= QMAKE_CXXFLAGS="${CXXFLAGS}" QMAKE_CXXFLAGS_RELEASE= QMAKE_CXXFLAGS_DEBUG= QMAKE_LFLAGS="${LDFLAGS}" QMAKE_LFLAGS_RELEASE= QMAKE_LFLAGS_DEBUG= "$@";
  1845. if ! eend $?; then
  1846. echo;
  1847. eerror "Running qmake has failed! (see above for details)";
  1848. eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/";
  1849. echo;
  1850. die "eqmake5 failed";
  1851. fi
  1852. }
  1853. eshopts_pop ()
  1854. {
  1855. local s;
  1856. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1857. if [[ ${s} == "shopt -"* ]]; then
  1858. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1859. else
  1860. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1861. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1862. fi
  1863. }
  1864. eshopts_push ()
  1865. {
  1866. if [[ $1 == -[su] ]]; then
  1867. estack_push eshopts "$(shopt -p)";
  1868. [[ $# -eq 0 ]] && return 0;
  1869. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1870. else
  1871. estack_push eshopts $-;
  1872. [[ $# -eq 0 ]] && return 0;
  1873. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1874. fi
  1875. }
  1876. estack_pop ()
  1877. {
  1878. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1879. local _estack_name="_ESTACK_$1_";
  1880. shift;
  1881. local _estack_retvar=$1;
  1882. shift;
  1883. eval local _estack_i=\${#${_estack_name}\[@\]};
  1884. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  1885. if [[ -n ${_estack_retvar} ]]; then
  1886. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  1887. fi;
  1888. eval unset \"${_estack_name}\[${_estack_i}\]\"
  1889. }
  1890. estack_push ()
  1891. {
  1892. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1893. local stack_name="_ESTACK_$1_";
  1894. shift;
  1895. eval ${stack_name}+=\( \"\$@\" \)
  1896. }
  1897. esvn_clean ()
  1898. {
  1899. [[ $# -eq 0 ]] && set -- .;
  1900. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1901. }
  1902. eumask_pop ()
  1903. {
  1904. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1905. local s;
  1906. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1907. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1908. }
  1909. eumask_push ()
  1910. {
  1911. estack_push eumask "$(umask)";
  1912. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1913. }
  1914. eutils_elt_patch_dir ()
  1915. {
  1916. local d="${ECLASSDIR}/ELT-patches";
  1917. if [[ ! -d ${d} ]]; then
  1918. d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches";
  1919. fi;
  1920. echo "${d}"
  1921. }
  1922. evar_pop ()
  1923. {
  1924. local cnt=${1:-bad};
  1925. case $# in
  1926. 0)
  1927. cnt=1
  1928. ;;
  1929. 1)
  1930. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  1931. ;;
  1932. *)
  1933. die "${FUNCNAME}: only accepts one arg: $*"
  1934. ;;
  1935. esac;
  1936. local var val;
  1937. while (( cnt-- )); do
  1938. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1939. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1940. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1941. done
  1942. }
  1943. evar_push ()
  1944. {
  1945. local var val;
  1946. for var in "$@";
  1947. do
  1948. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1949. estack_push evar "${var}" "${val}";
  1950. done
  1951. }
  1952. evar_push_set ()
  1953. {
  1954. local var=$1;
  1955. evar_push ${var};
  1956. case $# in
  1957. 1)
  1958. unset ${var}
  1959. ;;
  1960. 2)
  1961. printf -v "${var}" '%s' "$2"
  1962. ;;
  1963. *)
  1964. die "${FUNCNAME}: incorrect # of args: $*"
  1965. ;;
  1966. esac
  1967. }
  1968. fdo-mime_desktop_database_update ()
  1969. {
  1970. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  1971. has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}";
  1972. if [ -x "${EPREFIX}/usr/bin/update-desktop-database" ]; then
  1973. einfo "Updating desktop mime database ...";
  1974. "${EPREFIX}/usr/bin/update-desktop-database" -q "${EROOT}usr/share/applications";
  1975. fi
  1976. }
  1977. fdo-mime_mime_database_update ()
  1978. {
  1979. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  1980. has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}";
  1981. if [ -x "${EPREFIX}/usr/bin/update-mime-database" ]; then
  1982. einfo "Updating shared mime info database ...";
  1983. "${EPREFIX}/usr/bin/update-mime-database" "${EROOT}usr/share/mime";
  1984. fi
  1985. }
  1986. filter-flags ()
  1987. {
  1988. _filter-hardened "$@";
  1989. local v;
  1990. for v in $(all-flag-vars);
  1991. do
  1992. _filter-var ${v} "$@";
  1993. done;
  1994. return 0
  1995. }
  1996. filter-ldflags ()
  1997. {
  1998. _filter-var LDFLAGS "$@";
  1999. return 0
  2000. }
  2001. filter-lfs-flags ()
  2002. {
  2003. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2004. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  2005. }
  2006. filter-mfpmath ()
  2007. {
  2008. local orig_mfpmath new_math prune_math;
  2009. orig_mfpmath=$(get-flag -mfpmath);
  2010. new_math=$(get-flag mfpmath);
  2011. new_math=${new_math/both/387,sse};
  2012. new_math=" ${new_math//[,+]/ } ";
  2013. prune_math="";
  2014. for prune_math in "$@";
  2015. do
  2016. new_math=${new_math/ ${prune_math} / };
  2017. done;
  2018. new_math=$(echo ${new_math});
  2019. new_math=${new_math// /,};
  2020. if [[ -z ${new_math} ]]; then
  2021. filter-flags ${orig_mfpmath};
  2022. else
  2023. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2024. fi;
  2025. return 0
  2026. }
  2027. gcc-fullversion ()
  2028. {
  2029. _gcc_fullversion '$1.$2.$3' "$@"
  2030. }
  2031. gcc-major-version ()
  2032. {
  2033. _gcc_fullversion '$1' "$@"
  2034. }
  2035. gcc-micro-version ()
  2036. {
  2037. _gcc_fullversion '$3' "$@"
  2038. }
  2039. gcc-minor-version ()
  2040. {
  2041. _gcc_fullversion '$2' "$@"
  2042. }
  2043. gcc-specs-directive ()
  2044. {
  2045. local directive subdname subdirective;
  2046. directive="$(_gcc-specs-directive_raw $1)";
  2047. while [[ ${directive} == *%\(*\)* ]]; do
  2048. subdname=${directive/*%\(};
  2049. subdname=${subdname/\)*};
  2050. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2051. directive="${directive//\%(${subdname})/${subdirective}}";
  2052. done;
  2053. echo "${directive}";
  2054. return 0
  2055. }
  2056. gcc-specs-nostrict ()
  2057. {
  2058. local directive;
  2059. directive=$(gcc-specs-directive cc1);
  2060. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2061. }
  2062. gcc-specs-now ()
  2063. {
  2064. local directive;
  2065. directive=$(gcc-specs-directive link_command);
  2066. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2067. }
  2068. gcc-specs-pie ()
  2069. {
  2070. local directive;
  2071. directive=$(gcc-specs-directive cc1);
  2072. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2073. }
  2074. gcc-specs-relro ()
  2075. {
  2076. local directive;
  2077. directive=$(gcc-specs-directive link_command);
  2078. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2079. }
  2080. gcc-specs-ssp ()
  2081. {
  2082. local directive;
  2083. directive=$(gcc-specs-directive cc1);
  2084. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2085. }
  2086. gcc-specs-ssp-to-all ()
  2087. {
  2088. local directive;
  2089. directive=$(gcc-specs-directive cc1);
  2090. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2091. }
  2092. gcc-specs-stack-check ()
  2093. {
  2094. local directive;
  2095. directive=$(gcc-specs-directive cc1);
  2096. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2097. }
  2098. gcc-version ()
  2099. {
  2100. _gcc_fullversion '$1.$2' "$@"
  2101. }
  2102. gen_usr_ldscript ()
  2103. {
  2104. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2105. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2106. tc-is-static-only && return;
  2107. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2108. multilib_is_native_abi || return 0;
  2109. fi;
  2110. case ${CTARGET:-${CHOST}} in
  2111. *-darwin*)
  2112.  
  2113. ;;
  2114. *-android*)
  2115. return 0
  2116. ;;
  2117. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  2118. use prefix && return 0
  2119. ;;
  2120. *)
  2121. return 0
  2122. ;;
  2123. esac;
  2124. dodir /usr/${libdir};
  2125. if [[ $1 == "-a" ]]; then
  2126. auto=true;
  2127. shift;
  2128. dodir /${libdir};
  2129. fi;
  2130. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2131. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2132. local d="${T}/bfd-linker";
  2133. mkdir -p "${d}";
  2134. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  2135. flags+=(-B"${d}");
  2136. fi;
  2137. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2138. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2139. for lib in "$@";
  2140. do
  2141. local tlib;
  2142. if ${auto}; then
  2143. lib="lib${lib}${suffix}";
  2144. else
  2145. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2146. fi;
  2147. case ${CTARGET:-${CHOST}} in
  2148. *-darwin*)
  2149. if ${auto}; then
  2150. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2151. else
  2152. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2153. fi;
  2154. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2155. tlib=${tlib##*/};
  2156. if ${auto}; then
  2157. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2158. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2159. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2160. fi;
  2161. rm -f "${ED}"/${libdir}/${lib};
  2162. fi;
  2163. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2164. chmod u+w "${ED}${libdir}/${tlib}";
  2165. local nowrite=yes;
  2166. fi;
  2167. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2168. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2169. pushd "${ED}/usr/${libdir}" > /dev/null;
  2170. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2171. popd > /dev/null
  2172. ;;
  2173. *)
  2174. if ${auto}; then
  2175. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2176. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2177. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2178. if [[ ${tlib} != ${lib}* ]]; then
  2179. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2180. fi;
  2181. rm -f "${ED}"/${libdir}/${lib};
  2182. else
  2183. tlib=${lib};
  2184. fi;
  2185. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2186. /* GNU ld script
  2187. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2188. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2189. run into linking problems. This "fake" dynamic lib is a linker script that
  2190. redirects the linker to the real lib. And yes, this works in the cross-
  2191. compiling scenario as the sysroot-ed linker will prepend the real path.
  2192.  
  2193. See bug https://bugs.gentoo.org/4411 for more info.
  2194. */
  2195. ${output_format}
  2196. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2197. END_LDSCRIPT
  2198.  
  2199. ;;
  2200. esac
  2201. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2202. done
  2203. }
  2204. get-flag ()
  2205. {
  2206. local f var findflag="$1";
  2207. for var in $(all-flag-vars);
  2208. do
  2209. for f in ${!var};
  2210. do
  2211. if [ "${f/${findflag}}" != "${f}" ]; then
  2212. printf "%s\n" "${f/-${findflag}=}";
  2213. return 0;
  2214. fi;
  2215. done;
  2216. done;
  2217. return 1
  2218. }
  2219. get_abi_CFLAGS ()
  2220. {
  2221. get_abi_var CFLAGS "$@"
  2222. }
  2223. get_abi_CHOST ()
  2224. {
  2225. get_abi_var CHOST "$@"
  2226. }
  2227. get_abi_CTARGET ()
  2228. {
  2229. get_abi_var CTARGET "$@"
  2230. }
  2231. get_abi_FAKE_TARGETS ()
  2232. {
  2233. get_abi_var FAKE_TARGETS "$@"
  2234. }
  2235. get_abi_LDFLAGS ()
  2236. {
  2237. get_abi_var LDFLAGS "$@"
  2238. }
  2239. get_abi_LIBDIR ()
  2240. {
  2241. get_abi_var LIBDIR "$@"
  2242. }
  2243. get_abi_var ()
  2244. {
  2245. local flag=$1;
  2246. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2247. local var="${flag}_${abi}";
  2248. echo ${!var}
  2249. }
  2250. get_after_major_version ()
  2251. {
  2252. echo $(get_version_component_range 2- "${1:-${PV}}")
  2253. }
  2254. get_all_abis ()
  2255. {
  2256. local x order="" mvar dvar;
  2257. mvar="MULTILIB_ABIS";
  2258. dvar="DEFAULT_ABI";
  2259. if [[ -n $1 ]]; then
  2260. mvar="$1_${mvar}";
  2261. dvar="$1_${dvar}";
  2262. fi;
  2263. if [[ -z ${!mvar} ]]; then
  2264. echo "default";
  2265. return 0;
  2266. fi;
  2267. for x in ${!mvar};
  2268. do
  2269. if [[ ${x} != ${!dvar} ]]; then
  2270. order="${order:+${order} }${x}";
  2271. fi;
  2272. done;
  2273. order="${order:+${order} }${!dvar}";
  2274. echo ${order};
  2275. return 0
  2276. }
  2277. get_all_libdirs ()
  2278. {
  2279. local libdirs abi;
  2280. for abi in ${MULTILIB_ABIS};
  2281. do
  2282. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2283. done;
  2284. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2285. echo "${libdirs}"
  2286. }
  2287. get_all_version_components ()
  2288. {
  2289. eshopts_push -s extglob;
  2290. local ver_str=${1:-${PV}} result;
  2291. result=();
  2292. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  2293. echo ${VERSIONATOR_CACHE_RESULT};
  2294. eshopts_pop;
  2295. return;
  2296. fi;
  2297. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  2298. while [[ -n $ver_str ]]; do
  2299. case "${ver_str::1}" in
  2300. [[:digit:]])
  2301. result+=("${ver_str%%[^[:digit:]]*}");
  2302. ver_str=${ver_str##+([[:digit:]])}
  2303. ;;
  2304. [-_.])
  2305. result+=("${ver_str::1}");
  2306. ver_str=${ver_str:1}
  2307. ;;
  2308. [[:alpha:]])
  2309. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  2310. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2311. ver_str=${not_match}
  2312. ;;
  2313. *)
  2314. result+=("${ver_str::1}");
  2315. ver_str=${ver_str:1}
  2316. ;;
  2317. esac;
  2318. done;
  2319. export VERSIONATOR_CACHE_RESULT=${result[*]};
  2320. echo ${result[@]};
  2321. eshopts_pop
  2322. }
  2323. get_exeext ()
  2324. {
  2325. case ${CHOST} in
  2326. *-cygwin* | mingw* | *-mingw*)
  2327. echo ".exe"
  2328. ;;
  2329. esac
  2330. }
  2331. get_install_abis ()
  2332. {
  2333. local x order="";
  2334. if [[ -z ${MULTILIB_ABIS} ]]; then
  2335. echo "default";
  2336. return 0;
  2337. fi;
  2338. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2339. for x in ${MULTILIB_ABIS};
  2340. do
  2341. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2342. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2343. fi;
  2344. done;
  2345. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2346. if [[ -n ${ABI_ALLOW} ]]; then
  2347. local ordera="";
  2348. for x in ${order};
  2349. do
  2350. if has ${x} ${ABI_ALLOW}; then
  2351. ordera="${ordera} ${x}";
  2352. fi;
  2353. done;
  2354. order=${ordera};
  2355. fi;
  2356. else
  2357. order=${DEFAULT_ABI};
  2358. fi;
  2359. if [[ -z ${order} ]]; then
  2360. 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.";
  2361. fi;
  2362. echo ${order};
  2363. return 0
  2364. }
  2365. get_last_version_component_index ()
  2366. {
  2367. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2368. }
  2369. get_libdir ()
  2370. {
  2371. local CONF_LIBDIR;
  2372. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2373. echo ${CONF_LIBDIR_OVERRIDE};
  2374. else
  2375. get_abi_LIBDIR;
  2376. fi
  2377. }
  2378. get_libname ()
  2379. {
  2380. local libname;
  2381. local ver=$1;
  2382. case ${CHOST} in
  2383. *-cygwin*)
  2384. libname="dll.a"
  2385. ;;
  2386. mingw* | *-mingw*)
  2387. libname="dll"
  2388. ;;
  2389. *-darwin*)
  2390. libname="dylib"
  2391. ;;
  2392. *-mint*)
  2393. libname="irrelevant"
  2394. ;;
  2395. hppa*-hpux*)
  2396. libname="sl"
  2397. ;;
  2398. *)
  2399. libname="so"
  2400. ;;
  2401. esac;
  2402. if [[ -z $* ]]; then
  2403. echo ".${libname}";
  2404. else
  2405. for ver in "$@";
  2406. do
  2407. case ${CHOST} in
  2408. *-cygwin*)
  2409. echo ".${ver}.${libname}"
  2410. ;;
  2411. *-darwin*)
  2412. echo ".${ver}.${libname}"
  2413. ;;
  2414. *-mint*)
  2415. echo ".${libname}"
  2416. ;;
  2417. *)
  2418. echo ".${libname}.${ver}"
  2419. ;;
  2420. esac;
  2421. done;
  2422. fi
  2423. }
  2424. get_localversion ()
  2425. {
  2426. local lv_list i x;
  2427. for i in $(ls ${1}/localversion* 2>/dev/null);
  2428. do
  2429. [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}";
  2430. done;
  2431. for i in ${lv_list};
  2432. do
  2433. x="${x}$(<${i})";
  2434. done;
  2435. x=${x/ /};
  2436. echo ${x}
  2437. }
  2438. get_major_version ()
  2439. {
  2440. local c=($(get_all_version_components "${1:-${PV}}"));
  2441. echo ${c[0]}
  2442. }
  2443. get_makefile_extract_function ()
  2444. {
  2445. local a='' b='' mkfunc='getfilevar';
  2446. a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  2447. b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  2448. [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  2449. echo "${mkfunc}"
  2450. }
  2451. get_modname ()
  2452. {
  2453. local modname;
  2454. local ver=$1;
  2455. case ${CHOST} in
  2456. *-darwin*)
  2457. modname="bundle"
  2458. ;;
  2459. *)
  2460. modname="so"
  2461. ;;
  2462. esac;
  2463. echo ".${modname}"
  2464. }
  2465. get_running_version ()
  2466. {
  2467. KV_FULL=$(uname -r);
  2468. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2469. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  2470. KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  2471. unset KV_FULL;
  2472. get_version;
  2473. return $?;
  2474. else
  2475. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
  2476. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  2477. unset KV_FULL;
  2478. get_version;
  2479. return $?;
  2480. else
  2481. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2482. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  2483. unset KV_FULL;
  2484. get_version;
  2485. return $?;
  2486. else
  2487. local kv_full=${KV_FULL//[-+_]*};
  2488. KV_MAJOR=$(get_version_component_range 1 ${kv_full});
  2489. KV_MINOR=$(get_version_component_range 2 ${kv_full});
  2490. KV_PATCH=$(get_version_component_range 3 ${kv_full});
  2491. KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}";
  2492. : ${KV_PATCH:=0};
  2493. fi;
  2494. fi;
  2495. fi;
  2496. return 0
  2497. }
  2498. get_udevdir ()
  2499. {
  2500. debug-print-function ${FUNCNAME} "${@}";
  2501. echo "$(_udev_get_udevdir)"
  2502. }
  2503. get_version ()
  2504. {
  2505. local tmplocal;
  2506. [ -n "${KV_FULL}" ] && return 0;
  2507. unset KV_DIR;
  2508. [ -z "${get_version_warning_done}" ] && qeinfo "Determining the location of the kernel source code";
  2509. [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}";
  2510. if [ -z "${KV_DIR}" ]; then
  2511. if [ -z "${get_version_warning_done}" ]; then
  2512. get_version_warning_done=1;
  2513. qewarn "Unable to find kernel sources at ${KERNEL_DIR}";
  2514. if [ "${KERNEL_DIR}" == "/usr/src/linux" ]; then
  2515. qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  2516. qeinfo "(or the kernel you wish to build against).";
  2517. qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  2518. else
  2519. qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  2520. fi;
  2521. fi;
  2522. return 1;
  2523. fi;
  2524. if [ -z "${KBUILD_OUTPUT}" -a -L "${KERNEL_DIR}/source" ]; then
  2525. KBUILD_OUTPUT=${KERNEL_DIR};
  2526. KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source");
  2527. KV_DIR=${KERNEL_DIR};
  2528. fi;
  2529. if [ -z "${get_version_warning_done}" ]; then
  2530. qeinfo "Found kernel source directory:";
  2531. qeinfo " ${KV_DIR}";
  2532. fi;
  2533. if [ ! -s "${KV_DIR}/Makefile" ]; then
  2534. if [ -z "${get_version_warning_done}" ]; then
  2535. get_version_warning_done=1;
  2536. qeerror "Could not find a Makefile in the kernel source directory.";
  2537. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  2538. fi;
  2539. return 1;
  2540. fi;
  2541. local OUTPUT_DIR=${KBUILD_OUTPUT};
  2542. KERNEL_MAKEFILE="${KV_DIR}/Makefile";
  2543. if [[ -z ${OUTPUT_DIR} ]]; then
  2544. local mkfunc=$(get_makefile_extract_function "${KERNEL_MAKEFILE}");
  2545. OUTPUT_DIR=$(${mkfunc} KBUILD_OUTPUT "${KERNEL_MAKEFILE}");
  2546. fi;
  2547. KV_MAJOR=$(getfilevar_noexec VERSION "${KERNEL_MAKEFILE}");
  2548. KV_MINOR=$(getfilevar_noexec PATCHLEVEL "${KERNEL_MAKEFILE}");
  2549. KV_PATCH=$(getfilevar_noexec SUBLEVEL "${KERNEL_MAKEFILE}");
  2550. KV_EXTRA=$(getfilevar_noexec EXTRAVERSION "${KERNEL_MAKEFILE}");
  2551. if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then
  2552. if [ -z "${get_version_warning_done}" ]; then
  2553. get_version_warning_done=1;
  2554. qeerror "Could not detect kernel version.";
  2555. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  2556. fi;
  2557. return 1;
  2558. fi;
  2559. if [[ -z ${OUTPUT_DIR} ]]; then
  2560. for OUTPUT_DIR in "${SYSROOT}" "${ROOT}" "";
  2561. do
  2562. OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build";
  2563. if [[ -e ${OUTPUT_DIR} ]]; then
  2564. break;
  2565. fi;
  2566. done;
  2567. fi;
  2568. [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}";
  2569. if [ -n "${KV_OUT_DIR}" ]; then
  2570. qeinfo "Found kernel object directory:";
  2571. qeinfo " ${KV_OUT_DIR}";
  2572. fi;
  2573. KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  2574. if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
  2575. KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  2576. else
  2577. if [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
  2578. KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  2579. else
  2580. KV_LOCAL=;
  2581. fi;
  2582. fi;
  2583. tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  2584. if [ "$KV_LOCAL" = "$tmplocal" ]; then
  2585. KV_LOCAL=;
  2586. else
  2587. KV_LOCAL=$tmplocal;
  2588. fi;
  2589. KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  2590. qeinfo "Found sources for kernel version:";
  2591. qeinfo " ${KV_FULL}";
  2592. return 0
  2593. }
  2594. get_version_component_count ()
  2595. {
  2596. local a=($(get_version_components "${1:-${PV}}"));
  2597. echo ${#a[@]}
  2598. }
  2599. get_version_component_range ()
  2600. {
  2601. eshopts_push -s extglob;
  2602. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2603. local -i i=-1 j=0;
  2604. c=($(get_all_version_components "${v}"));
  2605. range_start=${range%-*};
  2606. range_start=${range_start:-1};
  2607. range_end=${range#*-};
  2608. range_end=${range_end:-${#c[@]}};
  2609. while ((j < range_start)); do
  2610. i+=1;
  2611. ((i > ${#c[@]})) && eshopts_pop && return;
  2612. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2613. done;
  2614. while ((j <= range_end)); do
  2615. echo -n ${c[i]};
  2616. ((i > ${#c[@]})) && eshopts_pop && return;
  2617. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2618. i+=1;
  2619. done;
  2620. eshopts_pop
  2621. }
  2622. get_version_components ()
  2623. {
  2624. local c=$(get_all_version_components "${1:-${PV}}");
  2625. echo ${c//[-._]/ }
  2626. }
  2627. getfilevar ()
  2628. {
  2629. local ERROR basefname basedname myARCH="${ARCH}" M="${S}";
  2630. ERROR=0;
  2631. [ -z "${1}" ] && ERROR=1;
  2632. [ ! -f "${2}" ] && ERROR=1;
  2633. if [ "${ERROR}" = 1 ]; then
  2634. echo -e "\n";
  2635. eerror "getfilevar requires 2 variables, with the second a valid file.";
  2636. eerror " getfilevar <VARIABLE> <CONFIGFILE>";
  2637. else
  2638. basefname="$(basename ${2})";
  2639. basedname="$(dirname ${2})";
  2640. unset ARCH;
  2641. [[ ${EAPI:-0} == [0123] ]] && function nonfatal ()
  2642. {
  2643. "$@"
  2644. };
  2645. case ${EBUILD_PHASE_FUNC} in
  2646. pkg_info | pkg_nofetch | pkg_pretend)
  2647. M="${T}"
  2648. ;;
  2649. esac;
  2650. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | nonfatal emake -C "${basedname}" M="${M}" ${BUILD_FIXES} -s -f - 2> /dev/null;
  2651. ARCH=${myARCH};
  2652. fi
  2653. }
  2654. getfilevar_noexec ()
  2655. {
  2656. local ERROR basefname basedname mycat myARCH="${ARCH}";
  2657. ERROR=0;
  2658. mycat='cat';
  2659. [ -z "${1}" ] && ERROR=1;
  2660. [ ! -f "${2}" ] && ERROR=1;
  2661. [ "${2%.gz}" != "${2}" ] && mycat='zcat';
  2662. if [ "${ERROR}" = 1 ]; then
  2663. echo -e "\n";
  2664. eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  2665. eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  2666. else
  2667. ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  2668. s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  2669. s,[[:space:]]*\$,,g ;
  2670. p
  2671. }";
  2672. fi
  2673. }
  2674. has_m32 ()
  2675. {
  2676. die "${FUNCNAME}: don't use this anymore"
  2677. }
  2678. has_m64 ()
  2679. {
  2680. eqawarn "${FUNCNAME}: don't use this anymore";
  2681. local temp="$(emktemp)";
  2682. echo "int main() { return(0); }" > "${temp}".c;
  2683. MY_CC=$(tc-getCC);
  2684. ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  2685. local ret=$?;
  2686. rm -f "${temp}".c;
  2687. [[ ${ret} != 1 ]] && return 0;
  2688. return 1
  2689. }
  2690. has_multilib_profile ()
  2691. {
  2692. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2693. }
  2694. host-is-pax ()
  2695. {
  2696. grep -qs ^PaX: /proc/self/status
  2697. }
  2698. in_iuse ()
  2699. {
  2700. debug-print-function ${FUNCNAME} "${@}";
  2701. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2702. local flag=${1};
  2703. local liuse=(${IUSE});
  2704. has "${flag}" "${liuse[@]#[+-]}"
  2705. }
  2706. increment-qa-violations ()
  2707. {
  2708. let "JAVA_PKG_QA_VIOLATIONS+=1";
  2709. export JAVA_PKG_QA_VIOLATIONS
  2710. }
  2711. is-flag ()
  2712. {
  2713. is-flagq "$@" && echo true
  2714. }
  2715. is-flagq ()
  2716. {
  2717. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2718. local var;
  2719. for var in $(all-flag-vars);
  2720. do
  2721. _is_flagq ${var} "$1" && return 0;
  2722. done;
  2723. return 1
  2724. }
  2725. is-java-strict ()
  2726. {
  2727. [[ -n ${JAVA_PKG_STRICT} ]];
  2728. return $?
  2729. }
  2730. is-ldflag ()
  2731. {
  2732. is-ldflagq "$@" && echo true
  2733. }
  2734. is-ldflagq ()
  2735. {
  2736. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2737. _is_flagq LDFLAGS $1
  2738. }
  2739. is_final_abi ()
  2740. {
  2741. has_multilib_profile || return 0;
  2742. set -- $(get_install_abis);
  2743. local LAST_ABI=$#;
  2744. [[ ${!LAST_ABI} == ${ABI} ]]
  2745. }
  2746. isdigit ()
  2747. {
  2748. local d;
  2749. for d in "$@";
  2750. do
  2751. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  2752. done;
  2753. return 0
  2754. }
  2755. java-pkg-opt-2_pkg_preinst ()
  2756. {
  2757. use ${JAVA_PKG_OPT_USE} && java-utils-2_pkg_preinst
  2758. }
  2759. java-pkg-opt-2_pkg_setup ()
  2760. {
  2761. use ${JAVA_PKG_OPT_USE} && java-pkg_init
  2762. }
  2763. java-pkg-opt-2_src_prepare ()
  2764. {
  2765. use ${JAVA_PKG_OPT_USE} && java-utils-2_src_prepare
  2766. }
  2767. java-pkg_addcp ()
  2768. {
  2769. java-pkg_append_ JAVA_PKG_CLASSPATH "${@}";
  2770. java-pkg_do_write_
  2771. }
  2772. java-pkg_addres ()
  2773. {
  2774. debug-print-function ${FUNCNAME} $*;
  2775. [[ ${#} -lt 2 ]] && die "at least two arguments needed";
  2776. local jar=$(realpath "$1" || die "realpath $1 failed");
  2777. local dir="$2";
  2778. shift 2;
  2779. pushd "${dir}" > /dev/null || die "pushd ${dir} failed";
  2780. find -L -type f ! -path "./target/*" ! -path "./sources.lst" ! -name "MANIFEST.MF" ! -regex ".*\.\(class\|jar\|java\)" "${@}" -print0 | xargs -r0 jar uf "${jar}" || die "jar failed";
  2781. popd > /dev/null || die "popd failed"
  2782. }
  2783. java-pkg_announce-qa-violation ()
  2784. {
  2785. local nodie;
  2786. if [[ ${1} == "--nodie" ]]; then
  2787. nodie="true";
  2788. shift;
  2789. fi;
  2790. echo "Java QA Notice: $@" 1>&2;
  2791. increment-qa-violations;
  2792. [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
  2793. }
  2794. java-pkg_ant-tasks-depend ()
  2795. {
  2796. debug-print-function ${FUNCNAME} ${WANT_ANT_TASKS};
  2797. if [[ -n "${WANT_ANT_TASKS}" ]]; then
  2798. local DEP="";
  2799. for i in ${WANT_ANT_TASKS};
  2800. do
  2801. if [[ ${i} = ant-* ]]; then
  2802. DEP="${DEP}dev-java/${i} ";
  2803. else
  2804. if [[ ${i} = */*:* ]]; then
  2805. DEP="${DEP}${i} ";
  2806. else
  2807. echo "Invalid atom in WANT_ANT_TASKS: ${i}";
  2808. return 1;
  2809. fi;
  2810. fi;
  2811. done;
  2812. echo ${DEP};
  2813. return 0;
  2814. else
  2815. return 0;
  2816. fi
  2817. }
  2818. java-pkg_append_ ()
  2819. {
  2820. debug-print-function ${FUNCNAME} $*;
  2821. local var="${1}" value="${2}";
  2822. if [[ -z "${!var}" ]]; then
  2823. export ${var}="${value}";
  2824. else
  2825. local oldIFS=${IFS} cur haveit;
  2826. IFS=':';
  2827. for cur in ${!var};
  2828. do
  2829. if [[ ${cur} == ${value} ]]; then
  2830. haveit="yes";
  2831. break;
  2832. fi;
  2833. done;
  2834. [[ -z ${haveit} ]] && export ${var}="${!var}:${value}";
  2835. IFS=${oldIFS};
  2836. fi
  2837. }
  2838. java-pkg_build-vm-from-handle ()
  2839. {
  2840. debug-print-function ${FUNCNAME} "$*";
  2841. local vm;
  2842. vm=$(java-pkg_get-current-vm 2>/dev/null);
  2843. if [[ $? -eq 0 ]]; then
  2844. if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
  2845. echo ${vm};
  2846. return 0;
  2847. fi;
  2848. fi;
  2849. for vm in ${JAVA_PKG_WANT_BUILD_VM};
  2850. do
  2851. if java-config-2 --select-vm=${vm} 2> /dev/null; then
  2852. echo ${vm};
  2853. return 0;
  2854. fi;
  2855. done;
  2856. eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}";
  2857. return 1
  2858. }
  2859. java-pkg_check-jikes ()
  2860. {
  2861. if has jikes ${IUSE}; then
  2862. java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE";
  2863. fi
  2864. }
  2865. java-pkg_check-phase ()
  2866. {
  2867. local phase=${1};
  2868. local funcname=${FUNCNAME[1]};
  2869. if [[ ${EBUILD_PHASE} != ${phase} ]]; then
  2870. local msg="${funcname} used outside of src_${phase}";
  2871. java-pkg_announce-qa-violation "${msg}";
  2872. fi
  2873. }
  2874. java-pkg_check-versioned-jar ()
  2875. {
  2876. local jar=${1};
  2877. if [[ ${jar} =~ ${PV} ]]; then
  2878. java-pkg_announce-qa-violation "installing versioned jar '${jar}'";
  2879. fi
  2880. }
  2881. java-pkg_clean ()
  2882. {
  2883. if [[ -z "${JAVA_PKG_NO_CLEAN}" ]]; then
  2884. find "${@}" '(' -name '*.class' -o -name '*.jar' ')' -type f -delete -print || die;
  2885. fi
  2886. }
  2887. java-pkg_current-vm-matches ()
  2888. {
  2889. has $(java-pkg_get-current-vm) ${@};
  2890. return $?
  2891. }
  2892. java-pkg_die ()
  2893. {
  2894. echo "!!! When you file a bug report, please include the following information:" 1>&2;
  2895. echo "GENTOO_VM=${GENTOO_VM} CLASSPATH=\"${CLASSPATH}\" JAVA_HOME=\"${JAVA_HOME}\"" 1>&2;
  2896. echo "JAVACFLAGS=\"${JAVACFLAGS}\" COMPILER=\"${GENTOO_COMPILER}\"" 1>&2;
  2897. echo "and of course, the output of emerge --info =${P}" 1>&2
  2898. }
  2899. java-pkg_do_write_ ()
  2900. {
  2901. debug-print-function ${FUNCNAME} $*;
  2902. java-pkg_init_paths_;
  2903. dodir "${JAVA_PKG_SHAREPATH}";
  2904. ( echo "DESCRIPTION=\"${DESCRIPTION}\"";
  2905. echo "GENERATION=\"2\"";
  2906. echo "SLOT=\"${SLOT}\"";
  2907. echo "CATEGORY=\"${CATEGORY}\"";
  2908. echo "PVR=\"${PVR}\"";
  2909. [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"";
  2910. [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"";
  2911. [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"";
  2912. [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\"";
  2913. [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\"";
  2914. echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"";
  2915. [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\"" ) > "${JAVA_PKG_ENV}";
  2916. local target="$(java-pkg_get-target)";
  2917. local source="$(java-pkg_get-source)";
  2918. [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}";
  2919. [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}";
  2920. [[ -n ${JAVADOC_PATH} ]] && echo "JAVADOC_PATH=\"${JAVADOC_PATH}\"" >> ${JAVA_PKG_ENV};
  2921. [[ -n ${JAVA_SOURCES} ]] && echo "JAVA_SOURCES=\"${JAVA_SOURCES}\"" >> ${JAVA_PKG_ENV};
  2922. echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}";
  2923. [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}";
  2924. if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
  2925. cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die;
  2926. echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" >> "${JAVA_PKG_ENV}" || die;
  2927. fi;
  2928. sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
  2929. }
  2930. java-pkg_doexamples ()
  2931. {
  2932. debug-print-function ${FUNCNAME} $*;
  2933. [[ ${#} -lt 1 ]] && die "At least one argument needed";
  2934. java-pkg_check-phase install;
  2935. java-pkg_init_paths_;
  2936. local dest=/usr/share/doc/${PF}/examples;
  2937. if [[ ${1} == --subdir ]]; then
  2938. local dest=${dest}/${2};
  2939. dodir ${dest};
  2940. shift 2;
  2941. fi;
  2942. if [[ ${#} = 1 && -d ${1} ]]; then
  2943. ( insinto "${dest}";
  2944. doins -r ${1}/* ) || die "Installing examples failed";
  2945. else
  2946. ( insinto "${dest}";
  2947. doins -r "$@" ) || die "Installing examples failed";
  2948. fi;
  2949. dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
  2950. }
  2951. java-pkg_dohtml ()
  2952. {
  2953. debug-print-function ${FUNCNAME} $*;
  2954. [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}";
  2955. dohtml -f package-list "$@";
  2956. java-pkg_recordjavadoc
  2957. }
  2958. java-pkg_dojar ()
  2959. {
  2960. debug-print-function ${FUNCNAME} $*;
  2961. [[ ${#} -lt 1 ]] && die "At least one argument needed";
  2962. java-pkg_check-phase install;
  2963. java-pkg_init_paths_;
  2964. dodir ${JAVA_PKG_JARDEST};
  2965. local jar;
  2966. for jar in "${@}";
  2967. do
  2968. local jar_basename=$(basename "${jar}");
  2969. java-pkg_check-versioned-jar ${jar_basename};
  2970. if [[ -e "${jar}" ]]; then
  2971. local dest="${D}${JAVA_PKG_JARDEST}/${jar_basename}";
  2972. if [[ -e "${dest}" ]]; then
  2973. ewarn "Overwriting ${dest}";
  2974. fi;
  2975. if [[ ! -L "${jar}" ]]; then
  2976. is-java-strict && java-pkg_verify-classes "${jar}";
  2977. ( insinto "${JAVA_PKG_JARDEST}";
  2978. doins "${jar}" ) || die "failed to install ${jar}";
  2979. java-pkg_append_ JAVA_PKG_CLASSPATH "${JAVA_PKG_JARDEST}/${jar_basename}";
  2980. debug-print "installed ${jar} to ${D}${JAVA_PKG_JARDEST}";
  2981. else
  2982. ln -s "$(readlink "${jar}")" "${D}${JAVA_PKG_JARDEST}/${jar_basename}";
  2983. debug-print "${jar} is a symlink, linking accordingly";
  2984. fi;
  2985. else
  2986. die "${jar} does not exist";
  2987. fi;
  2988. done;
  2989. if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  2990. einfo "Verbose logging for \"${FUNCNAME}\" function";
  2991. einfo "Jar file(s) destination: ${JAVA_PKG_JARDEST}";
  2992. einfo "Jar file(s) created: ${@}";
  2993. einfo "Complete command:";
  2994. einfo "${FUNCNAME} ${@}";
  2995. fi;
  2996. java-pkg_do_write_
  2997. }
  2998. java-pkg_dojavadoc ()
  2999. {
  3000. debug-print-function ${FUNCNAME} $*;
  3001. local symlink;
  3002. if [[ ${1} = --symlink ]]; then
  3003. symlink=${2};
  3004. shift 2;
  3005. fi;
  3006. local dir="$1";
  3007. local dest=/usr/share/doc/${PF}/html;
  3008. java-pkg_check-phase install;
  3009. java-pkg_init_paths_;
  3010. [[ -z "${dir}" ]] && die "Must specify a directory!";
  3011. [[ ! -d "${dir}" ]] && die "${dir} does not exist, or isn't a directory!";
  3012. if [[ ! -e "${dir}/index.html" ]]; then
  3013. local msg="No index.html in javadoc directory";
  3014. ewarn "${msg}";
  3015. is-java-strict && die "${msg}";
  3016. fi;
  3017. if [[ -e ${D}/${dest}/api ]]; then
  3018. eerror "${dest} already exists. Will not overwrite.";
  3019. die "${dest}";
  3020. fi;
  3021. local dir_to_install="${dir}";
  3022. if [[ "$(basename "${dir}")" != "api" ]]; then
  3023. dir_to_install="${T}/api";
  3024. cp -r "${dir}" "${dir_to_install}" || die "cp failed";
  3025. fi;
  3026. java-pkg_dohtml -r "${dir_to_install}";
  3027. dosym ${dest}/api "${JAVA_PKG_SHAREPATH}/api" || die;
  3028. if [[ -n ${symlink} ]]; then
  3029. debug-print "symlinking ${dest}/{api,${symlink}}";
  3030. dosym ${dest}/{api,${symlink}} || die;
  3031. fi;
  3032. if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  3033. einfo "Verbose logging for \"${FUNCNAME}\" function";
  3034. einfo "Documentation destination: ${dest}";
  3035. einfo "Directory to install: ${dir_to_install}";
  3036. einfo "Complete command:";
  3037. einfo "${FUNCNAME} ${@}";
  3038. fi
  3039. }
  3040. java-pkg_dolauncher ()
  3041. {
  3042. debug-print-function ${FUNCNAME} $*;
  3043. java-pkg_check-phase install;
  3044. java-pkg_init_paths_;
  3045. if [[ ${#} = 0 ]]; then
  3046. local name="${PN}";
  3047. else
  3048. local name="${1}";
  3049. shift;
  3050. fi;
  3051. local target="${T}/${name}";
  3052. local var_tmp="${T}/launcher_variables_tmp";
  3053. local target_dir pre;
  3054. while [[ -n "${1}" && -n "${2}" ]]; do
  3055. local var="${1}" value="${2}";
  3056. if [[ "${var:0:2}" == "--" ]]; then
  3057. local var=${var:2};
  3058. echo "gjl_${var}=\"${value}\"" >> "${var_tmp}";
  3059. local gjl_${var}="${value}";
  3060. else
  3061. if [[ "${var}" == "-into" ]]; then
  3062. target_dir="${value}";
  3063. else
  3064. if [[ "${var}" == "-pre" ]]; then
  3065. pre="${value}";
  3066. fi;
  3067. fi;
  3068. fi;
  3069. shift 2;
  3070. done;
  3071. if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
  3072. local cp="${JAVA_PKG_CLASSPATH}";
  3073. if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
  3074. echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}";
  3075. else
  3076. local msg="Not enough information to create a launcher given.";
  3077. msg="${msg} Please give --jar or --main argument to ${FUNCNAME}.";
  3078. die "${msg}";
  3079. fi;
  3080. fi;
  3081. echo "#!/bin/bash" > "${target}";
  3082. if [[ -n "${pre}" ]]; then
  3083. if [[ -f "${pre}" ]]; then
  3084. cat "${pre}" >> "${target}";
  3085. else
  3086. die "-pre specified file '${pre}' does not exist";
  3087. fi;
  3088. fi;
  3089. echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}";
  3090. cat "${var_tmp}" >> "${target}";
  3091. rm -f "${var_tmp}";
  3092. echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}";
  3093. if [[ -n "${target_dir}" ]]; then
  3094. ( into "${target_dir}";
  3095. dobin "${target}" );
  3096. local ret=$?;
  3097. return ${ret};
  3098. else
  3099. dobin "${target}";
  3100. fi
  3101. }
  3102. java-pkg_doso ()
  3103. {
  3104. debug-print-function ${FUNCNAME} $*;
  3105. java-pkg_check-phase install;
  3106. [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument";
  3107. java-pkg_init_paths_;
  3108. local lib;
  3109. for lib in "$@";
  3110. do
  3111. if [[ -e "${lib}" ]]; then
  3112. if [[ ! -L "${lib}" ]]; then
  3113. ( insinto "${JAVA_PKG_LIBDEST}";
  3114. insopts -m0755;
  3115. doins "${lib}" ) || die "failed to install ${lib}";
  3116. java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}";
  3117. debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}";
  3118. else
  3119. dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}";
  3120. debug-print "${lib} is a symlink, linking accordantly";
  3121. fi;
  3122. else
  3123. die "${lib} does not exist";
  3124. fi;
  3125. done;
  3126. java-pkg_do_write_
  3127. }
  3128. java-pkg_dosrc ()
  3129. {
  3130. debug-print-function ${FUNCNAME} $*;
  3131. [ ${#} -lt 1 ] && die "At least one argument needed";
  3132. java-pkg_check-phase install;
  3133. [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3134. if ! [[ ${DEPEND} = *app-arch/zip* ]]; then
  3135. local msg="${FUNCNAME} called without app-arch/zip in DEPEND";
  3136. java-pkg_announce-qa-violation ${msg};
  3137. fi;
  3138. java-pkg_init_paths_;
  3139. local zip_name="${PN}-src.zip";
  3140. local zip_path="${T}/${zip_name}";
  3141. local dir;
  3142. for dir in "${@}";
  3143. do
  3144. local dir_parent=$(dirname "${dir}");
  3145. local dir_name=$(basename "${dir}");
  3146. pushd ${dir_parent} > /dev/null || die "problem entering ${dir_parent}";
  3147. zip -q -r ${zip_path} ${dir_name} -i '*.java';
  3148. local result=$?;
  3149. if [[ ${result} != 12 && ${result} != 0 ]]; then
  3150. die "failed to zip ${dir_name}";
  3151. fi;
  3152. popd > /dev/null || die;
  3153. done;
  3154. ( insinto "${JAVA_PKG_SOURCESPATH}";
  3155. doins ${zip_path} ) || die "Failed to install source";
  3156. JAVA_SOURCES="${JAVA_PKG_SOURCESPATH}/${zip_name}";
  3157. if [[ -n ${JAVA_PKG_DEBUG} ]]; then
  3158. einfo "Verbose logging for \"${FUNCNAME}\" function";
  3159. einfo "Zip filename created: ${zip_name}";
  3160. einfo "Zip file destination: ${JAVA_PKG_SOURCESPATH}";
  3161. einfo "Directories zipped: ${@}";
  3162. einfo "Complete command:";
  3163. einfo "${FUNCNAME} ${@}";
  3164. fi;
  3165. java-pkg_do_write_
  3166. }
  3167. java-pkg_dowar ()
  3168. {
  3169. debug-print-function ${FUNCNAME} $*;
  3170. [[ ${#} -lt 1 ]] && die "At least one argument needed";
  3171. java-pkg_check-phase install;
  3172. java-pkg_init_paths_;
  3173. local war;
  3174. for war in $*;
  3175. do
  3176. local warpath;
  3177. if [[ -L "${war}" ]]; then
  3178. cp "${war}" "${T}";
  3179. warpath="${T}$(basename "${war}")";
  3180. else
  3181. if [[ -d "${war}" ]]; then
  3182. echo "dowar: warning, skipping directory ${war}";
  3183. continue;
  3184. else
  3185. warpath="${war}";
  3186. fi;
  3187. fi;
  3188. ( insopts -m0644;
  3189. insinto "${JAVA_PKG_WARDEST}";
  3190. doins ${warpath} );
  3191. done
  3192. }
  3193. java-pkg_ensure-dep ()
  3194. {
  3195. debug-print-function ${FUNCNAME} $*;
  3196. local limit_to="${1}";
  3197. local target_pkg="${2}";
  3198. local dev_error="";
  3199. local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b;
  3200. debug-print "Matching against: ${stripped_pkg}";
  3201. if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
  3202. dev_error="The ebuild is attempting to use ${target_pkg}, which is not ";
  3203. dev_error+="declared with a SLOT in DEPEND.";
  3204. eqawarn "java-pkg_ensure-dep: ${dev_error}";
  3205. else
  3206. if [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
  3207. dev_error="The ebuild is attempting to use ${target_pkg}, which is not ";
  3208. dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given.";
  3209. eqawarn "java-pkg_ensure-dep: ${dev_error}";
  3210. fi;
  3211. fi
  3212. }
  3213. java-pkg_ensure-gcj ()
  3214. {
  3215. die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
  3216. }
  3217. java-pkg_ensure-no-bundled-jars ()
  3218. {
  3219. debug-print-function ${FUNCNAME} $*;
  3220. local bundled_jars=$(java-pkg_find-normal-jars);
  3221. if [[ -n ${bundled_jars} ]]; then
  3222. echo "Bundled jars found:";
  3223. local jar;
  3224. for jar in ${bundled_jars};
  3225. do
  3226. echo $(pwd)${jar/./};
  3227. done;
  3228. die "Bundled jars found!";
  3229. fi
  3230. }
  3231. java-pkg_ensure-test ()
  3232. {
  3233. die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
  3234. }
  3235. java-pkg_ensure-vm-version-eq ()
  3236. {
  3237. debug-print-function ${FUNCNAME} $*;
  3238. if ! java-pkg_is-vm-version-eq $@; then
  3239. debug-print "VM is not suffient";
  3240. eerror "This package requires a Java VM version = $@";
  3241. einfo "Please use java-config -S to set the correct one";
  3242. die "Active Java VM too old";
  3243. fi
  3244. }
  3245. java-pkg_ensure-vm-version-ge ()
  3246. {
  3247. debug-print-function ${FUNCNAME} $*;
  3248. if ! java-pkg_is-vm-version-ge "$@"; then
  3249. debug-print "vm is not suffient";
  3250. eerror "This package requires a Java VM version >= $@";
  3251. einfo "Please use java-config -S to set the correct one";
  3252. die "Active Java VM too old";
  3253. fi
  3254. }
  3255. java-pkg_ensure-vm-version-sufficient ()
  3256. {
  3257. debug-print-function ${FUNCNAME} $*;
  3258. if ! java-pkg_is-vm-version-sufficient; then
  3259. debug-print "VM is not suffient";
  3260. eerror "Current Java VM cannot build this package";
  3261. einfo "Please use java-config -S to set the correct one";
  3262. die "Active Java VM cannot build this package";
  3263. fi
  3264. }
  3265. java-pkg_expand_dir_ ()
  3266. {
  3267. pushd "$(dirname "${1}")" > /dev/null 2>&1 || die;
  3268. pwd;
  3269. popd > /dev/null 2>&1 || die
  3270. }
  3271. java-pkg_filter-compiler ()
  3272. {
  3273. JAVA_PKG_FILTER_COMPILER="${JAVA_PKG_FILTER_COMPILER} $@"
  3274. }
  3275. java-pkg_find-normal-jars ()
  3276. {
  3277. local dir=$1;
  3278. [[ -n "${dir}" ]] || dir="${WORKDIR}";
  3279. local found;
  3280. for jar in $(find "${dir}" -name "*.jar" -type f);
  3281. do
  3282. echo "${jar}";
  3283. found="true";
  3284. done;
  3285. [[ -n "${found}" ]];
  3286. return $?
  3287. }
  3288. java-pkg_force-compiler ()
  3289. {
  3290. JAVA_PKG_FORCE_COMPILER="$@"
  3291. }
  3292. java-pkg_func-exists ()
  3293. {
  3294. declare -F ${1} > /dev/null
  3295. }
  3296. java-pkg_gen-cp ()
  3297. {
  3298. debug-print-function ${FUNCNAME} "${@}";
  3299. local atom;
  3300. for atom in ${CP_DEPEND};
  3301. do
  3302. if [[ ${atom} =~ /(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)?(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+) ]]; then
  3303. atom=${BASH_REMATCH[2]:-${BASH_REMATCH[1]}};
  3304. [[ ${BASH_REMATCH[6]} != 0 ]] && atom+=-${BASH_REMATCH[6]};
  3305. local regex="(^|\s|,)${atom}($|\s|,)";
  3306. [[ ${!1} =~ ${regex} ]] || declare -g ${1}+=${!1:+,}${atom};
  3307. else
  3308. die "Invalid CP_DEPEND atom ${atom}, ensure a SLOT is included";
  3309. fi;
  3310. done
  3311. }
  3312. java-pkg_get-bootclasspath ()
  3313. {
  3314. local version="${1}";
  3315. local bcp;
  3316. case "${version}" in
  3317. auto)
  3318. bcp="$(java-config -g BOOTCLASSPATH)"
  3319. ;;
  3320. 1.5)
  3321. bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
  3322. ;;
  3323. *)
  3324. eerror "unknown parameter of java-pkg_get-bootclasspath";
  3325. die "unknown parameter of java-pkg_get-bootclasspath"
  3326. ;;
  3327. esac;
  3328. echo "${bcp}"
  3329. }
  3330. java-pkg_get-current-vm ()
  3331. {
  3332. java-config -f
  3333. }
  3334. java-pkg_get-javac ()
  3335. {
  3336. debug-print-function ${FUNCNAME} $*;
  3337. java-pkg_init-compiler_;
  3338. local compiler="${GENTOO_COMPILER}";
  3339. local compiler_executable;
  3340. if [[ "${compiler}" = "javac" ]]; then
  3341. compiler_executable="javac";
  3342. else
  3343. local compiler_env="/usr/share/java-config-2/compiler/${compiler}";
  3344. if [[ -f ${compiler_env} ]]; then
  3345. local old_javac=${JAVAC};
  3346. unset JAVAC;
  3347. compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})";
  3348. export JAVAC=${old_javac};
  3349. if [[ -z ${compiler_executable} ]]; then
  3350. die "JAVAC is empty or undefined in ${compiler_env}";
  3351. fi;
  3352. if [[ ! -x ${compiler_executable} ]]; then
  3353. die "${compiler_executable} doesn't exist, or isn't executable";
  3354. fi;
  3355. else
  3356. die "Could not find environment file for ${compiler}";
  3357. fi;
  3358. fi;
  3359. echo ${compiler_executable}
  3360. }
  3361. java-pkg_get-jni-cflags ()
  3362. {
  3363. local flags="-I${JAVA_HOME}/include";
  3364. local platform="linux";
  3365. use elibc_FreeBSD && platform="freebsd";
  3366. flags="${flags} -I${JAVA_HOME}/include/${platform}";
  3367. echo ${flags}
  3368. }
  3369. java-pkg_get-source ()
  3370. {
  3371. echo ${JAVA_PKG_WANT_SOURCE:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
  3372. }
  3373. java-pkg_get-target ()
  3374. {
  3375. echo ${JAVA_PKG_WANT_TARGET:-$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")}
  3376. }
  3377. java-pkg_get-vm-vendor ()
  3378. {
  3379. debug-print-function ${FUNCNAME} $*;
  3380. local vm="$(java-pkg_get-current-vm)";
  3381. vm="${vm/-*/}";
  3382. echo "${vm}"
  3383. }
  3384. java-pkg_get-vm-version ()
  3385. {
  3386. debug-print-function ${FUNCNAME} $*;
  3387. java-config -g PROVIDES_VERSION
  3388. }
  3389. java-pkg_getjar ()
  3390. {
  3391. debug-print-function ${FUNCNAME} $*;
  3392. local build_only="";
  3393. local virtual="";
  3394. local record_jar="";
  3395. [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3396. while [[ "${1}" == --* ]]; do
  3397. if [[ "${1}" = "--build-only" ]]; then
  3398. build_only="build";
  3399. else
  3400. if [[ "${1}" == "--virtual" ]]; then
  3401. virtual="true";
  3402. else
  3403. die "java-pkg_getjar called with unknown parameter: ${1}";
  3404. fi;
  3405. fi;
  3406. shift;
  3407. done;
  3408. [[ ${#} -ne 2 ]] && die "${FUNCNAME} takes only two arguments besides --*";
  3409. local pkg="${1}" target_jar="${2}" jar;
  3410. if [[ "${EAPI}" == "1" ]]; then
  3411. pkg="${pkg//:/-}";
  3412. fi;
  3413. [[ -z ${pkg} ]] && die "Must specify package to get a jar from";
  3414. [[ -z ${target_jar} ]] && die "Must specify jar to get";
  3415. local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?";
  3416. local classpath;
  3417. classpath=$(java-config --classpath=${pkg});
  3418. [[ $? != 0 ]] && die ${error_msg};
  3419. java-pkg_ensure-dep "${build_only}" "${pkg}";
  3420. if [[ -n "${virtual}" ]]; then
  3421. if [[ -z "${build_only}" ]]; then
  3422. java-pkg_record-jar_ "${pkg}";
  3423. else
  3424. java-pkg_record-jar_ --build-only "${pkg}";
  3425. fi;
  3426. record_jar="true";
  3427. fi;
  3428. for jar in ${classpath//:/ };
  3429. do
  3430. if [[ ! -f "${jar}" ]]; then
  3431. die "Installation problem with jar ${jar} in ${pkg} - is it installed?";
  3432. fi;
  3433. if [[ "$(basename ${jar})" == "${target_jar}" ]]; then
  3434. if [[ -z "${record_jar}" ]]; then
  3435. if [[ -z "${build_only}" ]]; then
  3436. java-pkg_record-jar_ "${pkg}" "${jar}";
  3437. else
  3438. java-pkg_record-jar_ --build-only "${pkg}" "${jar}";
  3439. fi;
  3440. fi;
  3441. echo "${jar}";
  3442. return 0;
  3443. fi;
  3444. done;
  3445. die "Could not find ${target_jar} in ${pkg}";
  3446. return 1
  3447. }
  3448. java-pkg_getjars ()
  3449. {
  3450. debug-print-function ${FUNCNAME} $*;
  3451. local build_only="";
  3452. local deep="";
  3453. [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3454. while [[ "${1}" == --* ]]; do
  3455. if [[ "${1}" = "--build-only" ]]; then
  3456. build_only="build";
  3457. else
  3458. if [[ "${1}" = "--with-dependencies" ]]; then
  3459. deep="--with-dependencies";
  3460. else
  3461. die "java-pkg_jar-from called with unknown parameter: ${1}";
  3462. fi;
  3463. fi;
  3464. shift;
  3465. done;
  3466. [[ ${#} -ne 1 ]] && die "${FUNCNAME} takes only one argument besides --*";
  3467. local pkgs="${1}";
  3468. if [[ "${EAPI}" == "1" ]]; then
  3469. pkgs="${pkgs//:/-}";
  3470. fi;
  3471. jars="$(java-config ${deep} --classpath=${pkgs})";
  3472. [[ $? != 0 ]] && die "java-config --classpath=${pkgs} failed";
  3473. debug-print "${pkgs}:${jars}";
  3474. for pkg in ${pkgs//,/ };
  3475. do
  3476. java-pkg_ensure-dep "${build_only}" "${pkg}";
  3477. done;
  3478. for pkg in ${pkgs//,/ };
  3479. do
  3480. if [[ -z "${build_only}" ]]; then
  3481. java-pkg_record-jar_ "${pkg}";
  3482. else
  3483. java-pkg_record-jar_ --build-only "${pkg}";
  3484. fi;
  3485. done;
  3486. echo "${jars}"
  3487. }
  3488. java-pkg_init ()
  3489. {
  3490. debug-print-function ${FUNCNAME} $*;
  3491. [[ "${MERGE_TYPE}" == "binary" ]] && return;
  3492. has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return;
  3493. unset JAVAC;
  3494. unset JAVA_HOME;
  3495. java-config --help > /dev/null || {
  3496. eerror "";
  3497. eerror "Can't run java-config --help";
  3498. eerror "Have you upgraded python recently but haven't";
  3499. eerror "run python-updater yet?";
  3500. die "Can't run java-config --help"
  3501. };
  3502. local silence="${SILENCE_JAVA_OPTIONS_WARNING}";
  3503. local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}";
  3504. if [[ -n ${_JAVA_OPTIONS} && -z ${accept} && -z ${silence} ]]; then
  3505. ewarn "_JAVA_OPTIONS changes what java -version outputs at least for";
  3506. ewarn "sun-jdk vms and and as such break configure scripts that";
  3507. ewarn "use it (for example app-office/openoffice) so we filter it out.";
  3508. ewarn "Use SILENCE_JAVA_OPTIONS_WARNING=true in the environment (use";
  3509. ewarn "make.conf for example) to silence this warning or";
  3510. ewarn "I_WANT_GLOBAL_JAVA_OPTIONS to not filter it.";
  3511. fi;
  3512. if [[ -z ${accept} ]]; then
  3513. unset _JAVA_OPTIONS;
  3514. I_WANT_GLOBAL_JAVA_OPTIONS="true";
  3515. fi;
  3516. java-pkg_switch-vm;
  3517. PATH=${JAVA_HOME}/bin:${PATH};
  3518. java-pkg_check-jikes;
  3519. export CLASSPATH=;
  3520. export ANT_TASKS=;
  3521. export ANT_OPTS=;
  3522. export ANT_RESPECT_JAVA_HOME=
  3523. }
  3524. java-pkg_init-compiler_ ()
  3525. {
  3526. debug-print-function ${FUNCNAME} $*;
  3527. if [[ -n ${GENTOO_COMPILER} ]]; then
  3528. debug-print "GENTOO_COMPILER already set";
  3529. return;
  3530. fi;
  3531. local compilers;
  3532. if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
  3533. compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})";
  3534. else
  3535. compilers=${JAVA_PKG_FORCE_COMPILER};
  3536. fi;
  3537. debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}";
  3538. local compiler;
  3539. for compiler in ${compilers};
  3540. do
  3541. debug-print "Checking ${compiler}...";
  3542. if [[ ${compiler} = "javac" ]]; then
  3543. debug-print "Found javac... breaking";
  3544. export GENTOO_COMPILER="javac";
  3545. break;
  3546. fi;
  3547. if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
  3548. if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
  3549. einfo "Filtering ${compiler}" 1>&2;
  3550. continue;
  3551. fi;
  3552. fi;
  3553. local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}";
  3554. if [[ -f ${compiler_env} ]]; then
  3555. local desired_target="$(java-pkg_get-target)";
  3556. local desired_source="$(java-pkg_get-source)";
  3557. local supported_target=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_TARGET});
  3558. if ! has ${desired_target} ${supported_target}; then
  3559. ewarn "${compiler} does not support -target ${desired_target}, skipping";
  3560. continue;
  3561. fi;
  3562. local supported_source=$(source ${compiler_env} 1>/dev/null 2>&1; echo ${SUPPORTED_SOURCE});
  3563. if ! has ${desired_source} ${supported_source}; then
  3564. ewarn "${compiler} does not support -source ${desired_source}, skipping";
  3565. continue;
  3566. fi;
  3567. export GENTOO_COMPILER="${compiler}";
  3568. break;
  3569. else
  3570. ewarn "Could not find configuration for ${compiler}, skipping";
  3571. ewarn "Perhaps it is not installed?";
  3572. continue;
  3573. fi;
  3574. done;
  3575. if [[ -z ${GENTOO_COMPILER} ]]; then
  3576. if [[ -n ${compilers} ]]; then
  3577. einfo "No suitable compiler found: defaulting to JDK default for compilation" 1>&2;
  3578. else
  3579. :;
  3580. fi;
  3581. if java-config -g GENTOO_COMPILER 2> /dev/null; then
  3582. export GENTOO_COMPILER=$(java-config -g GENTOO_COMPILER);
  3583. else
  3584. export GENTOO_COMPILER=javac;
  3585. fi;
  3586. else
  3587. einfo "Using ${GENTOO_COMPILER} for compilation" 1>&2;
  3588. fi
  3589. }
  3590. java-pkg_init_paths_ ()
  3591. {
  3592. debug-print-function ${FUNCNAME} $*;
  3593. local pkg_name;
  3594. if [[ "${SLOT%/*}" == "0" ]]; then
  3595. JAVA_PKG_NAME="${PN}";
  3596. else
  3597. JAVA_PKG_NAME="${PN}-${SLOT%/*}";
  3598. fi;
  3599. JAVA_PKG_SHAREPATH="/usr/share/${JAVA_PKG_NAME}";
  3600. JAVA_PKG_SOURCESPATH="${JAVA_PKG_SHAREPATH}/sources/";
  3601. JAVA_PKG_ENV="${D}${JAVA_PKG_SHAREPATH}/package.env";
  3602. JAVA_PKG_VIRTUALS_PATH="/usr/share/java-config-2/virtuals";
  3603. JAVA_PKG_VIRTUAL_PROVIDER="${D}/${JAVA_PKG_VIRTUALS_PATH}/${JAVA_PKG_NAME}";
  3604. [[ -z "${JAVA_PKG_JARDEST}" ]] && JAVA_PKG_JARDEST="${JAVA_PKG_SHAREPATH}/lib";
  3605. [[ -z "${JAVA_PKG_LIBDEST}" ]] && JAVA_PKG_LIBDEST="/usr/$(get_libdir)/${JAVA_PKG_NAME}";
  3606. [[ -z "${JAVA_PKG_WARDEST}" ]] && JAVA_PKG_WARDEST="${JAVA_PKG_SHAREPATH}/webapps";
  3607. debug-print "JAVA_PKG_SHAREPATH: ${JAVA_PKG_SHAREPATH}";
  3608. debug-print "JAVA_PKG_ENV: ${JAVA_PKG_ENV}";
  3609. debug-print "JAVA_PKG_JARDEST: ${JAVA_PKG_JARDEST}";
  3610. debug-print "JAVA_PKG_LIBDEST: ${JAVA_PKG_LIBDEST}";
  3611. debug-print "JAVA_PKG_WARDEST: ${JAVA_PKG_WARDEST}"
  3612. }
  3613. java-pkg_is-vm-version-eq ()
  3614. {
  3615. debug-print-function ${FUNCNAME} $*;
  3616. local needed_version="$@";
  3617. [[ -z "${needed_version}" ]] && die "need an argument";
  3618. local vm_version="$(java-pkg_get-vm-version)";
  3619. vm_version="$(get_version_component_range 1-2 "${vm_version}")";
  3620. needed_version="$(get_version_component_range 1-2 "${needed_version}")";
  3621. if [[ -z "${vm_version}" ]]; then
  3622. debug-print "Could not get JDK version from DEPEND";
  3623. return 1;
  3624. else
  3625. if [[ "${vm_version}" == "${needed_version}" ]]; then
  3626. debug-print "Detected a JDK(${vm_version}) = ${needed_version}";
  3627. return 0;
  3628. else
  3629. debug-print "Detected a JDK(${vm_version}) != ${needed_version}";
  3630. return 1;
  3631. fi;
  3632. fi
  3633. }
  3634. java-pkg_is-vm-version-ge ()
  3635. {
  3636. debug-print-function ${FUNCNAME} $*;
  3637. local needed_version=$@;
  3638. local vm_version=$(java-pkg_get-vm-version);
  3639. if [[ -z "${vm_version}" ]]; then
  3640. debug-print "Could not get JDK version from DEPEND";
  3641. return 1;
  3642. else
  3643. if version_is_at_least "${needed_version}" "${vm_version}"; then
  3644. debug-print "Detected a JDK(${vm_version}) >= ${needed_version}";
  3645. return 0;
  3646. else
  3647. debug-print "Detected a JDK(${vm_version}) < ${needed_version}";
  3648. return 1;
  3649. fi;
  3650. fi
  3651. }
  3652. java-pkg_is-vm-version-sufficient ()
  3653. {
  3654. debug-print-function ${FUNCNAME} $*;
  3655. depend-java-query --is-sufficient "${DEPEND}" > /dev/null;
  3656. return $?
  3657. }
  3658. java-pkg_jar-from ()
  3659. {
  3660. debug-print-function ${FUNCNAME} $*;
  3661. local build_only="";
  3662. local destdir=".";
  3663. local deep="";
  3664. local virtual="";
  3665. local record_jar="";
  3666. [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build";
  3667. while [[ "${1}" == --* ]]; do
  3668. if [[ "${1}" = "--build-only" ]]; then
  3669. build_only="build";
  3670. else
  3671. if [[ "${1}" = "--with-dependencies" ]]; then
  3672. deep="--with-dependencies";
  3673. else
  3674. if [[ "${1}" = "--virtual" ]]; then
  3675. virtual="true";
  3676. else
  3677. if [[ "${1}" = "--into" ]]; then
  3678. destdir="${2}";
  3679. shift;
  3680. else
  3681. die "java-pkg_jar-from called with unknown parameter: ${1}";
  3682. fi;
  3683. fi;
  3684. fi;
  3685. fi;
  3686. shift;
  3687. done;
  3688. local target_pkg="${1}" target_jar="${2}" destjar="${3}";
  3689. [[ -z ${target_pkg} ]] && die "Must specify a package";
  3690. if [[ "${EAPI}" == "1" ]]; then
  3691. target_pkg="${target_pkg//:/-}";
  3692. fi;
  3693. [[ -z "${destjar}" ]] && destjar="${target_jar}";
  3694. local error_msg="There was a problem getting the classpath for ${target_pkg}.";
  3695. local classpath;
  3696. classpath="$(java-config ${deep} --classpath=${target_pkg})";
  3697. [[ $? != 0 ]] && die ${error_msg};
  3698. if [[ ${target_pkg} = *,* ]]; then
  3699. for pkg in ${target_pkg//,/ };
  3700. do
  3701. java-pkg_ensure-dep "${build_only}" "${pkg}";
  3702. [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}";
  3703. done;
  3704. record_jar="true";
  3705. else
  3706. java-pkg_ensure-dep "${build_only}" "${target_pkg}";
  3707. fi;
  3708. if [[ -z "${build_only}" && -n "${virtual}" ]]; then
  3709. java-pkg_record-jar_ "${target_pkg}";
  3710. record_jar="true";
  3711. fi;
  3712. pushd ${destdir} > /dev/null || die "failed to change directory to ${destdir}";
  3713. local jar;
  3714. for jar in ${classpath//:/ };
  3715. do
  3716. local jar_name=$(basename "${jar}");
  3717. if [[ ! -f "${jar}" ]]; then
  3718. debug-print "${jar} from ${target_pkg} does not exist";
  3719. die "Installation problems with jars in ${target_pkg} - is it installed?";
  3720. fi;
  3721. if [[ -z "${target_jar}" ]]; then
  3722. [[ -f "${target_jar}" ]] && rm "${target_jar}";
  3723. ln -snf "${jar}" || die "Failed to make symlink from ${jar} to ${jar_name}";
  3724. if [[ -z "${record_jar}" ]]; then
  3725. if [[ -z "${build_only}" ]]; then
  3726. java-pkg_record-jar_ "${target_pkg}" "${jar}";
  3727. else
  3728. java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}";
  3729. fi;
  3730. fi;
  3731. else
  3732. if [[ "${jar_name}" == "${target_jar}" ]]; then
  3733. [[ -f "${destjar}" ]] && rm "${destjar}";
  3734. ln -snf "${jar}" "${destjar}" || die "Failed to make symlink from ${jar} to ${destjar}";
  3735. if [[ -z "${record_jar}" ]]; then
  3736. if [[ -z "${build_only}" ]]; then
  3737. java-pkg_record-jar_ "${target_pkg}" "${jar}";
  3738. else
  3739. java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}";
  3740. fi;
  3741. fi;
  3742. popd > /dev/null || die;
  3743. return 0;
  3744. fi;
  3745. fi;
  3746. done;
  3747. popd > /dev/null || die;
  3748. if [[ -z "${target_jar}" ]]; then
  3749. return 0;
  3750. else
  3751. die "Failed to find ${target_jar:-jar} in ${target_pkg}";
  3752. fi
  3753. }
  3754. java-pkg_jar-list ()
  3755. {
  3756. if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
  3757. einfo "Linked Jars";
  3758. find "${S}" -type l -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  3759. einfo "Jars";
  3760. find "${S}" -type f -name '*.jar' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  3761. einfo "Classes";
  3762. find "${S}" -type f -name '*.class' -print0 | xargs -0 -r -n 500 ls -ald | sed -e "s,${WORKDIR},\${WORKDIR},";
  3763. fi
  3764. }
  3765. java-pkg_jarfrom ()
  3766. {
  3767. java-pkg_jar-from "$@"
  3768. }
  3769. java-pkg_jarinto ()
  3770. {
  3771. debug-print-function ${FUNCNAME} $*;
  3772. JAVA_PKG_JARDEST="${1}"
  3773. }
  3774. java-pkg_javac-args ()
  3775. {
  3776. debug-print-function ${FUNCNAME} $*;
  3777. local want_source="$(java-pkg_get-source)";
  3778. local want_target="$(java-pkg_get-target)";
  3779. local source_str="-source ${want_source}";
  3780. local target_str="-target ${want_target}";
  3781. debug-print "want source: ${want_source}";
  3782. debug-print "want target: ${want_target}";
  3783. if [[ -z "${want_source}" || -z "${want_target}" ]]; then
  3784. die "Could not find valid -source/-target values for javac";
  3785. else
  3786. echo "${source_str} ${target_str}";
  3787. fi
  3788. }
  3789. java-pkg_needs-vm ()
  3790. {
  3791. debug-print-function ${FUNCNAME} $*;
  3792. if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
  3793. return 0;
  3794. fi;
  3795. [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0;
  3796. return 1
  3797. }
  3798. java-pkg_newjar ()
  3799. {
  3800. debug-print-function ${FUNCNAME} $*;
  3801. local original_jar="${1}";
  3802. local new_jar="${2:-${PN}.jar}";
  3803. local new_jar_dest="${T}/${new_jar}";
  3804. [[ -z ${original_jar} ]] && die "Must specify a jar to install";
  3805. [[ ! -f ${original_jar} ]] && die "${original_jar} does not exist or is not a file!";
  3806. rm -f "${new_jar_dest}" || die "Failed to remove ${new_jar_dest}";
  3807. cp "${original_jar}" "${new_jar_dest}" || die "Failed to copy ${original_jar} to ${new_jar_dest}";
  3808. java-pkg_dojar "${new_jar_dest}"
  3809. }
  3810. java-pkg_record-jar_ ()
  3811. {
  3812. debug-print-function ${FUNCNAME} $*;
  3813. local depend_file="${JAVA_PKG_DEPEND_FILE}";
  3814. case "${1}" in
  3815. "--optional")
  3816. depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}";
  3817. shift
  3818. ;;
  3819. "--build-only")
  3820. depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}";
  3821. shift
  3822. ;;
  3823. esac;
  3824. local pkg=${1} jar=${2} append;
  3825. if [[ -z "${jar}" ]]; then
  3826. append="${pkg}";
  3827. else
  3828. append="$(basename ${jar})@${pkg}";
  3829. fi;
  3830. echo "${append}" >> "${depend_file}"
  3831. }
  3832. java-pkg_recordjavadoc ()
  3833. {
  3834. debug-print-function ${FUNCNAME} $*;
  3835. JAVADOC_PATH="$(find ${D}/usr/share/doc/ -name allclasses-frame.html -printf '%h:')";
  3836. JAVADOC_PATH="${JAVADOC_PATH//${D}}";
  3837. if [[ -n "${JAVADOC_PATH}" ]]; then
  3838. debug-print "javadocs found in ${JAVADOC_PATH%:}";
  3839. java-pkg_do_write_;
  3840. else
  3841. debug-print "No javadocs found";
  3842. fi
  3843. }
  3844. java-pkg_register-ant-task ()
  3845. {
  3846. local TASKS_DIR="tasks";
  3847. while [[ -n "${1}" && -n "${2}" ]]; do
  3848. local var="${1#--}";
  3849. local val="${2}";
  3850. if [[ "${var}" == "version" ]]; then
  3851. TASKS_DIR="tasks-${val}";
  3852. else
  3853. die "Unknown parameter passed to java-pkg_register-ant-tasks: ${1} ${2}";
  3854. fi;
  3855. shift 2;
  3856. done;
  3857. local TASK_NAME="${1:-${JAVA_PKG_NAME}}";
  3858. dodir /usr/share/ant/${TASKS_DIR};
  3859. touch "${D}/usr/share/ant/${TASKS_DIR}/${TASK_NAME}"
  3860. }
  3861. java-pkg_register-dependency ()
  3862. {
  3863. debug-print-function ${FUNCNAME} $*;
  3864. java-pkg_check-phase install;
  3865. [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments";
  3866. local pkgs="${1}";
  3867. local jar="${2}";
  3868. [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified";
  3869. if [[ "${EAPI}" == "1" ]]; then
  3870. pkgs="${pkgs//:/-}";
  3871. fi;
  3872. if [[ -z "${jar}" ]]; then
  3873. for pkg in ${pkgs//,/ };
  3874. do
  3875. java-pkg_ensure-dep runtime "${pkg}";
  3876. java-pkg_record-jar_ "${pkg}";
  3877. done;
  3878. else
  3879. [[ ${pkgs} == *,* ]] && die "${FUNCNAME} called with both package list and jar name";
  3880. java-pkg_ensure-dep runtime "${pkgs}";
  3881. java-pkg_record-jar_ "${pkgs}" "${jar}";
  3882. fi;
  3883. java-pkg_do_write_
  3884. }
  3885. java-pkg_register-environment-variable ()
  3886. {
  3887. debug-print-function ${FUNCNAME} $*;
  3888. java-pkg_check-phase install;
  3889. [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments";
  3890. echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV};
  3891. JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}";
  3892. java-pkg_do_write_
  3893. }
  3894. java-pkg_register-optional-dependency ()
  3895. {
  3896. debug-print-function ${FUNCNAME} $*;
  3897. java-pkg_check-phase install;
  3898. [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments";
  3899. local pkgs="${1}";
  3900. local jar="${2}";
  3901. [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified";
  3902. if [[ "${EAPI}" == "1" ]]; then
  3903. pkgs="${pkgs//:/-}";
  3904. fi;
  3905. if [[ -z "${jar}" ]]; then
  3906. for pkg in ${pkgs//,/ };
  3907. do
  3908. java-pkg_record-jar_ --optional "${pkg}";
  3909. done;
  3910. else
  3911. [[ ${pkgs} == *,* ]] && die "${FUNCNAME} called with both package list and jar name";
  3912. java-pkg_record-jar_ --optional "${pkgs}" "${jar}";
  3913. fi;
  3914. java-pkg_do_write_
  3915. }
  3916. java-pkg_regjar ()
  3917. {
  3918. debug-print-function ${FUNCNAME} $*;
  3919. java-pkg_check-phase install;
  3920. [[ ${#} -lt 1 ]] && die "at least one argument needed";
  3921. java-pkg_init_paths_;
  3922. local jar jar_dir jar_file;
  3923. for jar in "${@}";
  3924. do
  3925. if [[ -e "${jar}" || -e "${D}${jar}" ]]; then
  3926. [[ -d "${jar}" || -d "${D}${jar}" ]] && die "Called ${FUNCNAME} on a directory $*";
  3927. is-java-strict && java-pkg_verify-classes "${jar}";
  3928. java-pkg_append_ JAVA_PKG_CLASSPATH "${jar#${D}}";
  3929. else
  3930. if [[ ${jar} = *\** ]]; then
  3931. eerror "The argument ${jar} to ${FUNCNAME}";
  3932. eerror "has * in it. If you want it to glob in";
  3933. eerror '${D} add ${D} to the argument.';
  3934. fi;
  3935. debug-print "${jar} or ${D}${jar} not found";
  3936. die "${jar} does not exist";
  3937. fi;
  3938. done;
  3939. java-pkg_do_write_
  3940. }
  3941. java-pkg_regso ()
  3942. {
  3943. debug-print-function ${FUNCNAME} $*;
  3944. java-pkg_check-phase install;
  3945. [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument";
  3946. java-pkg_init_paths_;
  3947. local lib target_dir;
  3948. for lib in "$@";
  3949. do
  3950. if [[ -e "${lib}" ]]; then
  3951. target_dir="$(java-pkg_expand_dir_ ${lib})";
  3952. java-pkg_append_ JAVA_PKG_LIBRARY "/${target_dir#${D}}";
  3953. else
  3954. if [[ -e "${D}${lib}" ]]; then
  3955. target_dir="$(java-pkg_expand_dir_ ${D}${lib})";
  3956. java-pkg_append_ JAVA_PKG_LIBRARY "${target_dir}";
  3957. else
  3958. die "${lib} does not exist";
  3959. fi;
  3960. fi;
  3961. done;
  3962. java-pkg_do_write_
  3963. }
  3964. java-pkg_rm_files ()
  3965. {
  3966. debug-print-function ${FUNCNAME} $*;
  3967. local IFS="\n";
  3968. for filename in "$@";
  3969. do
  3970. [[ ! -f "${filename}" ]] && die "${filename} is not a regular file. Aborting.";
  3971. einfo "Removing unneeded file ${filename}";
  3972. rm -f "${S}/${filename}" || die "cannot remove ${filename}";
  3973. eend $?;
  3974. done
  3975. }
  3976. java-pkg_set-current-vm ()
  3977. {
  3978. export GENTOO_VM=${1}
  3979. }
  3980. java-pkg_setup-vm ()
  3981. {
  3982. debug-print-function ${FUNCNAME} $*;
  3983. local vendor="$(java-pkg_get-vm-vendor)";
  3984. if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5"; then
  3985. addpredict "/dev/random";
  3986. else
  3987. if [[ "${vendor}" == "ibm" ]]; then
  3988. addpredict "/proc/self/maps";
  3989. addpredict "/proc/cpuinfo";
  3990. addpredict "/proc/self/coredump_filter";
  3991. else
  3992. if [[ "${vendor}" == "oracle" ]]; then
  3993. addpredict "/dev/random";
  3994. addpredict "/proc/self/coredump_filter";
  3995. else
  3996. if [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7"; then
  3997. addpredict "/dev/random";
  3998. addpredict "/proc/self/coredump_filter";
  3999. else
  4000. if [[ "${vendor}" == "jrockit" ]]; then
  4001. addpredict "/proc/cpuinfo";
  4002. fi;
  4003. fi;
  4004. fi;
  4005. fi;
  4006. fi
  4007. }
  4008. java-pkg_sointo ()
  4009. {
  4010. debug-print-function ${FUNCNAME} $*;
  4011. JAVA_PKG_LIBDEST="${1}"
  4012. }
  4013. java-pkg_switch-vm ()
  4014. {
  4015. debug-print-function ${FUNCNAME} $*;
  4016. if java-pkg_needs-vm; then
  4017. if [[ -n "${JAVA_PKG_FORCE_VM}" ]]; then
  4018. debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}";
  4019. export GENTOO_VM="${JAVA_PKG_FORCE_VM}";
  4020. else
  4021. if [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
  4022. if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
  4023. debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}";
  4024. GENTOO_VM=$(java-pkg_build-vm-from-handle);
  4025. if [[ $? != 0 ]]; then
  4026. eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}";
  4027. die "${FUNCNAME}: Failed to determine VM for building";
  4028. fi;
  4029. if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
  4030. eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE";
  4031. die "Specify JAVA_PKG_WANT_SOURCE";
  4032. fi;
  4033. if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
  4034. eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET";
  4035. die "Specify JAVA_PKG_WANT_TARGET";
  4036. fi;
  4037. else
  4038. debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}";
  4039. GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")";
  4040. if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
  4041. eerror "Unable to determine VM for building from dependencies:";
  4042. echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}";
  4043. die "Failed to determine VM for building.";
  4044. fi;
  4045. fi;
  4046. export GENTOO_VM;
  4047. else
  4048. java-pkg_ensure-vm-version-sufficient;
  4049. fi;
  4050. fi;
  4051. debug-print "Using: $(java-config -f)";
  4052. java-pkg_setup-vm;
  4053. export JAVA=$(java-config --java);
  4054. export JAVAC=$(java-config --javac);
  4055. JAVACFLAGS="$(java-pkg_javac-args)";
  4056. [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}";
  4057. export JAVACFLAGS;
  4058. export JAVA_HOME="$(java-config -g JAVA_HOME)";
  4059. export JDK_HOME=${JAVA_HOME};
  4060. java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)";
  4061. local tann="${T}/announced-vm";
  4062. if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]]; then
  4063. einfo "Using: $(java-config -f)";
  4064. [[ ! -f "${tann}" ]] && touch "${tann}";
  4065. fi;
  4066. else
  4067. [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!";
  4068. fi
  4069. }
  4070. java-pkg_verify-classes ()
  4071. {
  4072. local version_verify="/usr/bin/class-version-verify.py";
  4073. if [[ ! -x "${version_verify}" ]]; then
  4074. version_verify="/usr/$(get_libdir)/javatoolkit/bin/class-version-verify.py";
  4075. fi;
  4076. if [[ ! -x "${version_verify}" ]]; then
  4077. ewarn "Unable to perform class version checks as";
  4078. ewarn "class-version-verify.py is unavailable";
  4079. ewarn "Please install dev-java/javatoolkit.";
  4080. return;
  4081. fi;
  4082. local target=$(java-pkg_get-target);
  4083. local result;
  4084. local log="${T}/class-version-verify.log";
  4085. if [[ -n "${1}" ]]; then
  4086. ${version_verify} -v -t ${target} "${1}" > "${log}";
  4087. result=$?;
  4088. else
  4089. ebegin "Verifying java class versions (target: ${target})";
  4090. ${version_verify} -v -t ${target} -r "${D}" > "${log}";
  4091. result=$?;
  4092. eend ${result};
  4093. fi;
  4094. [[ -n ${JAVA_PKG_DEBUG} ]] && cat "${log}";
  4095. if [[ ${result} != 0 ]]; then
  4096. eerror "Incorrect bytecode version found";
  4097. [[ -n "${1}" ]] && eerror "in file: ${1}";
  4098. eerror "See ${log} for more details.";
  4099. die "Incorrect bytecode found";
  4100. fi
  4101. }
  4102. java-utils-2_pkg_preinst ()
  4103. {
  4104. if is-java-strict; then
  4105. if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
  4106. return;
  4107. fi;
  4108. if has_version dev-java/java-dep-check; then
  4109. local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}");
  4110. [[ -n ${output} ]] && ewarn "${output}";
  4111. else
  4112. eerror "Install dev-java/java-dep-check for dependency checking";
  4113. fi;
  4114. fi
  4115. }
  4116. java-utils-2_src_prepare ()
  4117. {
  4118. case ${EAPI:-0} in
  4119. [0-5])
  4120. java-pkg_func-exists java_prepare && java_prepare
  4121. ;;
  4122. *)
  4123. java-pkg_func-exists java_prepare && eqawarn "java_prepare is no longer called, define src_prepare instead.";
  4124. eapply_user
  4125. ;;
  4126. esac;
  4127. if [[ -n ${JAVA_RM_FILES[@]} ]]; then
  4128. debug-print "$FUNCNAME: removing unneeded files";
  4129. java-pkg_rm_files "${JAVA_RM_FILES[@]}";
  4130. fi;
  4131. if is-java-strict; then
  4132. echo "Searching for bundled jars:";
  4133. java-pkg_find-normal-jars || echo "None found.";
  4134. echo "Searching for bundled classes (no output if none found):";
  4135. find "${WORKDIR}" -name "*.class";
  4136. echo "Search done.";
  4137. fi
  4138. }
  4139. kernel_is ()
  4140. {
  4141. linux-info_get_any_version;
  4142. local operator test value;
  4143. case ${1#-} in
  4144. lt)
  4145. operator="-lt";
  4146. shift
  4147. ;;
  4148. gt)
  4149. operator="-gt";
  4150. shift
  4151. ;;
  4152. le)
  4153. operator="-le";
  4154. shift
  4155. ;;
  4156. ge)
  4157. operator="-ge";
  4158. shift
  4159. ;;
  4160. eq)
  4161. operator="-eq";
  4162. shift
  4163. ;;
  4164. *)
  4165. operator="-eq"
  4166. ;;
  4167. esac;
  4168. [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters";
  4169. : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ));
  4170. : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ));
  4171. [ ${test} ${operator} ${value} ]
  4172. }
  4173. linux-info_get_any_version ()
  4174. {
  4175. get_version;
  4176. if [[ $? -ne 0 ]]; then
  4177. ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  4178. get_running_version;
  4179. fi
  4180. }
  4181. linux-info_pkg_setup ()
  4182. {
  4183. linux-info_get_any_version;
  4184. if kernel_is 2 4; then
  4185. if [ "$( gcc-major-version )" -eq "4" ]; then
  4186. echo;
  4187. ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with";
  4188. ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!";
  4189. echo;
  4190. ewarn "Either switch to another gcc-version (via gcc-config) or use a";
  4191. ewarn "newer kernel that supports gcc-4.";
  4192. echo;
  4193. ewarn "Also be aware that bugreports about gcc-4 not working";
  4194. ewarn "with linux-2.4 based ebuilds will be closed as INVALID!";
  4195. echo;
  4196. epause 10;
  4197. fi;
  4198. fi;
  4199. [ -n "${CONFIG_CHECK}" ] && check_extra_config
  4200. }
  4201. linux_chkconfig_builtin ()
  4202. {
  4203. linux_config_qa_check linux_chkconfig_builtin;
  4204. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
  4205. }
  4206. linux_chkconfig_module ()
  4207. {
  4208. linux_config_qa_check linux_chkconfig_module;
  4209. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
  4210. }
  4211. linux_chkconfig_present ()
  4212. {
  4213. linux_config_qa_check linux_chkconfig_present;
  4214. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
  4215. }
  4216. linux_chkconfig_string ()
  4217. {
  4218. linux_config_qa_check linux_chkconfig_string;
  4219. getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
  4220. }
  4221. linux_config_bin_exists ()
  4222. {
  4223. export _LINUX_CONFIG_EXISTS_DONE=1;
  4224. [[ -s /proc/config.gz ]]
  4225. }
  4226. linux_config_exists ()
  4227. {
  4228. linux_config_src_exists || linux_config_bin_exists
  4229. }
  4230. linux_config_path ()
  4231. {
  4232. if linux_config_src_exists; then
  4233. echo "${KV_OUT_DIR}/.config";
  4234. else
  4235. if linux_config_bin_exists; then
  4236. echo "/proc/config.gz";
  4237. else
  4238. return 1;
  4239. fi;
  4240. fi
  4241. }
  4242. linux_config_qa_check ()
  4243. {
  4244. local f="$1";
  4245. if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
  4246. ewarn "QA: You called $f before any linux_config_exists!";
  4247. ewarn "QA: The return value of $f will NOT guaranteed later!";
  4248. fi
  4249. }
  4250. linux_config_src_exists ()
  4251. {
  4252. export _LINUX_CONFIG_EXISTS_DONE=1;
  4253. [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
  4254. }
  4255. list-paxables ()
  4256. {
  4257. file "$@" 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//'
  4258. }
  4259. make_desktop_entry ()
  4260. {
  4261. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  4262. local exec=${1};
  4263. local name=${2:-${PN}};
  4264. local icon=${3:-${PN}};
  4265. local type=${4};
  4266. local fields=${5};
  4267. if [[ -z ${type} ]]; then
  4268. local catmaj=${CATEGORY%%-*};
  4269. local catmin=${CATEGORY##*-};
  4270. case ${catmaj} in
  4271. app)
  4272. case ${catmin} in
  4273. accessibility)
  4274. type="Utility;Accessibility"
  4275. ;;
  4276. admin)
  4277. type=System
  4278. ;;
  4279. antivirus)
  4280. type=System
  4281. ;;
  4282. arch)
  4283. type="Utility;Archiving"
  4284. ;;
  4285. backup)
  4286. type="Utility;Archiving"
  4287. ;;
  4288. cdr)
  4289. type="AudioVideo;DiscBurning"
  4290. ;;
  4291. dicts)
  4292. type="Office;Dictionary"
  4293. ;;
  4294. doc)
  4295. type=Documentation
  4296. ;;
  4297. editors)
  4298. type="Utility;TextEditor"
  4299. ;;
  4300. emacs)
  4301. type="Development;TextEditor"
  4302. ;;
  4303. emulation)
  4304. type="System;Emulator"
  4305. ;;
  4306. laptop)
  4307. type="Settings;HardwareSettings"
  4308. ;;
  4309. office)
  4310. type=Office
  4311. ;;
  4312. pda)
  4313. type="Office;PDA"
  4314. ;;
  4315. vim)
  4316. type="Development;TextEditor"
  4317. ;;
  4318. xemacs)
  4319. type="Development;TextEditor"
  4320. ;;
  4321. esac
  4322. ;;
  4323. dev)
  4324. type="Development"
  4325. ;;
  4326. games)
  4327. case ${catmin} in
  4328. action | fps)
  4329. type=ActionGame
  4330. ;;
  4331. arcade)
  4332. type=ArcadeGame
  4333. ;;
  4334. board)
  4335. type=BoardGame
  4336. ;;
  4337. emulation)
  4338. type=Emulator
  4339. ;;
  4340. kids)
  4341. type=KidsGame
  4342. ;;
  4343. puzzle)
  4344. type=LogicGame
  4345. ;;
  4346. roguelike)
  4347. type=RolePlaying
  4348. ;;
  4349. rpg)
  4350. type=RolePlaying
  4351. ;;
  4352. simulation)
  4353. type=Simulation
  4354. ;;
  4355. sports)
  4356. type=SportsGame
  4357. ;;
  4358. strategy)
  4359. type=StrategyGame
  4360. ;;
  4361. esac;
  4362. type="Game;${type}"
  4363. ;;
  4364. gnome)
  4365. type="Gnome;GTK"
  4366. ;;
  4367. kde)
  4368. type="KDE;Qt"
  4369. ;;
  4370. mail)
  4371. type="Network;Email"
  4372. ;;
  4373. media)
  4374. case ${catmin} in
  4375. gfx)
  4376. type=Graphics
  4377. ;;
  4378. *)
  4379. case ${catmin} in
  4380. radio)
  4381. type=Tuner
  4382. ;;
  4383. sound)
  4384. type=Audio
  4385. ;;
  4386. tv)
  4387. type=TV
  4388. ;;
  4389. video)
  4390. type=Video
  4391. ;;
  4392. esac;
  4393. type="AudioVideo;${type}"
  4394. ;;
  4395. esac
  4396. ;;
  4397. net)
  4398. case ${catmin} in
  4399. dialup)
  4400. type=Dialup
  4401. ;;
  4402. ftp)
  4403. type=FileTransfer
  4404. ;;
  4405. im)
  4406. type=InstantMessaging
  4407. ;;
  4408. irc)
  4409. type=IRCClient
  4410. ;;
  4411. mail)
  4412. type=Email
  4413. ;;
  4414. news)
  4415. type=News
  4416. ;;
  4417. nntp)
  4418. type=News
  4419. ;;
  4420. p2p)
  4421. type=FileTransfer
  4422. ;;
  4423. voip)
  4424. type=Telephony
  4425. ;;
  4426. esac;
  4427. type="Network;${type}"
  4428. ;;
  4429. sci)
  4430. case ${catmin} in
  4431. astro*)
  4432. type=Astronomy
  4433. ;;
  4434. bio*)
  4435. type=Biology
  4436. ;;
  4437. calc*)
  4438. type=Calculator
  4439. ;;
  4440. chem*)
  4441. type=Chemistry
  4442. ;;
  4443. elec*)
  4444. type=Electronics
  4445. ;;
  4446. geo*)
  4447. type=Geology
  4448. ;;
  4449. math*)
  4450. type=Math
  4451. ;;
  4452. physics)
  4453. type=Physics
  4454. ;;
  4455. visual*)
  4456. type=DataVisualization
  4457. ;;
  4458. esac;
  4459. type="Education;Science;${type}"
  4460. ;;
  4461. sys)
  4462. type="System"
  4463. ;;
  4464. www)
  4465. case ${catmin} in
  4466. client)
  4467. type=WebBrowser
  4468. ;;
  4469. esac;
  4470. type="Network;${type}"
  4471. ;;
  4472. *)
  4473. type=
  4474. ;;
  4475. esac;
  4476. fi;
  4477. local slot=${SLOT%/*};
  4478. if [[ ${slot} == "0" ]]; then
  4479. local desktop_name="${PN}";
  4480. else
  4481. local desktop_name="${PN}-${slot}";
  4482. fi;
  4483. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  4484. type=${type%;}${type:+;};
  4485. eshopts_push -s extglob;
  4486. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  4487. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  4488. ewarn "allowed in .desktop files if the value is not an absolute path.";
  4489. icon=${icon%.@(xpm|png|svg)};
  4490. fi;
  4491. eshopts_pop;
  4492. cat > "${desktop}" <<-EOF
  4493. [Desktop Entry]
  4494. Name=${name}
  4495. Type=Application
  4496. Comment=${DESCRIPTION}
  4497. Exec=${exec}
  4498. TryExec=${exec%% *}
  4499. Icon=${icon}
  4500. Categories=${type}
  4501. EOF
  4502.  
  4503. if [[ ${fields:-=} != *=* ]]; then
  4504. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  4505. fields="Path=${fields}";
  4506. fi;
  4507. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  4508. ( insinto /usr/share/applications;
  4509. doins "${desktop}" ) || die "installing desktop file failed"
  4510. }
  4511. make_session_desktop ()
  4512. {
  4513. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  4514. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  4515. local title=$1;
  4516. local command=$2;
  4517. local desktop=${T}/${wm:-${PN}}.desktop;
  4518. shift 2;
  4519. cat > "${desktop}" <<-EOF
  4520. [Desktop Entry]
  4521. Name=${title}
  4522. Comment=This session logs you into ${title}
  4523. Exec=${command} $*
  4524. TryExec=${command}
  4525. Type=XSession
  4526. EOF
  4527.  
  4528. ( insinto /usr/share/xsessions;
  4529. doins "${desktop}" )
  4530. }
  4531. make_wrapper ()
  4532. {
  4533. _eutils_eprefix_init;
  4534. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  4535. local tmpwrapper=$(emktemp);
  4536. ( echo '#!/bin/sh';
  4537. [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}";
  4538. if [[ -n ${libdir} ]]; then
  4539. local var;
  4540. if [[ ${CHOST} == *-darwin* ]]; then
  4541. var=DYLD_LIBRARY_PATH;
  4542. else
  4543. var=LD_LIBRARY_PATH;
  4544. fi;
  4545. cat <<-EOF
  4546. if [ "\${${var}+set}" = "set" ] ; then
  4547. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  4548. else
  4549. export ${var}="${EPREFIX}${libdir}"
  4550. fi
  4551. EOF
  4552.  
  4553. fi
  4554. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  4555. chmod go+rx "${tmpwrapper}";
  4556. if [[ -n ${path} ]]; then
  4557. ( exeinto "${path}";
  4558. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  4559. else
  4560. newbin "${tmpwrapper}" "${wrapper}" || die;
  4561. fi
  4562. }
  4563. multilib_env ()
  4564. {
  4565. local CTARGET=${1:-${CTARGET}};
  4566. local cpu=${CTARGET%%*-};
  4567. case ${cpu} in
  4568. aarch64*)
  4569. export CFLAGS_arm=${CFLAGS_arm-};
  4570. case ${cpu} in
  4571. aarch64*be)
  4572. export CHOST_arm="armv8b-${CTARGET#*-}"
  4573. ;;
  4574. *)
  4575. export CHOST_arm="armv8l-${CTARGET#*-}"
  4576. ;;
  4577. esac;
  4578. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  4579. export CTARGET_arm=${CHOST_arm};
  4580. export LIBDIR_arm="lib";
  4581. export CFLAGS_arm64=${CFLAGS_arm64-};
  4582. export CHOST_arm64=${CTARGET};
  4583. export CTARGET_arm64=${CHOST_arm64};
  4584. export LIBDIR_arm64="lib64";
  4585. : ${MULTILIB_ABIS=arm64};
  4586. : ${DEFAULT_ABI=arm64}
  4587. ;;
  4588. x86_64*)
  4589. export CFLAGS_x86=${CFLAGS_x86--m32};
  4590. export CHOST_x86=${CTARGET/x86_64/i686};
  4591. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  4592. export CTARGET_x86=${CHOST_x86};
  4593. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  4594. export LIBDIR_x86="lib32";
  4595. else
  4596. export LIBDIR_x86="lib";
  4597. fi;
  4598. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  4599. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  4600. export CTARGET_amd64=${CHOST_amd64};
  4601. export LIBDIR_amd64="lib64";
  4602. export CFLAGS_x32=${CFLAGS_x32--mx32};
  4603. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  4604. export CTARGET_x32=${CHOST_x32};
  4605. export LIBDIR_x32="libx32";
  4606. case ${CTARGET} in
  4607. *-gnux32)
  4608. : ${MULTILIB_ABIS=x32 amd64 x86};
  4609. : ${DEFAULT_ABI=x32}
  4610. ;;
  4611. *)
  4612. : ${MULTILIB_ABIS=amd64 x86};
  4613. : ${DEFAULT_ABI=amd64}
  4614. ;;
  4615. esac
  4616. ;;
  4617. mips64*)
  4618. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  4619. export CHOST_o32=${CTARGET/mips64/mips};
  4620. export CTARGET_o32=${CHOST_o32};
  4621. export LIBDIR_o32="lib";
  4622. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  4623. export CHOST_n32=${CTARGET};
  4624. export CTARGET_n32=${CHOST_n32};
  4625. export LIBDIR_n32="lib32";
  4626. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  4627. export CHOST_n64=${CTARGET};
  4628. export CTARGET_n64=${CHOST_n64};
  4629. export LIBDIR_n64="lib64";
  4630. : ${MULTILIB_ABIS=n64 n32 o32};
  4631. : ${DEFAULT_ABI=n32}
  4632. ;;
  4633. powerpc64*)
  4634. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  4635. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  4636. export CTARGET_ppc=${CHOST_ppc};
  4637. export LIBDIR_ppc="lib";
  4638. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  4639. export CHOST_ppc64=${CTARGET};
  4640. export CTARGET_ppc64=${CHOST_ppc64};
  4641. export LIBDIR_ppc64="lib64";
  4642. : ${MULTILIB_ABIS=ppc64 ppc};
  4643. : ${DEFAULT_ABI=ppc64}
  4644. ;;
  4645. s390x*)
  4646. export CFLAGS_s390=${CFLAGS_s390--m31};
  4647. export CHOST_s390=${CTARGET/s390x/s390};
  4648. export CTARGET_s390=${CHOST_s390};
  4649. export LIBDIR_s390="lib";
  4650. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  4651. export CHOST_s390x=${CTARGET};
  4652. export CTARGET_s390x=${CHOST_s390x};
  4653. export LIBDIR_s390x="lib64";
  4654. : ${MULTILIB_ABIS=s390x s390};
  4655. : ${DEFAULT_ABI=s390x}
  4656. ;;
  4657. sparc64*)
  4658. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  4659. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  4660. export CTARGET_sparc32=${CHOST_sparc32};
  4661. export LIBDIR_sparc32="lib";
  4662. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  4663. export CHOST_sparc64=${CTARGET};
  4664. export CTARGET_sparc64=${CHOST_sparc64};
  4665. export LIBDIR_sparc64="lib64";
  4666. : ${MULTILIB_ABIS=sparc64 sparc32};
  4667. : ${DEFAULT_ABI=sparc64}
  4668. ;;
  4669. *)
  4670. : ${MULTILIB_ABIS=default};
  4671. : ${DEFAULT_ABI=default}
  4672. ;;
  4673. esac;
  4674. export MULTILIB_ABIS DEFAULT_ABI
  4675. }
  4676. multilib_toolchain_setup ()
  4677. {
  4678. local v vv;
  4679. export ABI=$1;
  4680. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  4681. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  4682. do
  4683. vv="_abi_saved_${v}";
  4684. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  4685. unset ${vv};
  4686. done;
  4687. unset _DEFAULT_ABI_SAVED;
  4688. fi;
  4689. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  4690. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  4691. do
  4692. vv="_abi_saved_${v}";
  4693. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  4694. done;
  4695. export _DEFAULT_ABI_SAVED="true";
  4696. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  4697. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  4698. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  4699. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  4700. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  4701. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  4702. export CHOST=$(get_abi_CHOST $1);
  4703. export CBUILD=$(get_abi_CHOST $1);
  4704. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  4705. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  4706. fi
  4707. }
  4708. newicon ()
  4709. {
  4710. _iconins ${FUNCNAME} "$@"
  4711. }
  4712. newmenu ()
  4713. {
  4714. ( insinto /usr/share/applications;
  4715. newins "$@" )
  4716. }
  4717. no-as-needed ()
  4718. {
  4719. case $($(tc-getLD) -v 2>&1 </dev/null) in
  4720. *GNU*)
  4721. echo "-Wl,--no-as-needed"
  4722. ;;
  4723. esac
  4724. }
  4725. number_abis ()
  4726. {
  4727. set -- `get_install_abis`;
  4728. echo $#
  4729. }
  4730. optfeature ()
  4731. {
  4732. debug-print-function ${FUNCNAME} "$@";
  4733. local i j msg;
  4734. local desc=$1;
  4735. local flag=0;
  4736. shift;
  4737. for i in "$@";
  4738. do
  4739. for j in ${i};
  4740. do
  4741. if has_version "${j}"; then
  4742. flag=1;
  4743. else
  4744. flag=0;
  4745. break;
  4746. fi;
  4747. done;
  4748. if [[ ${flag} -eq 1 ]]; then
  4749. break;
  4750. fi;
  4751. done;
  4752. if [[ ${flag} -eq 0 ]]; then
  4753. for i in "$@";
  4754. do
  4755. msg=" ";
  4756. for j in ${i};
  4757. do
  4758. msg+=" ${j} and";
  4759. done;
  4760. msg="${msg:0: -4} for ${desc}";
  4761. elog "${msg}";
  4762. done;
  4763. fi
  4764. }
  4765. path_exists ()
  4766. {
  4767. local opt=$1;
  4768. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  4769. [[ $# -eq 0 ]] && return 1;
  4770. local p r=0;
  4771. for p in "$@";
  4772. do
  4773. [[ -e ${p} ]];
  4774. : $(( r += $? ));
  4775. done;
  4776. case ${opt} in
  4777. -a)
  4778. return $(( r != 0 ))
  4779. ;;
  4780. -o)
  4781. return $(( r == $# ))
  4782. ;;
  4783. esac
  4784. }
  4785. pax-mark ()
  4786. {
  4787. local f;
  4788. local flags;
  4789. local ret=0;
  4790. flags="${1//[!zPpEeMmRrSs]}";
  4791. [[ -n "${flags}" ]] || return 0;
  4792. shift;
  4793. local dodefault="";
  4794. [[ -n "${flags//[!z]}" ]] && dodefault="yes";
  4795. if has PT ${PAX_MARKINGS}; then
  4796. for f in "$@";
  4797. do
  4798. if type -p paxctl > /dev/null; then
  4799. einfo "PT_PAX marking -${flags} ${f} with paxctl";
  4800. paxctl -q${flags} "${f}" > /dev/null 2>&1 && continue;
  4801. fi;
  4802. if type -p paxctl-ng > /dev/null && paxctl-ng -L; then
  4803. einfo "PT_PAX marking -${flags} ${f} with paxctl-ng";
  4804. flags="${flags//z}";
  4805. [[ ${dodefault} == "yes" ]] && paxctl-ng -L -z "${f}" > /dev/null 2>&1;
  4806. [[ -n "${flags}" ]] || continue;
  4807. paxctl-ng -L -${flags} "${f}" > /dev/null 2>&1 && continue;
  4808. fi;
  4809. if type -p scanelf > /dev/null && [[ ${PAX_MARKINGS} != "none" ]]; then
  4810. einfo "PT_PAX marking -${flags} ${f} with scanelf";
  4811. scanelf -Xxz ${flags} "$f" > /dev/null 2>&1;
  4812. else
  4813. if [[ ${PAX_MARKINGS} != "none" ]]; then
  4814. elog "Failed to set PT_PAX markings -${flags} ${f}.";
  4815. ret=1;
  4816. fi;
  4817. fi;
  4818. done;
  4819. fi;
  4820. if has XT ${PAX_MARKINGS}; then
  4821. flags="${flags//z}";
  4822. for f in "$@";
  4823. do
  4824. if type -p paxctl-ng > /dev/null && paxctl-ng -l; then
  4825. einfo "XATTR_PAX marking -${flags} ${f} with paxctl-ng";
  4826. [[ ${dodefault} == "yes" ]] && paxctl-ng -d "${f}" > /dev/null 2>&1;
  4827. [[ -n "${flags}" ]] || continue;
  4828. paxctl-ng -l -${flags} "${f}" > /dev/null 2>&1 && continue;
  4829. fi;
  4830. if type -p setfattr > /dev/null; then
  4831. [[ -n "${flags//[!Ee]}" ]] || flags+="e";
  4832. einfo "XATTR_PAX marking -${flags} ${f} with setfattr";
  4833. [[ ${dodefault} == "yes" ]] && setfattr -x "user.pax.flags" "${f}" > /dev/null 2>&1;
  4834. setfattr -n "user.pax.flags" -v "${flags}" "${f}" > /dev/null 2>&1 && continue;
  4835. fi;
  4836. if [[ ${PAX_MARKINGS} != "none" ]]; then
  4837. elog "Failed to set XATTR_PAX markings -${flags} ${f}.";
  4838. ret=1;
  4839. fi;
  4840. done;
  4841. fi;
  4842. return ${ret}
  4843. }
  4844. pkg_nofetch ()
  4845. {
  4846. default
  4847. }
  4848. pkg_postinst ()
  4849. {
  4850. fdo-mime_desktop_database_update;
  4851. if use udev; then
  4852. udevadm control --reload-rules && udevadm trigger --subsystem-match=usb;
  4853. fi;
  4854. if ! use headless && use qt4; then
  4855. elog "To launch VirtualBox just type: \"VirtualBox\".";
  4856. fi;
  4857. elog "You must be in the vboxusers group to use VirtualBox.";
  4858. elog "";
  4859. elog "The latest user manual is available for download at:";
  4860. elog "http://download.virtualbox.org/virtualbox/${PV}/UserManual.pdf";
  4861. elog "";
  4862. elog "For advanced networking setups you should emerge:";
  4863. elog "net-misc/bridge-utils and sys-apps/usermode-utilities";
  4864. elog "";
  4865. elog "IMPORTANT!";
  4866. elog "If you upgrade from app-emulation/virtualbox-ose make sure to run";
  4867. elog "\"env-update\" as root and logout and relogin as the user you wish";
  4868. elog "to run ${PN} as.";
  4869. elog "";
  4870. elog "Starting with version 4.0.0, ${PN} has USB-1 support.";
  4871. elog "For USB-2 support, PXE-boot ability and VRDP support please emerge";
  4872. elog " app-emulation/virtualbox-extpack-oracle";
  4873. elog "package.";
  4874. if ! use udev; then
  4875. elog "";
  4876. elog "WARNING!";
  4877. elog "Without USE=udev, USB devices will likely not work in ${PN}.";
  4878. else
  4879. if [ -e "${ROOT}/etc/udev/rules.d/10-virtualbox.rules" ]; then
  4880. elog "";
  4881. elog "Please remove \"${ROOT}/etc/udev/rules.d/10-virtualbox.rules\"";
  4882. elog "or else USB in ${PN} won't work.";
  4883. fi;
  4884. fi
  4885. }
  4886. pkg_postrm ()
  4887. {
  4888. fdo-mime_desktop_database_update
  4889. }
  4890. pkg_preinst ()
  4891. {
  4892. java-pkg-opt-2_pkg_preinst "$@"
  4893. }
  4894. pkg_setup ()
  4895. {
  4896. if ! use headless && ! use qt4; then
  4897. einfo "No USE=\"qt4\" selected, this build will not include";
  4898. einfo "any Qt frontend.";
  4899. else
  4900. if use headless && use qt4; then
  4901. einfo "You selected USE=\"headless qt4\", defaulting to";
  4902. einfo "USE=\"headless\", this build will not include any X11/Qt frontend.";
  4903. fi;
  4904. fi;
  4905. if ! use opengl; then
  4906. einfo "No USE=\"opengl\" selected, this build will lack";
  4907. einfo "the OpenGL feature.";
  4908. fi;
  4909. if ! use python; then
  4910. einfo "You have disabled the \"python\" USE flag. This will only";
  4911. einfo "disable the python bindings being installed.";
  4912. fi;
  4913. java-pkg-opt-2_pkg_setup;
  4914. python-single-r1_pkg_setup;
  4915. tc-ld-disable-gold;
  4916. tc-export CC CXX LD AR RANLIB;
  4917. export HOST_CC="$(tc-getBUILD_CC)"
  4918. }
  4919. preserve_old_lib ()
  4920. {
  4921. _eutils_eprefix_init;
  4922. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  4923. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  4924. die "Invalid preserve_old_lib() usage";
  4925. fi;
  4926. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  4927. has preserve-libs ${FEATURES} && return 0;
  4928. local lib dir;
  4929. for lib in "$@";
  4930. do
  4931. [[ -e ${EROOT}/${lib} ]] || continue;
  4932. dir=${lib%/*};
  4933. dodir ${dir} || die "dodir ${dir} failed";
  4934. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  4935. touch "${ED}"/${lib};
  4936. done
  4937. }
  4938. preserve_old_lib_notify ()
  4939. {
  4940. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  4941. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  4942. die "Invalid preserve_old_lib_notify() usage";
  4943. fi;
  4944. has preserve-libs ${FEATURES} && return 0;
  4945. _eutils_eprefix_init;
  4946. local lib notice=0;
  4947. for lib in "$@";
  4948. do
  4949. [[ -e ${EROOT}/${lib} ]] || continue;
  4950. if [[ ${notice} -eq 0 ]]; then
  4951. notice=1;
  4952. ewarn "Old versions of installed libraries were detected on your system.";
  4953. ewarn "In order to avoid breaking packages that depend on these old libs,";
  4954. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  4955. ewarn "in order to remove these old dependencies. If you do not have this";
  4956. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  4957. ewarn;
  4958. fi;
  4959. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  4960. done
  4961. }
  4962. prune_libtool_files ()
  4963. {
  4964. debug-print-function ${FUNCNAME} "$@";
  4965. local removing_all removing_modules opt;
  4966. _eutils_eprefix_init;
  4967. for opt in "$@";
  4968. do
  4969. case "${opt}" in
  4970. --all)
  4971. removing_all=1;
  4972. removing_modules=1
  4973. ;;
  4974. --modules)
  4975. removing_modules=1
  4976. ;;
  4977. *)
  4978. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  4979. ;;
  4980. esac;
  4981. done;
  4982. local f;
  4983. local queue=();
  4984. while IFS= read -r -d '' f; do
  4985. local archivefile=${f/%.la/.a};
  4986. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  4987. continue;
  4988. fi;
  4989. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  4990. local reason= pkgconfig_scanned=;
  4991. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  4992. if [[ ${snotlink} == yes ]]; then
  4993. if [[ -f ${archivefile} ]]; then
  4994. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  4995. queue+=("${archivefile}");
  4996. fi;
  4997. if [[ -n ${removing_modules} ]]; then
  4998. reason='module';
  4999. fi;
  5000. else
  5001. if [[ -n ${removing_all} ]]; then
  5002. reason='requested';
  5003. else
  5004. if [[ ! -f ${archivefile} ]]; then
  5005. reason='no static archive';
  5006. else
  5007. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  5008. reason='no libs & flags';
  5009. else
  5010. if [[ ! -n ${pkgconfig_scanned} ]]; then
  5011. local pc_libs=();
  5012. if [[ ! -n ${removing_all} ]]; then
  5013. local pc;
  5014. local tf=${T}/prune-lt-files.pc;
  5015. local pkgconf=$(tc-getPKG_CONFIG);
  5016. while IFS= read -r -d '' pc; do
  5017. local arg libs;
  5018. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  5019. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  5020. libs=$(${pkgconf} --libs "${tf}");
  5021. else
  5022. libs=$(sed -ne 's/^Libs://p' "${pc}");
  5023. fi;
  5024. for arg in ${libs};
  5025. do
  5026. if [[ ${arg} == -l* ]]; then
  5027. if [[ ${arg} == '*$*' ]]; then
  5028. eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}";
  5029. eqawarn "(arg: ${arg})";
  5030. eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  5031. fi;
  5032. pc_libs+=(lib${arg#-l}.la);
  5033. fi;
  5034. done;
  5035. done < <(find "${D}" -type f -name '*.pc' -print0);
  5036. rm -f "${tf}";
  5037. fi;
  5038. pkgconfig_scanned=1;
  5039. fi;
  5040. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  5041. fi;
  5042. fi;
  5043. fi;
  5044. fi;
  5045. if [[ -n ${reason} ]]; then
  5046. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  5047. queue+=("${f}");
  5048. fi;
  5049. done < <(find "${ED}" -xtype f -name '*.la' -print0);
  5050. if [[ -n ${queue[@]} ]]; then
  5051. rm -f "${queue[@]}";
  5052. fi
  5053. }
  5054. python-single-r1_pkg_setup ()
  5055. {
  5056. debug-print-function ${FUNCNAME} "${@}";
  5057. [[ ${MERGE_TYPE} != binary ]] && python_setup
  5058. }
  5059. python_abi_depend ()
  5060. {
  5061. die "${FUNCNAME}() is invalid for python-r1 suite"
  5062. }
  5063. python_byte-compile_modules ()
  5064. {
  5065. die "${FUNCNAME}() is invalid for python-r1 suite"
  5066. }
  5067. python_clean_byte-compiled_modules ()
  5068. {
  5069. die "${FUNCNAME}() is invalid for python-r1 suite"
  5070. }
  5071. python_clean_installation_image ()
  5072. {
  5073. die "${FUNCNAME}() is invalid for python-r1 suite"
  5074. }
  5075. python_clean_py-compile_files ()
  5076. {
  5077. die "${FUNCNAME}() is invalid for python-r1 suite"
  5078. }
  5079. python_convert_shebangs ()
  5080. {
  5081. 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"
  5082. }
  5083. python_disable_pyc ()
  5084. {
  5085. die "${FUNCNAME}() is invalid for python-r1 suite"
  5086. }
  5087. python_doexe ()
  5088. {
  5089. debug-print-function ${FUNCNAME} "${@}";
  5090. local f;
  5091. for f in "$@";
  5092. do
  5093. python_newexe "${f}" "${f##*/}";
  5094. done
  5095. }
  5096. python_doheader ()
  5097. {
  5098. debug-print-function ${FUNCNAME} "${@}";
  5099. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5100. if [[ ${EAPI:-0} == [0123] ]]; then
  5101. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  5102. fi;
  5103. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  5104. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  5105. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  5106. ( insinto "${d}";
  5107. doins -r "${@}" || return ${?} )
  5108. }
  5109. python_domodule ()
  5110. {
  5111. debug-print-function ${FUNCNAME} "${@}";
  5112. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5113. if [[ ${EAPI:-0} == [0123] ]]; then
  5114. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  5115. fi;
  5116. local d;
  5117. if [[ ${python_moduleroot} == /* ]]; then
  5118. d=${python_moduleroot};
  5119. else
  5120. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  5121. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  5122. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot};
  5123. fi;
  5124. ( insinto "${d}";
  5125. doins -r "${@}" || return ${?} );
  5126. python_optimize "${ED}/${d}"
  5127. }
  5128. python_doscript ()
  5129. {
  5130. debug-print-function ${FUNCNAME} "${@}";
  5131. local _PYTHON_REWRITE_SHEBANG=1;
  5132. python_doexe "${@}"
  5133. }
  5134. python_enable_pyc ()
  5135. {
  5136. die "${FUNCNAME}() is invalid for python-r1 suite"
  5137. }
  5138. python_execute_function ()
  5139. {
  5140. 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"
  5141. }
  5142. python_execute_nosetests ()
  5143. {
  5144. die "${FUNCNAME}() is invalid for python-r1 suite"
  5145. }
  5146. python_execute_py.test ()
  5147. {
  5148. die "${FUNCNAME}() is invalid for python-r1 suite"
  5149. }
  5150. python_execute_trial ()
  5151. {
  5152. die "${FUNCNAME}() is invalid for python-r1 suite"
  5153. }
  5154. python_export ()
  5155. {
  5156. debug-print-function ${FUNCNAME} "${@}";
  5157. local impl var;
  5158. case "${1}" in
  5159. python* | jython*)
  5160. impl=${1/_/.};
  5161. shift
  5162. ;;
  5163. pypy | pypy3)
  5164. impl=${1};
  5165. shift
  5166. ;;
  5167. *)
  5168. impl=${EPYTHON};
  5169. if [[ -z ${impl} ]]; then
  5170. die "python_export called without a python implementation and EPYTHON is unset";
  5171. fi
  5172. ;;
  5173. esac;
  5174. debug-print "${FUNCNAME}: implementation: ${impl}";
  5175. for var in "$@";
  5176. do
  5177. case "${var}" in
  5178. EPYTHON)
  5179. export EPYTHON=${impl};
  5180. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  5181. ;;
  5182. PYTHON)
  5183. export PYTHON=${EPREFIX}/usr/bin/${impl};
  5184. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  5185. ;;
  5186. PYTHON_SITEDIR)
  5187. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5188. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  5189. export PYTHON_SITEDIR;
  5190. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  5191. ;;
  5192. PYTHON_INCLUDEDIR)
  5193. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5194. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  5195. export PYTHON_INCLUDEDIR;
  5196. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  5197. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  5198. die "${impl} does not install any header files!";
  5199. fi
  5200. ;;
  5201. PYTHON_LIBPATH)
  5202. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5203. 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;
  5204. export PYTHON_LIBPATH;
  5205. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  5206. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  5207. die "${impl} lacks a (usable) dynamic library";
  5208. fi
  5209. ;;
  5210. PYTHON_CFLAGS)
  5211. local val;
  5212. case "${impl}" in
  5213. python*)
  5214. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  5215. ;;
  5216. *)
  5217. die "${impl}: obtaining ${var} not supported"
  5218. ;;
  5219. esac;
  5220. export PYTHON_CFLAGS=${val};
  5221. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  5222. ;;
  5223. PYTHON_LIBS)
  5224. local val;
  5225. case "${impl}" in
  5226. python*)
  5227. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  5228. ;;
  5229. *)
  5230. die "${impl}: obtaining ${var} not supported"
  5231. ;;
  5232. esac;
  5233. export PYTHON_LIBS=${val};
  5234. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  5235. ;;
  5236. PYTHON_CONFIG)
  5237. local flags val;
  5238. case "${impl}" in
  5239. python*)
  5240. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  5241. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  5242. val=${PYTHON}${flags}-config
  5243. ;;
  5244. *)
  5245. die "${impl}: obtaining ${var} not supported"
  5246. ;;
  5247. esac;
  5248. export PYTHON_CONFIG=${val};
  5249. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  5250. ;;
  5251. PYTHON_PKG_DEP)
  5252. local d;
  5253. case ${impl} in
  5254. python2.7)
  5255. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  5256. ;;
  5257. python3.3)
  5258. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  5259. ;;
  5260. python*)
  5261. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  5262. ;;
  5263. pypy)
  5264. PYTHON_PKG_DEP='virtual/pypy:0='
  5265. ;;
  5266. pypy3)
  5267. PYTHON_PKG_DEP='virtual/pypy3:0='
  5268. ;;
  5269. jython2.7)
  5270. PYTHON_PKG_DEP='dev-java/jython:2.7'
  5271. ;;
  5272. *)
  5273. die "Invalid implementation: ${impl}"
  5274. ;;
  5275. esac;
  5276. if [[ -n ${PYTHON_REQ_USE} ]]; then
  5277. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  5278. fi;
  5279. export PYTHON_PKG_DEP;
  5280. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  5281. ;;
  5282. PYTHON_SCRIPTDIR)
  5283. local dir;
  5284. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  5285. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  5286. ;;
  5287. *)
  5288. die "python_export: unknown variable ${var}"
  5289. ;;
  5290. esac;
  5291. done
  5292. }
  5293. python_export_utf8_locale ()
  5294. {
  5295. debug-print-function ${FUNCNAME} "${@}";
  5296. type locale > /dev/null || return 0;
  5297. if [[ $(locale charmap) != UTF-8 ]]; then
  5298. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  5299. for lang in ${locales};
  5300. do
  5301. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  5302. if _python_check_locale_sanity "${lang}"; then
  5303. export LC_CTYPE=${lang};
  5304. if [[ -n ${LC_ALL} ]]; then
  5305. export LC_NUMERIC=${LC_ALL};
  5306. export LC_TIME=${LC_ALL};
  5307. export LC_COLLATE=${LC_ALL};
  5308. export LC_MONETARY=${LC_ALL};
  5309. export LC_MESSAGES=${LC_ALL};
  5310. export LC_PAPER=${LC_ALL};
  5311. export LC_NAME=${LC_ALL};
  5312. export LC_ADDRESS=${LC_ALL};
  5313. export LC_TELEPHONE=${LC_ALL};
  5314. export LC_MEASUREMENT=${LC_ALL};
  5315. export LC_IDENTIFICATION=${LC_ALL};
  5316. export LC_ALL=;
  5317. fi;
  5318. return 0;
  5319. fi;
  5320. fi;
  5321. done;
  5322. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  5323. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  5324. ewarn "/etc/locale.gen and run locale-gen.";
  5325. return 1;
  5326. fi;
  5327. return 0
  5328. }
  5329. python_fix_shebang ()
  5330. {
  5331. debug-print-function ${FUNCNAME} "${@}";
  5332. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  5333. local force quiet;
  5334. while [[ -n ${@} ]]; do
  5335. case "${1}" in
  5336. -f | --force)
  5337. force=1;
  5338. shift
  5339. ;;
  5340. -q | --quiet)
  5341. quiet=1;
  5342. shift
  5343. ;;
  5344. --)
  5345. shift;
  5346. break
  5347. ;;
  5348. *)
  5349. break
  5350. ;;
  5351. esac;
  5352. done;
  5353. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  5354. local path f;
  5355. for path in "$@";
  5356. do
  5357. local any_correct any_fixed is_recursive;
  5358. [[ -d ${path} ]] && is_recursive=1;
  5359. while IFS= read -r -d '' f; do
  5360. local shebang i;
  5361. local error= from=;
  5362. IFS= read -r shebang < "${f}";
  5363. if [[ ${shebang} == '#!'* ]]; then
  5364. local split_shebang=();
  5365. read -r -a split_shebang <<< ${shebang} || die;
  5366. for i in "${split_shebang[@]}";
  5367. do
  5368. case "${i}" in
  5369. *"${EPYTHON}")
  5370. debug-print "${FUNCNAME}: in file ${f#${D}}";
  5371. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  5372. any_correct=1;
  5373. from=${EPYTHON};
  5374. break
  5375. ;;
  5376. *python | *python[23])
  5377. debug-print "${FUNCNAME}: in file ${f#${D}}";
  5378. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  5379. if [[ ${i} == *python2 ]]; then
  5380. from=python2;
  5381. if [[ ! -n ${force} ]]; then
  5382. python_is_python3 "${EPYTHON}" && error=1;
  5383. fi;
  5384. else
  5385. if [[ ${i} == *python3 ]]; then
  5386. from=python3;
  5387. if [[ ! -n ${force} ]]; then
  5388. python_is_python3 "${EPYTHON}" || error=1;
  5389. fi;
  5390. else
  5391. from=python;
  5392. fi;
  5393. fi;
  5394. break
  5395. ;;
  5396. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  5397. if [[ ! -n ${force} ]]; then
  5398. error=1;
  5399. else
  5400. case "${i}" in
  5401. *python[23].[0123456789])
  5402. from="python[23].[0123456789]"
  5403. ;;
  5404. *pypy)
  5405. from="pypy"
  5406. ;;
  5407. *pypy3)
  5408. from="pypy3"
  5409. ;;
  5410. *jython[23].[0123456789])
  5411. from="jython[23].[0123456789]"
  5412. ;;
  5413. *)
  5414. die "${FUNCNAME}: internal error in 2nd pattern match"
  5415. ;;
  5416. esac;
  5417. fi;
  5418. break
  5419. ;;
  5420. esac;
  5421. done;
  5422. fi;
  5423. if [[ ! -n ${error} && ! -n ${from} ]]; then
  5424. [[ -n ${is_recursive} ]] && continue;
  5425. error=1;
  5426. fi;
  5427. if [[ ! -n ${quiet} ]]; then
  5428. einfo "Fixing shebang in ${f#${D}}.";
  5429. fi;
  5430. if [[ ! -n ${error} ]]; then
  5431. if [[ ${shebang} == *${from}" "* ]]; then
  5432. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  5433. else
  5434. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  5435. fi;
  5436. any_fixed=1;
  5437. else
  5438. eerror "The file has incompatible shebang:";
  5439. eerror " file: ${f#${D}}";
  5440. eerror " current shebang: ${shebang}";
  5441. eerror " requested impl: ${EPYTHON}";
  5442. die "${FUNCNAME}: conversion of incompatible shebang requested";
  5443. fi;
  5444. done < <(find -H "${path}" -type f -print0 || die);
  5445. if [[ ! -n ${any_fixed} ]]; then
  5446. local cmd=eerror;
  5447. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  5448. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D}} did not match any fixable files.";
  5449. if [[ -n ${any_correct} ]]; then
  5450. "${cmd}" "All files have ${EPYTHON} shebang already.";
  5451. else
  5452. "${cmd}" "There are no Python files in specified directory.";
  5453. fi;
  5454. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  5455. fi;
  5456. done
  5457. }
  5458. python_gen_cond_dep ()
  5459. {
  5460. debug-print-function ${FUNCNAME} "${@}";
  5461. local flag_prefix impl pattern;
  5462. local matches=();
  5463. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  5464. flag_prefix=python_targets;
  5465. else
  5466. flag_prefix=python_single_target;
  5467. fi;
  5468. local dep=${1};
  5469. shift;
  5470. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5471. do
  5472. for pattern in "$@";
  5473. do
  5474. if [[ ${impl} == ${pattern} ]]; then
  5475. if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  5476. local usedep=$(python_gen_usedep "${@}");
  5477. dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  5478. fi;
  5479. matches+=("${flag_prefix}_${impl}? ( ${dep} )");
  5480. break;
  5481. fi;
  5482. done;
  5483. done;
  5484. echo "${matches[@]}"
  5485. }
  5486. python_gen_impl_dep ()
  5487. {
  5488. debug-print-function ${FUNCNAME} "${@}";
  5489. local impl pattern;
  5490. local matches=();
  5491. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  5492. flag_prefix=python_targets;
  5493. else
  5494. flag_prefix=python_single_target;
  5495. fi;
  5496. local PYTHON_REQ_USE=${1};
  5497. shift;
  5498. local patterns=("${@-*}");
  5499. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5500. do
  5501. for pattern in "${patterns[@]}";
  5502. do
  5503. if [[ ${impl} == ${pattern} ]]; then
  5504. local PYTHON_PKG_DEP;
  5505. python_export "${impl}" PYTHON_PKG_DEP;
  5506. matches+=("${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )");
  5507. break;
  5508. fi;
  5509. done;
  5510. done;
  5511. echo "${matches[@]}"
  5512. }
  5513. python_gen_usedep ()
  5514. {
  5515. debug-print-function ${FUNCNAME} "${@}";
  5516. local impl pattern;
  5517. local matches=();
  5518. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5519. do
  5520. for pattern in "$@";
  5521. do
  5522. if [[ ${impl} == ${pattern} ]]; then
  5523. matches+=("python_targets_${impl}(-)?" "python_single_target_${impl}(+)?");
  5524. break;
  5525. fi;
  5526. done;
  5527. done;
  5528. [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  5529. local out=${matches[@]};
  5530. echo "${out// /,}"
  5531. }
  5532. python_gen_useflags ()
  5533. {
  5534. debug-print-function ${FUNCNAME} "${@}";
  5535. local flag_prefix impl pattern;
  5536. local matches=();
  5537. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  5538. flag_prefix=python_targets;
  5539. else
  5540. flag_prefix=python_single_target;
  5541. fi;
  5542. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5543. do
  5544. for pattern in "$@";
  5545. do
  5546. if [[ ${impl} == ${pattern} ]]; then
  5547. matches+=("${flag_prefix}_${impl}");
  5548. break;
  5549. fi;
  5550. done;
  5551. done;
  5552. echo "${matches[@]}"
  5553. }
  5554. python_generate_cffi_modules ()
  5555. {
  5556. die "${FUNCNAME}() is invalid for python-r1 suite"
  5557. }
  5558. python_generate_wrapper_scripts ()
  5559. {
  5560. die "${FUNCNAME}() is invalid for python-r1 suite"
  5561. }
  5562. python_get_CFLAGS ()
  5563. {
  5564. debug-print-function ${FUNCNAME} "${@}";
  5565. python_export "${@}" PYTHON_CFLAGS;
  5566. echo "${PYTHON_CFLAGS}"
  5567. }
  5568. python_get_LIBS ()
  5569. {
  5570. debug-print-function ${FUNCNAME} "${@}";
  5571. python_export "${@}" PYTHON_LIBS;
  5572. echo "${PYTHON_LIBS}"
  5573. }
  5574. python_get_PYTHON_CONFIG ()
  5575. {
  5576. debug-print-function ${FUNCNAME} "${@}";
  5577. python_export "${@}" PYTHON_CONFIG;
  5578. echo "${PYTHON_CONFIG}"
  5579. }
  5580. python_get_extension_module_suffix ()
  5581. {
  5582. die "${FUNCNAME}() is invalid for python-r1 suite"
  5583. }
  5584. python_get_implementation ()
  5585. {
  5586. die "${FUNCNAME}() is invalid for python-r1 suite"
  5587. }
  5588. python_get_implementation_and_version ()
  5589. {
  5590. die "${FUNCNAME}() is invalid for python-r1 suite"
  5591. }
  5592. python_get_implementational_package ()
  5593. {
  5594. die "${FUNCNAME}() is invalid for python-r1 suite"
  5595. }
  5596. python_get_includedir ()
  5597. {
  5598. debug-print-function ${FUNCNAME} "${@}";
  5599. python_export "${@}" PYTHON_INCLUDEDIR;
  5600. echo "${PYTHON_INCLUDEDIR}"
  5601. }
  5602. python_get_libdir ()
  5603. {
  5604. die "${FUNCNAME}() is invalid for python-r1 suite"
  5605. }
  5606. python_get_library ()
  5607. {
  5608. die "${FUNCNAME}() is invalid for python-r1 suite"
  5609. }
  5610. python_get_library_path ()
  5611. {
  5612. debug-print-function ${FUNCNAME} "${@}";
  5613. python_export "${@}" PYTHON_LIBPATH;
  5614. echo "${PYTHON_LIBPATH}"
  5615. }
  5616. python_get_scriptdir ()
  5617. {
  5618. debug-print-function ${FUNCNAME} "${@}";
  5619. python_export "${@}" PYTHON_SCRIPTDIR;
  5620. echo "${PYTHON_SCRIPTDIR}"
  5621. }
  5622. python_get_sitedir ()
  5623. {
  5624. debug-print-function ${FUNCNAME} "${@}";
  5625. python_export "${@}" PYTHON_SITEDIR;
  5626. echo "${PYTHON_SITEDIR}"
  5627. }
  5628. python_get_version ()
  5629. {
  5630. die "${FUNCNAME}() is invalid for python-r1 suite"
  5631. }
  5632. python_install_executables ()
  5633. {
  5634. die "${FUNCNAME}() is invalid for python-r1 suite"
  5635. }
  5636. python_is_installed ()
  5637. {
  5638. local impl=${1:-${EPYTHON}};
  5639. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  5640. local -x ROOT=/;
  5641. case "${impl}" in
  5642. pypy | pypy3)
  5643. local append=;
  5644. if [[ -n ${PYTHON_REQ_USE} ]]; then
  5645. append=[${PYTHON_REQ_USE}];
  5646. fi;
  5647. has_version "dev-python/${impl}${append}" || has_version "dev-python/${impl}-bin${append}"
  5648. ;;
  5649. *)
  5650. local PYTHON_PKG_DEP;
  5651. python_export "${impl}" PYTHON_PKG_DEP;
  5652. has_version "${PYTHON_PKG_DEP}"
  5653. ;;
  5654. esac
  5655. }
  5656. python_is_python3 ()
  5657. {
  5658. local impl=${1:-${EPYTHON}};
  5659. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  5660. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  5661. }
  5662. python_merge_intermediate_installation_images ()
  5663. {
  5664. die "${FUNCNAME}() is invalid for python-r1 suite"
  5665. }
  5666. python_mod_cleanup ()
  5667. {
  5668. 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"
  5669. }
  5670. python_mod_optimize ()
  5671. {
  5672. 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"
  5673. }
  5674. python_moduleinto ()
  5675. {
  5676. debug-print-function ${FUNCNAME} "${@}";
  5677. python_moduleroot=${1}
  5678. }
  5679. python_need_rebuild ()
  5680. {
  5681. die "${FUNCNAME}() is invalid for python-r1 suite"
  5682. }
  5683. python_newexe ()
  5684. {
  5685. debug-print-function ${FUNCNAME} "${@}";
  5686. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5687. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  5688. if [[ ${EAPI:-0} == [0123] ]]; then
  5689. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  5690. fi;
  5691. local wrapd=${python_scriptroot:-/usr/bin};
  5692. local f=${1};
  5693. local newfn=${2};
  5694. local PYTHON_SCRIPTDIR d;
  5695. python_export PYTHON_SCRIPTDIR;
  5696. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  5697. ( dodir "${wrapd}";
  5698. exeinto "${d}";
  5699. newexe "${f}" "${newfn}" || return ${?} );
  5700. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  5701. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  5702. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  5703. fi
  5704. }
  5705. python_newscript ()
  5706. {
  5707. debug-print-function ${FUNCNAME} "${@}";
  5708. local _PYTHON_REWRITE_SHEBANG=1;
  5709. python_newexe "${@}"
  5710. }
  5711. python_optimize ()
  5712. {
  5713. debug-print-function ${FUNCNAME} "${@}";
  5714. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  5715. eerror "The new Python eclasses expect the compiled Python files to";
  5716. eerror "be controlled by the Package Manager. For this reason,";
  5717. eerror "the python_optimize function can be used only during src_* phases";
  5718. eerror "(src_install most commonly) and not during pkg_* phases.";
  5719. echo;
  5720. die "python_optimize is not to be used in pre/post* phases";
  5721. fi;
  5722. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  5723. local PYTHON=${PYTHON};
  5724. [[ -n ${PYTHON} ]] || python_export PYTHON;
  5725. if [[ ${#} -eq 0 ]]; then
  5726. local f;
  5727. while IFS= read -r -d '' f; do
  5728. if [[ ${f} == /* && -d ${D}${f} ]]; then
  5729. set -- "${D}${f}" "${@}";
  5730. fi;
  5731. done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  5732. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  5733. fi;
  5734. local d;
  5735. for d in "$@";
  5736. do
  5737. local instpath=${d#${D}};
  5738. instpath=/${instpath##/};
  5739. case "${EPYTHON}" in
  5740. python2.7 | python3.[34])
  5741. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  5742. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  5743. ;;
  5744. python*)
  5745. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  5746. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  5747. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  5748. ;;
  5749. *)
  5750. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  5751. ;;
  5752. esac;
  5753. done
  5754. }
  5755. python_pkg_setup ()
  5756. {
  5757. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  5758. }
  5759. python_scriptinto ()
  5760. {
  5761. debug-print-function ${FUNCNAME} "${@}";
  5762. python_scriptroot=${1}
  5763. }
  5764. python_set_active_version ()
  5765. {
  5766. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  5767. }
  5768. python_setup ()
  5769. {
  5770. debug-print-function ${FUNCNAME} "${@}";
  5771. unset EPYTHON;
  5772. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  5773. local impls=(${PYTHON_COMPAT_OVERRIDE});
  5774. [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-single-r1";
  5775. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  5776. ewarn "implementation will be used:";
  5777. ewarn;
  5778. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  5779. ewarn;
  5780. ewarn "Dependencies won't be satisfied, and PYTHON_SINGLE_TARGET flags will be ignored.";
  5781. python_export "${impls[0]}" EPYTHON PYTHON;
  5782. python_wrapper_setup;
  5783. return;
  5784. fi;
  5785. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  5786. if use "python_targets_${_PYTHON_SUPPORTED_IMPLS[0]}"; then
  5787. python_export "${_PYTHON_SUPPORTED_IMPLS[0]}" EPYTHON PYTHON;
  5788. python_wrapper_setup;
  5789. fi;
  5790. else
  5791. local impl;
  5792. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5793. do
  5794. if use "python_single_target_${impl}"; then
  5795. if [[ -n ${EPYTHON} ]]; then
  5796. eerror "Your PYTHON_SINGLE_TARGET setting lists more than a single Python";
  5797. eerror "implementation. Please set it to just one value. If you need";
  5798. eerror "to override the value for a single package, please use package.env";
  5799. eerror "or an equivalent solution (man 5 portage).";
  5800. echo;
  5801. die "More than one implementation in PYTHON_SINGLE_TARGET.";
  5802. fi;
  5803. if ! use "python_targets_${impl}"; then
  5804. eerror "The implementation chosen as PYTHON_SINGLE_TARGET must be added";
  5805. eerror "to PYTHON_TARGETS as well. This is in order to ensure that";
  5806. eerror "dependencies are satisfied correctly. We're sorry";
  5807. eerror "for the inconvenience.";
  5808. echo;
  5809. die "Build target (${impl}) not in PYTHON_TARGETS.";
  5810. fi;
  5811. python_export "${impl}" EPYTHON PYTHON;
  5812. python_wrapper_setup;
  5813. fi;
  5814. done;
  5815. fi;
  5816. if [[ ! -n ${EPYTHON} ]]; then
  5817. eerror "No Python implementation selected for the build. Please set";
  5818. if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
  5819. eerror "the PYTHON_TARGETS variable in your make.conf to include one";
  5820. else
  5821. eerror "the PYTHON_SINGLE_TARGET variable in your make.conf to one";
  5822. fi;
  5823. eerror "of the following values:";
  5824. eerror;
  5825. eerror "${_PYTHON_SUPPORTED_IMPLS[@]}";
  5826. echo;
  5827. die "No supported Python implementation in PYTHON_SINGLE_TARGET/PYTHON_TARGETS.";
  5828. fi
  5829. }
  5830. python_wrapper_setup ()
  5831. {
  5832. debug-print-function ${FUNCNAME} "${@}";
  5833. local workdir=${1:-${T}/${EPYTHON}};
  5834. local impl=${2:-${EPYTHON}};
  5835. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  5836. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  5837. if [[ ! -x ${workdir}/bin/python ]]; then
  5838. _python_check_dead_variables;
  5839. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  5840. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  5841. rm -f "${workdir}"/bin/2to3 || die;
  5842. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  5843. local EPYTHON PYTHON PYTHON_CONFIG;
  5844. python_export "${impl}" EPYTHON PYTHON;
  5845. local pyver pyother;
  5846. if python_is_python3; then
  5847. pyver=3;
  5848. pyother=2;
  5849. else
  5850. pyver=2;
  5851. pyother=3;
  5852. fi;
  5853. cat > "${workdir}/bin/python" <<-_EOF_ ||
  5854. #!/bin/sh
  5855. exec "${PYTHON}" "\${@}"
  5856. _EOF_
  5857. die
  5858. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  5859. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  5860. local nonsupp=("python${pyother}" "python${pyother}-config");
  5861. if [[ ${EPYTHON} == python* ]]; then
  5862. python_export "${impl}" PYTHON_CONFIG;
  5863. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  5864. #!/bin/sh
  5865. exec "${PYTHON_CONFIG}" "\${@}"
  5866. _EOF_
  5867. die
  5868. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  5869. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  5870. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  5871. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  5872. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  5873. else
  5874. nonsupp+=(2to3 python-config "python${pyver}-config");
  5875. fi;
  5876. local x;
  5877. for x in "${nonsupp[@]}";
  5878. do
  5879. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  5880. #!/bin/sh
  5881. echo "${x} is not supported by ${EPYTHON}" >&2
  5882. exit 127
  5883. _EOF_
  5884. die
  5885. chmod +x "${workdir}"/bin/${x} || die;
  5886. done;
  5887. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  5888. PATH=${workdir}/bin${PATH:+:${PATH}};
  5889. fi;
  5890. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  5891. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  5892. fi;
  5893. export PATH PKG_CONFIG_PATH;
  5894. fi
  5895. }
  5896. qeerror ()
  5897. {
  5898. qout eerror "${@}"
  5899. }
  5900. qeinfo ()
  5901. {
  5902. qout einfo "${@}"
  5903. }
  5904. qewarn ()
  5905. {
  5906. qout ewarn "${@}"
  5907. }
  5908. qmake-utils_find_pro_file ()
  5909. {
  5910. local dir_name=$(basename "${S}");
  5911. eshopts_push -s nullglob;
  5912. local pro_files=(*.pro);
  5913. eshopts_pop;
  5914. case ${#pro_files[@]} in
  5915. 0)
  5916. :
  5917. ;;
  5918. 1)
  5919. echo "${pro_files}"
  5920. ;;
  5921. *)
  5922. for pro_file in "${pro_files[@]}";
  5923. do
  5924. if [[ ${pro_file%.pro} == ${dir_name} || ${pro_file%.pro} == ${PN} ]]; then
  5925. echo "${pro_file}";
  5926. break;
  5927. fi;
  5928. done
  5929. ;;
  5930. esac
  5931. }
  5932. qout ()
  5933. {
  5934. local outputmsg type;
  5935. type=${1};
  5936. shift;
  5937. outputmsg="${@}";
  5938. case "${EBUILD_PHASE}" in
  5939. depend)
  5940. unset outputmsg
  5941. ;;
  5942. clean)
  5943. unset outputmsg
  5944. ;;
  5945. preinst)
  5946. unset outputmsg
  5947. ;;
  5948. esac;
  5949. [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
  5950. }
  5951. qt4-r2_src_compile ()
  5952. {
  5953. debug-print-function $FUNCNAME "$@";
  5954. base_src_compile "$@"
  5955. }
  5956. qt4-r2_src_configure ()
  5957. {
  5958. debug-print-function $FUNCNAME "$@";
  5959. local project_file=$(qmake-utils_find_pro_file);
  5960. if [[ -n ${project_file} ]]; then
  5961. eqmake4 "${project_file}";
  5962. else
  5963. base_src_configure "$@";
  5964. fi
  5965. }
  5966. qt4-r2_src_install ()
  5967. {
  5968. debug-print-function $FUNCNAME "$@";
  5969. base_src_install INSTALL_ROOT="${D}" "$@";
  5970. einstalldocs
  5971. }
  5972. qt4-r2_src_prepare ()
  5973. {
  5974. debug-print-function $FUNCNAME "$@";
  5975. base_src_prepare "$@"
  5976. }
  5977. qt4-r2_src_unpack ()
  5978. {
  5979. debug-print-function $FUNCNAME "$@";
  5980. base_src_unpack "$@"
  5981. }
  5982. qt4_get_bindir ()
  5983. {
  5984. has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  5985. local qtbindir=${EPREFIX}$(qt4_get_libdir)/bin;
  5986. if [[ -d ${qtbindir} ]]; then
  5987. echo ${qtbindir};
  5988. else
  5989. echo ${EPREFIX}/usr/bin;
  5990. fi
  5991. }
  5992. qt4_get_headerdir ()
  5993. {
  5994. echo /usr/include/qt4
  5995. }
  5996. qt4_get_libdir ()
  5997. {
  5998. echo /usr/$(get_libdir)/qt4
  5999. }
  6000. qt4_get_mkspecsdir ()
  6001. {
  6002. echo /usr/share/qt4/mkspecs
  6003. }
  6004. qt4_get_plugindir ()
  6005. {
  6006. echo $(qt4_get_libdir)/plugins
  6007. }
  6008. qt5_get_bindir ()
  6009. {
  6010. has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=;
  6011. echo ${EPREFIX}$(qt5_get_libdir)/qt5/bin
  6012. }
  6013. qt5_get_headerdir ()
  6014. {
  6015. echo /usr/include/qt5
  6016. }
  6017. qt5_get_libdir ()
  6018. {
  6019. echo /usr/$(get_libdir)
  6020. }
  6021. qt5_get_mkspecsdir ()
  6022. {
  6023. echo $(qt5_get_libdir)/qt5/mkspecs
  6024. }
  6025. qt5_get_plugindir ()
  6026. {
  6027. echo $(qt5_get_libdir)/qt5/plugins
  6028. }
  6029. raw-ldflags ()
  6030. {
  6031. local x input="$@";
  6032. [[ -z ${input} ]] && input=${LDFLAGS};
  6033. set --;
  6034. for x in ${input};
  6035. do
  6036. case ${x} in
  6037. -Wl,*)
  6038. x=${x#-Wl,};
  6039. set -- "$@" ${x//,/ }
  6040. ;;
  6041. *)
  6042.  
  6043. ;;
  6044. esac;
  6045. done;
  6046. echo "$@"
  6047. }
  6048. replace-cpu-flags ()
  6049. {
  6050. local newcpu="$#";
  6051. newcpu="${!newcpu}";
  6052. while [ $# -gt 1 ]; do
  6053. replace-flags "-march=${1}" "-march=${newcpu}";
  6054. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  6055. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  6056. shift;
  6057. done;
  6058. return 0
  6059. }
  6060. replace-flags ()
  6061. {
  6062. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  6063. local f var new;
  6064. for var in $(all-flag-vars);
  6065. do
  6066. new=();
  6067. for f in ${!var};
  6068. do
  6069. [[ ${f} == ${1} ]] && f=${2};
  6070. new+=("${f}");
  6071. done;
  6072. eval export ${var}=\""${new[*]}"\";
  6073. done;
  6074. return 0
  6075. }
  6076. replace-sparc64-flags ()
  6077. {
  6078. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  6079. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  6080. for x in ${SPARC64_CPUS};
  6081. do
  6082. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  6083. done;
  6084. else
  6085. for x in ${SPARC64_CPUS};
  6086. do
  6087. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  6088. done;
  6089. fi;
  6090. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  6091. for x in ${SPARC64_CPUS};
  6092. do
  6093. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  6094. done;
  6095. else
  6096. for x in ${SPARC64_CPUS};
  6097. do
  6098. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  6099. done;
  6100. fi;
  6101. export CFLAGS CXXFLAGS
  6102. }
  6103. replace_all_version_separators ()
  6104. {
  6105. local c=($(get_all_version_components "${2:-${PV}}"));
  6106. c=${c[@]//[-._]/$1};
  6107. echo ${c// }
  6108. }
  6109. replace_version_separator ()
  6110. {
  6111. eshopts_push -s extglob;
  6112. local w c v="${3:-${PV}}";
  6113. declare -i i found=0;
  6114. w=${1:-1};
  6115. c=($(get_all_version_components ${v}));
  6116. if [[ ${w} != *[[:digit:]]* ]]; then
  6117. for ((i = 0; i < ${#c[@]}; i++))
  6118. do
  6119. if [[ ${c[i]} == ${w} ]]; then
  6120. c[i]=${2};
  6121. break;
  6122. fi;
  6123. done;
  6124. else
  6125. for ((i = 0; i < ${#c[@]}; i++))
  6126. do
  6127. if [[ -n "${c[i]//[^-._]}" ]]; then
  6128. found+=1;
  6129. if ((found == w)); then
  6130. c[i]=${2};
  6131. break;
  6132. fi;
  6133. fi;
  6134. done;
  6135. fi;
  6136. c=${c[*]};
  6137. echo ${c// };
  6138. eshopts_pop
  6139. }
  6140. require_configured_kernel ()
  6141. {
  6142. if ! linux_config_src_exists; then
  6143. qeerror "Could not find a usable .config in the kernel source directory.";
  6144. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  6145. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  6146. qeerror "it points to the necessary object directory so that it might find .config.";
  6147. die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  6148. fi
  6149. }
  6150. set_arch_to_kernel ()
  6151. {
  6152. export ARCH=$(tc-arch-kernel)
  6153. }
  6154. set_arch_to_portage ()
  6155. {
  6156. export ARCH=$(tc-arch)
  6157. }
  6158. setup-allowed-flags ()
  6159. {
  6160. 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,*');
  6161. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  6162. 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)
  6163. }
  6164. src_compile ()
  6165. {
  6166. source ./env.sh;
  6167. MAKEJOBS=$(echo ${MAKEOPTS} | egrep -o '(\-j|\-\-jobs)(=?|[[:space:]]*)[[:digit:]]+');
  6168. MAKELOAD=$(echo ${MAKEOPTS} | egrep -o '(\-l|\-\-load-average)(=?|[[:space:]]*)[[:digit:]]+');
  6169. MAKEOPTS="${MAKEJOBS} ${MAKELOAD}";
  6170. MAKE="kmk" emake VBOX_BUILD_PUBLISHER=_Gentoo TOOL_GCC3_CC="$(tc-getCC)" TOOL_GCC3_CXX="$(tc-getCXX)" TOOL_GCC3_AS="$(tc-getCC)" TOOL_GCC3_AR="$(tc-getAR)" TOOL_GCC3_LD="$(tc-getCXX)" TOOL_GCC3_LD_SYSMOD="$(tc-getLD)" TOOL_GCC3_CFLAGS="${CFLAGS}" TOOL_GCC3_CXXFLAGS="${CXXFLAGS}" VBOX_GCC_OPT="${CXXFLAGS}" TOOL_YASM_AS=yasm KBUILD_VERBOSE=2 all
  6171. }
  6172. src_configure ()
  6173. {
  6174. local myconf;
  6175. use alsa || myconf+=" --disable-alsa";
  6176. use doc || myconf+=" --disable-docs";
  6177. use java || myconf+=" --disable-java";
  6178. use opengl || myconf+=" --disable-opengl";
  6179. use pulseaudio || myconf+=" --disable-pulse";
  6180. use python || myconf+=" --disable-python";
  6181. use vboxwebsrv && myconf+=" --enable-webservice";
  6182. use vnc && myconf+=" --enable-vnc";
  6183. if ! use headless; then
  6184. use qt4 || myconf+=" --disable-qt4";
  6185. else
  6186. myconf+=" --build-headless --disable-opengl";
  6187. fi;
  6188. if use amd64 && ! has_multilib_profile; then
  6189. myconf+=" --disable-vmmraw";
  6190. fi;
  6191. ./configure --with-gcc="$(tc-getCC)" --with-g++="$(tc-getCXX)" --disable-kmods --disable-dbus --disable-devmapper ${myconf} || die "configure failed"
  6192. }
  6193. src_install ()
  6194. {
  6195. cd "${S}"/out/linux.${ARCH}/release/bin || die;
  6196. insinto /etc/vbox;
  6197. newins "${FILESDIR}/${PN}-4-config" vbox.cfg;
  6198. sed -i -e "s@MY_LIBDIR@$(get_libdir)@" "${D}"/etc/vbox/vbox.cfg || die "vbox.cfg sed failed";
  6199. exeinto /usr/$(get_libdir)/${PN};
  6200. newexe "${FILESDIR}/${PN}-ose-3-wrapper" "VBox";
  6201. fowners root:vboxusers /usr/$(get_libdir)/${PN}/VBox;
  6202. fperms 0750 /usr/$(get_libdir)/${PN}/VBox;
  6203. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/VBoxManage;
  6204. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/VBoxVRDP;
  6205. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/VBoxHeadless;
  6206. dosym /usr/$(get_libdir)/${PN}/VBoxTunctl /usr/bin/VBoxTunctl;
  6207. insinto /usr/$(get_libdir)/${PN};
  6208. doins -r components;
  6209. if use sdk; then
  6210. doins -r sdk;
  6211. fi;
  6212. if use vboxwebsrv; then
  6213. doins vboxwebsrv;
  6214. fowners root:vboxusers /usr/$(get_libdir)/${PN}/vboxwebsrv;
  6215. fperms 0750 /usr/$(get_libdir)/${PN}/vboxwebsrv;
  6216. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/vboxwebsrv;
  6217. newinitd "${FILESDIR}"/vboxwebsrv-initd vboxwebsrv;
  6218. newconfd "${FILESDIR}"/vboxwebsrv-confd vboxwebsrv;
  6219. fi;
  6220. local gcfiles="*gc";
  6221. if use amd64 && ! has_multilib_profile; then
  6222. gcfiles="";
  6223. fi;
  6224. for each in VBox{Manage,SVC,XPCOMIPCD,Tunctl,ExtPackHelperApp} *so *r0 ${gcfiles};
  6225. do
  6226. doins ${each};
  6227. fowners root:vboxusers /usr/$(get_libdir)/${PN}/${each};
  6228. fperms 0750 /usr/$(get_libdir)/${PN}/${each};
  6229. done;
  6230. for each in VBoxNet{AdpCtl,DHCP,NAT};
  6231. do
  6232. doins ${each};
  6233. fowners root:vboxusers /usr/$(get_libdir)/${PN}/${each};
  6234. fperms 4750 /usr/$(get_libdir)/${PN}/${each};
  6235. done;
  6236. for each in VBox{Manage,SVC,XPCOMIPCD};
  6237. do
  6238. pax-mark -m "${D}"/usr/$(get_libdir)/${PN}/${each};
  6239. done;
  6240. if ! use headless; then
  6241. doins VBoxSDL;
  6242. fowners root:vboxusers /usr/$(get_libdir)/${PN}/VBoxSDL;
  6243. fperms 4750 /usr/$(get_libdir)/${PN}/VBoxSDL;
  6244. pax-mark -m "${D}"/usr/$(get_libdir)/${PN}/VBoxSDL;
  6245. if use opengl && use qt4; then
  6246. doins VBoxTestOGL;
  6247. fowners root:vboxusers /usr/$(get_libdir)/${PN}/VBoxTestOGL;
  6248. fperms 0750 /usr/$(get_libdir)/${PN}/VBoxTestOGL;
  6249. pax-mark -m "${D}"/usr/$(get_libdir)/${PN}/VBoxTestOGL;
  6250. fi;
  6251. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/VBoxSDL;
  6252. if use qt4; then
  6253. doins VirtualBox;
  6254. fowners root:vboxusers /usr/$(get_libdir)/${PN}/VirtualBox;
  6255. fperms 4750 /usr/$(get_libdir)/${PN}/VirtualBox;
  6256. pax-mark -m "${D}"/usr/$(get_libdir)/${PN}/VirtualBox;
  6257. dosym /usr/$(get_libdir)/${PN}/VBox /usr/bin/VirtualBox;
  6258. newmenu "${FILESDIR}"/${PN}-ose.desktop-2 ${PN}.desktop;
  6259. fi;
  6260. pushd "${S}"/src/VBox/Resources/OSE &> /dev/null || die;
  6261. for size in 16 32 48 64 128;
  6262. do
  6263. newicon -s ${size} ${PN}-${size}px.png ${PN}.png;
  6264. done;
  6265. newicon ${PN}-48px.png ${PN}.png;
  6266. doicon -s scalable ${PN}.svg;
  6267. popd &> /dev/null || die;
  6268. fi;
  6269. doins VBoxHeadless;
  6270. fowners root:vboxusers /usr/$(get_libdir)/${PN}/VBoxHeadless;
  6271. fperms 4750 /usr/$(get_libdir)/${PN}/VBoxHeadless;
  6272. pax-mark -m "${D}"/usr/$(get_libdir)/${PN}/VBoxHeadless;
  6273. insinto /usr/$(get_libdir)/${PN};
  6274. pushd "${S}"/src/VBox/Devices/EFI/FirmwareBin &> /dev/null || die;
  6275. for fwfile in VBoxEFI{32,64}.fd;
  6276. do
  6277. doins ${fwfile};
  6278. fowners root:vboxusers /usr/$(get_libdir)/${PN}/${fwfile};
  6279. done;
  6280. popd &> /dev/null || die;
  6281. if use udev; then
  6282. local udevdir="$(get_udevdir)";
  6283. insinto ${udevdir};
  6284. doins VBoxCreateUSBNode.sh;
  6285. fowners root:vboxusers ${udevdir}/VBoxCreateUSBNode.sh;
  6286. fperms 0750 ${udevdir}/VBoxCreateUSBNode.sh;
  6287. insinto ${udevdir}/rules.d;
  6288. doins "${FILESDIR}"/10-virtualbox.rules;
  6289. sed "s@%UDEVDIR%@${udevdir}@" -i "${D}"${udevdir}/rules.d/10-virtualbox.rules || die;
  6290. fi;
  6291. insinto /usr/share/${PN};
  6292. if ! use headless && use qt4; then
  6293. doins -r nls;
  6294. fi;
  6295. dosym VBoxAuth.so /usr/$(get_libdir)/${PN}/VRDPAuth.so;
  6296. echo -n "VBOX_APP_HOME=/usr/$(get_libdir)/${PN}" > "${T}/90virtualbox";
  6297. doenvd "${T}/90virtualbox";
  6298. if use java; then
  6299. java-pkg_regjar "${D}/usr/$(get_libdir)/${PN}/sdk/bindings/xpcom/java/vboxjxpcom.jar";
  6300. java-pkg_regso "${D}/usr/$(get_libdir)/${PN}/libvboxjxpcom.so";
  6301. fi
  6302. }
  6303. src_prepare ()
  6304. {
  6305. rm -rf kBuild/bin tools;
  6306. sed -e "/\s*-o\s*\\\(\s*\$cc_maj\s*-eq\s*[5-9]\s*-a\s*\$cc_min\s*-gt\s*[0-5]\s*\\\)\s*\\\/d" -i configure || die;
  6307. sed -e "s@MY_LIBDIR@$(get_libdir)@" "${FILESDIR}"/${PN}-4-localconfig > LocalConfig.kmk || die;
  6308. sed -e "s@_LDFLAGS\.${ARCH}*.*=@& ${LDFLAGS}@g" -i Config.kmk src/libs/xpcom18a4/Config.kmk || die;
  6309. sed -e '/QUIET)ld /s/ld /$(LD) /' -i src/VBox/Devices/PC/ipxe/Makefile.kmk || die;
  6310. if ! use pam; then
  6311. elog "Disabling PAM removes the possibility to use the VRDP features.";
  6312. sed -i 's@^.*VBOX_WITH_PAM@#VBOX_WITH_PAM@' Config.kmk || die;
  6313. sed -i 's@\(.*/auth/Makefile.kmk.*\)@#\1@' src/VBox/HostServices/Makefile.kmk || die;
  6314. fi;
  6315. if use java; then
  6316. sed "s@/usr/lib/jvm/java-6-sun@$(java-config -O)@" -i "${S}"/Config.kmk || die;
  6317. java-pkg-opt-2_src_prepare;
  6318. fi;
  6319. if ! gcc-specs-pie; then
  6320. EPATCH_EXCLUDE="050_${PN}-4.3.14-nopie.patch";
  6321. fi;
  6322. EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch "${WORKDIR}/patches";
  6323. epatch_user
  6324. }
  6325. src_test ()
  6326. {
  6327. default
  6328. }
  6329. src_unpack ()
  6330. {
  6331. qt4-r2_src_unpack "$@"
  6332. }
  6333. strip-flags ()
  6334. {
  6335. local x y var;
  6336. local ALLOWED_FLAGS;
  6337. setup-allowed-flags;
  6338. set -f;
  6339. for var in $(all-flag-vars);
  6340. do
  6341. local new=();
  6342. for x in ${!var};
  6343. do
  6344. local flag=${x%%=*};
  6345. for y in "${ALLOWED_FLAGS[@]}";
  6346. do
  6347. if [[ -z ${flag%%${y}} ]]; then
  6348. new+=("${x}");
  6349. break;
  6350. fi;
  6351. done;
  6352. done;
  6353. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  6354. new+=(-O2);
  6355. fi;
  6356. if [[ ${!var} != "${new[*]}" ]]; then
  6357. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  6358. fi;
  6359. eval export ${var}=\""${new[*]}"\";
  6360. done;
  6361. set +f;
  6362. return 0
  6363. }
  6364. strip-linguas ()
  6365. {
  6366. local ls newls nols;
  6367. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  6368. local op=$1;
  6369. shift;
  6370. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  6371. shift;
  6372. local d f;
  6373. for d in "$@";
  6374. do
  6375. if [[ ${op} == "-u" ]]; then
  6376. newls=${ls};
  6377. else
  6378. newls="";
  6379. fi;
  6380. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  6381. do
  6382. if [[ ${op} == "-i" ]]; then
  6383. has ${f} ${ls} && newls="${newls} ${f}";
  6384. else
  6385. has ${f} ${ls} || newls="${newls} ${f}";
  6386. fi;
  6387. done;
  6388. ls=${newls};
  6389. done;
  6390. else
  6391. ls="$@";
  6392. fi;
  6393. nols="";
  6394. newls="";
  6395. for f in ${LINGUAS};
  6396. do
  6397. if has ${f} ${ls}; then
  6398. newls="${newls} ${f}";
  6399. else
  6400. nols="${nols} ${f}";
  6401. fi;
  6402. done;
  6403. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  6404. export LINGUAS=${newls:1}
  6405. }
  6406. strip-unsupported-flags ()
  6407. {
  6408. export CFLAGS=$(test-flags-CC ${CFLAGS});
  6409. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  6410. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  6411. export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  6412. }
  6413. tc-arch ()
  6414. {
  6415. tc-ninja_magic_to_arch portage "$@"
  6416. }
  6417. tc-arch-kernel ()
  6418. {
  6419. tc-ninja_magic_to_arch kern "$@"
  6420. }
  6421. tc-check-openmp ()
  6422. {
  6423. if ! tc-has-openmp; then
  6424. eerror "Your current compiler does not support OpenMP!";
  6425. if tc-is-gcc; then
  6426. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  6427. else
  6428. if tc-is-clang; then
  6429. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  6430. fi;
  6431. fi;
  6432. die "Active compiler does not have required support for OpenMP";
  6433. fi
  6434. }
  6435. tc-endian ()
  6436. {
  6437. local host=$1;
  6438. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  6439. host=${host%%-*};
  6440. case ${host} in
  6441. aarch64*be)
  6442. echo big
  6443. ;;
  6444. aarch64)
  6445. echo little
  6446. ;;
  6447. alpha*)
  6448. echo big
  6449. ;;
  6450. arm*b*)
  6451. echo big
  6452. ;;
  6453. arm*)
  6454. echo little
  6455. ;;
  6456. cris*)
  6457. echo little
  6458. ;;
  6459. hppa*)
  6460. echo big
  6461. ;;
  6462. i?86*)
  6463. echo little
  6464. ;;
  6465. ia64*)
  6466. echo little
  6467. ;;
  6468. m68*)
  6469. echo big
  6470. ;;
  6471. mips*l*)
  6472. echo little
  6473. ;;
  6474. mips*)
  6475. echo big
  6476. ;;
  6477. powerpc*le)
  6478. echo little
  6479. ;;
  6480. powerpc*)
  6481. echo big
  6482. ;;
  6483. s390*)
  6484. echo big
  6485. ;;
  6486. sh*b*)
  6487. echo big
  6488. ;;
  6489. sh*)
  6490. echo little
  6491. ;;
  6492. sparc*)
  6493. echo big
  6494. ;;
  6495. x86_64*)
  6496. echo little
  6497. ;;
  6498. *)
  6499. echo wtf
  6500. ;;
  6501. esac
  6502. }
  6503. tc-env_build ()
  6504. {
  6505. tc-export_build_env;
  6506. 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) "$@"
  6507. }
  6508. tc-export ()
  6509. {
  6510. local var;
  6511. for var in "$@";
  6512. do
  6513. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  6514. eval tc-get${var} > /dev/null;
  6515. done
  6516. }
  6517. tc-export_build_env ()
  6518. {
  6519. tc-export "$@";
  6520. : ${BUILD_CFLAGS:=-O1 -pipe};
  6521. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  6522. : ${BUILD_CPPFLAGS:= };
  6523. : ${BUILD_LDFLAGS:= };
  6524. export BUILD_{C,CXX,CPP,LD}FLAGS;
  6525. local v;
  6526. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  6527. do
  6528. export ${v#BUILD_}_FOR_BUILD="${!v}";
  6529. done
  6530. }
  6531. tc-get-compiler-type ()
  6532. {
  6533. local code='
  6534. #if defined(__PATHSCALE__)
  6535. HAVE_PATHCC
  6536. #elif defined(__clang__)
  6537. HAVE_CLANG
  6538. #elif defined(__GNUC__)
  6539. HAVE_GCC
  6540. #endif
  6541. ';
  6542. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  6543. case ${res} in
  6544. *HAVE_PATHCC*)
  6545. echo pathcc
  6546. ;;
  6547. *HAVE_CLANG*)
  6548. echo clang
  6549. ;;
  6550. *HAVE_GCC*)
  6551. echo gcc
  6552. ;;
  6553. *)
  6554. echo unknown
  6555. ;;
  6556. esac
  6557. }
  6558. tc-getAR ()
  6559. {
  6560. tc-getPROG AR ar "$@"
  6561. }
  6562. tc-getAS ()
  6563. {
  6564. tc-getPROG AS as "$@"
  6565. }
  6566. tc-getBUILD_AR ()
  6567. {
  6568. tc-getBUILD_PROG AR ar "$@"
  6569. }
  6570. tc-getBUILD_AS ()
  6571. {
  6572. tc-getBUILD_PROG AS as "$@"
  6573. }
  6574. tc-getBUILD_CC ()
  6575. {
  6576. tc-getBUILD_PROG CC gcc "$@"
  6577. }
  6578. tc-getBUILD_CPP ()
  6579. {
  6580. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  6581. }
  6582. tc-getBUILD_CXX ()
  6583. {
  6584. tc-getBUILD_PROG CXX g++ "$@"
  6585. }
  6586. tc-getBUILD_LD ()
  6587. {
  6588. tc-getBUILD_PROG LD ld "$@"
  6589. }
  6590. tc-getBUILD_NM ()
  6591. {
  6592. tc-getBUILD_PROG NM nm "$@"
  6593. }
  6594. tc-getBUILD_OBJCOPY ()
  6595. {
  6596. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  6597. }
  6598. tc-getBUILD_PKG_CONFIG ()
  6599. {
  6600. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  6601. }
  6602. tc-getBUILD_PROG ()
  6603. {
  6604. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  6605. }
  6606. tc-getBUILD_RANLIB ()
  6607. {
  6608. tc-getBUILD_PROG RANLIB ranlib "$@"
  6609. }
  6610. tc-getBUILD_STRIP ()
  6611. {
  6612. tc-getBUILD_PROG STRIP strip "$@"
  6613. }
  6614. tc-getCC ()
  6615. {
  6616. tc-getPROG CC gcc "$@"
  6617. }
  6618. tc-getCPP ()
  6619. {
  6620. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  6621. }
  6622. tc-getCXX ()
  6623. {
  6624. tc-getPROG CXX g++ "$@"
  6625. }
  6626. tc-getDLLWRAP ()
  6627. {
  6628. tc-getPROG DLLWRAP dllwrap "$@"
  6629. }
  6630. tc-getF77 ()
  6631. {
  6632. tc-getPROG F77 gfortran "$@"
  6633. }
  6634. tc-getFC ()
  6635. {
  6636. tc-getPROG FC gfortran "$@"
  6637. }
  6638. tc-getGCJ ()
  6639. {
  6640. tc-getPROG GCJ gcj "$@"
  6641. }
  6642. tc-getGO ()
  6643. {
  6644. tc-getPROG GO gccgo "$@"
  6645. }
  6646. tc-getLD ()
  6647. {
  6648. tc-getPROG LD ld "$@"
  6649. }
  6650. tc-getNM ()
  6651. {
  6652. tc-getPROG NM nm "$@"
  6653. }
  6654. tc-getOBJCOPY ()
  6655. {
  6656. tc-getPROG OBJCOPY objcopy "$@"
  6657. }
  6658. tc-getOBJDUMP ()
  6659. {
  6660. tc-getPROG OBJDUMP objdump "$@"
  6661. }
  6662. tc-getPKG_CONFIG ()
  6663. {
  6664. tc-getPROG PKG_CONFIG pkg-config "$@"
  6665. }
  6666. tc-getPROG ()
  6667. {
  6668. _tc-getPROG CHOST "$@"
  6669. }
  6670. tc-getRANLIB ()
  6671. {
  6672. tc-getPROG RANLIB ranlib "$@"
  6673. }
  6674. tc-getRC ()
  6675. {
  6676. tc-getPROG RC windres "$@"
  6677. }
  6678. tc-getSTRIP ()
  6679. {
  6680. tc-getPROG STRIP strip "$@"
  6681. }
  6682. tc-has-openmp ()
  6683. {
  6684. local base="${T}/test-tc-openmp";
  6685. cat > "${base}.c" <<-EOF
  6686. #include <omp.h>
  6687. int main() {
  6688. int nthreads, tid, ret = 0;
  6689. #pragma omp parallel private(nthreads, tid)
  6690. {
  6691. tid = omp_get_thread_num();
  6692. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  6693. }
  6694. return ret;
  6695. }
  6696. EOF
  6697.  
  6698. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  6699. local ret=$?;
  6700. rm -f "${base}"*;
  6701. return ${ret}
  6702. }
  6703. tc-has-tls ()
  6704. {
  6705. local base="${T}/test-tc-tls";
  6706. cat > "${base}.c" <<-EOF
  6707. int foo(int *i) {
  6708. static __thread int j = 0;
  6709. return *i ? j : *i;
  6710. }
  6711. EOF
  6712.  
  6713. local flags;
  6714. case $1 in
  6715. -s)
  6716. flags="-S"
  6717. ;;
  6718. -c)
  6719. flags="-c"
  6720. ;;
  6721. -l)
  6722.  
  6723. ;;
  6724. -*)
  6725. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  6726. ;;
  6727. esac;
  6728. : ${flags:=-fPIC -shared -Wl,-z,defs};
  6729. [[ $1 == -* ]] && shift;
  6730. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  6731. local ret=$?;
  6732. rm -f "${base}"*;
  6733. return ${ret}
  6734. }
  6735. tc-is-clang ()
  6736. {
  6737. [[ $(tc-get-compiler-type) == clang ]]
  6738. }
  6739. tc-is-cross-compiler ()
  6740. {
  6741. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  6742. }
  6743. tc-is-gcc ()
  6744. {
  6745. [[ $(tc-get-compiler-type) == gcc ]]
  6746. }
  6747. tc-is-softfloat ()
  6748. {
  6749. local CTARGET=${CTARGET:-${CHOST}};
  6750. case ${CTARGET} in
  6751. bfin* | h8300*)
  6752. echo "only"
  6753. ;;
  6754. *)
  6755. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  6756. echo "yes";
  6757. else
  6758. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  6759. echo "softfp";
  6760. else
  6761. echo "no";
  6762. fi;
  6763. fi
  6764. ;;
  6765. esac
  6766. }
  6767. tc-is-static-only ()
  6768. {
  6769. local host=${CTARGET:-${CHOST}};
  6770. [[ ${host} == *-mint* ]]
  6771. }
  6772. tc-ld-disable-gold ()
  6773. {
  6774. if ! tc-ld-is-gold "$@"; then
  6775. return;
  6776. fi;
  6777. ewarn "Forcing usage of the BFD linker instead of GOLD";
  6778. local ld=$(tc-getLD "$@");
  6779. local bfd_ld="${ld%% *}.bfd";
  6780. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  6781. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  6782. local major=$(gcc-major-version "$@");
  6783. local minor=$(gcc-minor-version "$@");
  6784. if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]]; then
  6785. if [[ -e ${path_ld} ]]; then
  6786. local d="${T}/bfd-linker";
  6787. mkdir -p "${d}";
  6788. ln -sf "${path_ld}" "${d}"/ld;
  6789. export LDFLAGS="${LDFLAGS} -B${d}";
  6790. else
  6791. die "unable to locate a BFD linker to bypass gold";
  6792. fi;
  6793. else
  6794. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  6795. fi
  6796. }
  6797. tc-ld-is-gold ()
  6798. {
  6799. local out;
  6800. out=$($(tc-getLD "$@") --version 2>&1);
  6801. if [[ ${out} == *"GNU gold"* ]]; then
  6802. return 0;
  6803. fi;
  6804. local base="${T}/test-tc-gold";
  6805. cat > "${base}.c" <<-EOF
  6806. int main() { return 0; }
  6807. EOF
  6808.  
  6809. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  6810. rm -f "${base}"*;
  6811. if [[ ${out} == *"GNU gold"* ]]; then
  6812. return 0;
  6813. fi;
  6814. return 1
  6815. }
  6816. tc-ninja_magic_to_arch ()
  6817. {
  6818. function ninj ()
  6819. {
  6820. [[ ${type} == "kern" ]] && echo $1 || echo $2
  6821. };
  6822. local type=$1;
  6823. local host=$2;
  6824. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  6825. case ${host} in
  6826. aarch64*)
  6827. echo arm64
  6828. ;;
  6829. alpha*)
  6830. echo alpha
  6831. ;;
  6832. arm*)
  6833. echo arm
  6834. ;;
  6835. avr*)
  6836. ninj avr32 avr
  6837. ;;
  6838. bfin*)
  6839. ninj blackfin bfin
  6840. ;;
  6841. c6x*)
  6842. echo c6x
  6843. ;;
  6844. cris*)
  6845. echo cris
  6846. ;;
  6847. frv*)
  6848. echo frv
  6849. ;;
  6850. hexagon*)
  6851. echo hexagon
  6852. ;;
  6853. hppa*)
  6854. ninj parisc hppa
  6855. ;;
  6856. i?86*)
  6857. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  6858. echo i386;
  6859. else
  6860. echo x86;
  6861. fi
  6862. ;;
  6863. ia64*)
  6864. echo ia64
  6865. ;;
  6866. m68*)
  6867. echo m68k
  6868. ;;
  6869. metag*)
  6870. echo metag
  6871. ;;
  6872. microblaze*)
  6873. echo microblaze
  6874. ;;
  6875. mips*)
  6876. echo mips
  6877. ;;
  6878. nios2*)
  6879. echo nios2
  6880. ;;
  6881. nios*)
  6882. echo nios
  6883. ;;
  6884. or1k | or32*)
  6885. echo openrisc
  6886. ;;
  6887. powerpc*)
  6888. if [[ ${type} == "kern" ]]; then
  6889. echo powerpc;
  6890. else
  6891. if [[ ${host} == powerpc64* ]]; then
  6892. echo ppc64;
  6893. else
  6894. echo ppc;
  6895. fi;
  6896. fi
  6897. ;;
  6898. riscv*)
  6899. echo riscv
  6900. ;;
  6901. s390*)
  6902. echo s390
  6903. ;;
  6904. score*)
  6905. echo score
  6906. ;;
  6907. sh64*)
  6908. ninj sh64 sh
  6909. ;;
  6910. sh*)
  6911. echo sh
  6912. ;;
  6913. sparc64*)
  6914. ninj sparc64 sparc
  6915. ;;
  6916. sparc*)
  6917. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  6918. ;;
  6919. tile*)
  6920. echo tile
  6921. ;;
  6922. vax*)
  6923. echo vax
  6924. ;;
  6925. x86_64*freebsd*)
  6926. echo amd64
  6927. ;;
  6928. x86_64*)
  6929. if [[ ${type} == "kern" ]]; then
  6930. echo x86;
  6931. else
  6932. echo amd64;
  6933. fi
  6934. ;;
  6935. xtensa*)
  6936. echo xtensa
  6937. ;;
  6938. *)
  6939. echo unknown
  6940. ;;
  6941. esac
  6942. }
  6943. tc-stack-grows-down ()
  6944. {
  6945. case ${ARCH} in
  6946. hppa | metag)
  6947. return 1
  6948. ;;
  6949. esac;
  6950. return 0
  6951. }
  6952. test-flag-CC ()
  6953. {
  6954. test-flag-PROG "CC" c "$1"
  6955. }
  6956. test-flag-CXX ()
  6957. {
  6958. test-flag-PROG "CXX" c++ "$1"
  6959. }
  6960. test-flag-F77 ()
  6961. {
  6962. test-flag-PROG "F77" f77 "$1"
  6963. }
  6964. test-flag-FC ()
  6965. {
  6966. test-flag-PROG "FC" f95 "$1"
  6967. }
  6968. test-flag-PROG ()
  6969. {
  6970. local comp=$1;
  6971. local lang=$2;
  6972. local flag=$3;
  6973. [[ -z ${comp} || -z ${flag} ]] && return 1;
  6974. local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  6975. if "${cmdline[@]}" -x${lang} - < /dev/null > /dev/null 2>&1; then
  6976. "${cmdline[@]}" "${flag}" -x${lang} - < /dev/null > /dev/null 2>&1;
  6977. else
  6978. "${cmdline[@]}" "${flag}" -c -o /dev/null /dev/null > /dev/null 2>&1;
  6979. fi
  6980. }
  6981. test-flags ()
  6982. {
  6983. test-flags-CC "$@"
  6984. }
  6985. test-flags-CC ()
  6986. {
  6987. test-flags-PROG "CC" "$@"
  6988. }
  6989. test-flags-CXX ()
  6990. {
  6991. test-flags-PROG "CXX" "$@"
  6992. }
  6993. test-flags-F77 ()
  6994. {
  6995. test-flags-PROG "F77" "$@"
  6996. }
  6997. test-flags-FC ()
  6998. {
  6999. test-flags-PROG "FC" "$@"
  7000. }
  7001. test-flags-PROG ()
  7002. {
  7003. local comp=$1;
  7004. local flags=();
  7005. local x;
  7006. shift;
  7007. [[ -z ${comp} ]] && return 1;
  7008. for x in "$@";
  7009. do
  7010. test-flag-${comp} "${x}" && flags+=("${x}");
  7011. done;
  7012. echo "${flags[*]}";
  7013. [[ ${#flags[@]} -gt 0 ]]
  7014. }
  7015. test_version_info ()
  7016. {
  7017. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  7018. return 0;
  7019. else
  7020. return 1;
  7021. fi
  7022. }
  7023. udev_dorules ()
  7024. {
  7025. debug-print-function ${FUNCNAME} "${@}";
  7026. ( insinto "$(_udev_get_udevdir)"/rules.d;
  7027. doins "${@}" )
  7028. }
  7029. udev_get_udevdir ()
  7030. {
  7031. debug-print-function ${FUNCNAME} "${@}";
  7032. eerror "This ebuild should be using the get_udevdir() function instead of the deprecated udev_get_udevdir()";
  7033. die "Deprecated function call: udev_get_udevdir(), please report to (overlay) maintainers."
  7034. }
  7035. udev_newrules ()
  7036. {
  7037. debug-print-function ${FUNCNAME} "${@}";
  7038. ( insinto "$(_udev_get_udevdir)"/rules.d;
  7039. newins "${@}" )
  7040. }
  7041. udev_reload ()
  7042. {
  7043. if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
  7044. return 0;
  7045. fi;
  7046. if [[ -d ${ROOT}/run/udev ]]; then
  7047. ebegin "Running udev control --reload for reloading rules and databases";
  7048. udevadm control --reload;
  7049. eend $?;
  7050. fi
  7051. }
  7052. use_doc ()
  7053. {
  7054. use doc && echo ${@:-javadoc}
  7055. }
  7056. use_if_iuse ()
  7057. {
  7058. in_iuse $1 || return 1;
  7059. use $1
  7060. }
  7061. validate_desktop_entries ()
  7062. {
  7063. _eutils_eprefix_init;
  7064. if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]]; then
  7065. einfo "Checking desktop entry validity";
  7066. local directories="";
  7067. for d in /usr/share/applications $@;
  7068. do
  7069. [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}";
  7070. done;
  7071. if [[ -n ${directories} ]]; then
  7072. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  7073. do
  7074. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  7075. [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:};
  7076. done;
  7077. fi;
  7078. echo "";
  7079. else
  7080. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  7081. fi
  7082. }
  7083. version_compare ()
  7084. {
  7085. eshopts_push -s extglob;
  7086. local ver_a=${1} ver_b=${2} parts_a parts_b;
  7087. local cur_tok_a cur_tok_b num_part_a num_part_b;
  7088. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  7089. parts_a=($(get_all_version_components "${ver_a}" ));
  7090. parts_b=($(get_all_version_components "${ver_b}" ));
  7091. local -i inf_loop=0;
  7092. while true; do
  7093. inf_loop+=1;
  7094. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  7095. prev_idx_a=cur_idx_a;
  7096. prev_idx_b=cur_idx_b;
  7097. cur_tok_a=${parts_a[cur_idx_a]};
  7098. cur_tok_b=${parts_b[cur_idx_b]};
  7099. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  7100. cur_idx_a+=1;
  7101. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  7102. else
  7103. cur_tok_a=;
  7104. fi;
  7105. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  7106. cur_idx_b+=1;
  7107. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  7108. else
  7109. cur_tok_b=;
  7110. fi;
  7111. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  7112. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  7113. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  7114. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  7115. cur_tok_a=${cur_tok_a%%+(0)};
  7116. cur_tok_b=${cur_tok_b%%+(0)};
  7117. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  7118. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  7119. else
  7120. cur_tok_a=${cur_tok_a##+(0)};
  7121. cur_tok_b=${cur_tok_b##+(0)};
  7122. : ${cur_tok_a:=0};
  7123. : ${cur_tok_b:=0};
  7124. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  7125. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  7126. fi;
  7127. done;
  7128. local letter_a=;
  7129. letter_a=${parts_a[cur_idx_a]};
  7130. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  7131. cur_idx_a+=1;
  7132. else
  7133. letter_a=@;
  7134. fi;
  7135. local letter_b=;
  7136. letter_b=${parts_b[cur_idx_b]};
  7137. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  7138. cur_idx_b+=1;
  7139. else
  7140. letter_b=@;
  7141. fi;
  7142. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  7143. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  7144. inf_loop=0;
  7145. while true; do
  7146. inf_loop+=1;
  7147. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  7148. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  7149. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  7150. cur_tok_a=${parts_a[cur_idx_a]};
  7151. cur_tok_b=${parts_b[cur_idx_b]};
  7152. num_part_a=0;
  7153. num_part_b=0;
  7154. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  7155. cur_idx_a+=1;
  7156. num_part_a=${cur_tok_a##+([a-z])};
  7157. num_part_a=${num_part_a##+(0)};
  7158. : ${num_part_a:=0};
  7159. cur_tok_a=${cur_tok_a%%+([0-9])};
  7160. else
  7161. cur_tok_a=;
  7162. fi;
  7163. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  7164. cur_idx_b+=1;
  7165. num_part_b=${cur_tok_b##+([a-z])};
  7166. num_part_b=${num_part_b##+(0)};
  7167. : ${num_part_b:=0};
  7168. cur_tok_b=${cur_tok_b%%+([0-9])};
  7169. else
  7170. cur_tok_b=;
  7171. fi;
  7172. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  7173. local suffix;
  7174. for suffix in alpha beta pre rc "" p;
  7175. do
  7176. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  7177. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  7178. done;
  7179. else
  7180. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  7181. break;
  7182. else
  7183. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  7184. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  7185. fi;
  7186. fi;
  7187. done;
  7188. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  7189. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  7190. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  7191. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  7192. fi;
  7193. num_part_a=${parts_a[cur_idx_a]#r};
  7194. num_part_a=${num_part_a##+(0)};
  7195. : ${num_part_a:=0};
  7196. num_part_b=${parts_b[cur_idx_b]#r};
  7197. num_part_b=${num_part_b##+(0)};
  7198. : ${num_part_b:=0};
  7199. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  7200. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  7201. eshopts_pop;
  7202. return 2
  7203. }
  7204. version_format_string ()
  7205. {
  7206. local fstr=$1;
  7207. shift;
  7208. set -- $(get_version_components "$@");
  7209. eval echo "${fstr}"
  7210. }
  7211. version_is_at_least ()
  7212. {
  7213. local want_s="$1" have_s="${2:-${PVR}}" r;
  7214. version_compare "${want_s}" "${have_s}";
  7215. r=$?;
  7216. case $r in
  7217. 1 | 2)
  7218. return 0
  7219. ;;
  7220. 3)
  7221. return 1
  7222. ;;
  7223. *)
  7224. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  7225. ;;
  7226. esac
  7227. }
  7228. version_sort ()
  7229. {
  7230. eshopts_push -s extglob;
  7231. local items=;
  7232. local -i left=0;
  7233. items=("$@");
  7234. while ((left < ${#items[@]})); do
  7235. local -i lowest_idx=left;
  7236. local -i idx=lowest_idx+1;
  7237. while ((idx < ${#items[@]})); do
  7238. version_compare "${items[lowest_idx]}" "${items[idx]}";
  7239. [[ $? -eq 3 ]] && lowest_idx=idx;
  7240. idx+=1;
  7241. done;
  7242. local tmp=${items[lowest_idx]};
  7243. items[lowest_idx]=${items[left]};
  7244. items[left]=${tmp};
  7245. left+=1;
  7246. done;
  7247. echo ${items[@]};
  7248. eshopts_pop
  7249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement