Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 176.69 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_PPC=""
  4. declare -x ABI_RISCV=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86="64"
  7. declare -x ADA_TARGET=""
  8. declare -- ALL_DEPEND="
  9. >=dev-libs/glib-2.0[static-libs(+)]
  10. sys-libs/zlib[static-libs(+)]
  11. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  12. systemtap? ( dev-util/systemtap )
  13. xattr? ( sys-apps/attr[static-libs(+)] )"
  14. declare -x ALSA_CARDS=""
  15. declare -x APACHE2_MODULES=""
  16. declare -x APACHE2_MPMS=""
  17. declare -x AR="x86_64-pc-linux-gnu-ar"
  18. declare -x ARCH="amd64"
  19. declare BDEPEND="
  20. python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) python_targets_python3_5? ( dev-lang/python:3.5 ) python_targets_python3_6? ( dev-lang/python:3.6 ) python_targets_python3_7? ( dev-lang/python:3.7 )
  21. dev-lang/perl
  22. sys-apps/texinfo
  23. virtual/pkgconfig
  24. doc? ( dev-python/sphinx )
  25. gtk? ( nls? ( sys-devel/gettext ) )
  26. test? (
  27. dev-libs/glib[utils]
  28. sys-devel/bc
  29. )
  30. virtual/pkgconfig"
  31. declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  32. declare -x CALLIGRA_FEATURES=""
  33. declare -x CAMERAS=""
  34. declare -x CBUILD="x86_64-pc-linux-gnu"
  35. declare -- CDEPEND="
  36. !static? (
  37.  
  38. >=dev-libs/glib-2.0
  39. sys-libs/zlib
  40. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  41. systemtap? ( dev-util/systemtap )
  42. xattr? ( sys-apps/attr )
  43.  
  44. dev-libs/libxml2
  45. xkb? ( x11-libs/libxkbcommon )
  46. >=x11-libs/pixman-0.28.0
  47. accessibility? (
  48. app-accessibility/brltty[api]
  49. app-accessibility/brltty
  50. )
  51. aio? ( dev-libs/libaio )
  52. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  53. bzip2? ( app-arch/bzip2 )
  54. capstone? ( dev-libs/capstone:= )
  55. caps? ( sys-libs/libcap-ng )
  56. curl? ( >=net-misc/curl-7.15.4 )
  57. fdt? ( >=sys-apps/dtc-1.5.0 )
  58. glusterfs? ( >=sys-cluster/glusterfs-3.4.0 )
  59. gnutls? (
  60. dev-libs/nettle:=
  61. >=net-libs/gnutls-3.0:=
  62. )
  63. gtk? (
  64. x11-libs/gtk+:3
  65. vte? ( x11-libs/vte:2.91 )
  66. )
  67. infiniband? (
  68. sys-fabric/libibumad:=
  69. sys-fabric/libibverbs:=
  70. sys-fabric/librdmacm:=
  71. )
  72. iscsi? ( net-libs/libiscsi )
  73. jemalloc? ( dev-libs/jemalloc )
  74. jpeg? ( virtual/jpeg:0= )
  75. lzo? ( dev-libs/lzo:2 )
  76. ncurses? (
  77. sys-libs/ncurses:0=[unicode]
  78. sys-libs/ncurses:0=
  79. )
  80. nfs? ( >=net-fs/libnfs-1.9.3:= )
  81. numa? ( sys-process/numactl )
  82. opengl? (
  83. virtual/opengl
  84. media-libs/libepoxy
  85. media-libs/mesa
  86. media-libs/mesa[egl,gbm]
  87. )
  88. png? ( media-libs/libpng:0= )
  89. pulseaudio? ( media-sound/pulseaudio )
  90. rbd? ( sys-cluster/ceph )
  91. sasl? ( dev-libs/cyrus-sasl )
  92. sdl? (
  93. media-libs/libsdl2[X]
  94. media-libs/libsdl2
  95. )
  96. seccomp? ( >=sys-libs/libseccomp-2.1.0 )
  97. smartcard? ( >=app-emulation/libcacard-2.5.0 )
  98. snappy? ( app-arch/snappy:= )
  99. spice? (
  100. >=app-emulation/spice-protocol-0.12.3
  101. >=app-emulation/spice-0.12.0
  102. )
  103. ssh? ( >=net-libs/libssh-0.8.6 )
  104. usb? ( >=virtual/libusb-1-r2 )
  105. usbredir? ( >=sys-apps/usbredir-0.6 )
  106. vde? ( net-misc/vde )
  107. virgl? ( media-libs/virglrenderer )
  108. virtfs? ( sys-libs/libcap )
  109. xen? ( app-emulation/xen-tools:= )
  110. xfs? ( sys-fs/xfsprogs )
  111. )
  112. qemu_softmmu_targets_i386? (
  113. pin-upstream-blobs? (
  114. ~sys-firmware/edk2-ovmf-201905[binary]
  115. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  116. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  117. ~sys-firmware/sgabios-0.1_pre8[binary]
  118. )
  119. !pin-upstream-blobs? (
  120. sys-firmware/edk2-ovmf
  121. sys-firmware/ipxe
  122. >=sys-firmware/seabios-1.10.2[seavgabios]
  123. sys-firmware/sgabios
  124. ) )
  125. qemu_softmmu_targets_x86_64? (
  126. pin-upstream-blobs? (
  127. ~sys-firmware/edk2-ovmf-201905[binary]
  128. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  129. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  130. ~sys-firmware/sgabios-0.1_pre8[binary]
  131. )
  132. !pin-upstream-blobs? (
  133. sys-firmware/edk2-ovmf
  134. sys-firmware/ipxe
  135. >=sys-firmware/seabios-1.10.2[seavgabios]
  136. sys-firmware/sgabios
  137. ) )
  138. qemu_softmmu_targets_ppc64? (
  139. pin-upstream-blobs? (
  140. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  141. )
  142. !pin-upstream-blobs? (
  143. >=sys-firmware/seabios-1.10.2[seavgabios]
  144. )
  145. )
  146. "
  147. declare -x CFLAGS="-march=native -O2 -pipe"
  148. declare -x CFLAGS_amd64="-m64"
  149. declare -x CFLAGS_default
  150. declare -x CFLAGS_x32="-mx32"
  151. declare -x CFLAGS_x86="-m32"
  152. declare -x CHOST="x86_64-pc-linux-gnu"
  153. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  154. declare -x CHOST_default="x86_64-pc-linux-gnu"
  155. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  156. declare -x CHOST_x86="i686-pc-linux-gnu"
  157. declare -x COLLECTD_PLUGINS=""
  158. declare -x COMMON_FLAGS="-march=native -O2 -pipe"
  159. declare -- COMMON_TARGETS="aarch64 alpha arm cris hppa i386 m68k microblaze microblazeel
  160. mips mips64 mips64el mipsel nios2 or1k ppc ppc64 riscv32 riscv64 s390x
  161. sh4 sh4eb sparc sparc64 x86_64 xtensa xtensaeb"
  162. declare -x CPU_FLAGS_ARM=""
  163. declare -x CPU_FLAGS_PPC=""
  164. declare -x CPU_FLAGS_X86=""
  165. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  166. declare -x CURL_SSL=""
  167. declare -x CXXFLAGS="-march=native -O2 -pipe"
  168. declare -x DEFAULT_ABI="amd64"
  169. declare -x DEFINED_PHASES=" compile configure info install postinst postrm prepare pretend setup test"
  170. declare DEPEND="
  171. !static? (
  172.  
  173. >=dev-libs/glib-2.0
  174. sys-libs/zlib
  175. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  176. systemtap? ( dev-util/systemtap )
  177. xattr? ( sys-apps/attr )
  178.  
  179. dev-libs/libxml2
  180. xkb? ( x11-libs/libxkbcommon )
  181. >=x11-libs/pixman-0.28.0
  182. accessibility? (
  183. app-accessibility/brltty[api]
  184. app-accessibility/brltty
  185. )
  186. aio? ( dev-libs/libaio )
  187. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  188. bzip2? ( app-arch/bzip2 )
  189. capstone? ( dev-libs/capstone:= )
  190. caps? ( sys-libs/libcap-ng )
  191. curl? ( >=net-misc/curl-7.15.4 )
  192. fdt? ( >=sys-apps/dtc-1.5.0 )
  193. glusterfs? ( >=sys-cluster/glusterfs-3.4.0 )
  194. gnutls? (
  195. dev-libs/nettle:=
  196. >=net-libs/gnutls-3.0:=
  197. )
  198. gtk? (
  199. x11-libs/gtk+:3
  200. vte? ( x11-libs/vte:2.91 )
  201. )
  202. infiniband? (
  203. sys-fabric/libibumad:=
  204. sys-fabric/libibverbs:=
  205. sys-fabric/librdmacm:=
  206. )
  207. iscsi? ( net-libs/libiscsi )
  208. jemalloc? ( dev-libs/jemalloc )
  209. jpeg? ( virtual/jpeg:0= )
  210. lzo? ( dev-libs/lzo:2 )
  211. ncurses? (
  212. sys-libs/ncurses:0=[unicode]
  213. sys-libs/ncurses:0=
  214. )
  215. nfs? ( >=net-fs/libnfs-1.9.3:= )
  216. numa? ( sys-process/numactl )
  217. opengl? (
  218. virtual/opengl
  219. media-libs/libepoxy
  220. media-libs/mesa
  221. media-libs/mesa[egl,gbm]
  222. )
  223. png? ( media-libs/libpng:0= )
  224. pulseaudio? ( media-sound/pulseaudio )
  225. rbd? ( sys-cluster/ceph )
  226. sasl? ( dev-libs/cyrus-sasl )
  227. sdl? (
  228. media-libs/libsdl2[X]
  229. media-libs/libsdl2
  230. )
  231. seccomp? ( >=sys-libs/libseccomp-2.1.0 )
  232. smartcard? ( >=app-emulation/libcacard-2.5.0 )
  233. snappy? ( app-arch/snappy:= )
  234. spice? (
  235. >=app-emulation/spice-protocol-0.12.3
  236. >=app-emulation/spice-0.12.0
  237. )
  238. ssh? ( >=net-libs/libssh-0.8.6 )
  239. usb? ( >=virtual/libusb-1-r2 )
  240. usbredir? ( >=sys-apps/usbredir-0.6 )
  241. vde? ( net-misc/vde )
  242. virgl? ( media-libs/virglrenderer )
  243. virtfs? ( sys-libs/libcap )
  244. xen? ( app-emulation/xen-tools:= )
  245. xfs? ( sys-fs/xfsprogs )
  246. )
  247. qemu_softmmu_targets_i386? (
  248. pin-upstream-blobs? (
  249. ~sys-firmware/edk2-ovmf-201905[binary]
  250. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  251. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  252. ~sys-firmware/sgabios-0.1_pre8[binary]
  253. )
  254. !pin-upstream-blobs? (
  255. sys-firmware/edk2-ovmf
  256. sys-firmware/ipxe
  257. >=sys-firmware/seabios-1.10.2[seavgabios]
  258. sys-firmware/sgabios
  259. ) )
  260. qemu_softmmu_targets_x86_64? (
  261. pin-upstream-blobs? (
  262. ~sys-firmware/edk2-ovmf-201905[binary]
  263. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  264. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  265. ~sys-firmware/sgabios-0.1_pre8[binary]
  266. )
  267. !pin-upstream-blobs? (
  268. sys-firmware/edk2-ovmf
  269. sys-firmware/ipxe
  270. >=sys-firmware/seabios-1.10.2[seavgabios]
  271. sys-firmware/sgabios
  272. ) )
  273. qemu_softmmu_targets_ppc64? (
  274. pin-upstream-blobs? (
  275. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  276. )
  277. !pin-upstream-blobs? (
  278. >=sys-firmware/seabios-1.10.2[seavgabios]
  279. )
  280. )
  281.  
  282. kernel_linux? ( >=sys-kernel/linux-headers-2.6.35 )
  283. static? (
  284.  
  285. >=dev-libs/glib-2.0[static-libs(+)]
  286. sys-libs/zlib[static-libs(+)]
  287. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  288. systemtap? ( dev-util/systemtap )
  289. xattr? ( sys-apps/attr[static-libs(+)] )
  290.  
  291. dev-libs/libxml2[static-libs(+)]
  292. xkb? ( x11-libs/libxkbcommon[static-libs(+)] )
  293. >=x11-libs/pixman-0.28.0[static-libs(+)]
  294. accessibility? (
  295. app-accessibility/brltty[api]
  296. app-accessibility/brltty[static-libs(+)]
  297. )
  298. aio? ( dev-libs/libaio[static-libs(+)] )
  299. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  300. bzip2? ( app-arch/bzip2[static-libs(+)] )
  301. capstone? ( dev-libs/capstone:= )
  302. caps? ( sys-libs/libcap-ng[static-libs(+)] )
  303. curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
  304. fdt? ( >=sys-apps/dtc-1.5.0[static-libs(+)] )
  305. glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
  306. gnutls? (
  307. dev-libs/nettle:=[static-libs(+)]
  308. >=net-libs/gnutls-3.0:=[static-libs(+)]
  309. )
  310. gtk? (
  311. x11-libs/gtk+:3
  312. vte? ( x11-libs/vte:2.91 )
  313. )
  314. infiniband? (
  315. sys-fabric/libibumad:=[static-libs(+)]
  316. sys-fabric/libibverbs:=[static-libs(+)]
  317. sys-fabric/librdmacm:=[static-libs(+)]
  318. )
  319. iscsi? ( net-libs/libiscsi )
  320. jemalloc? ( dev-libs/jemalloc )
  321. jpeg? ( virtual/jpeg:0=[static-libs(+)] )
  322. lzo? ( dev-libs/lzo:2[static-libs(+)] )
  323. ncurses? (
  324. sys-libs/ncurses:0=[unicode]
  325. sys-libs/ncurses:0=[static-libs(+)]
  326. )
  327. nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
  328. numa? ( sys-process/numactl[static-libs(+)] )
  329. opengl? (
  330. virtual/opengl
  331. media-libs/libepoxy[static-libs(+)]
  332. media-libs/mesa[static-libs(+)]
  333. media-libs/mesa[egl,gbm]
  334. )
  335. png? ( media-libs/libpng:0=[static-libs(+)] )
  336. pulseaudio? ( media-sound/pulseaudio )
  337. rbd? ( sys-cluster/ceph[static-libs(+)] )
  338. sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
  339. sdl? (
  340. media-libs/libsdl2[X]
  341. media-libs/libsdl2[static-libs(+)]
  342. )
  343. seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
  344. smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
  345. snappy? ( app-arch/snappy:= )
  346. spice? (
  347. >=app-emulation/spice-protocol-0.12.3
  348. >=app-emulation/spice-0.12.0[static-libs(+)]
  349. )
  350. ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
  351. usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
  352. usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
  353. vde? ( net-misc/vde[static-libs(+)] )
  354. virgl? ( media-libs/virglrenderer[static-libs(+)] )
  355. virtfs? ( sys-libs/libcap )
  356. xen? ( app-emulation/xen-tools:= )
  357. xfs? ( sys-fs/xfsprogs[static-libs(+)] )
  358. )
  359. static-user? (
  360. >=dev-libs/glib-2.0[static-libs(+)]
  361. sys-libs/zlib[static-libs(+)]
  362. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  363. systemtap? ( dev-util/systemtap )
  364. xattr? ( sys-apps/attr[static-libs(+)] ) ) filecaps? ( sys-libs/libcap )"
  365. declare DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
  366. declare -- DESKTOP_DATABASE_DIR="/usr/share/applications"
  367. declare -x DIROPTIONS="-m0755"
  368. declare -- DOC_CONTENTS="If you don't have kvm compiled into the kernel, make sure you have the
  369. kernel module loaded before running kvm. The easiest way to ensure that the
  370. kernel module is loaded is to load it on boot.
  371. For AMD CPUs the module is called 'kvm-amd'.
  372. For Intel CPUs the module is called 'kvm-intel'.
  373. Please review /etc/conf.d/modules for how to load these.
  374.  
  375. Make sure your user is in the 'kvm' group. Just run
  376. \$ gpasswd -a <USER> kvm
  377. then have <USER> re-login.
  378.  
  379. For brand new installs, the default permissions on /dev/kvm might not let
  380. you access it. You can tell udev to reset ownership/perms:
  381. \$ udevadm trigger -c add /dev/kvm
  382.  
  383. If you want to register binfmt handlers for qemu user targets:
  384. For openrc:
  385. # rc-update add qemu-binfmt
  386. For systemd:
  387. # ln -s /usr/share/qemu/binfmt.d/qemu.conf /etc/binfmt.d/qemu.conf"
  388. declare -x EAPI="7"
  389. declare -x ELIBC="glibc"
  390. declare -x ENLIGHTENMENT_MODULES=""
  391. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  392. declare -- EPOCHREALTIME="1574046709.087706"
  393. declare -- EPOCHSECONDS="1574046709"
  394. declare -x EPYTHON="python3.6"
  395. declare -x EXEOPTIONS="-m0755"
  396. declare -x FCFLAGS="-march=native -O2 -pipe"
  397. 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}\""
  398. declare -x FFLAGS="-march=native -O2 -pipe"
  399. declare -x FFTOOLS=""
  400. declare -- FIRMWARE_ABI_VERSION="4.0.0-r50"
  401. declare -x GCC_SPECS=""
  402. declare -x GPSD_PROTOCOLS=""
  403. declare -x GRUB_PLATFORMS=""
  404. declare -x GSETTINGS_BACKEND="dconf"
  405. declare HDEPEND=""
  406. declare HOMEPAGE="http://www.qemu.org http://www.linux-kvm.org"
  407. declare -x INHERITED=" eutils toolchain-funcs multilib linux-info multibuild python-utils-r1 python-r1 udev fcaps readme.gentoo-r1 pax-utils l10n xdg-utils"
  408. declare -x INPUT_DEVICES=""
  409. declare -x INSOPTIONS="-m0644"
  410. declare IUSE="accessibility +aio alsa bzip2 capstone +caps +curl debug doc
  411. +fdt glusterfs gnutls gtk infiniband iscsi jemalloc +jpeg kernel_linux
  412. kernel_FreeBSD lzo ncurses nfs nls numa opengl +oss +pin-upstream-blobs
  413. +png pulseaudio python rbd sasl +seccomp sdl selinux smartcard snappy
  414. spice ssh static static-user systemtap tci test usb usbredir vde
  415. +vhost-net virgl virtfs +vnc vte xattr xen xfs +xkb qemu_softmmu_targets_aarch64 qemu_softmmu_targets_alpha qemu_softmmu_targets_arm qemu_softmmu_targets_cris qemu_softmmu_targets_hppa qemu_softmmu_targets_i386 qemu_softmmu_targets_m68k qemu_softmmu_targets_microblaze qemu_softmmu_targets_microblazeel qemu_softmmu_targets_mips qemu_softmmu_targets_mips64 qemu_softmmu_targets_mips64el qemu_softmmu_targets_mipsel qemu_softmmu_targets_nios2 qemu_softmmu_targets_or1k qemu_softmmu_targets_ppc qemu_softmmu_targets_ppc64 qemu_softmmu_targets_riscv32 qemu_softmmu_targets_riscv64 qemu_softmmu_targets_s390x qemu_softmmu_targets_sh4 qemu_softmmu_targets_sh4eb qemu_softmmu_targets_sparc qemu_softmmu_targets_sparc64 qemu_softmmu_targets_x86_64 qemu_softmmu_targets_xtensa qemu_softmmu_targets_xtensaeb qemu_softmmu_targets_lm32 qemu_softmmu_targets_moxie qemu_softmmu_targets_tricore qemu_softmmu_targets_unicore32 qemu_user_targets_aarch64 qemu_user_targets_alpha qemu_user_targets_arm qemu_user_targets_cris qemu_user_targets_hppa qemu_user_targets_i386 qemu_user_targets_m68k qemu_user_targets_microblaze qemu_user_targets_microblazeel qemu_user_targets_mips qemu_user_targets_mips64 qemu_user_targets_mips64el qemu_user_targets_mipsel qemu_user_targets_nios2 qemu_user_targets_or1k qemu_user_targets_ppc qemu_user_targets_ppc64 qemu_user_targets_riscv32 qemu_user_targets_riscv64 qemu_user_targets_s390x qemu_user_targets_sh4 qemu_user_targets_sh4eb qemu_user_targets_sparc qemu_user_targets_sparc64 qemu_user_targets_x86_64 qemu_user_targets_xtensa qemu_user_targets_xtensaeb qemu_user_targets_aarch64_be qemu_user_targets_armeb qemu_user_targets_mipsn32 qemu_user_targets_mipsn32el qemu_user_targets_ppc64abi32 qemu_user_targets_ppc64le qemu_user_targets_sparc32plus qemu_user_targets_tilegx kernel_linux python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 +filecaps"
  416. declare -x IUSE_EFFECTIVE="abi_x86_64 accessibility aio alpha alsa amd64 amd64-fbsd amd64-linux arm arm64 bzip2 caps capstone curl debug 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 fdt filecaps glusterfs gnutls gtk hppa ia64 infiniband iscsi jemalloc jpeg kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux lzo m68k m68k-mint mips ncurses nfs nls numa opengl oss pin-upstream-blobs png ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack pulseaudio python python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 qemu_softmmu_targets_aarch64 qemu_softmmu_targets_alpha qemu_softmmu_targets_arm qemu_softmmu_targets_cris qemu_softmmu_targets_hppa qemu_softmmu_targets_i386 qemu_softmmu_targets_lm32 qemu_softmmu_targets_m68k qemu_softmmu_targets_microblaze qemu_softmmu_targets_microblazeel qemu_softmmu_targets_mips qemu_softmmu_targets_mips64 qemu_softmmu_targets_mips64el qemu_softmmu_targets_mipsel qemu_softmmu_targets_moxie qemu_softmmu_targets_nios2 qemu_softmmu_targets_or1k qemu_softmmu_targets_ppc qemu_softmmu_targets_ppc64 qemu_softmmu_targets_riscv32 qemu_softmmu_targets_riscv64 qemu_softmmu_targets_s390x qemu_softmmu_targets_sh4 qemu_softmmu_targets_sh4eb qemu_softmmu_targets_sparc qemu_softmmu_targets_sparc64 qemu_softmmu_targets_tricore qemu_softmmu_targets_unicore32 qemu_softmmu_targets_x86_64 qemu_softmmu_targets_xtensa qemu_softmmu_targets_xtensaeb qemu_user_targets_aarch64 qemu_user_targets_aarch64_be qemu_user_targets_alpha qemu_user_targets_arm qemu_user_targets_armeb qemu_user_targets_cris qemu_user_targets_hppa qemu_user_targets_i386 qemu_user_targets_m68k qemu_user_targets_microblaze qemu_user_targets_microblazeel qemu_user_targets_mips qemu_user_targets_mips64 qemu_user_targets_mips64el qemu_user_targets_mipsel qemu_user_targets_mipsn32 qemu_user_targets_mipsn32el qemu_user_targets_nios2 qemu_user_targets_or1k qemu_user_targets_ppc qemu_user_targets_ppc64 qemu_user_targets_ppc64abi32 qemu_user_targets_ppc64le qemu_user_targets_riscv32 qemu_user_targets_riscv64 qemu_user_targets_s390x qemu_user_targets_sh4 qemu_user_targets_sh4eb qemu_user_targets_sparc qemu_user_targets_sparc32plus qemu_user_targets_sparc64 qemu_user_targets_tilegx qemu_user_targets_x86_64 qemu_user_targets_xtensa qemu_user_targets_xtensaeb rbd riscv s390 sasl sdl seccomp selinux sh smartcard snappy sparc sparc-solaris sparc64-solaris spice ssh static static-user systemtap tci test usb usbredir userland_BSD userland_GNU vde vhost-net virgl virtfs vnc vte x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt xattr xen xfs xkb"
  417. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-guest prefix-stack"
  418. declare -- IUSE_SOFTMMU_TARGETS="aarch64 alpha arm cris hppa i386 m68k microblaze microblazeel
  419. mips mips64 mips64el mipsel nios2 or1k ppc ppc64 riscv32 riscv64 s390x
  420. sh4 sh4eb sparc sparc64 x86_64 xtensa xtensaeb
  421. lm32 moxie tricore unicore32"
  422. declare -- IUSE_USER_TARGETS="aarch64 alpha arm cris hppa i386 m68k microblaze microblazeel
  423. mips mips64 mips64el mipsel nios2 or1k ppc ppc64 riscv32 riscv64 s390x
  424. sh4 sh4eb sparc sparc64 x86_64 xtensa xtensaeb
  425. aarch64_be armeb mipsn32 mipsn32el ppc64abi32 ppc64le sparc32plus
  426. tilegx"
  427. declare -x KERNEL="linux"
  428. declare -x KERNEL_ABI="amd64"
  429. declare -- KERNEL_DIR="/usr/src/linux"
  430. declare -- KERNEL_MAKEFILE="/usr/src/linux/Makefile"
  431. declare -x KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~x86"
  432. declare -- KV_DIR="/usr/src/linux"
  433. declare -- KV_EXTRA="-gentoo"
  434. declare -- KV_FULL="5.3.11-gentoo"
  435. declare -- KV_LOCAL=""
  436. declare -- KV_MAJOR="5"
  437. declare -- KV_MINOR="3"
  438. declare -- KV_OUT_DIR="/usr/src/linux"
  439. declare -- KV_PATCH="11"
  440. declare -x L10N=""
  441. declare -x LANG="en_US.utf8"
  442. declare -x LCD_DEVICES=""
  443. declare -x LC_COLLATE="C"
  444. declare -x LC_MESSAGES="C"
  445. declare -x LD="x86_64-pc-linux-gnu-ld"
  446. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  447. declare -x LDFLAGS_amd64="-m elf_x86_64"
  448. declare -x LDFLAGS_default
  449. declare -x LDFLAGS_x32="-m elf32_x86_64"
  450. declare -x LDFLAGS_x86="-m elf_i386"
  451. declare -x LIBDIR_amd64="lib64"
  452. declare -x LIBDIR_default="lib"
  453. declare -x LIBDIR_x32="libx32"
  454. declare -x LIBDIR_x86="lib"
  455. declare -x LIBOPTIONS="-m0644"
  456. declare -x LIBREOFFICE_EXTENSIONS=""
  457. declare -x LICENSE="GPL-2 LGPL-2 BSD-2"
  458. declare -x LIRC_DEVICES=""
  459. declare -x LLVM_TARGETS=""
  460. declare -x LV2_PATH="/usr/lib64/lv2"
  461. declare -x MAIL="/var/mail/root"
  462. declare -x MAKEOPTS="-j5 V=1"
  463. declare -x MANPAGER="manpager"
  464. declare -- MIMEINFO_DATABASE_DIR="/usr/share/mime"
  465. declare -x MONKEYD_PLUGINS=""
  466. declare -x MOZ_GMP_PATH="/usr/lib64/nsbrowser/plugins/gmp-gmpopenh264/system-installed"
  467. declare -x MULTILIB_ABIS="amd64 x86"
  468. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  469. 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"
  470. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  471. declare -x NETBEANS_MODULES=""
  472. declare -x NGINX_MODULES_HTTP=""
  473. declare -x NGINX_MODULES_MAIL=""
  474. declare -x NGINX_MODULES_STREAM=""
  475. declare -x NM="x86_64-pc-linux-gnu-nm"
  476. declare -x OBJCOPY="x86_64-pc-linux-gnu-objcopy"
  477. declare -x OFED_DRIVERS=""
  478. declare -x OFFICE_IMPLEMENTATION=""
  479. declare -x OPENGL_PROFILE="xorg-x11"
  480. declare -x OPENMPI_FABRICS=""
  481. declare -x OPENMPI_OFED_FEATURES=""
  482. declare -x OPENMPI_RM=""
  483. declare -a PATCHES=([0]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-2.5.0-cflags.patch" [1]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-2.5.0-sysmacros.patch" [2]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-2.11.1-capstone_include_path.patch" [3]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-4.0.0-sanitize-interp_info.patch" [4]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-4.0.0-mkdir_systemtap.patch" [5]="/var/tmp/portage/app-emulation/qemu-4.1.0/files/qemu-4.0.0-xkbcommon.patch")
  484. declare -x PATH="/var/tmp/portage/app-emulation/qemu-4.1.0/temp/python3.6/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/lib/llvm/9/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  485. declare -- PAX_MARKINGS="none"
  486. declare PDEPEND=""
  487. declare -x PHP_TARGETS=""
  488. declare -x PKG_CONFIG="x86_64-pc-linux-gnu-pkg-config"
  489. declare -x PKG_CONFIG_PATH="/var/tmp/portage/app-emulation/qemu-4.1.0/temp/python3.6/pkgconfig:/usr/lib64/pkgconfig"
  490. declare -- PLOCALES="bg de_DE fr_FR hu it tr zh_CN"
  491. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  492. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  493. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  494. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/qemu-4.1.0/html")
  495. declare -a PORTAGE_DOSTRIP=([0]="/")
  496. declare -a PORTAGE_DOSTRIP_SKIP=()
  497. declare -x POSTGRES_TARGETS=""
  498. declare -- PPC64_FIRMWARE_DEPEND="
  499. pin-upstream-blobs? (
  500. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  501. )
  502. !pin-upstream-blobs? (
  503. >=sys-firmware/seabios-1.10.2[seavgabios]
  504. )
  505. "
  506. 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"
  507. declare -x PROPERTIES=""
  508. declare -x PYTHON="/usr/bin/python3.6"
  509. declare -x PYTHONDONTWRITEBYTECODE="1"
  510. declare -a PYTHON_COMPAT=([0]="python2_7" [1]="python3_5" [2]="python3_6" [3]="python3_7")
  511. declare -- PYTHON_DEPS="python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)]"
  512. declare -- PYTHON_REQUIRED_USE="|| ( python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 )"
  513. declare -- PYTHON_REQ_USE="ncurses,readline"
  514. declare -x PYTHON_SINGLE_TARGET=""
  515. declare -x PYTHON_TARGETS="python2_7 python3_6"
  516. declare -- PYTHON_USEDEP="python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)"
  517. declare -- QA_PREBUILT="
  518. usr/share/qemu/hppa-firmware.img
  519. usr/share/qemu/openbios-ppc
  520. usr/share/qemu/openbios-sparc64
  521. usr/share/qemu/openbios-sparc32
  522. usr/share/qemu/palcode-clipper
  523. usr/share/qemu/s390-ccw.img
  524. usr/share/qemu/s390-netboot.img
  525. usr/share/qemu/u-boot.e500"
  526. declare -- QA_WX_LOAD="usr/bin/qemu-i386
  527. usr/bin/qemu-x86_64
  528. usr/bin/qemu-alpha
  529. usr/bin/qemu-arm
  530. usr/bin/qemu-cris
  531. usr/bin/qemu-m68k
  532. usr/bin/qemu-microblaze
  533. usr/bin/qemu-microblazeel
  534. usr/bin/qemu-mips
  535. usr/bin/qemu-mipsel
  536. usr/bin/qemu-or1k
  537. usr/bin/qemu-ppc
  538. usr/bin/qemu-ppc64
  539. usr/bin/qemu-ppc64abi32
  540. usr/bin/qemu-sh4
  541. usr/bin/qemu-sh4eb
  542. usr/bin/qemu-sparc
  543. usr/bin/qemu-sparc64
  544. usr/bin/qemu-armeb
  545. usr/bin/qemu-sparc32plus
  546. usr/bin/qemu-s390x
  547. usr/bin/qemu-unicore32"
  548. declare -x QEMU_SOFTMMU_TARGETS="x86_64 i386"
  549. declare -x QEMU_USER_TARGETS="x86_64 i386"
  550. declare -x QT_QPA_PLATFORMTHEME="qt5ct"
  551. declare RDEPEND="
  552. !static? (
  553.  
  554. >=dev-libs/glib-2.0
  555. sys-libs/zlib
  556. python? ( python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[ncurses,readline] ) python_targets_python3_5? ( dev-lang/python:3.5[ncurses,readline] ) python_targets_python3_6? ( dev-lang/python:3.6[ncurses,readline] ) python_targets_python3_7? ( dev-lang/python:3.7[ncurses,readline] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,python_targets_python3_5(-)?,python_targets_python3_6(-)?,python_targets_python3_7(-)?,-python_single_target_python2_7(-),-python_single_target_python3_5(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-)] )
  557. systemtap? ( dev-util/systemtap )
  558. xattr? ( sys-apps/attr )
  559.  
  560. dev-libs/libxml2
  561. xkb? ( x11-libs/libxkbcommon )
  562. >=x11-libs/pixman-0.28.0
  563. accessibility? (
  564. app-accessibility/brltty[api]
  565. app-accessibility/brltty
  566. )
  567. aio? ( dev-libs/libaio )
  568. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  569. bzip2? ( app-arch/bzip2 )
  570. capstone? ( dev-libs/capstone:= )
  571. caps? ( sys-libs/libcap-ng )
  572. curl? ( >=net-misc/curl-7.15.4 )
  573. fdt? ( >=sys-apps/dtc-1.5.0 )
  574. glusterfs? ( >=sys-cluster/glusterfs-3.4.0 )
  575. gnutls? (
  576. dev-libs/nettle:=
  577. >=net-libs/gnutls-3.0:=
  578. )
  579. gtk? (
  580. x11-libs/gtk+:3
  581. vte? ( x11-libs/vte:2.91 )
  582. )
  583. infiniband? (
  584. sys-fabric/libibumad:=
  585. sys-fabric/libibverbs:=
  586. sys-fabric/librdmacm:=
  587. )
  588. iscsi? ( net-libs/libiscsi )
  589. jemalloc? ( dev-libs/jemalloc )
  590. jpeg? ( virtual/jpeg:0= )
  591. lzo? ( dev-libs/lzo:2 )
  592. ncurses? (
  593. sys-libs/ncurses:0=[unicode]
  594. sys-libs/ncurses:0=
  595. )
  596. nfs? ( >=net-fs/libnfs-1.9.3:= )
  597. numa? ( sys-process/numactl )
  598. opengl? (
  599. virtual/opengl
  600. media-libs/libepoxy
  601. media-libs/mesa
  602. media-libs/mesa[egl,gbm]
  603. )
  604. png? ( media-libs/libpng:0= )
  605. pulseaudio? ( media-sound/pulseaudio )
  606. rbd? ( sys-cluster/ceph )
  607. sasl? ( dev-libs/cyrus-sasl )
  608. sdl? (
  609. media-libs/libsdl2[X]
  610. media-libs/libsdl2
  611. )
  612. seccomp? ( >=sys-libs/libseccomp-2.1.0 )
  613. smartcard? ( >=app-emulation/libcacard-2.5.0 )
  614. snappy? ( app-arch/snappy:= )
  615. spice? (
  616. >=app-emulation/spice-protocol-0.12.3
  617. >=app-emulation/spice-0.12.0
  618. )
  619. ssh? ( >=net-libs/libssh-0.8.6 )
  620. usb? ( >=virtual/libusb-1-r2 )
  621. usbredir? ( >=sys-apps/usbredir-0.6 )
  622. vde? ( net-misc/vde )
  623. virgl? ( media-libs/virglrenderer )
  624. virtfs? ( sys-libs/libcap )
  625. xen? ( app-emulation/xen-tools:= )
  626. xfs? ( sys-fs/xfsprogs )
  627. )
  628. qemu_softmmu_targets_i386? (
  629. pin-upstream-blobs? (
  630. ~sys-firmware/edk2-ovmf-201905[binary]
  631. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  632. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  633. ~sys-firmware/sgabios-0.1_pre8[binary]
  634. )
  635. !pin-upstream-blobs? (
  636. sys-firmware/edk2-ovmf
  637. sys-firmware/ipxe
  638. >=sys-firmware/seabios-1.10.2[seavgabios]
  639. sys-firmware/sgabios
  640. ) )
  641. qemu_softmmu_targets_x86_64? (
  642. pin-upstream-blobs? (
  643. ~sys-firmware/edk2-ovmf-201905[binary]
  644. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  645. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  646. ~sys-firmware/sgabios-0.1_pre8[binary]
  647. )
  648. !pin-upstream-blobs? (
  649. sys-firmware/edk2-ovmf
  650. sys-firmware/ipxe
  651. >=sys-firmware/seabios-1.10.2[seavgabios]
  652. sys-firmware/sgabios
  653. ) )
  654. qemu_softmmu_targets_ppc64? (
  655. pin-upstream-blobs? (
  656. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  657. )
  658. !pin-upstream-blobs? (
  659. >=sys-firmware/seabios-1.10.2[seavgabios]
  660. )
  661. )
  662.  
  663. acct-group/kvm
  664. selinux? ( sec-policy/selinux-qemu ) "
  665. declare -- README_GENTOO_SUFFIX=""
  666. declare REPOSITORY
  667. declare REQUIRED_USE="|| ( python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 )
  668. qemu_softmmu_targets_arm? ( fdt )
  669. qemu_softmmu_targets_microblaze? ( fdt )
  670. qemu_softmmu_targets_mips64el? ( fdt )
  671. qemu_softmmu_targets_ppc64? ( fdt )
  672. qemu_softmmu_targets_ppc? ( fdt )
  673. qemu_softmmu_targets_riscv32? ( fdt )
  674. qemu_softmmu_targets_riscv64? ( fdt )
  675. static? ( static-user !alsa !gtk !opengl !pulseaudio !snappy )
  676. virtfs? ( xattr )
  677. vte? ( gtk ) "
  678. declare -x RESTRICT=""
  679. 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}\""
  680. declare -x ROS_MESSAGES=""
  681. declare -x RUBY_TARGETS=""
  682. declare -x S="/var/tmp/portage/app-emulation/qemu-4.1.0/work/qemu-4.1.0"
  683. declare -x SANDBOX_DEBUG="0"
  684. declare -x SANDBOX_DENY=""
  685. declare -x SANDBOX_PREDICT="/var/tmp/portage/app-emulation/qemu-4.1.0/homedir:/dev/crypto:/var/cache/man:/dev/random:/proc/self/coredump_filter:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  686. declare -x SANDBOX_READ="/:/var/tmp/portage"
  687. declare -x SANDBOX_VERBOSE="1"
  688. 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/portage:/var/tmp/portage/app-emulation/qemu-4.1.0/homedir/.bash_history"
  689. declare -x SANE_BACKENDS=""
  690. declare -x SHELL="/bin/bash"
  691. declare -x SLOT="0"
  692. declare -- SOFTMMU_TOOLS_DEPEND="
  693. dev-libs/libxml2[static-libs(+)]
  694. xkb? ( x11-libs/libxkbcommon[static-libs(+)] )
  695. >=x11-libs/pixman-0.28.0[static-libs(+)]
  696. accessibility? (
  697. app-accessibility/brltty[api]
  698. app-accessibility/brltty[static-libs(+)]
  699. )
  700. aio? ( dev-libs/libaio[static-libs(+)] )
  701. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  702. bzip2? ( app-arch/bzip2[static-libs(+)] )
  703. capstone? ( dev-libs/capstone:= )
  704. caps? ( sys-libs/libcap-ng[static-libs(+)] )
  705. curl? ( >=net-misc/curl-7.15.4[static-libs(+)] )
  706. fdt? ( >=sys-apps/dtc-1.5.0[static-libs(+)] )
  707. glusterfs? ( >=sys-cluster/glusterfs-3.4.0[static-libs(+)] )
  708. gnutls? (
  709. dev-libs/nettle:=[static-libs(+)]
  710. >=net-libs/gnutls-3.0:=[static-libs(+)]
  711. )
  712. gtk? (
  713. x11-libs/gtk+:3
  714. vte? ( x11-libs/vte:2.91 )
  715. )
  716. infiniband? (
  717. sys-fabric/libibumad:=[static-libs(+)]
  718. sys-fabric/libibverbs:=[static-libs(+)]
  719. sys-fabric/librdmacm:=[static-libs(+)]
  720. )
  721. iscsi? ( net-libs/libiscsi )
  722. jemalloc? ( dev-libs/jemalloc )
  723. jpeg? ( virtual/jpeg:0=[static-libs(+)] )
  724. lzo? ( dev-libs/lzo:2[static-libs(+)] )
  725. ncurses? (
  726. sys-libs/ncurses:0=[unicode]
  727. sys-libs/ncurses:0=[static-libs(+)]
  728. )
  729. nfs? ( >=net-fs/libnfs-1.9.3:=[static-libs(+)] )
  730. numa? ( sys-process/numactl[static-libs(+)] )
  731. opengl? (
  732. virtual/opengl
  733. media-libs/libepoxy[static-libs(+)]
  734. media-libs/mesa[static-libs(+)]
  735. media-libs/mesa[egl,gbm]
  736. )
  737. png? ( media-libs/libpng:0=[static-libs(+)] )
  738. pulseaudio? ( media-sound/pulseaudio )
  739. rbd? ( sys-cluster/ceph[static-libs(+)] )
  740. sasl? ( dev-libs/cyrus-sasl[static-libs(+)] )
  741. sdl? (
  742. media-libs/libsdl2[X]
  743. media-libs/libsdl2[static-libs(+)]
  744. )
  745. seccomp? ( >=sys-libs/libseccomp-2.1.0[static-libs(+)] )
  746. smartcard? ( >=app-emulation/libcacard-2.5.0[static-libs(+)] )
  747. snappy? ( app-arch/snappy:= )
  748. spice? (
  749. >=app-emulation/spice-protocol-0.12.3
  750. >=app-emulation/spice-0.12.0[static-libs(+)]
  751. )
  752. ssh? ( >=net-libs/libssh-0.8.6[static-libs(+)] )
  753. usb? ( >=virtual/libusb-1-r2[static-libs(+)] )
  754. usbredir? ( >=sys-apps/usbredir-0.6[static-libs(+)] )
  755. vde? ( net-misc/vde[static-libs(+)] )
  756. virgl? ( media-libs/virglrenderer[static-libs(+)] )
  757. virtfs? ( sys-libs/libcap )
  758. xen? ( app-emulation/xen-tools:= )
  759. xfs? ( sys-fs/xfsprogs[static-libs(+)] )"
  760. declare SRC_URI="http://wiki.qemu-project.org/download/qemu-4.1.0.tar.xz"
  761. declare -x SUDO_COMMAND="/usr/bin/emerge -v @preserved-rebuild"
  762. declare -x SUDO_GID="1000"
  763. declare -x SUDO_UID="1000"
  764. declare -x SUDO_USER="ethan"
  765. declare -x SYMLINK_LIB="no"
  766. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  767. declare -x USE="abi_x86_64 aio alsa amd64 bzip2 caps curl elibc_glibc fdt filecaps gtk jpeg kernel_linux ncurses nfs nls opengl oss pin-upstream-blobs png pulseaudio python_targets_python2_7 python_targets_python3_6 qemu_softmmu_targets_i386 qemu_softmmu_targets_x86_64 qemu_user_targets_i386 qemu_user_targets_x86_64 sdl seccomp snappy spice ssh usb userland_GNU vhost-net virgl vnc xattr xkb"
  768. declare -x USERLAND="GNU"
  769. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  770. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  771. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos riscv s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  772. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  773. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  774. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  775. declare -x UWSGI_PLUGINS=""
  776. declare -x VIDEO_CARDS=""
  777. declare -x VOICEMAIL_STORAGE=""
  778. declare -x WINDRES="x86_64-pc-linux-gnu-windres"
  779. declare -- X86_FIRMWARE_DEPEND="
  780. pin-upstream-blobs? (
  781. ~sys-firmware/edk2-ovmf-201905[binary]
  782. ~sys-firmware/ipxe-1.0.0_p20190728[binary]
  783. ~sys-firmware/seabios-1.12.0[binary,seavgabios]
  784. ~sys-firmware/sgabios-0.1_pre8[binary]
  785. )
  786. !pin-upstream-blobs? (
  787. sys-firmware/edk2-ovmf
  788. sys-firmware/ipxe
  789. >=sys-firmware/seabios-1.10.2[seavgabios]
  790. sys-firmware/sgabios
  791. )"
  792. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  793. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  794. declare -x XFCE_PLUGINS=""
  795. declare -x XTABLES_ADDONS=""
  796. declare -- _EUTILS_ECLASS="1"
  797. declare -x _E_DESTTREE_="/usr"
  798. declare -x _E_DOCDESTTREE_=""
  799. declare -x _E_EXEDESTTREE_=""
  800. declare -x _E_INSDESTTREE_=""
  801. declare -- _FCAPS_ECLASS="1"
  802. declare -- _LINUX_CONFIG_EXISTS_DONE=""
  803. declare -- _MULTIBUILD="1"
  804. declare -- _MULTILIB_ECLASS="1"
  805. declare -- _PAX_UTILS_ECLASS="1"
  806. declare -a _PYTHON_ALL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_5" [5]="python3_6" [6]="python3_7" [7]="python3_8")
  807. declare -- _PYTHON_R1="1"
  808. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python2_7" [1]="python3_5" [2]="python3_6" [3]="python3_7")
  809. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python3_8")
  810. declare -- _PYTHON_UTILS_R1="1"
  811. declare -- _README_GENTOO_ECLASS="1"
  812. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  813. declare -- _UDEV_ECLASS="1"
  814. declare -- get_version_warning_done=""
  815. declare -- i="2"
  816. declare -a softmmu_bins=([0]="qemu-system-i386" [1]="qemu-system-x86_64")
  817. declare -- softmmu_targets="i386-softmmu,x86_64-softmmu"
  818. declare -- use_softmmu_targets=" qemu_softmmu_targets_aarch64 qemu_softmmu_targets_alpha qemu_softmmu_targets_arm qemu_softmmu_targets_cris qemu_softmmu_targets_hppa qemu_softmmu_targets_i386 qemu_softmmu_targets_m68k qemu_softmmu_targets_microblaze qemu_softmmu_targets_microblazeel qemu_softmmu_targets_mips qemu_softmmu_targets_mips64 qemu_softmmu_targets_mips64el qemu_softmmu_targets_mipsel qemu_softmmu_targets_nios2 qemu_softmmu_targets_or1k qemu_softmmu_targets_ppc qemu_softmmu_targets_ppc64 qemu_softmmu_targets_riscv32 qemu_softmmu_targets_riscv64 qemu_softmmu_targets_s390x qemu_softmmu_targets_sh4 qemu_softmmu_targets_sh4eb qemu_softmmu_targets_sparc qemu_softmmu_targets_sparc64 qemu_softmmu_targets_x86_64 qemu_softmmu_targets_xtensa qemu_softmmu_targets_xtensaeb qemu_softmmu_targets_lm32 qemu_softmmu_targets_moxie qemu_softmmu_targets_tricore qemu_softmmu_targets_unicore32"
  819. declare -- use_user_targets=" qemu_user_targets_aarch64 qemu_user_targets_alpha qemu_user_targets_arm qemu_user_targets_cris qemu_user_targets_hppa qemu_user_targets_i386 qemu_user_targets_m68k qemu_user_targets_microblaze qemu_user_targets_microblazeel qemu_user_targets_mips qemu_user_targets_mips64 qemu_user_targets_mips64el qemu_user_targets_mipsel qemu_user_targets_nios2 qemu_user_targets_or1k qemu_user_targets_ppc qemu_user_targets_ppc64 qemu_user_targets_riscv32 qemu_user_targets_riscv64 qemu_user_targets_s390x qemu_user_targets_sh4 qemu_user_targets_sh4eb qemu_user_targets_sparc qemu_user_targets_sparc64 qemu_user_targets_x86_64 qemu_user_targets_xtensa qemu_user_targets_xtensaeb qemu_user_targets_aarch64_be qemu_user_targets_armeb qemu_user_targets_mipsn32 qemu_user_targets_mipsn32el qemu_user_targets_ppc64abi32 qemu_user_targets_ppc64le qemu_user_targets_sparc32plus qemu_user_targets_tilegx"
  820. declare -a user_bins=([0]="qemu-i386" [1]="qemu-x86_64")
  821. declare -- user_targets="i386-linux-user,x86_64-linux-user"
  822. PYTHON ()
  823. {
  824. 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"
  825. }
  826. __eapi6_src_install ()
  827. {
  828. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  829. emake DESTDIR="${D}" install;
  830. fi;
  831. einstalldocs
  832. }
  833. __eapi6_src_prepare ()
  834. {
  835. if ___is_indexed_array_var PATCHES; then
  836. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  837. else
  838. if [[ -n ${PATCHES} ]]; then
  839. eapply ${PATCHES};
  840. fi;
  841. fi;
  842. eapply_user
  843. }
  844. __eapi7_ver_compare ()
  845. {
  846. local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C;
  847. re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$";
  848. [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}";
  849. an=${BASH_REMATCH[1]};
  850. al=${BASH_REMATCH[3]};
  851. as=${BASH_REMATCH[4]};
  852. ar=${BASH_REMATCH[7]};
  853. [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}";
  854. bn=${BASH_REMATCH[1]};
  855. bl=${BASH_REMATCH[3]};
  856. bs=${BASH_REMATCH[4]};
  857. br=${BASH_REMATCH[7]};
  858. __eapi7_ver_compare_int "${an%%.*}" "${bn%%.*}" || return;
  859. while [[ ${an} == *.* && ${bn} == *.* ]]; do
  860. an=${an#*.};
  861. bn=${bn#*.};
  862. a=${an%%.*};
  863. b=${bn%%.*};
  864. if [[ ${a} == 0* || ${b} == 0* ]]; then
  865. [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"};
  866. [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"};
  867. [[ ${a} > ${b} ]] && return 3;
  868. [[ ${a} < ${b} ]] && return 1;
  869. else
  870. __eapi7_ver_compare_int "${a}" "${b}" || return;
  871. fi;
  872. done;
  873. [[ ${an} == *.* ]] && return 3;
  874. [[ ${bn} == *.* ]] && return 1;
  875. [[ ${al} > ${bl} ]] && return 3;
  876. [[ ${al} < ${bl} ]] && return 1;
  877. as=${as#_}${as:+_};
  878. bs=${bs#_}${bs:+_};
  879. while [[ -n ${as} && -n ${bs} ]]; do
  880. a=${as%%_*};
  881. b=${bs%%_*};
  882. if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
  883. __eapi7_ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return;
  884. else
  885. [[ ${a%%[0-9]*} == p ]] && return 3;
  886. [[ ${b%%[0-9]*} == p ]] && return 1;
  887. [[ ${a} > ${b} ]] && return 3 || return 1;
  888. fi;
  889. as=${as#*_};
  890. bs=${bs#*_};
  891. done;
  892. if [[ -n ${as} ]]; then
  893. [[ ${as} == p[_0-9]* ]] && return 3 || return 1;
  894. else
  895. if [[ -n ${bs} ]]; then
  896. [[ ${bs} == p[_0-9]* ]] && return 1 || return 3;
  897. fi;
  898. fi;
  899. __eapi7_ver_compare_int "${ar#-r}" "${br#-r}" || return;
  900. return 2
  901. }
  902. __eapi7_ver_compare_int ()
  903. {
  904. local a=$1 b=$2 d=$(( ${#1}-${#2} ));
  905. if [[ ${d} -gt 0 ]]; then
  906. printf -v b "%0${d}d%s" 0 "${b}";
  907. else
  908. if [[ ${d} -lt 0 ]]; then
  909. printf -v a "%0$(( -d ))d%s" 0 "${a}";
  910. fi;
  911. fi;
  912. [[ ${a} > ${b} ]] && return 3;
  913. [[ ${a} == "${b}" ]]
  914. }
  915. __eapi7_ver_parse_range ()
  916. {
  917. local range=${1};
  918. local max=${2};
  919. [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number";
  920. start=${range%-*};
  921. [[ ${range} == *-* ]] && end=${range#*-} || end=${start};
  922. if [[ -n ${end} ]]; then
  923. [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start";
  924. [[ ${end} -le ${max} ]] || end=${max};
  925. else
  926. end=${max};
  927. fi
  928. }
  929. __eapi7_ver_split ()
  930. {
  931. local v=${1} LC_ALL=C;
  932. comp=();
  933. local s c;
  934. while [[ -n ${v} ]]; do
  935. s=${v%%[a-zA-Z0-9]*};
  936. v=${v:${#s}};
  937. [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*};
  938. v=${v:${#c}};
  939. comp+=("${s}" "${c}");
  940. done
  941. }
  942. _clang_fullversion ()
  943. {
  944. local ver="$1";
  945. shift;
  946. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  947. eval echo "$ver"
  948. }
  949. _eapply_patch ()
  950. {
  951. local f=${1};
  952. local prefix=${2};
  953. ebegin "${prefix:-Applying }${f##*/}";
  954. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  955. failed=${?};
  956. if ! eend "${failed}"; then
  957. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  958. fi
  959. }
  960. _gcc-install-dir ()
  961. {
  962. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  963. }
  964. _gcc-specs-directive_raw ()
  965. {
  966. local cc=$(tc-getCC);
  967. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  968. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  969. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  970. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  971. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  972. { spec=spec $0 }
  973. END { print spec }';
  974. return 0
  975. }
  976. _gcc-specs-exists ()
  977. {
  978. [[ -f $(_gcc-install-dir)/$1 ]]
  979. }
  980. _gcc_fullversion ()
  981. {
  982. local ver="$1";
  983. shift;
  984. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  985. eval echo "$ver"
  986. }
  987. _pax_list_files ()
  988. {
  989. local f cmd;
  990. cmd=$1;
  991. shift;
  992. for f in "$@";
  993. do
  994. ${cmd} " ${f}";
  995. done
  996. }
  997. _python_check_dead_variables ()
  998. {
  999. local v;
  1000. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  1001. do
  1002. if [[ -n ${!v} ]]; then
  1003. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  1004. fi;
  1005. done;
  1006. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  1007. do
  1008. if [[ -n ${!v} ]]; then
  1009. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  1010. fi;
  1011. done;
  1012. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  1013. do
  1014. if [[ -n ${!v} ]]; then
  1015. die "${v} is invalid for python-r1 suite";
  1016. fi;
  1017. done;
  1018. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  1019. do
  1020. if [[ -n ${!v} ]]; then
  1021. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  1022. fi;
  1023. done;
  1024. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  1025. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  1026. fi;
  1027. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  1028. do
  1029. if [[ -n ${!v} ]]; then
  1030. die "${v} is invalid for python-r1 suite";
  1031. fi;
  1032. done
  1033. }
  1034. _python_check_locale_sanity ()
  1035. {
  1036. local -x LC_ALL=${1};
  1037. local IFS=;
  1038. local lc=({a..z});
  1039. local uc=({A..Z});
  1040. local input="${lc[*]}${uc[*]}";
  1041. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  1042. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  1043. }
  1044. _python_impl_matches ()
  1045. {
  1046. [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  1047. local impl=${1} pattern;
  1048. shift;
  1049. for pattern in "$@";
  1050. do
  1051. if [[ ${pattern} == -2 ]]; then
  1052. ! python_is_python3 "${impl}";
  1053. return;
  1054. else
  1055. if [[ ${pattern} == -3 ]]; then
  1056. python_is_python3 "${impl}";
  1057. return;
  1058. else
  1059. if [[ ${impl/./_} == ${pattern/./_} ]]; then
  1060. return 0;
  1061. fi;
  1062. fi;
  1063. fi;
  1064. done;
  1065. return 1
  1066. }
  1067. _python_impl_supported ()
  1068. {
  1069. debug-print-function ${FUNCNAME} "${@}";
  1070. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  1071. local impl=${1};
  1072. case "${impl}" in
  1073. python2_7 | python3_[5678] | jython2_7)
  1074. return 0
  1075. ;;
  1076. pypy1_[89] | pypy2_0 | python2_[56] | python3_[1234])
  1077. return 1
  1078. ;;
  1079. pypy | pypy3)
  1080. if [[ ${EAPI:-0} == [01234] ]]; then
  1081. die "PyPy is supported in EAPI 5 and newer only.";
  1082. fi
  1083. ;;
  1084. *)
  1085. [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  1086. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  1087. ;;
  1088. esac
  1089. }
  1090. _python_ln_rel ()
  1091. {
  1092. debug-print-function ${FUNCNAME} "${@}";
  1093. local target=${1};
  1094. local symname=${2};
  1095. local tgpath=${target%/*}/;
  1096. local sympath=${symname%/*}/;
  1097. local rel_target=;
  1098. while [[ -n ${sympath} ]]; do
  1099. local tgseg= symseg=;
  1100. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  1101. tgseg=${tgpath%%/*};
  1102. tgpath=${tgpath#${tgseg}/};
  1103. done;
  1104. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  1105. symseg=${sympath%%/*};
  1106. sympath=${sympath#${symseg}/};
  1107. done;
  1108. if [[ ${tgseg} != ${symseg} ]]; then
  1109. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  1110. fi;
  1111. done;
  1112. rel_target+=${tgpath}${target##*/};
  1113. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  1114. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  1115. ln -fs "${rel_target}" "${symname}"
  1116. }
  1117. _python_multibuild_wrapper ()
  1118. {
  1119. debug-print-function ${FUNCNAME} "${@}";
  1120. local -x EPYTHON PYTHON;
  1121. local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH};
  1122. python_export "${MULTIBUILD_VARIANT}" EPYTHON PYTHON;
  1123. python_wrapper_setup;
  1124. "${@}"
  1125. }
  1126. _python_obtain_impls ()
  1127. {
  1128. _python_validate_useflags;
  1129. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  1130. MULTIBUILD_VARIANTS=(${PYTHON_COMPAT_OVERRIDE});
  1131. return;
  1132. fi;
  1133. MULTIBUILD_VARIANTS=();
  1134. local impl;
  1135. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1136. do
  1137. has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}" && MULTIBUILD_VARIANTS+=("${impl}");
  1138. done
  1139. }
  1140. _python_set_impls ()
  1141. {
  1142. local i;
  1143. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  1144. die 'PYTHON_COMPAT not declared.';
  1145. fi;
  1146. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  1147. die 'PYTHON_COMPAT must be an array.';
  1148. fi;
  1149. for i in "${PYTHON_COMPAT[@]}";
  1150. do
  1151. _python_impl_supported "${i}";
  1152. done;
  1153. local supp=() unsupp=();
  1154. for i in "${_PYTHON_ALL_IMPLS[@]}";
  1155. do
  1156. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  1157. supp+=("${i}");
  1158. else
  1159. unsupp+=("${i}");
  1160. fi;
  1161. done;
  1162. if [[ ! -n ${supp[@]} ]]; then
  1163. die "No supported implementation in PYTHON_COMPAT.";
  1164. fi;
  1165. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  1166. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  1167. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  1168. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  1169. eerror "Now : ${supp[*]}";
  1170. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  1171. fi;
  1172. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  1173. eerror "Unsupported impls changed between inherits!";
  1174. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  1175. eerror "Now : ${unsupp[*]}";
  1176. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  1177. fi;
  1178. else
  1179. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  1180. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  1181. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  1182. fi
  1183. }
  1184. _python_validate_useflags ()
  1185. {
  1186. debug-print-function ${FUNCNAME} "${@}";
  1187. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  1188. if [[ ! -n ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
  1189. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  1190. ewarn "implementations will be enabled:";
  1191. ewarn;
  1192. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  1193. ewarn;
  1194. ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored.";
  1195. _PYTHON_COMPAT_OVERRIDE_WARNED=1;
  1196. fi;
  1197. return;
  1198. fi;
  1199. local i;
  1200. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  1201. do
  1202. use "python_targets_${i}" && return 0;
  1203. done;
  1204. eerror "No Python implementation selected for the build. Please add one";
  1205. eerror "of the following values to your PYTHON_TARGETS (in make.conf):";
  1206. eerror;
  1207. eerror "${PYTHON_COMPAT[@]}";
  1208. echo;
  1209. die "No supported Python implementation in PYTHON_TARGETS."
  1210. }
  1211. _tc-getPROG ()
  1212. {
  1213. local tuple=$1;
  1214. local v var vars=$2;
  1215. local prog=($3);
  1216. var=${vars%% *};
  1217. for v in ${vars};
  1218. do
  1219. if [[ -n ${!v} ]]; then
  1220. export ${var}="${!v}";
  1221. echo "${!v}";
  1222. return 0;
  1223. fi;
  1224. done;
  1225. local search=;
  1226. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  1227. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  1228. [[ -n ${search} ]] && prog[0]=${search##*/};
  1229. export ${var}="${prog[*]}";
  1230. echo "${!var}"
  1231. }
  1232. _udev_get_udevdir ()
  1233. {
  1234. if $($(tc-getPKG_CONFIG) --exists udev); then
  1235. local udevdir="$($(tc-getPKG_CONFIG) --variable=udevdir udev)";
  1236. echo "${udevdir#${EPREFIX%/}}";
  1237. else
  1238. echo /lib/udev;
  1239. fi
  1240. }
  1241. check_extra_config ()
  1242. {
  1243. use kernel_linux || return;
  1244. local config negate die error reworkmodulenames;
  1245. local soft_errors_count=0 hard_errors_count=0 config_required=0;
  1246. local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  1247. linux-info_get_any_version;
  1248. for config in ${CONFIG_CHECK};
  1249. do
  1250. if [[ "${config:0:1}" != "~" ]]; then
  1251. config_required=1;
  1252. break;
  1253. fi;
  1254. done;
  1255. if [[ ${config_required} == 0 ]]; then
  1256. if ! linux_config_exists; then
  1257. ewarn "Unable to check for the following kernel config options due";
  1258. ewarn "to absence of any configured kernel sources or compiled";
  1259. ewarn "config:";
  1260. for config in ${CONFIG_CHECK};
  1261. do
  1262. config=${config#\~};
  1263. config=${config#\!};
  1264. local_error="ERROR_${config}";
  1265. msg="${!local_error}";
  1266. if [[ -z ${msg} ]]; then
  1267. local_error="WARNING_${config}";
  1268. msg="${!local_error}";
  1269. fi;
  1270. ewarn " - ${config}${msg:+ - }${msg}";
  1271. done;
  1272. ewarn "You're on your own to make sure they are set if needed.";
  1273. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1274. return 0;
  1275. fi;
  1276. else
  1277. require_configured_kernel;
  1278. fi;
  1279. einfo "Checking for suitable kernel configuration options...";
  1280. for config in ${CONFIG_CHECK};
  1281. do
  1282. die=1;
  1283. error=0;
  1284. negate=0;
  1285. reworkmodulenames=0;
  1286. if [[ ${config:0:1} == "~" ]]; then
  1287. die=0;
  1288. config=${config:1};
  1289. else
  1290. if [[ ${config:0:1} == "@" ]]; then
  1291. die=0;
  1292. reworkmodulenames=1;
  1293. config=${config:1};
  1294. fi;
  1295. fi;
  1296. if [[ ${config:0:1} == "!" ]]; then
  1297. negate=1;
  1298. config=${config:1};
  1299. fi;
  1300. if [[ ${negate} == 1 ]]; then
  1301. linux_chkconfig_present ${config} && error=2;
  1302. else
  1303. if [[ ${reworkmodulenames} == 1 ]]; then
  1304. local temp_config="${config//*:}" i n;
  1305. config="${config//:*}";
  1306. if linux_chkconfig_present ${config}; then
  1307. for i in ${MODULE_NAMES};
  1308. do
  1309. n="${i//${temp_config}}";
  1310. [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  1311. done;
  1312. error=2;
  1313. fi;
  1314. else
  1315. linux_chkconfig_present ${config} || error=1;
  1316. fi;
  1317. fi;
  1318. if [[ ${error} > 0 ]]; then
  1319. local report_func="eerror" local_error;
  1320. local_error="ERROR_${config}";
  1321. local_error="${!local_error}";
  1322. if [[ -z "${local_error}" ]]; then
  1323. local_error="${config}_ERROR";
  1324. local_error="${!local_error}";
  1325. fi;
  1326. if [[ ${die} == 0 && -z "${local_error}" ]]; then
  1327. local_error="WARNING_${config}";
  1328. local_error="${!local_error}";
  1329. if [[ -n "${local_error}" ]]; then
  1330. report_func="ewarn";
  1331. fi;
  1332. fi;
  1333. if [[ -z "${local_error}" ]]; then
  1334. [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  1335. local_error="CONFIG_${config}:\t ${local_error}";
  1336. fi;
  1337. if [[ ${die} == 0 ]]; then
  1338. ${report_func} " ${local_error}";
  1339. soft_errors_count=$[soft_errors_count + 1];
  1340. else
  1341. ${report_func} " ${local_error}";
  1342. hard_errors_count=$[hard_errors_count + 1];
  1343. fi;
  1344. fi;
  1345. done;
  1346. if [[ ${hard_errors_count} > 0 ]]; then
  1347. eerror "Please check to make sure these options are set correctly.";
  1348. eerror "Failure to do so may cause unexpected problems.";
  1349. eerror "Once you have satisfied these options, please try merging";
  1350. eerror "this package again.";
  1351. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  1352. die "Incorrect kernel configuration options";
  1353. else
  1354. if [[ ${soft_errors_count} > 0 ]]; then
  1355. ewarn "Please check to make sure these options are set correctly.";
  1356. ewarn "Failure to do so may cause unexpected problems.";
  1357. else
  1358. eend 0;
  1359. fi;
  1360. fi;
  1361. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  1362. }
  1363. check_kernel_built ()
  1364. {
  1365. if ! use kernel_linux; then
  1366. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1367. fi;
  1368. require_configured_kernel;
  1369. local versionh_path;
  1370. if kernel_is -ge 3 7; then
  1371. versionh_path="include/generated/uapi/linux/version.h";
  1372. else
  1373. versionh_path="include/linux/version.h";
  1374. fi;
  1375. if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]; then
  1376. eerror "These sources have not yet been prepared.";
  1377. eerror "We cannot build against an unprepared tree.";
  1378. eerror "To resolve this, please type the following:";
  1379. eerror;
  1380. eerror "# cd ${KV_DIR}";
  1381. eerror "# make oldconfig";
  1382. eerror "# make modules_prepare";
  1383. eerror;
  1384. eerror "Then please try merging this module again.";
  1385. die "Kernel sources need compiling first";
  1386. fi
  1387. }
  1388. check_modules_supported ()
  1389. {
  1390. if ! use kernel_linux; then
  1391. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1392. fi;
  1393. require_configured_kernel;
  1394. if ! linux_chkconfig_builtin "MODULES"; then
  1395. eerror "These sources do not support loading external modules.";
  1396. eerror "to be able to use this module please enable \"Loadable modules support\"";
  1397. eerror "in your kernel, recompile and then try merging this module again.";
  1398. die "No support for external modules in ${KV_FULL} config";
  1399. fi
  1400. }
  1401. check_targets ()
  1402. {
  1403. local var=$1 mak=$2;
  1404. local detected sorted;
  1405. pushd "${S}"/default-configs > /dev/null || die;
  1406. detected=$(echo $(printf '%s\n' *-${mak}.mak | sed "s:-${mak}.mak::" | LC_COLLATE=C sort -u));
  1407. sorted=$(echo $(printf '%s\n' ${!var} | LC_COLLATE=C sort -u));
  1408. if [[ ${sorted} != "${detected}" ]]; then
  1409. eerror "The ebuild needs to be kept in sync.";
  1410. eerror "${var}: ${sorted}";
  1411. eerror "$(printf '%-*s' ${#var} configure): ${detected}";
  1412. die "sync ${var} to the list of targets";
  1413. fi;
  1414. popd > /dev/null
  1415. }
  1416. check_zlibinflate ()
  1417. {
  1418. if ! use kernel_linux; then
  1419. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  1420. fi;
  1421. require_configured_kernel;
  1422. local INFLATE;
  1423. local DEFLATE;
  1424. einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  1425. ebegin "checking ZLIB_INFLATE";
  1426. linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  1427. eend $? || die;
  1428. ebegin "checking ZLIB_DEFLATE";
  1429. linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  1430. eend $? || die;
  1431. local LINENO_START;
  1432. local LINENO_END;
  1433. local SYMBOLS;
  1434. local x;
  1435. LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  1436. LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  1437. (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ));
  1438. (( LINENO_END = $LINENO_END - 1 ));
  1439. SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  1440. for x in $SYMBOLS;
  1441. do
  1442. if [ "${!x}" = "y" ]; then
  1443. einfo "${x} ensures zlib is linked into your kernel - excellent";
  1444. return 0;
  1445. fi;
  1446. done;
  1447. eerror;
  1448. eerror "This kernel module requires ZLIB library support.";
  1449. eerror "You have enabled zlib support in your kernel, but haven't enabled";
  1450. eerror "enabled any option that will ensure that zlib is linked into your";
  1451. eerror "kernel.";
  1452. eerror;
  1453. eerror "Please ensure that you enable at least one of these options:";
  1454. eerror;
  1455. for x in $SYMBOLS;
  1456. do
  1457. eerror " * $x";
  1458. done;
  1459. eerror;
  1460. eerror "Please remember to recompile and install your kernel, and reboot";
  1461. eerror "into your new kernel before attempting to load this kernel module.";
  1462. die "Kernel doesn't include zlib support"
  1463. }
  1464. clang-fullversion ()
  1465. {
  1466. _clang_fullversion '$1.$2.$3' "$@"
  1467. }
  1468. clang-major-version ()
  1469. {
  1470. _clang_fullversion '$1' "$@"
  1471. }
  1472. clang-micro-version ()
  1473. {
  1474. _clang_fullversion '$3' "$@"
  1475. }
  1476. clang-minor-version ()
  1477. {
  1478. _clang_fullversion '$2' "$@"
  1479. }
  1480. clang-version ()
  1481. {
  1482. _clang_fullversion '$1.$2' "$@"
  1483. }
  1484. conf_notuser ()
  1485. {
  1486. if [[ ${buildtype} == "user" ]]; then
  1487. echo "--disable-${2:-$1}";
  1488. else
  1489. use_enable "$@";
  1490. fi
  1491. }
  1492. eapply ()
  1493. {
  1494. local failed patch_cmd=patch;
  1495. local -x LC_COLLATE=POSIX;
  1496. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1497. function _eapply_patch ()
  1498. {
  1499. local f=${1};
  1500. local prefix=${2};
  1501. ebegin "${prefix:-Applying }${f##*/}";
  1502. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1503. failed=${?};
  1504. if ! eend "${failed}"; then
  1505. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1506. fi
  1507. };
  1508. local patch_options=() files=();
  1509. local i found_doublehyphen;
  1510. for ((i = 1; i <= ${#@}; ++i ))
  1511. do
  1512. if [[ ${@:i:1} == -- ]]; then
  1513. patch_options=("${@:1:i-1}");
  1514. files=("${@:i+1}");
  1515. found_doublehyphen=1;
  1516. break;
  1517. fi;
  1518. done;
  1519. if [[ -z ${found_doublehyphen} ]]; then
  1520. for ((i = 1; i <= ${#@}; ++i ))
  1521. do
  1522. if [[ ${@:i:1} != -* ]]; then
  1523. patch_options=("${@:1:i-1}");
  1524. files=("${@:i}");
  1525. break;
  1526. fi;
  1527. done;
  1528. for i in "${files[@]}";
  1529. do
  1530. if [[ ${i} == -* ]]; then
  1531. die "eapply: all options must be passed before non-options";
  1532. fi;
  1533. done;
  1534. fi;
  1535. if [[ ${#files[@]} -eq 0 ]]; then
  1536. die "eapply: no files specified";
  1537. fi;
  1538. local f;
  1539. for f in "${files[@]}";
  1540. do
  1541. if [[ -d ${f} ]]; then
  1542. function _eapply_get_files ()
  1543. {
  1544. local LC_ALL=POSIX;
  1545. local prev_shopt=$(shopt -p nullglob);
  1546. shopt -s nullglob;
  1547. local f;
  1548. for f in "${1}"/*;
  1549. do
  1550. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1551. files+=("${f}");
  1552. fi;
  1553. done;
  1554. ${prev_shopt}
  1555. };
  1556. local files=();
  1557. _eapply_get_files "${f}";
  1558. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1559. einfo "Applying patches from ${f} ...";
  1560. local f2;
  1561. for f2 in "${files[@]}";
  1562. do
  1563. _eapply_patch "${f2}" ' ';
  1564. [[ ${failed} -ne 0 ]] && return "${failed}";
  1565. done;
  1566. else
  1567. _eapply_patch "${f}";
  1568. [[ ${failed} -ne 0 ]] && return "${failed}";
  1569. fi;
  1570. done;
  1571. return 0
  1572. }
  1573. eapply_user ()
  1574. {
  1575. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1576. local tagfile=${T}/.portage_user_patches_applied;
  1577. [[ -f ${tagfile} ]] && return;
  1578. >> "${tagfile}";
  1579. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1580. local applied d f;
  1581. local -A _eapply_user_patches;
  1582. local prev_shopt=$(shopt -p nullglob);
  1583. shopt -s nullglob;
  1584. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1585. do
  1586. for f in "${d}"/*;
  1587. do
  1588. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1589. _eapply_user_patches[${f##*/}]=${f};
  1590. fi;
  1591. done;
  1592. done;
  1593. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1594. while read -r -d '' f; do
  1595. f=${_eapply_user_patches[${f}]};
  1596. if [[ -s ${f} ]]; then
  1597. eapply "${f}";
  1598. applied=1;
  1599. fi;
  1600. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1601. LC_ALL=C sort -z);
  1602. fi;
  1603. ${prev_shopt};
  1604. [[ -n ${applied} ]] && ewarn "User patches applied."
  1605. }
  1606. ebeep ()
  1607. {
  1608. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1609. }
  1610. econf_build ()
  1611. {
  1612. local CBUILD=${CBUILD:-${CHOST}};
  1613. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1614. }
  1615. edos2unix ()
  1616. {
  1617. [[ $# -eq 0 ]] && return 0;
  1618. sed -i 's/\r$//' -- "$@" || die
  1619. }
  1620. einstalldocs ()
  1621. {
  1622. ( if ! declare -p DOCS &> /dev/null; then
  1623. local d;
  1624. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1625. do
  1626. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1627. done;
  1628. else
  1629. if ___is_indexed_array_var DOCS; then
  1630. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1631. else
  1632. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1633. fi;
  1634. fi );
  1635. ( if ___is_indexed_array_var HTML_DOCS; then
  1636. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1637. else
  1638. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1639. fi )
  1640. }
  1641. emktemp ()
  1642. {
  1643. local exe="touch";
  1644. [[ $1 == -d ]] && exe="mkdir" && shift;
  1645. local topdir=$1;
  1646. if [[ -z ${topdir} ]]; then
  1647. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1648. fi;
  1649. if ! type -P mktemp > /dev/null; then
  1650. local tmp=/;
  1651. while [[ -e ${tmp} ]]; do
  1652. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1653. done;
  1654. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1655. echo "${tmp}";
  1656. else
  1657. if [[ ${exe} == "touch" ]]; then
  1658. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1659. else
  1660. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1661. fi;
  1662. fi
  1663. }
  1664. epause ()
  1665. {
  1666. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1667. }
  1668. fcaps ()
  1669. {
  1670. debug-print-function ${FUNCNAME} "$@";
  1671. local owner='root';
  1672. local group='0';
  1673. local mode='4711';
  1674. local caps_mode='711';
  1675. while [[ $# -gt 0 ]]; do
  1676. case $1 in
  1677. -o)
  1678. owner=$2;
  1679. shift
  1680. ;;
  1681. -g)
  1682. group=$2;
  1683. shift
  1684. ;;
  1685. -m)
  1686. mode=$2;
  1687. shift
  1688. ;;
  1689. -M)
  1690. caps_mode=$2;
  1691. shift
  1692. ;;
  1693. *)
  1694. break
  1695. ;;
  1696. esac;
  1697. shift;
  1698. done;
  1699. [[ $# -lt 2 ]] && die "${FUNCNAME}: wrong arg count";
  1700. local caps=$1;
  1701. [[ ${caps} == *[-=+]* ]] || caps+="=ep";
  1702. shift;
  1703. local root;
  1704. case ${EBUILD_PHASE} in
  1705. compile | install | preinst)
  1706. root=${ED:-${D}}
  1707. ;;
  1708. postinst)
  1709. root=${EROOT:-${ROOT}}
  1710. ;;
  1711. esac;
  1712. root=${root%/};
  1713. local file;
  1714. for file in "$@";
  1715. do
  1716. [[ ${file} != /* ]] && file="${root}/${file}";
  1717. if use filecaps; then
  1718. debug-print "${FUNCNAME}: setting caps '${caps}' on '${file}'";
  1719. chmod ${caps_mode} "${file}" || die;
  1720. function _libcap ()
  1721. {
  1722. setcap "${caps}" "${file}"
  1723. };
  1724. function _libcap_verify ()
  1725. {
  1726. setcap -v "${caps}" "${file}" > /dev/null
  1727. };
  1728. function _libcap_ng ()
  1729. {
  1730. local caps=",${caps%=ep}";
  1731. filecap "${file}" "${caps//,cap_}"
  1732. };
  1733. function _libcap_ng_verify ()
  1734. {
  1735. local rcaps icaps caps=",${caps%=ep}";
  1736. rcaps=$(filecap "${file}" | sed -nr -e "s:^.{${#file}} +::" -e 's:, +:\n:g' -e 2p | LC_ALL=C sort);
  1737. [[ ${PIPESTATUS[0]} -eq 0 ]] || return 1;
  1738. icaps=$(echo "${caps//,cap_}" | LC_ALL=C sort);
  1739. [[ ${rcaps} == ${icaps} ]]
  1740. };
  1741. local out cmd notfound=0;
  1742. for cmd in _libcap _libcap_ng;
  1743. do
  1744. if ! out=$(LC_ALL=C ${cmd} 2>&1); then
  1745. case ${out} in
  1746. *"command not found"*)
  1747. : $(( ++notfound ));
  1748. continue
  1749. ;;
  1750. *"Not supported"* | *"Operation not supported"*)
  1751. local fstype=$(stat -f -c %T "${file}");
  1752. ewarn "Could not set caps on '${file}' due to missing filesystem support:";
  1753. ewarn "* enable XATTR support for '${fstype}' in your kernel (if configurable)";
  1754. ewarn "* mount the fs with the user_xattr option (if not the default)";
  1755. ewarn "* enable the relevant FS_SECURITY option (if configurable)";
  1756. break
  1757. ;;
  1758. *)
  1759. eerror "Setting caps '${caps}' on file '${file}' failed:";
  1760. eerror "${out}";
  1761. die "could not set caps"
  1762. ;;
  1763. esac;
  1764. else
  1765. ${cmd}_verify || die "Checking caps '${caps}' on '${file}' failed";
  1766. continue 2;
  1767. fi;
  1768. done;
  1769. if [[ ${notfound} -eq 2 ]] && [[ -z ${_FCAPS_WARNED} ]]; then
  1770. _FCAPS_WARNED="true";
  1771. ewarn "Could not find cap utils; make sure libcap or libcap-ng is available.";
  1772. fi;
  1773. fi;
  1774. debug-print "${FUNCNAME}: setting owner/mode on '${file}'";
  1775. chown "${owner}:${group}" "${file}" || die;
  1776. chmod ${mode} "${file}" || die;
  1777. done
  1778. }
  1779. fcaps_pkg_postinst ()
  1780. {
  1781. local arg args=();
  1782. for arg in "${FILECAPS[@]}" "--";
  1783. do
  1784. if [[ ${arg} == "--" ]]; then
  1785. fcaps "${args[@]}";
  1786. args=();
  1787. else
  1788. args+=("${arg}");
  1789. fi;
  1790. done
  1791. }
  1792. firmware_abi_change ()
  1793. {
  1794. local pv;
  1795. for pv in ${REPLACING_VERSIONS};
  1796. do
  1797. if ver_test $pv -lt ${FIRMWARE_ABI_VERSION}; then
  1798. return 0;
  1799. fi;
  1800. done;
  1801. return 1
  1802. }
  1803. gcc-fullversion ()
  1804. {
  1805. _gcc_fullversion '$1.$2.$3' "$@"
  1806. }
  1807. gcc-major-version ()
  1808. {
  1809. _gcc_fullversion '$1' "$@"
  1810. }
  1811. gcc-micro-version ()
  1812. {
  1813. _gcc_fullversion '$3' "$@"
  1814. }
  1815. gcc-minor-version ()
  1816. {
  1817. _gcc_fullversion '$2' "$@"
  1818. }
  1819. gcc-specs-directive ()
  1820. {
  1821. local directive subdname subdirective;
  1822. directive="$(_gcc-specs-directive_raw $1)";
  1823. while [[ ${directive} == *%\(*\)* ]]; do
  1824. subdname=${directive/*%\(};
  1825. subdname=${subdname/\)*};
  1826. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1827. directive="${directive//\%(${subdname})/${subdirective}}";
  1828. done;
  1829. echo "${directive}";
  1830. return 0
  1831. }
  1832. gcc-specs-nostrict ()
  1833. {
  1834. local directive;
  1835. directive=$(gcc-specs-directive cc1);
  1836. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1837. }
  1838. gcc-specs-now ()
  1839. {
  1840. local directive;
  1841. directive=$(gcc-specs-directive link_command);
  1842. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1843. }
  1844. gcc-specs-pie ()
  1845. {
  1846. local directive;
  1847. directive=$(gcc-specs-directive cc1);
  1848. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1849. }
  1850. gcc-specs-relro ()
  1851. {
  1852. local directive;
  1853. directive=$(gcc-specs-directive link_command);
  1854. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1855. }
  1856. gcc-specs-ssp ()
  1857. {
  1858. local directive;
  1859. directive=$(gcc-specs-directive cc1);
  1860. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1861. }
  1862. gcc-specs-ssp-to-all ()
  1863. {
  1864. local directive;
  1865. directive=$(gcc-specs-directive cc1);
  1866. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1867. }
  1868. gcc-specs-stack-check ()
  1869. {
  1870. local directive;
  1871. directive=$(gcc-specs-directive cc1);
  1872. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1873. }
  1874. gcc-version ()
  1875. {
  1876. _gcc_fullversion '$1.$2' "$@"
  1877. }
  1878. gen_usr_ldscript ()
  1879. {
  1880. ewarn "${FUNCNAME}: Please migrate to usr-ldscript.eclass";
  1881. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1882. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1883. tc-is-static-only && return;
  1884. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1885. multilib_is_native_abi || return 0;
  1886. fi;
  1887. case ${CTARGET:-${CHOST}} in
  1888. *-darwin*)
  1889.  
  1890. ;;
  1891. *-android*)
  1892. return 0
  1893. ;;
  1894. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1895. use prefix && return 0
  1896. ;;
  1897. *)
  1898. return 0
  1899. ;;
  1900. esac;
  1901. dodir /usr/${libdir};
  1902. if [[ $1 == "-a" ]]; then
  1903. auto=true;
  1904. shift;
  1905. dodir /${libdir};
  1906. fi;
  1907. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1908. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1909. local d="${T}/bfd-linker";
  1910. mkdir -p "${d}";
  1911. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1912. flags+=(-B"${d}");
  1913. fi;
  1914. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1915. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1916. for lib in "$@";
  1917. do
  1918. local tlib;
  1919. if ${auto}; then
  1920. lib="lib${lib}${suffix}";
  1921. else
  1922. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1923. fi;
  1924. case ${CTARGET:-${CHOST}} in
  1925. *-darwin*)
  1926. if ${auto}; then
  1927. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1928. else
  1929. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1930. fi;
  1931. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1932. tlib=${tlib##*/};
  1933. if ${auto}; then
  1934. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1935. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1936. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1937. fi;
  1938. rm -f "${ED}"/${libdir}/${lib};
  1939. fi;
  1940. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1941. chmod u+w "${ED}${libdir}/${tlib}";
  1942. local nowrite=yes;
  1943. fi;
  1944. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1945. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1946. pushd "${ED}/usr/${libdir}" > /dev/null;
  1947. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1948. popd > /dev/null
  1949. ;;
  1950. *)
  1951. if ${auto}; then
  1952. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1953. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1954. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1955. if [[ ${tlib} != ${lib}* ]]; then
  1956. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1957. fi;
  1958. rm -f "${ED}"/${libdir}/${lib};
  1959. else
  1960. tlib=${lib};
  1961. fi;
  1962. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1963. /* GNU ld script
  1964. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1965. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1966. run into linking problems. This "fake" dynamic lib is a linker script that
  1967. redirects the linker to the real lib. And yes, this works in the cross-
  1968. compiling scenario as the sysroot-ed linker will prepend the real path.
  1969.  
  1970. See bug https://bugs.gentoo.org/4411 for more info.
  1971. */
  1972. ${output_format}
  1973. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1974. END_LDSCRIPT
  1975.  
  1976. ;;
  1977. esac
  1978. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1979. done
  1980. }
  1981. generate_initd ()
  1982. {
  1983. local out="${T}/qemu-binfmt";
  1984. local out_systemd="${T}/qemu.conf";
  1985. local d="${T}/binfmt.d";
  1986. einfo "Generating qemu binfmt scripts and configuration files";
  1987. mkdir -p "${d}";
  1988. "${S}"/scripts/qemu-binfmt-conf.sh --debian --exportdir "${d}" --qemu-path "${EPREFIX}/usr/bin" || die;
  1989. sed -E -i -e 's:^([^ ]+) (.*)$:\1="\2":' "${d}"/* || die;
  1990. local f qcpu package interpreter magic mask;
  1991. cat "${FILESDIR}"/qemu-binfmt.initd.head > "${out}" || die;
  1992. for f in "${d}"/qemu-*;
  1993. do
  1994. source "${f}";
  1995. qcpu=${package#qemu-};
  1996. case ${qcpu} in
  1997. arm*)
  1998. qcpu="arm"
  1999. ;;
  2000. mips*)
  2001. qcpu="mips"
  2002. ;;
  2003. ppc*)
  2004. qcpu="ppc"
  2005. ;;
  2006. s390*)
  2007. qcpu="s390"
  2008. ;;
  2009. sh*)
  2010. qcpu="sh"
  2011. ;;
  2012. sparc*)
  2013. qcpu="sparc"
  2014. ;;
  2015. esac;
  2016. cat <<EOF >> "${out}"
  2017. if [ "\${cpu}" != "${qcpu}" -a -x "${interpreter}" ] ; then
  2018. printf '%s\n' ':${package}:M::${magic}:${mask}:${interpreter}:'"\${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register
  2019. fi
  2020. EOF
  2021.  
  2022. echo ":${package}:M::${magic}:${mask}:${interpreter}:OC" >> "${out_systemd}";
  2023. done;
  2024. cat "${FILESDIR}"/qemu-binfmt.initd.tail >> "${out}" || die
  2025. }
  2026. get_abi_CFLAGS ()
  2027. {
  2028. get_abi_var CFLAGS "$@"
  2029. }
  2030. get_abi_CHOST ()
  2031. {
  2032. get_abi_var CHOST "$@"
  2033. }
  2034. get_abi_CTARGET ()
  2035. {
  2036. get_abi_var CTARGET "$@"
  2037. }
  2038. get_abi_FAKE_TARGETS ()
  2039. {
  2040. get_abi_var FAKE_TARGETS "$@"
  2041. }
  2042. get_abi_LDFLAGS ()
  2043. {
  2044. get_abi_var LDFLAGS "$@"
  2045. }
  2046. get_abi_LIBDIR ()
  2047. {
  2048. get_abi_var LIBDIR "$@"
  2049. }
  2050. get_abi_var ()
  2051. {
  2052. local flag=$1;
  2053. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2054. local var="${flag}_${abi}";
  2055. echo ${!var}
  2056. }
  2057. get_all_abis ()
  2058. {
  2059. local x order="" mvar dvar;
  2060. mvar="MULTILIB_ABIS";
  2061. dvar="DEFAULT_ABI";
  2062. if [[ -n $1 ]]; then
  2063. mvar="$1_${mvar}";
  2064. dvar="$1_${dvar}";
  2065. fi;
  2066. if [[ -z ${!mvar} ]]; then
  2067. echo "default";
  2068. return 0;
  2069. fi;
  2070. for x in ${!mvar};
  2071. do
  2072. if [[ ${x} != ${!dvar} ]]; then
  2073. order="${order:+${order} }${x}";
  2074. fi;
  2075. done;
  2076. order="${order:+${order} }${!dvar}";
  2077. echo ${order};
  2078. return 0
  2079. }
  2080. get_all_libdirs ()
  2081. {
  2082. local libdirs abi;
  2083. for abi in ${MULTILIB_ABIS};
  2084. do
  2085. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2086. done;
  2087. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2088. echo "${libdirs}"
  2089. }
  2090. get_exeext ()
  2091. {
  2092. case ${CHOST} in
  2093. *-cygwin* | mingw* | *-mingw*)
  2094. echo ".exe"
  2095. ;;
  2096. esac
  2097. }
  2098. get_install_abis ()
  2099. {
  2100. local x order="";
  2101. if [[ -z ${MULTILIB_ABIS} ]]; then
  2102. echo "default";
  2103. return 0;
  2104. fi;
  2105. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2106. for x in ${MULTILIB_ABIS};
  2107. do
  2108. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2109. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2110. fi;
  2111. done;
  2112. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2113. if [[ -n ${ABI_ALLOW} ]]; then
  2114. local ordera="";
  2115. for x in ${order};
  2116. do
  2117. if has ${x} ${ABI_ALLOW}; then
  2118. ordera="${ordera} ${x}";
  2119. fi;
  2120. done;
  2121. order=${ordera};
  2122. fi;
  2123. else
  2124. order=${DEFAULT_ABI};
  2125. fi;
  2126. if [[ -z ${order} ]]; then
  2127. 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.";
  2128. fi;
  2129. echo ${order};
  2130. return 0
  2131. }
  2132. get_libdir ()
  2133. {
  2134. local libdir_var="LIBDIR_${ABI}";
  2135. local libdir="lib";
  2136. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2137. echo "${libdir}"
  2138. }
  2139. get_libname ()
  2140. {
  2141. local libname;
  2142. local ver=$1;
  2143. case ${CHOST} in
  2144. *-cygwin*)
  2145. libname="dll.a"
  2146. ;;
  2147. mingw* | *-mingw*)
  2148. libname="dll"
  2149. ;;
  2150. *-darwin*)
  2151. libname="dylib"
  2152. ;;
  2153. *-mint*)
  2154. libname="irrelevant"
  2155. ;;
  2156. hppa*-hpux*)
  2157. libname="sl"
  2158. ;;
  2159. *)
  2160. libname="so"
  2161. ;;
  2162. esac;
  2163. if [[ -z $* ]]; then
  2164. echo ".${libname}";
  2165. else
  2166. for ver in "$@";
  2167. do
  2168. case ${CHOST} in
  2169. *-cygwin*)
  2170. echo ".${ver}.${libname}"
  2171. ;;
  2172. *-darwin*)
  2173. echo ".${ver}.${libname}"
  2174. ;;
  2175. *-mint*)
  2176. echo ".${libname}"
  2177. ;;
  2178. *)
  2179. echo ".${libname}.${ver}"
  2180. ;;
  2181. esac;
  2182. done;
  2183. fi
  2184. }
  2185. get_localversion ()
  2186. {
  2187. local lv_list i x;
  2188. local shopt_save=$(shopt -p nullglob);
  2189. shopt -s nullglob;
  2190. local files=(${1}/localversion*);
  2191. ${shopt_save};
  2192. for i in "${files[@]}";
  2193. do
  2194. [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}";
  2195. done;
  2196. for i in ${lv_list};
  2197. do
  2198. x="${x}$(<${i})";
  2199. done;
  2200. x=${x/ /};
  2201. echo ${x}
  2202. }
  2203. get_makefile_extract_function ()
  2204. {
  2205. local a='' b='' mkfunc='getfilevar';
  2206. a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  2207. b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  2208. [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  2209. echo "${mkfunc}"
  2210. }
  2211. get_modname ()
  2212. {
  2213. local modname;
  2214. local ver=$1;
  2215. case ${CHOST} in
  2216. *-darwin*)
  2217. modname="bundle"
  2218. ;;
  2219. *)
  2220. modname="so"
  2221. ;;
  2222. esac;
  2223. echo ".${modname}"
  2224. }
  2225. get_running_version ()
  2226. {
  2227. if ! use kernel_linux; then
  2228. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2229. fi;
  2230. KV_FULL=$(uname -r);
  2231. if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2232. KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source);
  2233. KBUILD_OUTPUT=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build);
  2234. unset KV_FULL;
  2235. get_version;
  2236. return $?;
  2237. else
  2238. if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/source/Makefile ]]; then
  2239. KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/source);
  2240. unset KV_FULL;
  2241. get_version;
  2242. return $?;
  2243. else
  2244. if [[ -f ${ROOT%/}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2245. KERNEL_DIR=$(readlink -f ${ROOT%/}/lib/modules/${KV_FULL}/build);
  2246. unset KV_FULL;
  2247. get_version;
  2248. return $?;
  2249. else
  2250. local kv_full=${KV_FULL//[-+_]*};
  2251. KV_MAJOR=$(ver_cut 1 ${kv_full});
  2252. KV_MINOR=$(ver_cut 2 ${kv_full});
  2253. KV_PATCH=$(ver_cut 3 ${kv_full});
  2254. KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}${KV_PATCH:+.${KV_PATCH}}}";
  2255. : ${KV_PATCH:=0};
  2256. fi;
  2257. fi;
  2258. fi;
  2259. return 0
  2260. }
  2261. get_udevdir ()
  2262. {
  2263. debug-print-function ${FUNCNAME} "${@}";
  2264. echo "$(_udev_get_udevdir)"
  2265. }
  2266. get_version ()
  2267. {
  2268. if ! use kernel_linux; then
  2269. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2270. fi;
  2271. local tmplocal;
  2272. [ -n "${KV_FULL}" ] && return 0;
  2273. unset KV_DIR;
  2274. [ -z "${get_version_warning_done}" ] && qeinfo "Determining the location of the kernel source code";
  2275. [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}";
  2276. if [ -z "${KV_DIR}" ]; then
  2277. if [ -z "${get_version_warning_done}" ]; then
  2278. get_version_warning_done=1;
  2279. qewarn "Unable to find kernel sources at ${KERNEL_DIR}";
  2280. if [ "${KERNEL_DIR}" == "/usr/src/linux" ]; then
  2281. qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  2282. qeinfo "(or the kernel you wish to build against).";
  2283. qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  2284. else
  2285. qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  2286. fi;
  2287. fi;
  2288. return 1;
  2289. fi;
  2290. if [ -z "${KBUILD_OUTPUT}" -a -L "${KERNEL_DIR}/source" ]; then
  2291. KBUILD_OUTPUT=${KERNEL_DIR};
  2292. KERNEL_DIR=$(readlink -f "${KERNEL_DIR}/source");
  2293. KV_DIR=${KERNEL_DIR};
  2294. fi;
  2295. if [ -z "${get_version_warning_done}" ]; then
  2296. qeinfo "Found kernel source directory:";
  2297. qeinfo " ${KV_DIR}";
  2298. fi;
  2299. if [ ! -s "${KV_DIR}/Makefile" ]; then
  2300. if [ -z "${get_version_warning_done}" ]; then
  2301. get_version_warning_done=1;
  2302. qeerror "Could not find a Makefile in the kernel source directory.";
  2303. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  2304. fi;
  2305. return 1;
  2306. fi;
  2307. local OUTPUT_DIR=${KBUILD_OUTPUT};
  2308. KERNEL_MAKEFILE="${KV_DIR}/Makefile";
  2309. if [[ -z ${OUTPUT_DIR} ]]; then
  2310. local mkfunc=$(get_makefile_extract_function "${KERNEL_MAKEFILE}");
  2311. OUTPUT_DIR=$(${mkfunc} KBUILD_OUTPUT "${KERNEL_MAKEFILE}");
  2312. fi;
  2313. KV_MAJOR=$(getfilevar_noexec VERSION "${KERNEL_MAKEFILE}");
  2314. KV_MINOR=$(getfilevar_noexec PATCHLEVEL "${KERNEL_MAKEFILE}");
  2315. KV_PATCH=$(getfilevar_noexec SUBLEVEL "${KERNEL_MAKEFILE}");
  2316. KV_EXTRA=$(getfilevar_noexec EXTRAVERSION "${KERNEL_MAKEFILE}");
  2317. if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then
  2318. if [ -z "${get_version_warning_done}" ]; then
  2319. get_version_warning_done=1;
  2320. qeerror "Could not detect kernel version.";
  2321. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  2322. fi;
  2323. return 1;
  2324. fi;
  2325. [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}";
  2326. if [ -n "${KV_OUT_DIR}" ]; then
  2327. qeinfo "Found kernel object directory:";
  2328. qeinfo " ${KV_OUT_DIR}";
  2329. fi;
  2330. KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  2331. if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
  2332. KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  2333. else
  2334. if [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
  2335. KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  2336. else
  2337. KV_LOCAL=;
  2338. fi;
  2339. fi;
  2340. tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  2341. if [ "$KV_LOCAL" = "$tmplocal" ]; then
  2342. KV_LOCAL=;
  2343. else
  2344. KV_LOCAL=$tmplocal;
  2345. fi;
  2346. if [[ -z ${OUTPUT_DIR} ]]; then
  2347. for OUTPUT_DIR in "${SYSROOT}" "${ROOT%/}" "";
  2348. do
  2349. OUTPUT_DIR+="/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}/build";
  2350. if [[ -e ${OUTPUT_DIR} ]]; then
  2351. break;
  2352. fi;
  2353. done;
  2354. fi;
  2355. KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  2356. qeinfo "Found sources for kernel version:";
  2357. qeinfo " ${KV_FULL}";
  2358. return 0
  2359. }
  2360. getfilevar ()
  2361. {
  2362. local ERROR basefname basedname myARCH="${ARCH}" M="${S}";
  2363. ERROR=0;
  2364. [ -z "${1}" ] && ERROR=1;
  2365. [ ! -f "${2}" ] && ERROR=1;
  2366. if [ "${ERROR}" = 1 ]; then
  2367. echo -e "\n";
  2368. eerror "getfilevar requires 2 variables, with the second a valid file.";
  2369. eerror " getfilevar <VARIABLE> <CONFIGFILE>";
  2370. else
  2371. basefname="$(basename ${2})";
  2372. basedname="$(dirname ${2})";
  2373. unset ARCH;
  2374. [[ ${EAPI:-0} == [0123] ]] && function nonfatal ()
  2375. {
  2376. "$@"
  2377. };
  2378. case ${EBUILD_PHASE_FUNC} in
  2379. pkg_info | pkg_nofetch | pkg_pretend)
  2380. M="${T}"
  2381. ;;
  2382. esac;
  2383. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | nonfatal emake -C "${basedname}" M="${M}" ${BUILD_FIXES} -s -f - 2> /dev/null;
  2384. ARCH=${myARCH};
  2385. fi
  2386. }
  2387. getfilevar_noexec ()
  2388. {
  2389. local ERROR basefname basedname mycat myARCH="${ARCH}";
  2390. ERROR=0;
  2391. mycat='cat';
  2392. [ -z "${1}" ] && ERROR=1;
  2393. [ ! -f "${2}" ] && ERROR=1;
  2394. [ "${2%.gz}" != "${2}" ] && mycat='zcat';
  2395. if [ "${ERROR}" = 1 ]; then
  2396. echo -e "\n";
  2397. eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  2398. eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  2399. else
  2400. ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  2401. s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  2402. s,[[:space:]]*\$,,g ;
  2403. p
  2404. }";
  2405. fi
  2406. }
  2407. handle_locales ()
  2408. {
  2409. local detected sorted;
  2410. detected=$(echo $(cd po && printf '%s\n' *.po | grep -v messages.po | sed 's:.po$::' | sort -u));
  2411. sorted=$(echo $(printf '%s\n' ${PLOCALES} | sort -u));
  2412. if [[ ${sorted} != "${detected}" ]]; then
  2413. eerror "The ebuild needs to be kept in sync.";
  2414. eerror "PLOCALES: ${sorted}";
  2415. eerror " po/*.po: ${detected}";
  2416. die "sync PLOCALES";
  2417. fi;
  2418. if use nls; then
  2419. function rm_loc ()
  2420. {
  2421. rm po/$1.po || die
  2422. };
  2423. l10n_for_each_disabled_locale_do rm_loc;
  2424. else
  2425. rm -f po/*.po;
  2426. fi
  2427. }
  2428. has_multilib_profile ()
  2429. {
  2430. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2431. }
  2432. host-is-pax ()
  2433. {
  2434. grep -qs ^PaX: /proc/self/status
  2435. }
  2436. in_iuse ()
  2437. {
  2438. local use=${1};
  2439. if [[ -z "${use}" ]]; then
  2440. echo "!!! in_iuse() called without a parameter." 1>&2;
  2441. echo "!!! in_iuse <USEFLAG>" 1>&2;
  2442. die "in_iuse() called without a parameter";
  2443. fi;
  2444. local liuse=(${IUSE_EFFECTIVE});
  2445. has "${use}" "${liuse[@]#[+-]}"
  2446. }
  2447. is_final_abi ()
  2448. {
  2449. has_multilib_profile || return 0;
  2450. set -- $(get_install_abis);
  2451. local LAST_ABI=$#;
  2452. [[ ${!LAST_ABI} == ${ABI} ]]
  2453. }
  2454. kernel_is ()
  2455. {
  2456. if ! use kernel_linux; then
  2457. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2458. fi;
  2459. linux-info_get_any_version;
  2460. local operator test value;
  2461. case ${1#-} in
  2462. lt)
  2463. operator="-lt";
  2464. shift
  2465. ;;
  2466. gt)
  2467. operator="-gt";
  2468. shift
  2469. ;;
  2470. le)
  2471. operator="-le";
  2472. shift
  2473. ;;
  2474. ge)
  2475. operator="-ge";
  2476. shift
  2477. ;;
  2478. eq)
  2479. operator="-eq";
  2480. shift
  2481. ;;
  2482. *)
  2483. operator="-eq"
  2484. ;;
  2485. esac;
  2486. [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters";
  2487. : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ));
  2488. : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ));
  2489. [ ${test} ${operator} ${value} ]
  2490. }
  2491. l10n_find_plocales_changes ()
  2492. {
  2493. [[ $# -ne 3 ]] && die "Exactly 3 arguments are needed!";
  2494. ebegin "Looking in ${1} for new locales";
  2495. pushd "${1}" > /dev/null || die "Cannot access ${1}";
  2496. local current= x=;
  2497. for x in ${2}*${3};
  2498. do
  2499. x=${x#"${2}"};
  2500. x=${x%"${3}"};
  2501. current+="${x} ";
  2502. done;
  2503. popd > /dev/null;
  2504. if [[ "$(printf '%s\n' ${PLOCALES} | LC_ALL=C sort)" != "$(printf '%s\n' ${current} | LC_ALL=C sort)" ]]; then
  2505. eend 1 "There are changes in locales! This ebuild should be updated to:";
  2506. eerror "PLOCALES=\"${current%[[:space:]]}\"";
  2507. return 1;
  2508. else
  2509. eend 0;
  2510. fi
  2511. }
  2512. l10n_for_each_disabled_locale_do ()
  2513. {
  2514. local locs x;
  2515. locs=$(l10n_get_locales disabled);
  2516. for x in ${locs};
  2517. do
  2518. "${@}" ${x} || die "failed to process disabled ${x} locale";
  2519. done
  2520. }
  2521. l10n_for_each_locale_do ()
  2522. {
  2523. local locs x;
  2524. locs=$(l10n_get_locales);
  2525. for x in ${locs};
  2526. do
  2527. "${@}" ${x} || die "failed to process enabled ${x} locale";
  2528. done
  2529. }
  2530. l10n_get_locales ()
  2531. {
  2532. local loc locs;
  2533. if [[ -z ${LINGUAS+set} ]]; then
  2534. locs=${PLOCALES};
  2535. else
  2536. for loc in ${LINGUAS};
  2537. do
  2538. has ${loc} ${PLOCALES} && locs+="${loc} ";
  2539. done;
  2540. fi;
  2541. [[ -z ${locs} ]] && locs=${PLOCALE_BACKUP};
  2542. if [[ ${1} == disabled ]]; then
  2543. local disabled_locs;
  2544. for loc in ${PLOCALES};
  2545. do
  2546. has ${loc} ${locs} || disabled_locs+="${loc} ";
  2547. done;
  2548. locs=${disabled_locs};
  2549. fi;
  2550. printf "%s" "${locs}"
  2551. }
  2552. linux-info_get_any_version ()
  2553. {
  2554. if ! use kernel_linux; then
  2555. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  2556. fi;
  2557. if ! get_version; then
  2558. ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  2559. if ! get_running_version; then
  2560. die "Unable to determine any Linux Kernel version, please report a bug";
  2561. fi;
  2562. fi
  2563. }
  2564. linux-info_pkg_setup ()
  2565. {
  2566. use kernel_linux || return;
  2567. linux-info_get_any_version;
  2568. if kernel_is 2 4; then
  2569. if [ "$( gcc-major-version )" -eq "4" ]; then
  2570. echo;
  2571. ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with";
  2572. ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!";
  2573. echo;
  2574. ewarn "Either switch to another gcc-version (via gcc-config) or use a";
  2575. ewarn "newer kernel that supports gcc-4.";
  2576. echo;
  2577. ewarn "Also be aware that bugreports about gcc-4 not working";
  2578. ewarn "with linux-2.4 based ebuilds will be closed as INVALID!";
  2579. echo;
  2580. fi;
  2581. fi;
  2582. [ -n "${CONFIG_CHECK}" ] && check_extra_config
  2583. }
  2584. linux_chkconfig_builtin ()
  2585. {
  2586. linux_config_qa_check linux_chkconfig_builtin;
  2587. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == y ]]
  2588. }
  2589. linux_chkconfig_module ()
  2590. {
  2591. linux_config_qa_check linux_chkconfig_module;
  2592. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == m ]]
  2593. }
  2594. linux_chkconfig_present ()
  2595. {
  2596. linux_config_qa_check linux_chkconfig_present;
  2597. [[ $(getfilevar_noexec "CONFIG_$1" "$(linux_config_path)") == [my] ]]
  2598. }
  2599. linux_chkconfig_string ()
  2600. {
  2601. linux_config_qa_check linux_chkconfig_string;
  2602. getfilevar_noexec "CONFIG_$1" "$(linux_config_path)"
  2603. }
  2604. linux_config_bin_exists ()
  2605. {
  2606. export _LINUX_CONFIG_EXISTS_DONE=1;
  2607. use kernel_linux && [[ -s /proc/config.gz ]]
  2608. }
  2609. linux_config_exists ()
  2610. {
  2611. linux_config_src_exists || linux_config_bin_exists
  2612. }
  2613. linux_config_path ()
  2614. {
  2615. if linux_config_src_exists; then
  2616. echo "${KV_OUT_DIR}/.config";
  2617. else
  2618. if linux_config_bin_exists; then
  2619. echo "/proc/config.gz";
  2620. else
  2621. return 1;
  2622. fi;
  2623. fi
  2624. }
  2625. linux_config_qa_check ()
  2626. {
  2627. local f="$1";
  2628. if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
  2629. ewarn "QA: You called $f before any linux_config_exists!";
  2630. ewarn "QA: The return value of $f will NOT guaranteed later!";
  2631. fi;
  2632. if ! use kernel_linux; then
  2633. die "$f called on non-Linux system, please fix the ebuild";
  2634. fi
  2635. }
  2636. linux_config_src_exists ()
  2637. {
  2638. export _LINUX_CONFIG_EXISTS_DONE=1;
  2639. use kernel_linux && [[ -n ${KV_OUT_DIR} && -s ${KV_OUT_DIR}/.config ]]
  2640. }
  2641. list-paxables ()
  2642. {
  2643. file "$@" 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//'
  2644. }
  2645. make_wrapper ()
  2646. {
  2647. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2648. local tmpwrapper=$(emktemp);
  2649. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  2650. ( echo '#!/bin/sh';
  2651. if [[ -n ${libdir} ]]; then
  2652. local var;
  2653. if [[ ${CHOST} == *-darwin* ]]; then
  2654. var=DYLD_LIBRARY_PATH;
  2655. else
  2656. var=LD_LIBRARY_PATH;
  2657. fi;
  2658. cat <<-EOF
  2659. if [ "\${${var}+set}" = "set" ] ; then
  2660. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  2661. else
  2662. export ${var}="${EPREFIX}${libdir}"
  2663. fi
  2664. EOF
  2665.  
  2666. fi
  2667. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  2668. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  2669. chmod go+rx "${tmpwrapper}";
  2670. if [[ -n ${path} ]]; then
  2671. ( exeopts -m 0755;
  2672. exeinto "${path}";
  2673. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2674. else
  2675. newbin "${tmpwrapper}" "${wrapper}" || die;
  2676. fi
  2677. }
  2678. multibuild_copy_sources ()
  2679. {
  2680. debug-print-function ${FUNCNAME} "${@}";
  2681. local _MULTIBUILD_INITIAL_BUILD_DIR=${BUILD_DIR:-${S}};
  2682. einfo "Will copy sources from ${_MULTIBUILD_INITIAL_BUILD_DIR}";
  2683. local cp_args=();
  2684. if cp --reflink=auto --version &> /dev/null; then
  2685. cp_args+=(--reflink=auto);
  2686. fi;
  2687. function _multibuild_create_source_copy ()
  2688. {
  2689. einfo "${MULTIBUILD_VARIANT}: copying to ${BUILD_DIR}";
  2690. cp -p -R "${cp_args[@]}" "${_MULTIBUILD_INITIAL_BUILD_DIR}" "${BUILD_DIR}" || die
  2691. };
  2692. multibuild_foreach_variant _multibuild_create_source_copy
  2693. }
  2694. multibuild_for_best_variant ()
  2695. {
  2696. debug-print-function ${FUNCNAME} "${@}";
  2697. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2698. local MULTIBUILD_VARIANTS=("${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}");
  2699. multibuild_foreach_variant "${@}"
  2700. }
  2701. multibuild_foreach_variant ()
  2702. {
  2703. debug-print-function ${FUNCNAME} "${@}";
  2704. [[ -n ${MULTIBUILD_VARIANTS} ]] || die "MULTIBUILD_VARIANTS need to be set";
  2705. local bdir=${BUILD_DIR:-${S}};
  2706. [[ ${bdir%%/} == ${WORKDIR%%/} ]] && bdir=${WORKDIR}/build;
  2707. local prev_id=${MULTIBUILD_ID:+${MULTIBUILD_ID}-};
  2708. local ret=0 lret=0 v;
  2709. debug-print "${FUNCNAME}: initial build_dir = ${bdir}";
  2710. for v in "${MULTIBUILD_VARIANTS[@]}";
  2711. do
  2712. local MULTIBUILD_VARIANT=${v};
  2713. local MULTIBUILD_ID=${prev_id}${v};
  2714. local BUILD_DIR=${bdir%%/}-${v};
  2715. function _multibuild_run ()
  2716. {
  2717. local i=1;
  2718. while [[ ${!i} == _* ]]; do
  2719. (( i += 1 ));
  2720. done;
  2721. [[ ${i} -le ${#} ]] && einfo "${v}: running ${@:${i}}";
  2722. "${@}"
  2723. };
  2724. _multibuild_run "${@}" > >(exec tee -a "${T}/build-${MULTIBUILD_ID}.log") 2>&1;
  2725. lret=${?};
  2726. done;
  2727. [[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret};
  2728. return ${ret}
  2729. }
  2730. multibuild_merge_root ()
  2731. {
  2732. local src=${1};
  2733. local dest=${2};
  2734. local ret;
  2735. if use userland_BSD; then
  2736. tar -C "${src}" -f - -c . | tar -x -f - -C "${dest}";
  2737. [[ ${PIPESTATUS[*]} == '0 0' ]];
  2738. ret=${?};
  2739. else
  2740. local cp_args=();
  2741. if cp -a --version &> /dev/null; then
  2742. cp_args+=(-a);
  2743. else
  2744. cp_args+=(-P -R -p);
  2745. fi;
  2746. if cp --reflink=auto --version &> /dev/null; then
  2747. cp_args+=(--reflink=auto);
  2748. fi;
  2749. cp "${cp_args[@]}" "${src}"/. "${dest}"/;
  2750. ret=${?};
  2751. fi;
  2752. if [[ ${ret} -ne 0 ]]; then
  2753. die "${MULTIBUILD_VARIANT:-(unknown)}: merging image failed.";
  2754. fi;
  2755. rm -rf "${src}"
  2756. }
  2757. multibuild_parallel_foreach_variant ()
  2758. {
  2759. debug-print-function ${FUNCNAME} "${@}";
  2760. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  2761. multibuild_foreach_variant "${@}"
  2762. }
  2763. multilib_env ()
  2764. {
  2765. local CTARGET=${1:-${CTARGET}};
  2766. local cpu=${CTARGET%%*-};
  2767. case ${cpu} in
  2768. aarch64*)
  2769. export CFLAGS_arm=${CFLAGS_arm-};
  2770. case ${cpu} in
  2771. aarch64*be)
  2772. export CHOST_arm="armv8b-${CTARGET#*-}"
  2773. ;;
  2774. *)
  2775. export CHOST_arm="armv8l-${CTARGET#*-}"
  2776. ;;
  2777. esac;
  2778. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  2779. export CTARGET_arm=${CHOST_arm};
  2780. export LIBDIR_arm="lib";
  2781. export CFLAGS_arm64=${CFLAGS_arm64-};
  2782. export CHOST_arm64=${CTARGET};
  2783. export CTARGET_arm64=${CHOST_arm64};
  2784. export LIBDIR_arm64="lib64";
  2785. : ${MULTILIB_ABIS=arm64};
  2786. : ${DEFAULT_ABI=arm64}
  2787. ;;
  2788. x86_64*)
  2789. export CFLAGS_x86=${CFLAGS_x86--m32};
  2790. export CHOST_x86=${CTARGET/x86_64/i686};
  2791. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2792. export CTARGET_x86=${CHOST_x86};
  2793. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2794. export LIBDIR_x86="lib32";
  2795. else
  2796. export LIBDIR_x86="lib";
  2797. fi;
  2798. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2799. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2800. export CTARGET_amd64=${CHOST_amd64};
  2801. export LIBDIR_amd64="lib64";
  2802. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2803. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2804. export CTARGET_x32=${CHOST_x32};
  2805. export LIBDIR_x32="libx32";
  2806. case ${CTARGET} in
  2807. *-gnux32)
  2808. : ${MULTILIB_ABIS=x32 amd64 x86};
  2809. : ${DEFAULT_ABI=x32}
  2810. ;;
  2811. *)
  2812. : ${MULTILIB_ABIS=amd64 x86};
  2813. : ${DEFAULT_ABI=amd64}
  2814. ;;
  2815. esac
  2816. ;;
  2817. mips64* | mipsisa64*)
  2818. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2819. export CHOST_o32=${CTARGET/mips64/mips};
  2820. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  2821. export CTARGET_o32=${CHOST_o32};
  2822. export LIBDIR_o32="lib";
  2823. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2824. export CHOST_n32=${CTARGET};
  2825. export CTARGET_n32=${CHOST_n32};
  2826. export LIBDIR_n32="lib32";
  2827. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2828. export CHOST_n64=${CTARGET};
  2829. export CTARGET_n64=${CHOST_n64};
  2830. export LIBDIR_n64="lib64";
  2831. : ${MULTILIB_ABIS=n64 n32 o32};
  2832. : ${DEFAULT_ABI=n32}
  2833. ;;
  2834. powerpc64*)
  2835. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2836. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2837. export CTARGET_ppc=${CHOST_ppc};
  2838. export LIBDIR_ppc="lib";
  2839. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2840. export CHOST_ppc64=${CTARGET};
  2841. export CTARGET_ppc64=${CHOST_ppc64};
  2842. export LIBDIR_ppc64="lib64";
  2843. : ${MULTILIB_ABIS=ppc64 ppc};
  2844. : ${DEFAULT_ABI=ppc64}
  2845. ;;
  2846. riscv64*)
  2847. export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d};
  2848. export CHOST_lp64d=${CTARGET};
  2849. export CTARGET_lp64d=${CTARGET};
  2850. export LIBDIR_lp64d="lib64/lp64d";
  2851. export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64};
  2852. export CHOST_lp64=${CTARGET};
  2853. export CTARGET_lp64=${CTARGET};
  2854. export LIBDIR_lp64="lib64/lp64";
  2855. : ${MULTILIB_ABIS=lp64d lp64};
  2856. : ${DEFAULT_ABI=lp64d}
  2857. ;;
  2858. s390x*)
  2859. export CFLAGS_s390=${CFLAGS_s390--m31};
  2860. export CHOST_s390=${CTARGET/s390x/s390};
  2861. export CTARGET_s390=${CHOST_s390};
  2862. export LIBDIR_s390="lib";
  2863. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2864. export CHOST_s390x=${CTARGET};
  2865. export CTARGET_s390x=${CHOST_s390x};
  2866. export LIBDIR_s390x="lib64";
  2867. : ${MULTILIB_ABIS=s390x s390};
  2868. : ${DEFAULT_ABI=s390x}
  2869. ;;
  2870. sparc64*)
  2871. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2872. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2873. export CTARGET_sparc32=${CHOST_sparc32};
  2874. export LIBDIR_sparc32="lib";
  2875. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2876. export CHOST_sparc64=${CTARGET};
  2877. export CTARGET_sparc64=${CHOST_sparc64};
  2878. export LIBDIR_sparc64="lib64";
  2879. : ${MULTILIB_ABIS=sparc64 sparc32};
  2880. : ${DEFAULT_ABI=sparc64}
  2881. ;;
  2882. *)
  2883. : ${MULTILIB_ABIS=default};
  2884. : ${DEFAULT_ABI=default}
  2885. ;;
  2886. esac;
  2887. export MULTILIB_ABIS DEFAULT_ABI
  2888. }
  2889. multilib_toolchain_setup ()
  2890. {
  2891. local v vv;
  2892. export ABI=$1;
  2893. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  2894. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2895. do
  2896. vv="_abi_saved_${v}";
  2897. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  2898. unset ${vv};
  2899. done;
  2900. unset _DEFAULT_ABI_SAVED;
  2901. fi;
  2902. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2903. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  2904. do
  2905. vv="_abi_saved_${v}";
  2906. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  2907. done;
  2908. export _DEFAULT_ABI_SAVED="true";
  2909. if [[ ${CBUILD} == "${CHOST}" ]]; then
  2910. export CBUILD=$(get_abi_CHOST $1);
  2911. fi;
  2912. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2913. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2914. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2915. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  2916. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  2917. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2918. export CHOST=$(get_abi_CHOST $1);
  2919. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  2920. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  2921. fi
  2922. }
  2923. number_abis ()
  2924. {
  2925. set -- `get_install_abis`;
  2926. echo $#
  2927. }
  2928. optfeature ()
  2929. {
  2930. debug-print-function ${FUNCNAME} "$@";
  2931. local i j msg;
  2932. local desc=$1;
  2933. local flag=0;
  2934. shift;
  2935. for i in "$@";
  2936. do
  2937. for j in ${i};
  2938. do
  2939. if has_version "${j}"; then
  2940. flag=1;
  2941. else
  2942. flag=0;
  2943. break;
  2944. fi;
  2945. done;
  2946. if [[ ${flag} -eq 1 ]]; then
  2947. break;
  2948. fi;
  2949. done;
  2950. if [[ ${flag} -eq 0 ]]; then
  2951. for i in "$@";
  2952. do
  2953. msg=" ";
  2954. for j in ${i};
  2955. do
  2956. msg+=" ${j} and";
  2957. done;
  2958. msg="${msg:0: -4} for ${desc}";
  2959. elog "${msg}";
  2960. done;
  2961. fi
  2962. }
  2963. path_exists ()
  2964. {
  2965. eerror "path_exists has been removed. Please see the following post";
  2966. eerror "for a replacement snippet:";
  2967. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  2968. die "path_exists is banned"
  2969. }
  2970. pax-mark ()
  2971. {
  2972. local f;
  2973. local flags;
  2974. local ret=0;
  2975. flags="${1//[!zPpEeMmRrSs]}";
  2976. [[ -n "${flags}" ]] || return 0;
  2977. shift;
  2978. local dodefault="";
  2979. [[ -n "${flags//[!z]}" ]] && dodefault="yes";
  2980. if has PT ${PAX_MARKINGS}; then
  2981. for f in "$@";
  2982. do
  2983. if type -p paxctl > /dev/null; then
  2984. einfo "PT_PAX marking -${flags} ${f} with paxctl";
  2985. paxctl -q${flags} "${f}" > /dev/null 2>&1 && continue;
  2986. fi;
  2987. if type -p paxctl-ng > /dev/null && paxctl-ng -L; then
  2988. einfo "PT_PAX marking -${flags} ${f} with paxctl-ng";
  2989. flags="${flags//z}";
  2990. [[ ${dodefault} == "yes" ]] && paxctl-ng -L -z "${f}" > /dev/null 2>&1;
  2991. [[ -n "${flags}" ]] || continue;
  2992. paxctl-ng -L -${flags} "${f}" > /dev/null 2>&1 && continue;
  2993. fi;
  2994. if type -p scanelf > /dev/null && [[ ${PAX_MARKINGS} != "none" ]]; then
  2995. einfo "PT_PAX marking -${flags} ${f} with scanelf";
  2996. scanelf -Xxz ${flags} "$f" > /dev/null 2>&1;
  2997. else
  2998. if [[ ${PAX_MARKINGS} != "none" ]]; then
  2999. elog "Failed to set PT_PAX markings -${flags} ${f}.";
  3000. ret=1;
  3001. fi;
  3002. fi;
  3003. done;
  3004. fi;
  3005. if has XT ${PAX_MARKINGS}; then
  3006. flags="${flags//z}";
  3007. for f in "$@";
  3008. do
  3009. if type -p paxctl-ng > /dev/null && paxctl-ng -l; then
  3010. einfo "XATTR_PAX marking -${flags} ${f} with paxctl-ng";
  3011. [[ ${dodefault} == "yes" ]] && paxctl-ng -d "${f}" > /dev/null 2>&1;
  3012. [[ -n "${flags}" ]] || continue;
  3013. paxctl-ng -l -${flags} "${f}" > /dev/null 2>&1 && continue;
  3014. fi;
  3015. if type -p setfattr > /dev/null; then
  3016. [[ -n "${flags//[!Ee]}" ]] || flags+="e";
  3017. einfo "XATTR_PAX marking -${flags} ${f} with setfattr";
  3018. [[ ${dodefault} == "yes" ]] && setfattr -x "user.pax.flags" "${f}" > /dev/null 2>&1;
  3019. setfattr -n "user.pax.flags" -v "${flags}" "${f}" > /dev/null 2>&1 && continue;
  3020. fi;
  3021. if [[ ${PAX_MARKINGS} != "none" ]]; then
  3022. elog "Failed to set XATTR_PAX markings -${flags} ${f}.";
  3023. ret=1;
  3024. fi;
  3025. done;
  3026. fi;
  3027. return ${ret}
  3028. }
  3029. pkg_info ()
  3030. {
  3031. echo "Using:";
  3032. echo " $(best_version app-emulation/spice-protocol)";
  3033. echo " $(best_version sys-firmware/edk2-ovmf)";
  3034. if has_version 'sys-firmware/edk2-ovmf[binary]'; then
  3035. echo " USE=binary";
  3036. else
  3037. echo " USE=''";
  3038. fi;
  3039. echo " $(best_version sys-firmware/ipxe)";
  3040. echo " $(best_version sys-firmware/seabios)";
  3041. if has_version 'sys-firmware/seabios[binary]'; then
  3042. echo " USE=binary";
  3043. else
  3044. echo " USE=''";
  3045. fi;
  3046. echo " $(best_version sys-firmware/sgabios)"
  3047. }
  3048. pkg_nofetch ()
  3049. {
  3050. default
  3051. }
  3052. pkg_postinst ()
  3053. {
  3054. if [[ -n ${softmmu_targets} ]] && use kernel_linux; then
  3055. udev_reload;
  3056. fi;
  3057. xdg_icon_cache_update;
  3058. [[ -z ${EPREFIX} ]] && [[ -f ${EROOT}/usr/libexec/qemu-bridge-helper ]] && fcaps cap_net_admin ${EROOT}/usr/libexec/qemu-bridge-helper;
  3059. DISABLE_AUTOFORMATTING=true;
  3060. readme.gentoo_print_elog;
  3061. if use pin-upstream-blobs && firmware_abi_change; then
  3062. ewarn "This version of qemu pins new versions of firmware blobs:";
  3063. ewarn " $(best_version sys-firmware/edk2-ovmf)";
  3064. ewarn " $(best_version sys-firmware/ipxe)";
  3065. ewarn " $(best_version sys-firmware/seabios)";
  3066. ewarn " $(best_version sys-firmware/sgabios)";
  3067. ewarn "This might break resume of hibernated guests (started with a different";
  3068. ewarn "firmware version) and live migration to/from qemu versions with different";
  3069. ewarn "firmware. Please (cold) restart all running guests. For functional";
  3070. ewarn "guest migration ensure that all";
  3071. ewarn "hosts run at least";
  3072. ewarn " app-emulation/qemu-${FIRMWARE_ABI_VERSION}.";
  3073. fi
  3074. }
  3075. pkg_postrm ()
  3076. {
  3077. xdg_icon_cache_update
  3078. }
  3079. pkg_pretend ()
  3080. {
  3081. if use kernel_linux && kernel_is lt 2 6 25; then
  3082. eerror "This version of KVM requres a host kernel of 2.6.25 or higher.";
  3083. else
  3084. if use kernel_linux; then
  3085. if ! linux_config_exists; then
  3086. eerror "Unable to check your kernel for KVM support";
  3087. else
  3088. CONFIG_CHECK="~KVM ~TUN ~BRIDGE";
  3089. ERROR_KVM="You must enable KVM in your kernel to continue";
  3090. ERROR_KVM_AMD="If you have an AMD CPU, you must enable KVM_AMD in";
  3091. ERROR_KVM_AMD+=" your kernel configuration.";
  3092. ERROR_KVM_INTEL="If you have an Intel CPU, you must enable";
  3093. ERROR_KVM_INTEL+=" KVM_INTEL in your kernel configuration.";
  3094. ERROR_TUN="You will need the Universal TUN/TAP driver compiled";
  3095. ERROR_TUN+=" into your kernel or loaded as a module to use the";
  3096. ERROR_TUN+=" virtual network device if using -net tap.";
  3097. ERROR_BRIDGE="You will also need support for 802.1d";
  3098. ERROR_BRIDGE+=" Ethernet Bridging for some network configurations.";
  3099. use vhost-net && CONFIG_CHECK+=" ~VHOST_NET";
  3100. ERROR_VHOST_NET="You must enable VHOST_NET to have vhost-net";
  3101. ERROR_VHOST_NET+=" support";
  3102. if use amd64 || use x86 || use amd64-linux || use x86-linux; then
  3103. if grep -q AuthenticAMD /proc/cpuinfo; then
  3104. CONFIG_CHECK+=" ~KVM_AMD";
  3105. else
  3106. if grep -q GenuineIntel /proc/cpuinfo; then
  3107. CONFIG_CHECK+=" ~KVM_INTEL";
  3108. fi;
  3109. fi;
  3110. fi;
  3111. use python && CONFIG_CHECK+=" ~DEBUG_FS";
  3112. ERROR_DEBUG_FS="debugFS support required for kvm_stat";
  3113. check_extra_config;
  3114. fi;
  3115. fi;
  3116. fi;
  3117. if grep -qs '/usr/bin/qemu-kvm' "${EROOT}"/etc/libvirt/qemu/*.xml; then
  3118. eerror "The kvm/qemu-kvm wrappers no longer exist, but your libvirt";
  3119. eerror "instances are still pointing to it. Please update your";
  3120. eerror "configs in /etc/libvirt/qemu/ to use the -enable-kvm flag";
  3121. eerror "and the right system binary (e.g. qemu-system-x86_64).";
  3122. die "update your virt configs to not use qemu-kvm";
  3123. fi
  3124. }
  3125. pkg_setup ()
  3126. {
  3127. linux-info_pkg_setup "$@"
  3128. }
  3129. python_abi_depend ()
  3130. {
  3131. die "${FUNCNAME}() is invalid for python-r1 suite"
  3132. }
  3133. python_byte-compile_modules ()
  3134. {
  3135. die "${FUNCNAME}() is invalid for python-r1 suite"
  3136. }
  3137. python_clean_byte-compiled_modules ()
  3138. {
  3139. die "${FUNCNAME}() is invalid for python-r1 suite"
  3140. }
  3141. python_clean_installation_image ()
  3142. {
  3143. die "${FUNCNAME}() is invalid for python-r1 suite"
  3144. }
  3145. python_clean_py-compile_files ()
  3146. {
  3147. die "${FUNCNAME}() is invalid for python-r1 suite"
  3148. }
  3149. python_convert_shebangs ()
  3150. {
  3151. 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"
  3152. }
  3153. python_copy_sources ()
  3154. {
  3155. debug-print-function ${FUNCNAME} "${@}";
  3156. local MULTIBUILD_VARIANTS;
  3157. _python_obtain_impls;
  3158. multibuild_copy_sources
  3159. }
  3160. python_disable_pyc ()
  3161. {
  3162. die "${FUNCNAME}() is invalid for python-r1 suite"
  3163. }
  3164. python_doexe ()
  3165. {
  3166. debug-print-function ${FUNCNAME} "${@}";
  3167. local f;
  3168. for f in "$@";
  3169. do
  3170. python_newexe "${f}" "${f##*/}";
  3171. done
  3172. }
  3173. python_doheader ()
  3174. {
  3175. debug-print-function ${FUNCNAME} "${@}";
  3176. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3177. if [[ ${EAPI:-0} == [0123] ]]; then
  3178. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  3179. fi;
  3180. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  3181. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  3182. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  3183. ( insopts -m 0644;
  3184. insinto "${d}";
  3185. doins -r "${@}" || return ${?} )
  3186. }
  3187. python_domodule ()
  3188. {
  3189. debug-print-function ${FUNCNAME} "${@}";
  3190. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3191. if [[ ${EAPI:-0} == [0123] ]]; then
  3192. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  3193. fi;
  3194. local d;
  3195. if [[ ${python_moduleroot} == /* ]]; then
  3196. d=${python_moduleroot};
  3197. else
  3198. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  3199. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  3200. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  3201. fi;
  3202. ( insopts -m 0644;
  3203. insinto "${d}";
  3204. doins -r "${@}" || return ${?} );
  3205. python_optimize "${ED%/}/${d}"
  3206. }
  3207. python_doscript ()
  3208. {
  3209. debug-print-function ${FUNCNAME} "${@}";
  3210. local _PYTHON_REWRITE_SHEBANG=1;
  3211. python_doexe "${@}"
  3212. }
  3213. python_enable_pyc ()
  3214. {
  3215. die "${FUNCNAME}() is invalid for python-r1 suite"
  3216. }
  3217. python_execute_function ()
  3218. {
  3219. 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"
  3220. }
  3221. python_execute_nosetests ()
  3222. {
  3223. die "${FUNCNAME}() is invalid for python-r1 suite"
  3224. }
  3225. python_execute_py.test ()
  3226. {
  3227. die "${FUNCNAME}() is invalid for python-r1 suite"
  3228. }
  3229. python_execute_trial ()
  3230. {
  3231. die "${FUNCNAME}() is invalid for python-r1 suite"
  3232. }
  3233. python_export ()
  3234. {
  3235. debug-print-function ${FUNCNAME} "${@}";
  3236. local impl var;
  3237. case "${1}" in
  3238. python* | jython*)
  3239. impl=${1/_/.};
  3240. shift
  3241. ;;
  3242. pypy | pypy3)
  3243. impl=${1};
  3244. shift
  3245. ;;
  3246. *)
  3247. impl=${EPYTHON};
  3248. if [[ -z ${impl} ]]; then
  3249. die "python_export called without a python implementation and EPYTHON is unset";
  3250. fi
  3251. ;;
  3252. esac;
  3253. debug-print "${FUNCNAME}: implementation: ${impl}";
  3254. for var in "$@";
  3255. do
  3256. case "${var}" in
  3257. EPYTHON)
  3258. export EPYTHON=${impl};
  3259. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  3260. ;;
  3261. PYTHON)
  3262. export PYTHON=${EPREFIX}/usr/bin/${impl};
  3263. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  3264. ;;
  3265. PYTHON_SITEDIR)
  3266. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3267. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  3268. export PYTHON_SITEDIR;
  3269. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  3270. ;;
  3271. PYTHON_INCLUDEDIR)
  3272. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3273. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  3274. export PYTHON_INCLUDEDIR;
  3275. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  3276. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  3277. die "${impl} does not install any header files!";
  3278. fi
  3279. ;;
  3280. PYTHON_LIBPATH)
  3281. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3282. 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;
  3283. export PYTHON_LIBPATH;
  3284. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  3285. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  3286. die "${impl} lacks a (usable) dynamic library";
  3287. fi
  3288. ;;
  3289. PYTHON_CFLAGS)
  3290. local val;
  3291. case "${impl}" in
  3292. python*)
  3293. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  3294. ;;
  3295. *)
  3296. die "${impl}: obtaining ${var} not supported"
  3297. ;;
  3298. esac;
  3299. export PYTHON_CFLAGS=${val};
  3300. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  3301. ;;
  3302. PYTHON_LIBS)
  3303. local val;
  3304. case "${impl}" in
  3305. python*)
  3306. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  3307. ;;
  3308. *)
  3309. die "${impl}: obtaining ${var} not supported"
  3310. ;;
  3311. esac;
  3312. export PYTHON_LIBS=${val};
  3313. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  3314. ;;
  3315. PYTHON_CONFIG)
  3316. local flags val;
  3317. case "${impl}" in
  3318. python*)
  3319. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  3320. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  3321. val=${PYTHON}${flags}-config
  3322. ;;
  3323. *)
  3324. die "${impl}: obtaining ${var} not supported"
  3325. ;;
  3326. esac;
  3327. export PYTHON_CONFIG=${val};
  3328. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  3329. ;;
  3330. PYTHON_PKG_DEP)
  3331. local d;
  3332. case ${impl} in
  3333. python2.7)
  3334. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  3335. ;;
  3336. python3.3)
  3337. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  3338. ;;
  3339. python*)
  3340. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  3341. ;;
  3342. pypy)
  3343. PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  3344. ;;
  3345. pypy3)
  3346. PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  3347. ;;
  3348. jython2.7)
  3349. PYTHON_PKG_DEP='dev-java/jython:2.7'
  3350. ;;
  3351. *)
  3352. die "Invalid implementation: ${impl}"
  3353. ;;
  3354. esac;
  3355. if [[ -n ${PYTHON_REQ_USE} ]]; then
  3356. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  3357. fi;
  3358. export PYTHON_PKG_DEP;
  3359. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  3360. ;;
  3361. PYTHON_SCRIPTDIR)
  3362. local dir;
  3363. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  3364. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  3365. ;;
  3366. *)
  3367. die "python_export: unknown variable ${var}"
  3368. ;;
  3369. esac;
  3370. done
  3371. }
  3372. python_export_best ()
  3373. {
  3374. debug-print-function ${FUNCNAME} "${@}";
  3375. [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}";
  3376. eqawarn "python_export_best() is deprecated. Please use python_setup instead,";
  3377. eqawarn "combined with python_export if necessary.";
  3378. [[ ${#} -gt 0 ]] || set -- EPYTHON PYTHON;
  3379. local best MULTIBUILD_VARIANTS;
  3380. _python_obtain_impls;
  3381. function _python_set_best ()
  3382. {
  3383. best=${MULTIBUILD_VARIANT}
  3384. };
  3385. multibuild_for_best_variant _python_set_best;
  3386. unset -f _python_set_best;
  3387. debug-print "${FUNCNAME}: Best implementation is: ${best}";
  3388. python_export "${best}" "${@}";
  3389. python_wrapper_setup
  3390. }
  3391. python_export_utf8_locale ()
  3392. {
  3393. debug-print-function ${FUNCNAME} "${@}";
  3394. type locale > /dev/null || return 0;
  3395. if [[ $(locale charmap) != UTF-8 ]]; then
  3396. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  3397. for lang in ${locales};
  3398. do
  3399. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  3400. if _python_check_locale_sanity "${lang}"; then
  3401. export LC_CTYPE=${lang};
  3402. if [[ -n ${LC_ALL} ]]; then
  3403. export LC_NUMERIC=${LC_ALL};
  3404. export LC_TIME=${LC_ALL};
  3405. export LC_COLLATE=${LC_ALL};
  3406. export LC_MONETARY=${LC_ALL};
  3407. export LC_MESSAGES=${LC_ALL};
  3408. export LC_PAPER=${LC_ALL};
  3409. export LC_NAME=${LC_ALL};
  3410. export LC_ADDRESS=${LC_ALL};
  3411. export LC_TELEPHONE=${LC_ALL};
  3412. export LC_MEASUREMENT=${LC_ALL};
  3413. export LC_IDENTIFICATION=${LC_ALL};
  3414. export LC_ALL=;
  3415. fi;
  3416. return 0;
  3417. fi;
  3418. fi;
  3419. done;
  3420. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  3421. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  3422. ewarn "/etc/locale.gen and run locale-gen.";
  3423. return 1;
  3424. fi;
  3425. return 0
  3426. }
  3427. python_fix_shebang ()
  3428. {
  3429. debug-print-function ${FUNCNAME} "${@}";
  3430. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  3431. local force quiet;
  3432. while [[ -n ${@} ]]; do
  3433. case "${1}" in
  3434. -f | --force)
  3435. force=1;
  3436. shift
  3437. ;;
  3438. -q | --quiet)
  3439. quiet=1;
  3440. shift
  3441. ;;
  3442. --)
  3443. shift;
  3444. break
  3445. ;;
  3446. *)
  3447. break
  3448. ;;
  3449. esac;
  3450. done;
  3451. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  3452. local path f;
  3453. for path in "$@";
  3454. do
  3455. local any_correct any_fixed is_recursive;
  3456. [[ -d ${path} ]] && is_recursive=1;
  3457. while IFS= read -r -d '' f; do
  3458. local shebang i;
  3459. local error= from=;
  3460. IFS= read -r shebang < "${f}";
  3461. if [[ ${shebang} == '#!'* ]]; then
  3462. local split_shebang=();
  3463. read -r -a split_shebang <<< ${shebang} || die;
  3464. for i in "${split_shebang[@]}";
  3465. do
  3466. case "${i}" in
  3467. *"${EPYTHON}")
  3468. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3469. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  3470. any_correct=1;
  3471. from=${EPYTHON};
  3472. break
  3473. ;;
  3474. *python | *python[23])
  3475. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  3476. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  3477. if [[ ${i} == *python2 ]]; then
  3478. from=python2;
  3479. if [[ ! -n ${force} ]]; then
  3480. python_is_python3 "${EPYTHON}" && error=1;
  3481. fi;
  3482. else
  3483. if [[ ${i} == *python3 ]]; then
  3484. from=python3;
  3485. if [[ ! -n ${force} ]]; then
  3486. python_is_python3 "${EPYTHON}" || error=1;
  3487. fi;
  3488. else
  3489. from=python;
  3490. fi;
  3491. fi;
  3492. break
  3493. ;;
  3494. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  3495. if [[ ! -n ${force} ]]; then
  3496. error=1;
  3497. else
  3498. case "${i}" in
  3499. *python[23].[0123456789])
  3500. from="python[23].[0123456789]"
  3501. ;;
  3502. *pypy)
  3503. from="pypy"
  3504. ;;
  3505. *pypy3)
  3506. from="pypy3"
  3507. ;;
  3508. *jython[23].[0123456789])
  3509. from="jython[23].[0123456789]"
  3510. ;;
  3511. *)
  3512. die "${FUNCNAME}: internal error in 2nd pattern match"
  3513. ;;
  3514. esac;
  3515. fi;
  3516. break
  3517. ;;
  3518. esac;
  3519. done;
  3520. fi;
  3521. if [[ ! -n ${error} && ! -n ${from} ]]; then
  3522. [[ -n ${is_recursive} ]] && continue;
  3523. error=1;
  3524. fi;
  3525. if [[ ! -n ${quiet} ]]; then
  3526. einfo "Fixing shebang in ${f#${D%/}}.";
  3527. fi;
  3528. if [[ ! -n ${error} ]]; then
  3529. if [[ ${shebang} == *${from}" "* ]]; then
  3530. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  3531. else
  3532. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  3533. fi;
  3534. any_fixed=1;
  3535. else
  3536. eerror "The file has incompatible shebang:";
  3537. eerror " file: ${f#${D%/}}";
  3538. eerror " current shebang: ${shebang}";
  3539. eerror " requested impl: ${EPYTHON}";
  3540. die "${FUNCNAME}: conversion of incompatible shebang requested";
  3541. fi;
  3542. done < <(find -H "${path}" -type f -print0 || die);
  3543. if [[ ! -n ${any_fixed} ]]; then
  3544. local cmd=eerror;
  3545. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  3546. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  3547. if [[ -n ${any_correct} ]]; then
  3548. "${cmd}" "All files have ${EPYTHON} shebang already.";
  3549. else
  3550. "${cmd}" "There are no Python files in specified directory.";
  3551. fi;
  3552. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  3553. fi;
  3554. done
  3555. }
  3556. python_foreach_impl ()
  3557. {
  3558. debug-print-function ${FUNCNAME} "${@}";
  3559. local MULTIBUILD_VARIANTS;
  3560. _python_obtain_impls;
  3561. multibuild_foreach_variant _python_multibuild_wrapper "${@}"
  3562. }
  3563. python_gen_any_dep ()
  3564. {
  3565. debug-print-function ${FUNCNAME} "${@}";
  3566. local depstr=${1};
  3567. [[ -n ${depstr} ]] || die "No dependency string provided";
  3568. shift;
  3569. local i PYTHON_PKG_DEP out=;
  3570. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3571. do
  3572. if _python_impl_matches "${i}" "${@-*}"; then
  3573. local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  3574. python_export "${i}" PYTHON_PKG_DEP;
  3575. local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  3576. out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}";
  3577. fi;
  3578. done;
  3579. echo "|| ( ${out})"
  3580. }
  3581. python_gen_cond_dep ()
  3582. {
  3583. debug-print-function ${FUNCNAME} "${@}";
  3584. local impl matches=();
  3585. local dep=${1};
  3586. shift;
  3587. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3588. do
  3589. if _python_impl_matches "${impl}" "${@}"; then
  3590. if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
  3591. local usedep=$(python_gen_usedep "${@}");
  3592. dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}};
  3593. fi;
  3594. matches+=("python_targets_${impl}? ( ${dep} )");
  3595. fi;
  3596. done;
  3597. echo "${matches[@]}"
  3598. }
  3599. python_gen_impl_dep ()
  3600. {
  3601. debug-print-function ${FUNCNAME} "${@}";
  3602. local impl matches=();
  3603. local PYTHON_REQ_USE=${1};
  3604. shift;
  3605. local patterns=("${@-*}");
  3606. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3607. do
  3608. if _python_impl_matches "${impl}" "${patterns[@]}"; then
  3609. local PYTHON_PKG_DEP;
  3610. python_export "${impl}" PYTHON_PKG_DEP;
  3611. matches+=("python_targets_${impl}? ( ${PYTHON_PKG_DEP} )");
  3612. fi;
  3613. done;
  3614. echo "${matches[@]}"
  3615. }
  3616. python_gen_usedep ()
  3617. {
  3618. debug-print-function ${FUNCNAME} "${@}";
  3619. local impl matches=();
  3620. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3621. do
  3622. if _python_impl_matches "${impl}" "${@}"; then
  3623. matches+=("python_targets_${impl}(-)?" "-python_single_target_${impl}(-)");
  3624. fi;
  3625. done;
  3626. [[ -n ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}";
  3627. local out=${matches[@]};
  3628. echo "${out// /,}"
  3629. }
  3630. python_gen_useflags ()
  3631. {
  3632. debug-print-function ${FUNCNAME} "${@}";
  3633. local impl matches=();
  3634. for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  3635. do
  3636. if _python_impl_matches "${impl}" "${@}"; then
  3637. matches+=("python_targets_${impl}");
  3638. fi;
  3639. done;
  3640. echo "${matches[@]}"
  3641. }
  3642. python_generate_cffi_modules ()
  3643. {
  3644. die "${FUNCNAME}() is invalid for python-r1 suite"
  3645. }
  3646. python_generate_wrapper_scripts ()
  3647. {
  3648. die "${FUNCNAME}() is invalid for python-r1 suite"
  3649. }
  3650. python_get_CFLAGS ()
  3651. {
  3652. debug-print-function ${FUNCNAME} "${@}";
  3653. python_export "${@}" PYTHON_CFLAGS;
  3654. echo "${PYTHON_CFLAGS}"
  3655. }
  3656. python_get_LIBS ()
  3657. {
  3658. debug-print-function ${FUNCNAME} "${@}";
  3659. python_export "${@}" PYTHON_LIBS;
  3660. echo "${PYTHON_LIBS}"
  3661. }
  3662. python_get_PYTHON_CONFIG ()
  3663. {
  3664. debug-print-function ${FUNCNAME} "${@}";
  3665. python_export "${@}" PYTHON_CONFIG;
  3666. echo "${PYTHON_CONFIG}"
  3667. }
  3668. python_get_extension_module_suffix ()
  3669. {
  3670. die "${FUNCNAME}() is invalid for python-r1 suite"
  3671. }
  3672. python_get_implementation ()
  3673. {
  3674. die "${FUNCNAME}() is invalid for python-r1 suite"
  3675. }
  3676. python_get_implementation_and_version ()
  3677. {
  3678. die "${FUNCNAME}() is invalid for python-r1 suite"
  3679. }
  3680. python_get_implementational_package ()
  3681. {
  3682. die "${FUNCNAME}() is invalid for python-r1 suite"
  3683. }
  3684. python_get_includedir ()
  3685. {
  3686. debug-print-function ${FUNCNAME} "${@}";
  3687. python_export "${@}" PYTHON_INCLUDEDIR;
  3688. echo "${PYTHON_INCLUDEDIR}"
  3689. }
  3690. python_get_libdir ()
  3691. {
  3692. die "${FUNCNAME}() is invalid for python-r1 suite"
  3693. }
  3694. python_get_library ()
  3695. {
  3696. die "${FUNCNAME}() is invalid for python-r1 suite"
  3697. }
  3698. python_get_library_path ()
  3699. {
  3700. debug-print-function ${FUNCNAME} "${@}";
  3701. python_export "${@}" PYTHON_LIBPATH;
  3702. echo "${PYTHON_LIBPATH}"
  3703. }
  3704. python_get_scriptdir ()
  3705. {
  3706. debug-print-function ${FUNCNAME} "${@}";
  3707. python_export "${@}" PYTHON_SCRIPTDIR;
  3708. echo "${PYTHON_SCRIPTDIR}"
  3709. }
  3710. python_get_sitedir ()
  3711. {
  3712. debug-print-function ${FUNCNAME} "${@}";
  3713. python_export "${@}" PYTHON_SITEDIR;
  3714. echo "${PYTHON_SITEDIR}"
  3715. }
  3716. python_get_version ()
  3717. {
  3718. die "${FUNCNAME}() is invalid for python-r1 suite"
  3719. }
  3720. python_install_executables ()
  3721. {
  3722. die "${FUNCNAME}() is invalid for python-r1 suite"
  3723. }
  3724. python_is_installed ()
  3725. {
  3726. local impl=${1:-${EPYTHON}};
  3727. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  3728. local hasv_args=();
  3729. case ${EAPI:-0} in
  3730. 0 | 1 | 2 | 3 | 4)
  3731. local -x ROOT=/
  3732. ;;
  3733. 5 | 6)
  3734. hasv_args+=(--host-root)
  3735. ;;
  3736. *)
  3737. hasv_args+=(-b)
  3738. ;;
  3739. esac;
  3740. case "${impl}" in
  3741. pypy | pypy3)
  3742. local append=;
  3743. if [[ -n ${PYTHON_REQ_USE} ]]; then
  3744. append=[${PYTHON_REQ_USE}];
  3745. fi;
  3746. has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  3747. ;;
  3748. *)
  3749. local PYTHON_PKG_DEP;
  3750. python_export "${impl}" PYTHON_PKG_DEP;
  3751. has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  3752. ;;
  3753. esac
  3754. }
  3755. python_is_python3 ()
  3756. {
  3757. local impl=${1:-${EPYTHON}};
  3758. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  3759. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  3760. }
  3761. python_merge_intermediate_installation_images ()
  3762. {
  3763. die "${FUNCNAME}() is invalid for python-r1 suite"
  3764. }
  3765. python_mod_cleanup ()
  3766. {
  3767. 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"
  3768. }
  3769. python_mod_optimize ()
  3770. {
  3771. 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"
  3772. }
  3773. python_moduleinto ()
  3774. {
  3775. debug-print-function ${FUNCNAME} "${@}";
  3776. python_moduleroot=${1}
  3777. }
  3778. python_need_rebuild ()
  3779. {
  3780. die "${FUNCNAME}() is invalid for python-r1 suite"
  3781. }
  3782. python_newexe ()
  3783. {
  3784. debug-print-function ${FUNCNAME} "${@}";
  3785. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3786. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  3787. if [[ ${EAPI:-0} == [0123] ]]; then
  3788. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  3789. fi;
  3790. local wrapd=${python_scriptroot:-/usr/bin};
  3791. local f=${1};
  3792. local newfn=${2};
  3793. local PYTHON_SCRIPTDIR d;
  3794. python_export PYTHON_SCRIPTDIR;
  3795. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  3796. ( dodir "${wrapd}";
  3797. exeopts -m 0755;
  3798. exeinto "${d}";
  3799. newexe "${f}" "${newfn}" || return ${?} );
  3800. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  3801. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  3802. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  3803. fi
  3804. }
  3805. python_newscript ()
  3806. {
  3807. debug-print-function ${FUNCNAME} "${@}";
  3808. local _PYTHON_REWRITE_SHEBANG=1;
  3809. python_newexe "${@}"
  3810. }
  3811. python_optimize ()
  3812. {
  3813. debug-print-function ${FUNCNAME} "${@}";
  3814. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  3815. eerror "The new Python eclasses expect the compiled Python files to";
  3816. eerror "be controlled by the Package Manager. For this reason,";
  3817. eerror "the python_optimize function can be used only during src_* phases";
  3818. eerror "(src_install most commonly) and not during pkg_* phases.";
  3819. echo;
  3820. die "python_optimize is not to be used in pre/post* phases";
  3821. fi;
  3822. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  3823. local PYTHON=${PYTHON};
  3824. [[ -n ${PYTHON} ]] || python_export PYTHON;
  3825. if [[ ${#} -eq 0 ]]; then
  3826. local f;
  3827. while IFS= read -r -d '' f; do
  3828. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  3829. set -- "${D%/}${f}" "${@}";
  3830. fi;
  3831. done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for x in sys.path))' || die);
  3832. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  3833. fi;
  3834. local d;
  3835. for d in "$@";
  3836. do
  3837. local instpath=${d#${D%/}};
  3838. instpath=/${instpath##/};
  3839. case "${EPYTHON}" in
  3840. python2.7 | python3.[34])
  3841. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3842. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3843. ;;
  3844. python* | pypy3)
  3845. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  3846. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  3847. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  3848. ;;
  3849. *)
  3850. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  3851. ;;
  3852. esac;
  3853. done
  3854. }
  3855. python_pkg_setup ()
  3856. {
  3857. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3858. }
  3859. python_replicate_script ()
  3860. {
  3861. debug-print-function ${FUNCNAME} "${@}";
  3862. function _python_replicate_script ()
  3863. {
  3864. local _PYTHON_FIX_SHEBANG_QUIET=1;
  3865. local PYTHON_SCRIPTDIR;
  3866. python_export PYTHON_SCRIPTDIR;
  3867. ( exeopts -m 0755;
  3868. exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}";
  3869. doexe "${files[@]}" );
  3870. python_fix_shebang -q "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
  3871. };
  3872. local files=("${@}");
  3873. python_foreach_impl _python_replicate_script;
  3874. unset -f _python_replicate_script;
  3875. local f;
  3876. for f in "$@";
  3877. do
  3878. _python_ln_rel "${ED%/}/usr/lib/python-exec/python-exec2" "${f}" || die;
  3879. done
  3880. }
  3881. python_scriptinto ()
  3882. {
  3883. debug-print-function ${FUNCNAME} "${@}";
  3884. python_scriptroot=${1}
  3885. }
  3886. python_set_active_version ()
  3887. {
  3888. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  3889. }
  3890. python_setup ()
  3891. {
  3892. debug-print-function ${FUNCNAME} "${@}";
  3893. _python_validate_useflags;
  3894. local pycompat=("${PYTHON_COMPAT[@]}");
  3895. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  3896. pycompat=(${PYTHON_COMPAT_OVERRIDE});
  3897. fi;
  3898. local has_check_deps;
  3899. declare -f python_check_deps > /dev/null && has_check_deps=1;
  3900. local found;
  3901. for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  3902. do
  3903. local impl=${_PYTHON_SUPPORTED_IMPLS[i]};
  3904. has "${impl}" "${pycompat[@]}" || continue;
  3905. if [[ ! -n ${PYTHON_COMPAT_OVERRIDE} && ! -n ${has_check_deps} ]]; then
  3906. use "python_targets_${impl}" || continue;
  3907. fi;
  3908. _python_impl_matches "${impl}" "${@-*}" || continue;
  3909. python_export "${impl}" EPYTHON PYTHON;
  3910. if [[ -n ${has_check_deps} ]]; then
  3911. python_is_installed "${impl}" || continue;
  3912. local PYTHON_USEDEP="python_targets_${impl}(-),python_single_target_${impl}(+)";
  3913. python_check_deps || continue;
  3914. fi;
  3915. found=1;
  3916. break;
  3917. done;
  3918. if [[ ! -n ${found} ]]; then
  3919. eerror "${FUNCNAME}: none of the enabled implementation matched the patterns.";
  3920. eerror " patterns: ${@-'(*)'}";
  3921. eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing.";
  3922. eerror " suggested: || ( \$(python_gen_useflags ${@}) )";
  3923. eerror "(remember to quote all the patterns with '')";
  3924. die "${FUNCNAME}: no enabled implementation satisfy requirements";
  3925. fi;
  3926. python_wrapper_setup
  3927. }
  3928. python_wrapper_setup ()
  3929. {
  3930. debug-print-function ${FUNCNAME} "${@}";
  3931. local workdir=${1:-${T}/${EPYTHON}};
  3932. local impl=${2:-${EPYTHON}};
  3933. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  3934. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  3935. if [[ ! -x ${workdir}/bin/python ]]; then
  3936. _python_check_dead_variables;
  3937. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  3938. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  3939. rm -f "${workdir}"/bin/2to3 || die;
  3940. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  3941. local EPYTHON PYTHON;
  3942. python_export "${impl}" EPYTHON PYTHON;
  3943. local pyver pyother;
  3944. if python_is_python3; then
  3945. pyver=3;
  3946. pyother=2;
  3947. else
  3948. pyver=2;
  3949. pyother=3;
  3950. fi;
  3951. cat > "${workdir}/bin/python" <<-_EOF_ ||
  3952. #!/bin/sh
  3953. exec "${PYTHON}" "\${@}"
  3954. _EOF_
  3955. die
  3956. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3957. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  3958. local nonsupp=("python${pyother}" "python${pyother}-config");
  3959. if [[ ${EPYTHON} == python* ]]; then
  3960. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  3961. #!/bin/sh
  3962. exec "${PYTHON}-config" "\${@}"
  3963. _EOF_
  3964. die
  3965. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3966. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  3967. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  3968. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  3969. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  3970. else
  3971. nonsupp+=(2to3 python-config "python${pyver}-config");
  3972. fi;
  3973. local x;
  3974. for x in "${nonsupp[@]}";
  3975. do
  3976. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  3977. #!/bin/sh
  3978. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  3979. exit 127
  3980. _EOF_
  3981. die
  3982. chmod +x "${workdir}"/bin/${x} || die;
  3983. done;
  3984. fi;
  3985. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  3986. PATH=${workdir}/bin${PATH:+:${PATH}};
  3987. fi;
  3988. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  3989. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  3990. fi;
  3991. export PATH PKG_CONFIG_PATH
  3992. }
  3993. qeerror ()
  3994. {
  3995. qout eerror "${@}"
  3996. }
  3997. qeinfo ()
  3998. {
  3999. qout einfo "${@}"
  4000. }
  4001. qemu_python_install ()
  4002. {
  4003. python_domodule "${S}/python/qemu/qmp.py";
  4004. python_doscript "${S}/scripts/kvm/vmxcap";
  4005. python_doscript "${S}/scripts/qmp/qmp-shell";
  4006. python_doscript "${S}/scripts/qmp/qemu-ga-client"
  4007. }
  4008. qemu_src_configure ()
  4009. {
  4010. debug-print-function ${FUNCNAME} "$@";
  4011. local buildtype=$1;
  4012. local builddir="${S}/${buildtype}-build";
  4013. mkdir "${builddir}";
  4014. local conf_opts=(--prefix=/usr --sysconfdir=/etc --bindir=/usr/bin --libdir=/usr/$(get_libdir) --datadir=/usr/share --docdir=/usr/share/doc/${PF}/html --mandir=/usr/share/man --with-confsuffix=/qemu --localstatedir=/var --disable-bsd-user --disable-guest-agent --disable-strip --disable-werror --disable-gcrypt --python="${PYTHON}" --cc="$(tc-getCC)" --cxx="$(tc-getCXX)" --host-cc="$(tc-getBUILD_CC)" $(use_enable debug debug-info) $(use_enable debug debug-tcg) $(use_enable doc docs) $(use_enable tci tcg-interpreter) $(use_enable xattr attr));
  4015. function conf_notuser ()
  4016. {
  4017. if [[ ${buildtype} == "user" ]]; then
  4018. echo "--disable-${2:-$1}";
  4019. else
  4020. use_enable "$@";
  4021. fi
  4022. };
  4023. conf_opts+=(--disable-bluez $(conf_notuser accessibility brlapi) $(conf_notuser aio linux-aio) $(conf_notuser bzip2) $(conf_notuser capstone) $(conf_notuser caps cap-ng) $(conf_notuser curl) $(conf_notuser fdt) $(conf_notuser glusterfs) $(conf_notuser gnutls) $(conf_notuser gnutls nettle) $(conf_notuser gtk) $(conf_notuser infiniband rdma) $(conf_notuser iscsi libiscsi) $(conf_notuser jemalloc jemalloc) $(conf_notuser jpeg vnc-jpeg) $(conf_notuser kernel_linux kvm) $(conf_notuser lzo) $(conf_notuser ncurses curses) $(conf_notuser nfs libnfs) $(conf_notuser numa) $(conf_notuser opengl) $(conf_notuser png vnc-png) $(conf_notuser rbd) $(conf_notuser sasl vnc-sasl) $(conf_notuser sdl) $(conf_notuser seccomp) $(conf_notuser smartcard) $(conf_notuser snappy) $(conf_notuser spice) $(conf_notuser ssh libssh) $(conf_notuser usb libusb) $(conf_notuser usbredir usb-redir) $(conf_notuser vde) $(conf_notuser vhost-net) $(conf_notuser virgl virglrenderer) $(conf_notuser virtfs) $(conf_notuser vnc) $(conf_notuser vte) $(conf_notuser xen) $(conf_notuser xen xen-pci-passthrough) $(conf_notuser xfs xfsctl) $(conf_notuser xkb xkbcommon));
  4024. if [[ ${buildtype} == "user" ]]; then
  4025. conf_opts+=(--disable-libxml2);
  4026. else
  4027. conf_opts+=(--enable-libxml2);
  4028. fi;
  4029. if [[ ! ${buildtype} == "user" ]]; then
  4030. local audio_opts=($(usev alsa) $(usev oss) $(usev sdl) $(usex pulseaudio pa ""));
  4031. conf_opts+=(--audio-drv-list=$(printf "%s," "${audio_opts[@]}"));
  4032. fi;
  4033. case ${buildtype} in
  4034. user)
  4035. conf_opts+=(--enable-linux-user --disable-system --disable-blobs --disable-tools);
  4036. local static_flag="static-user"
  4037. ;;
  4038. softmmu)
  4039. conf_opts+=(--disable-linux-user --enable-system --disable-tools);
  4040. local static_flag="static"
  4041. ;;
  4042. tools)
  4043. conf_opts+=(--disable-linux-user --disable-system --disable-blobs --enable-tools);
  4044. local static_flag="static"
  4045. ;;
  4046. esac;
  4047. local targets="${buildtype}_targets";
  4048. [[ -n ${targets} ]] && conf_opts+=(--target-list="${!targets}");
  4049. use systemtap && conf_opts+=(--enable-trace-backend=dtrace);
  4050. if use ${static_flag}; then
  4051. conf_opts+=(--static --disable-pie);
  4052. else
  4053. tc-enables-pie && conf_opts+=(--enable-pie);
  4054. fi;
  4055. echo "../configure ${conf_opts[*]}";
  4056. cd "${builddir}";
  4057. ../configure "${conf_opts[@]}" || die "configure failed";
  4058. use kernel_FreeBSD && sed -i -E -e "s|^(HOST_USB=)bsd|\1stub|" "${S}"/config-host.mak
  4059. }
  4060. qewarn ()
  4061. {
  4062. qout ewarn "${@}"
  4063. }
  4064. qout ()
  4065. {
  4066. local outputmsg type;
  4067. type=${1};
  4068. shift;
  4069. outputmsg="${@}";
  4070. case "${EBUILD_PHASE}" in
  4071. depend)
  4072. unset outputmsg
  4073. ;;
  4074. clean)
  4075. unset outputmsg
  4076. ;;
  4077. preinst)
  4078. unset outputmsg
  4079. ;;
  4080. esac;
  4081. [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
  4082. }
  4083. readme.gentoo_create_doc ()
  4084. {
  4085. debug-print-function ${FUNCNAME} "${@}";
  4086. if [[ -n "${DOC_CONTENTS}" ]]; then
  4087. if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
  4088. echo "${DOC_CONTENTS}" > "${T}"/README.gentoo || die;
  4089. else
  4090. local saved_flags=$-;
  4091. set -f;
  4092. echo -e ${DOC_CONTENTS} | fold -s -w 70 | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo;
  4093. assert;
  4094. set +f -${saved_flags};
  4095. fi;
  4096. else
  4097. if [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
  4098. cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die;
  4099. else
  4100. if [[ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]]; then
  4101. cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die;
  4102. else
  4103. die "You are not specifying README.gentoo contents!";
  4104. fi;
  4105. fi;
  4106. fi;
  4107. dodoc "${T}"/README.gentoo;
  4108. README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
  4109. }
  4110. readme.gentoo_print_elog ()
  4111. {
  4112. debug-print-function ${FUNCNAME} "${@}";
  4113. if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
  4114. die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!";
  4115. else
  4116. if ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
  4117. echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do
  4118. elog "${ELINE}";
  4119. done;
  4120. elog "";
  4121. elog "(Note: Above message is only printed the first time package is";
  4122. elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*";
  4123. elog "for future reference)";
  4124. fi;
  4125. fi
  4126. }
  4127. require_configured_kernel ()
  4128. {
  4129. if ! use kernel_linux; then
  4130. die "${FUNCNAME}() called on non-Linux system, please fix the ebuild";
  4131. fi;
  4132. if ! linux_config_src_exists; then
  4133. qeerror "Could not find a usable .config in the kernel source directory.";
  4134. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  4135. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  4136. qeerror "it points to the necessary object directory so that it might find .config.";
  4137. die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  4138. fi;
  4139. get_version || die "Unable to determine configured kernel version"
  4140. }
  4141. rm_loc ()
  4142. {
  4143. rm po/$1.po || die
  4144. }
  4145. run_in_build_dir ()
  4146. {
  4147. debug-print-function ${FUNCNAME} "${@}";
  4148. local ret;
  4149. [[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified.";
  4150. [[ -n ${BUILD_DIR} ]] || die "${FUNCNAME}: BUILD_DIR not set.";
  4151. mkdir -p "${BUILD_DIR}" || die;
  4152. pushd "${BUILD_DIR}" > /dev/null || die;
  4153. "${@}";
  4154. ret=${?};
  4155. popd > /dev/null || die;
  4156. return ${ret}
  4157. }
  4158. set_arch_to_kernel ()
  4159. {
  4160. export ARCH=$(tc-arch-kernel)
  4161. }
  4162. set_arch_to_portage ()
  4163. {
  4164. export ARCH=$(tc-arch)
  4165. }
  4166. src_compile ()
  4167. {
  4168. if [[ -n ${user_targets} ]]; then
  4169. cd "${S}/user-build";
  4170. default;
  4171. fi;
  4172. if [[ -n ${softmmu_targets} ]]; then
  4173. cd "${S}/softmmu-build";
  4174. default;
  4175. fi;
  4176. cd "${S}/tools-build";
  4177. default
  4178. }
  4179. src_configure ()
  4180. {
  4181. local target;
  4182. python_setup;
  4183. softmmu_targets= softmmu_bins=();
  4184. user_targets= user_bins=();
  4185. for target in ${IUSE_SOFTMMU_TARGETS};
  4186. do
  4187. if use "qemu_softmmu_targets_${target}"; then
  4188. softmmu_targets+=",${target}-softmmu";
  4189. softmmu_bins+=("qemu-system-${target}");
  4190. fi;
  4191. done;
  4192. for target in ${IUSE_USER_TARGETS};
  4193. do
  4194. if use "qemu_user_targets_${target}"; then
  4195. user_targets+=",${target}-linux-user";
  4196. user_bins+=("qemu-${target}");
  4197. fi;
  4198. done;
  4199. softmmu_targets=${softmmu_targets#,};
  4200. user_targets=${user_targets#,};
  4201. [[ -n ${softmmu_targets} ]] && qemu_src_configure "softmmu";
  4202. [[ -n ${user_targets} ]] && qemu_src_configure "user";
  4203. qemu_src_configure "tools"
  4204. }
  4205. src_install ()
  4206. {
  4207. if [[ -n ${user_targets} ]]; then
  4208. cd "${S}/user-build";
  4209. emake DESTDIR="${ED}" install;
  4210. generate_initd;
  4211. doinitd "${T}/qemu-binfmt";
  4212. insinto "/usr/share/qemu/binfmt.d";
  4213. doins "${T}/qemu.conf";
  4214. fi;
  4215. if [[ -n ${softmmu_targets} ]]; then
  4216. cd "${S}/softmmu-build";
  4217. emake DESTDIR="${ED}" install;
  4218. [[ -e check-report.html ]] && dodoc check-report.html;
  4219. if use kernel_linux; then
  4220. udev_newrules "${FILESDIR}"/65-kvm.rules-r1 65-kvm.rules;
  4221. fi;
  4222. if use python; then
  4223. python_foreach_impl qemu_python_install;
  4224. fi;
  4225. fi;
  4226. cd "${S}/tools-build";
  4227. emake DESTDIR="${ED}" install;
  4228. pushd "${ED}"/usr/bin > /dev/null;
  4229. pax-mark mr "${softmmu_bins[@]}" "${user_bins[@]}";
  4230. popd > /dev/null;
  4231. insinto "/etc/qemu";
  4232. doins "${FILESDIR}/bridge.conf";
  4233. cd "${S}";
  4234. dodoc Changelog MAINTAINERS docs/specs/pci-ids.txt;
  4235. newdoc pc-bios/README README.pc-bios;
  4236. dostrip -x ${QA_PREBUILT};
  4237. if [[ -n ${softmmu_targets} ]]; then
  4238. rm "${ED}/usr/share/qemu/bios.bin";
  4239. rm "${ED}/usr/share/qemu/bios-256k.bin";
  4240. if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
  4241. dosym ../seabios/bios.bin /usr/share/qemu/bios.bin;
  4242. dosym ../seabios/bios-256k.bin /usr/share/qemu/bios-256k.bin;
  4243. fi;
  4244. rm "${ED}/usr/share/qemu/vgabios.bin";
  4245. rm "${ED}/usr/share/qemu/vgabios-cirrus.bin";
  4246. rm "${ED}/usr/share/qemu/vgabios-qxl.bin";
  4247. rm "${ED}/usr/share/qemu/vgabios-stdvga.bin";
  4248. rm "${ED}/usr/share/qemu/vgabios-virtio.bin";
  4249. rm "${ED}/usr/share/qemu/vgabios-vmware.bin";
  4250. if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386 || use qemu_softmmu_targets_ppc64; then
  4251. dosym ../seavgabios/vgabios-isavga.bin /usr/share/qemu/vgabios.bin;
  4252. dosym ../seavgabios/vgabios-cirrus.bin /usr/share/qemu/vgabios-cirrus.bin;
  4253. dosym ../seavgabios/vgabios-qxl.bin /usr/share/qemu/vgabios-qxl.bin;
  4254. dosym ../seavgabios/vgabios-stdvga.bin /usr/share/qemu/vgabios-stdvga.bin;
  4255. dosym ../seavgabios/vgabios-virtio.bin /usr/share/qemu/vgabios-virtio.bin;
  4256. dosym ../seavgabios/vgabios-vmware.bin /usr/share/qemu/vgabios-vmware.bin;
  4257. fi;
  4258. rm "${ED}/usr/share/qemu/sgabios.bin";
  4259. if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
  4260. dosym ../sgabios/sgabios.bin /usr/share/qemu/sgabios.bin;
  4261. fi;
  4262. rm "${ED}"/usr/share/qemu/pxe-*.rom;
  4263. if use qemu_softmmu_targets_x86_64 || use qemu_softmmu_targets_i386; then
  4264. dosym ../ipxe/8086100e.rom /usr/share/qemu/pxe-e1000.rom;
  4265. dosym ../ipxe/80861209.rom /usr/share/qemu/pxe-eepro100.rom;
  4266. dosym ../ipxe/10500940.rom /usr/share/qemu/pxe-ne2k_pci.rom;
  4267. dosym ../ipxe/10222000.rom /usr/share/qemu/pxe-pcnet.rom;
  4268. dosym ../ipxe/10ec8139.rom /usr/share/qemu/pxe-rtl8139.rom;
  4269. dosym ../ipxe/1af41000.rom /usr/share/qemu/pxe-virtio.rom;
  4270. fi;
  4271. fi;
  4272. DISABLE_AUTOFORMATTING=true;
  4273. readme.gentoo_create_doc
  4274. }
  4275. src_prepare ()
  4276. {
  4277. check_targets IUSE_SOFTMMU_TARGETS softmmu;
  4278. check_targets IUSE_USER_TARGETS linux-user;
  4279. default;
  4280. tc-export AR LD NM OBJCOPY PKG_CONFIG;
  4281. export WINDRES=${CHOST}-windres;
  4282. MAKEOPTS+=" V=1";
  4283. handle_locales;
  4284. rm -r dtc || die
  4285. }
  4286. src_test ()
  4287. {
  4288. if [[ -n ${softmmu_targets} ]]; then
  4289. cd "${S}/softmmu-build";
  4290. pax-mark m */qemu-system-*;
  4291. emake -j1 check;
  4292. emake -j1 check-report.html;
  4293. fi
  4294. }
  4295. src_unpack ()
  4296. {
  4297. default
  4298. }
  4299. strip-linguas ()
  4300. {
  4301. local ls newls nols;
  4302. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  4303. local op=$1;
  4304. shift;
  4305. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  4306. shift;
  4307. local d f;
  4308. for d in "$@";
  4309. do
  4310. if [[ ${op} == "-u" ]]; then
  4311. newls=${ls};
  4312. else
  4313. newls="";
  4314. fi;
  4315. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  4316. do
  4317. if [[ ${op} == "-i" ]]; then
  4318. has ${f} ${ls} && newls="${newls} ${f}";
  4319. else
  4320. has ${f} ${ls} || newls="${newls} ${f}";
  4321. fi;
  4322. done;
  4323. ls=${newls};
  4324. done;
  4325. else
  4326. ls="$@";
  4327. fi;
  4328. nols="";
  4329. newls="";
  4330. for f in ${LINGUAS};
  4331. do
  4332. if has ${f} ${ls}; then
  4333. newls="${newls} ${f}";
  4334. else
  4335. nols="${nols} ${f}";
  4336. fi;
  4337. done;
  4338. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  4339. export LINGUAS=${newls:1}
  4340. }
  4341. tc-arch ()
  4342. {
  4343. tc-ninja_magic_to_arch portage "$@"
  4344. }
  4345. tc-arch-kernel ()
  4346. {
  4347. tc-ninja_magic_to_arch kern "$@"
  4348. }
  4349. tc-check-openmp ()
  4350. {
  4351. if ! tc-has-openmp; then
  4352. eerror "Your current compiler does not support OpenMP!";
  4353. if tc-is-gcc; then
  4354. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  4355. else
  4356. if tc-is-clang; then
  4357. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  4358. fi;
  4359. fi;
  4360. die "Active compiler does not have required support for OpenMP";
  4361. fi
  4362. }
  4363. tc-cpp-is-true ()
  4364. {
  4365. local CONDITION=${1};
  4366. shift;
  4367. $(tc-getTARGET_CPP) "${@}" -P - <<-EOF > /dev/null 2>&1
  4368. #if ${CONDITION}
  4369. true
  4370. #else
  4371. #error false
  4372. #endif
  4373. EOF
  4374.  
  4375. }
  4376. tc-detect-is-softfloat ()
  4377. {
  4378. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  4379. case ${CTARGET:-${CHOST}} in
  4380. *-newlib | *-elf | *-eabi)
  4381. return 1
  4382. ;;
  4383. arm*)
  4384. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  4385. echo "no";
  4386. else
  4387. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  4388. echo "yes";
  4389. else
  4390. echo "softfp";
  4391. fi;
  4392. fi;
  4393. return 0
  4394. ;;
  4395. *)
  4396. return 1
  4397. ;;
  4398. esac
  4399. }
  4400. tc-enables-pie ()
  4401. {
  4402. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  4403. }
  4404. tc-enables-ssp ()
  4405. {
  4406. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4407. }
  4408. tc-enables-ssp-all ()
  4409. {
  4410. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4411. }
  4412. tc-enables-ssp-strong ()
  4413. {
  4414. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4415. }
  4416. tc-endian ()
  4417. {
  4418. local host=$1;
  4419. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4420. host=${host%%-*};
  4421. case ${host} in
  4422. aarch64*be)
  4423. echo big
  4424. ;;
  4425. aarch64)
  4426. echo little
  4427. ;;
  4428. alpha*)
  4429. echo little
  4430. ;;
  4431. arm*b*)
  4432. echo big
  4433. ;;
  4434. arm*)
  4435. echo little
  4436. ;;
  4437. cris*)
  4438. echo little
  4439. ;;
  4440. hppa*)
  4441. echo big
  4442. ;;
  4443. i?86*)
  4444. echo little
  4445. ;;
  4446. ia64*)
  4447. echo little
  4448. ;;
  4449. m68*)
  4450. echo big
  4451. ;;
  4452. mips*l*)
  4453. echo little
  4454. ;;
  4455. mips*)
  4456. echo big
  4457. ;;
  4458. powerpc*le)
  4459. echo little
  4460. ;;
  4461. powerpc*)
  4462. echo big
  4463. ;;
  4464. riscv*)
  4465. echo little
  4466. ;;
  4467. s390*)
  4468. echo big
  4469. ;;
  4470. sh*b*)
  4471. echo big
  4472. ;;
  4473. sh*)
  4474. echo little
  4475. ;;
  4476. sparc*)
  4477. echo big
  4478. ;;
  4479. x86_64*)
  4480. echo little
  4481. ;;
  4482. *)
  4483. echo wtf
  4484. ;;
  4485. esac
  4486. }
  4487. tc-env_build ()
  4488. {
  4489. tc-export_build_env;
  4490. 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) "$@"
  4491. }
  4492. tc-export ()
  4493. {
  4494. local var;
  4495. for var in "$@";
  4496. do
  4497. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4498. "tc-get${var}" > /dev/null;
  4499. done
  4500. }
  4501. tc-export_build_env ()
  4502. {
  4503. tc-export "$@";
  4504. if tc-is-cross-compiler; then
  4505. : ${BUILD_CFLAGS:=-O1 -pipe};
  4506. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  4507. : ${BUILD_CPPFLAGS:= };
  4508. : ${BUILD_LDFLAGS:= };
  4509. else
  4510. : ${BUILD_CFLAGS:=${CFLAGS}};
  4511. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  4512. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  4513. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  4514. fi;
  4515. export BUILD_{C,CXX,CPP,LD}FLAGS;
  4516. local v;
  4517. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4518. do
  4519. export ${v#BUILD_}_FOR_BUILD="${!v}";
  4520. done
  4521. }
  4522. tc-get-compiler-type ()
  4523. {
  4524. local code='
  4525. #if defined(__PATHSCALE__)
  4526. HAVE_PATHCC
  4527. #elif defined(__clang__)
  4528. HAVE_CLANG
  4529. #elif defined(__GNUC__)
  4530. HAVE_GCC
  4531. #endif
  4532. ';
  4533. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4534. case ${res} in
  4535. *HAVE_PATHCC*)
  4536. echo pathcc
  4537. ;;
  4538. *HAVE_CLANG*)
  4539. echo clang
  4540. ;;
  4541. *HAVE_GCC*)
  4542. echo gcc
  4543. ;;
  4544. *)
  4545. echo unknown
  4546. ;;
  4547. esac
  4548. }
  4549. tc-getAR ()
  4550. {
  4551. tc-getPROG AR ar "$@"
  4552. }
  4553. tc-getAS ()
  4554. {
  4555. tc-getPROG AS as "$@"
  4556. }
  4557. tc-getBUILD_AR ()
  4558. {
  4559. tc-getBUILD_PROG AR ar "$@"
  4560. }
  4561. tc-getBUILD_AS ()
  4562. {
  4563. tc-getBUILD_PROG AS as "$@"
  4564. }
  4565. tc-getBUILD_CC ()
  4566. {
  4567. tc-getBUILD_PROG CC gcc "$@"
  4568. }
  4569. tc-getBUILD_CPP ()
  4570. {
  4571. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4572. }
  4573. tc-getBUILD_CXX ()
  4574. {
  4575. tc-getBUILD_PROG CXX g++ "$@"
  4576. }
  4577. tc-getBUILD_LD ()
  4578. {
  4579. tc-getBUILD_PROG LD ld "$@"
  4580. }
  4581. tc-getBUILD_NM ()
  4582. {
  4583. tc-getBUILD_PROG NM nm "$@"
  4584. }
  4585. tc-getBUILD_OBJCOPY ()
  4586. {
  4587. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4588. }
  4589. tc-getBUILD_PKG_CONFIG ()
  4590. {
  4591. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4592. }
  4593. tc-getBUILD_PROG ()
  4594. {
  4595. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4596. tc-is-cross-compiler || vars+=" $1";
  4597. _tc-getPROG CBUILD "${vars}" "${@:2}"
  4598. }
  4599. tc-getBUILD_RANLIB ()
  4600. {
  4601. tc-getBUILD_PROG RANLIB ranlib "$@"
  4602. }
  4603. tc-getBUILD_STRIP ()
  4604. {
  4605. tc-getBUILD_PROG STRIP strip "$@"
  4606. }
  4607. tc-getCC ()
  4608. {
  4609. tc-getPROG CC gcc "$@"
  4610. }
  4611. tc-getCPP ()
  4612. {
  4613. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4614. }
  4615. tc-getCXX ()
  4616. {
  4617. tc-getPROG CXX g++ "$@"
  4618. }
  4619. tc-getDLLWRAP ()
  4620. {
  4621. tc-getPROG DLLWRAP dllwrap "$@"
  4622. }
  4623. tc-getF77 ()
  4624. {
  4625. tc-getPROG F77 gfortran "$@"
  4626. }
  4627. tc-getFC ()
  4628. {
  4629. tc-getPROG FC gfortran "$@"
  4630. }
  4631. tc-getGCJ ()
  4632. {
  4633. tc-getPROG GCJ gcj "$@"
  4634. }
  4635. tc-getGO ()
  4636. {
  4637. tc-getPROG GO gccgo "$@"
  4638. }
  4639. tc-getLD ()
  4640. {
  4641. tc-getPROG LD ld "$@"
  4642. }
  4643. tc-getNM ()
  4644. {
  4645. tc-getPROG NM nm "$@"
  4646. }
  4647. tc-getOBJCOPY ()
  4648. {
  4649. tc-getPROG OBJCOPY objcopy "$@"
  4650. }
  4651. tc-getOBJDUMP ()
  4652. {
  4653. tc-getPROG OBJDUMP objdump "$@"
  4654. }
  4655. tc-getPKG_CONFIG ()
  4656. {
  4657. tc-getPROG PKG_CONFIG pkg-config "$@"
  4658. }
  4659. tc-getPROG ()
  4660. {
  4661. _tc-getPROG CHOST "$@"
  4662. }
  4663. tc-getRANLIB ()
  4664. {
  4665. tc-getPROG RANLIB ranlib "$@"
  4666. }
  4667. tc-getRC ()
  4668. {
  4669. tc-getPROG RC windres "$@"
  4670. }
  4671. tc-getSTRIP ()
  4672. {
  4673. tc-getPROG STRIP strip "$@"
  4674. }
  4675. tc-getTARGET_CPP ()
  4676. {
  4677. if [[ -n ${CTARGET} ]]; then
  4678. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4679. else
  4680. tc-getCPP "$@";
  4681. fi
  4682. }
  4683. tc-has-openmp ()
  4684. {
  4685. local base="${T}/test-tc-openmp";
  4686. cat <<-EOF > "${base}.c"
  4687. #include <omp.h>
  4688. int main() {
  4689. int nthreads, tid, ret = 0;
  4690. #pragma omp parallel private(nthreads, tid)
  4691. {
  4692. tid = omp_get_thread_num();
  4693. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  4694. }
  4695. return ret;
  4696. }
  4697. EOF
  4698.  
  4699. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  4700. local ret=$?;
  4701. rm -f "${base}"*;
  4702. return ${ret}
  4703. }
  4704. tc-has-tls ()
  4705. {
  4706. local base="${T}/test-tc-tls";
  4707. cat <<-EOF > "${base}.c"
  4708. int foo(int *i) {
  4709. static __thread int j = 0;
  4710. return *i ? j : *i;
  4711. }
  4712. EOF
  4713.  
  4714. local flags;
  4715. case $1 in
  4716. -s)
  4717. flags="-S"
  4718. ;;
  4719. -c)
  4720. flags="-c"
  4721. ;;
  4722. -l)
  4723.  
  4724. ;;
  4725. -*)
  4726. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4727. ;;
  4728. esac;
  4729. : ${flags:=-fPIC -shared -Wl,-z,defs};
  4730. [[ $1 == -* ]] && shift;
  4731. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4732. local ret=$?;
  4733. rm -f "${base}"*;
  4734. return ${ret}
  4735. }
  4736. tc-is-clang ()
  4737. {
  4738. [[ $(tc-get-compiler-type) == clang ]]
  4739. }
  4740. tc-is-cross-compiler ()
  4741. {
  4742. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4743. }
  4744. tc-is-gcc ()
  4745. {
  4746. [[ $(tc-get-compiler-type) == gcc ]]
  4747. }
  4748. tc-is-softfloat ()
  4749. {
  4750. tc-detect-is-softfloat || tc-tuple-is-softfloat
  4751. }
  4752. tc-is-static-only ()
  4753. {
  4754. local host=${CTARGET:-${CHOST}};
  4755. [[ ${host} == *-mint* ]]
  4756. }
  4757. tc-ld-disable-gold ()
  4758. {
  4759. if ! tc-ld-is-gold "$@"; then
  4760. return;
  4761. fi;
  4762. ewarn "Forcing usage of the BFD linker instead of GOLD";
  4763. local ld=$(tc-getLD "$@");
  4764. local bfd_ld="${ld%% *}.bfd";
  4765. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  4766. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  4767. local fallback="true";
  4768. if tc-is-gcc; then
  4769. local major=$(gcc-major-version "$@");
  4770. local minor=$(gcc-minor-version "$@");
  4771. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  4772. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4773. fallback="false";
  4774. fi;
  4775. else
  4776. if tc-is-clang; then
  4777. local major=$(clang-major-version "$@");
  4778. local minor=$(clang-minor-version "$@");
  4779. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  4780. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4781. fallback="false";
  4782. fi;
  4783. fi;
  4784. fi;
  4785. if [[ ${fallback} == "true" ]]; then
  4786. if [[ -e ${path_ld} ]]; then
  4787. local d="${T}/bfd-linker";
  4788. mkdir -p "${d}";
  4789. ln -sf "${path_ld}" "${d}"/ld;
  4790. export LDFLAGS="${LDFLAGS} -B${d}";
  4791. else
  4792. die "unable to locate a BFD linker to bypass gold";
  4793. fi;
  4794. fi
  4795. }
  4796. tc-ld-is-gold ()
  4797. {
  4798. local out;
  4799. out=$($(tc-getLD "$@") --version 2>&1);
  4800. if [[ ${out} == *"GNU gold"* ]]; then
  4801. return 0;
  4802. fi;
  4803. local base="${T}/test-tc-gold";
  4804. cat <<-EOF > "${base}.c"
  4805. int main() { return 0; }
  4806. EOF
  4807.  
  4808. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4809. rm -f "${base}"*;
  4810. if [[ ${out} == *"GNU gold"* ]]; then
  4811. return 0;
  4812. fi;
  4813. return 1
  4814. }
  4815. tc-ld-is-lld ()
  4816. {
  4817. local out;
  4818. out=$($(tc-getLD "$@") --version 2>&1);
  4819. if [[ ${out} == *"LLD"* ]]; then
  4820. return 0;
  4821. fi;
  4822. local base="${T}/test-tc-lld";
  4823. cat <<-EOF > "${base}.c"
  4824. int main() { return 0; }
  4825. EOF
  4826.  
  4827. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4828. rm -f "${base}"*;
  4829. if [[ ${out} == *"LLD"* ]]; then
  4830. return 0;
  4831. fi;
  4832. return 1
  4833. }
  4834. tc-ninja_magic_to_arch ()
  4835. {
  4836. function ninj ()
  4837. {
  4838. [[ ${type} == "kern" ]] && echo $1 || echo $2
  4839. };
  4840. local type=$1;
  4841. local host=$2;
  4842. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4843. case ${host} in
  4844. aarch64*)
  4845. echo arm64
  4846. ;;
  4847. alpha*)
  4848. echo alpha
  4849. ;;
  4850. arm*)
  4851. echo arm
  4852. ;;
  4853. avr*)
  4854. ninj avr32 avr
  4855. ;;
  4856. bfin*)
  4857. ninj blackfin bfin
  4858. ;;
  4859. c6x*)
  4860. echo c6x
  4861. ;;
  4862. cris*)
  4863. echo cris
  4864. ;;
  4865. frv*)
  4866. echo frv
  4867. ;;
  4868. hexagon*)
  4869. echo hexagon
  4870. ;;
  4871. hppa*)
  4872. ninj parisc hppa
  4873. ;;
  4874. i?86*)
  4875. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  4876. echo i386;
  4877. else
  4878. echo x86;
  4879. fi
  4880. ;;
  4881. ia64*)
  4882. echo ia64
  4883. ;;
  4884. m68*)
  4885. echo m68k
  4886. ;;
  4887. metag*)
  4888. echo metag
  4889. ;;
  4890. microblaze*)
  4891. echo microblaze
  4892. ;;
  4893. mips*)
  4894. echo mips
  4895. ;;
  4896. nios2*)
  4897. echo nios2
  4898. ;;
  4899. nios*)
  4900. echo nios
  4901. ;;
  4902. or1k | or32*)
  4903. echo openrisc
  4904. ;;
  4905. powerpc*)
  4906. if [[ ${type} == "kern" ]]; then
  4907. echo powerpc;
  4908. else
  4909. if [[ ${host} == powerpc64* ]]; then
  4910. echo ppc64;
  4911. else
  4912. echo ppc;
  4913. fi;
  4914. fi
  4915. ;;
  4916. riscv*)
  4917. echo riscv
  4918. ;;
  4919. s390*)
  4920. echo s390
  4921. ;;
  4922. score*)
  4923. echo score
  4924. ;;
  4925. sh64*)
  4926. ninj sh64 sh
  4927. ;;
  4928. sh*)
  4929. echo sh
  4930. ;;
  4931. sparc64*)
  4932. ninj sparc64 sparc
  4933. ;;
  4934. sparc*)
  4935. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  4936. ;;
  4937. tile*)
  4938. echo tile
  4939. ;;
  4940. vax*)
  4941. echo vax
  4942. ;;
  4943. x86_64*freebsd*)
  4944. echo amd64
  4945. ;;
  4946. x86_64*)
  4947. if [[ ${type} == "kern" ]]; then
  4948. echo x86;
  4949. else
  4950. echo amd64;
  4951. fi
  4952. ;;
  4953. xtensa*)
  4954. echo xtensa
  4955. ;;
  4956. *)
  4957. echo unknown
  4958. ;;
  4959. esac
  4960. }
  4961. tc-stack-grows-down ()
  4962. {
  4963. case ${ARCH} in
  4964. hppa | metag)
  4965. return 1
  4966. ;;
  4967. esac;
  4968. return 0
  4969. }
  4970. tc-tuple-is-softfloat ()
  4971. {
  4972. local CTARGET=${CTARGET:-${CHOST}};
  4973. case ${CTARGET//_/-} in
  4974. bfin* | h8300*)
  4975. echo "only"
  4976. ;;
  4977. *-softfloat-*)
  4978. echo "yes"
  4979. ;;
  4980. *-softfp-*)
  4981. echo "softfp"
  4982. ;;
  4983. arm*-hardfloat-* | arm*eabihf)
  4984. echo "no"
  4985. ;;
  4986. *-newlib | *-elf | *-eabi)
  4987. echo "no"
  4988. ;;
  4989. arm*)
  4990. echo "yes"
  4991. ;;
  4992. *)
  4993. echo "no"
  4994. ;;
  4995. esac
  4996. }
  4997. udev_dorules ()
  4998. {
  4999. debug-print-function ${FUNCNAME} "${@}";
  5000. ( insopts -m 0644;
  5001. insinto "$(_udev_get_udevdir)"/rules.d;
  5002. doins "${@}" )
  5003. }
  5004. udev_get_udevdir ()
  5005. {
  5006. debug-print-function ${FUNCNAME} "${@}";
  5007. eerror "This ebuild should be using the get_udevdir() function instead of the deprecated udev_get_udevdir()";
  5008. die "Deprecated function call: udev_get_udevdir(), please report to (overlay) maintainers."
  5009. }
  5010. udev_newrules ()
  5011. {
  5012. debug-print-function ${FUNCNAME} "${@}";
  5013. ( insopts -m 0644;
  5014. insinto "$(_udev_get_udevdir)"/rules.d;
  5015. newins "${@}" )
  5016. }
  5017. udev_reload ()
  5018. {
  5019. if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
  5020. return 0;
  5021. fi;
  5022. if [[ -d ${ROOT}/run/udev ]]; then
  5023. ebegin "Running udev control --reload for reloading rules and databases";
  5024. udevadm control --reload;
  5025. eend $?;
  5026. fi
  5027. }
  5028. use_if_iuse ()
  5029. {
  5030. in_iuse $1 || return 1;
  5031. use $1
  5032. }
  5033. ver_cut ()
  5034. {
  5035. local range=${1};
  5036. local v=${2:-${PV}};
  5037. local start end;
  5038. local -a comp;
  5039. __eapi7_ver_split "${v}";
  5040. local max=$((${#comp[@]}/2));
  5041. __eapi7_ver_parse_range "${range}" "${max}";
  5042. local IFS=;
  5043. if [[ ${start} -gt 0 ]]; then
  5044. start=$(( start*2 - 1 ));
  5045. fi;
  5046. echo "${comp[*]:start:end*2-start}"
  5047. }
  5048. ver_rs ()
  5049. {
  5050. local v;
  5051. (( ${#} & 1 )) && v=${@: -1} || v=${PV};
  5052. local start end i;
  5053. local -a comp;
  5054. __eapi7_ver_split "${v}";
  5055. local max=$((${#comp[@]}/2 - 1));
  5056. while [[ ${#} -ge 2 ]]; do
  5057. __eapi7_ver_parse_range "${1}" "${max}";
  5058. for ((i = start*2; i <= end*2; i+=2 ))
  5059. do
  5060. [[ ${i} -eq 0 && -z ${comp[i]} ]] && continue;
  5061. comp[i]=${2};
  5062. done;
  5063. shift 2;
  5064. done;
  5065. local IFS=;
  5066. echo "${comp[*]}"
  5067. }
  5068. ver_test ()
  5069. {
  5070. local va op vb;
  5071. if [[ $# -eq 3 ]]; then
  5072. va=${1};
  5073. shift;
  5074. else
  5075. va=${PVR};
  5076. fi;
  5077. [[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments";
  5078. op=${1};
  5079. vb=${2};
  5080. case ${op} in
  5081. -eq | -ne | -lt | -le | -gt | -ge)
  5082.  
  5083. ;;
  5084. *)
  5085. die "${FUNCNAME}: invalid operator: ${op}"
  5086. ;;
  5087. esac;
  5088. __eapi7_ver_compare "${va}" "${vb}";
  5089. test $? "${op}" 2
  5090. }
  5091. xdg_desktop_database_update ()
  5092. {
  5093. if [[ ${EBUILD_PHASE} != post* ]]; then
  5094. die "xdg_desktop_database_update must be used in pkg_post* phases.";
  5095. fi;
  5096. if ! type update-desktop-database &> /dev/null; then
  5097. debug-print "update-desktop-database is not found";
  5098. return;
  5099. fi;
  5100. ebegin "Updating .desktop files database";
  5101. update-desktop-database -q "${EROOT%/}${DESKTOP_DATABASE_DIR}";
  5102. eend $?
  5103. }
  5104. xdg_environment_reset ()
  5105. {
  5106. export XDG_DATA_HOME="${HOME}/.local/share";
  5107. export XDG_CONFIG_HOME="${HOME}/.config";
  5108. export XDG_CACHE_HOME="${HOME}/.cache";
  5109. export XDG_RUNTIME_DIR="${T}/run";
  5110. mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_RUNTIME_DIR}" || die;
  5111. chmod 0700 "${XDG_RUNTIME_DIR}" || die;
  5112. unset DBUS_SESSION_BUS_ADDRESS
  5113. }
  5114. xdg_icon_cache_update ()
  5115. {
  5116. if [[ ${EBUILD_PHASE} != post* ]]; then
  5117. die "xdg_icon_cache_update must be used in pkg_post* phases.";
  5118. fi;
  5119. if ! type gtk-update-icon-cache &> /dev/null; then
  5120. debug-print "gtk-update-icon-cache is not found";
  5121. return;
  5122. fi;
  5123. ebegin "Updating icons cache";
  5124. local dir f retval=0;
  5125. local fails=();
  5126. for dir in "${EROOT%/}"/usr/share/icons/*;
  5127. do
  5128. if [[ -f "${dir}/index.theme" ]]; then
  5129. local rv=0;
  5130. gtk-update-icon-cache -qf "${dir}";
  5131. rv=$?;
  5132. if [[ ! $rv -eq 0 ]]; then
  5133. debug-print "Updating cache failed on ${dir}";
  5134. fails+=("${dir}");
  5135. retval=2;
  5136. fi;
  5137. else
  5138. if [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
  5139. rm "${dir}/icon-theme.cache";
  5140. fi;
  5141. fi;
  5142. if [[ -z $(ls "${dir}") ]]; then
  5143. rmdir "${dir}";
  5144. fi;
  5145. done;
  5146. eend ${retval};
  5147. for f in "${fails[@]}";
  5148. do
  5149. eerror "Failed to update cache with icon $f";
  5150. done
  5151. }
  5152. xdg_mimeinfo_database_update ()
  5153. {
  5154. if [[ ${EBUILD_PHASE} != post* ]]; then
  5155. die "xdg_mimeinfo_database_update must be used in pkg_post* phases.";
  5156. fi;
  5157. if ! type update-mime-database &> /dev/null; then
  5158. debug-print "update-mime-database is not found";
  5159. return;
  5160. fi;
  5161. ebegin "Updating shared mime info database";
  5162. update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}";
  5163. eend $?
  5164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement