spacepaste

  1.  
  2. declare -x ABI="arm64"
  3. declare -x ABI_MIPS=""
  4. declare -x ABI_PPC=""
  5. declare -x ABI_S390=""
  6. declare -x ABI_X86=""
  7. declare -x ALSA_CARDS=""
  8. declare -x APACHE2_MODULES=""
  9. declare -x APACHE2_MPMS=""
  10. declare -x ARCH="arm64"
  11. declare BDEPEND=""
  12. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  13. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  14. declare -x CALLIGRA_FEATURES=""
  15. declare -x CAMERAS=""
  16. declare -x CBUILD="aarch64-unknown-linux-gnu"
  17. declare -x CFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error -ggdb "
  18. declare -x CFLAGS_default
  19. declare -x CHOST="aarch64-unknown-linux-gnu"
  20. declare -x CHOST_arm64="aarch64-unknown-linux-gnu"
  21. declare -x CHOST_default="aarch64-unknown-linux-gnu"
  22. declare -x COLLECTD_PLUGINS=""
  23. declare -x CPU_FLAGS_ARM=""
  24. declare -x CPU_FLAGS_X86=""
  25. declare -x CTARGET_default="aarch64-unknown-linux-gnu"
  26. declare -x CURL_SSL=""
  27. declare -x CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a53 -ftree-vectorize -O2 -pipe -fomit-frame-pointer -Wno-error -ggdb "
  28. declare -x DCC_EMAILLOG_WHOM_TO_BLAME=""
  29. declare -x DEFAULT_ABI="arm64"
  30. declare -x DEFINED_PHASES=" compile install prepare setup test"
  31. declare DEPEND="!gcrypt? (
  32. !libressl? ( dev-libs/openssl:0 )
  33. libressl? ( dev-libs/libressl )
  34. )
  35. gcrypt? ( dev-libs/libgcrypt:0 )
  36. dev-libs/libnl:3
  37. net-wireless/wireless-regdb
  38. || ( >=dev-lang/python-2.7.5-r2:2.7 )
  39. || ( ( >=dev-lang/python-2.7.5-r2:2.7 dev-python/m2crypto[python_targets_python2_7(-),python_single_target_python2_7(+)] ) )
  40. virtual/pkgconfig virtual/pkgconfig"
  41. declare DESCRIPTION="Central Regulatory Domain Agent for wireless networks"
  42. declare -x DESTTREE="/usr"
  43. declare -x DIROPTIONS="-m0755"
  44. declare -x EAPI="5"
  45. declare -x ELIBC="glibc"
  46. declare -x ENLIGHTENMENT_MODULES=""
  47. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  48. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  49. declare -- EPATCH_EXCLUDE=""
  50. declare -- EPATCH_FORCE="no"
  51. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  52. declare -- EPATCH_N_APPLIED_PATCHES="5"
  53. declare -- EPATCH_OPTS=""
  54. declare -- EPATCH_SINGLE_MSG=""
  55. declare -- EPATCH_SOURCE="/var/tmp/portage/net-wireless/crda-3.18-r1/work/patch"
  56. declare -- EPATCH_SUFFIX="patch.bz2"
  57. declare -- EPATCH_USER_SOURCE="/etc/portage/patches"
  58. declare -x EPYTHON="python2.7"
  59. declare -x EVCS_OFFLINE="1"
  60. declare -x EXEOPTIONS="-m0755"
  61. declare -x FCFLAGS="-O2"
  62. 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}\""
  63. declare -x FFLAGS="-O2"
  64. declare -x FFTOOLS=""
  65. declare -x GCC_SPECS=""
  66. declare -x GENTOO_WS="/home/Necktwi/Workspace/Gentoo/"
  67. declare -x GPSD_PROTOCOLS=""
  68. declare -x GRUB_PLATFORMS=""
  69. declare HDEPEND=""
  70. declare HOMEPAGE="https://wireless.wiki.kernel.org/en/developers/regulatory/crda"
  71. declare -x INCLUDE_SERVER_DIR="/tmp/distcc-pump.UupIzq"
  72. declare -x INCLUDE_SERVER_PID="26685"
  73. declare -x INCLUDE_SERVER_PORT="/tmp/distcc-pump.UupIzq/socket"
  74. declare -x INHERITED=" desktop epatch estack toolchain-funcs multilib ltprune preserve-libs vcs-clean eutils python-utils-r1 python-any-r1 udev"
  75. declare -x INPUT_DEVICES=""
  76. declare -x INSDESTTREE=""
  77. declare -x INSOPTIONS="-m0644"
  78. declare IUSE="gcrypt libressl "
  79. declare -x IUSE_EFFECTIVE="alpha amd64 amd64-fbsd amd64-linux arm arm64 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 gcrypt hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux libressl m68k m68k-mint mips ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest s390 sh sparc sparc-solaris sparc64-solaris userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  80. declare -x IUSE_IMPLICIT="prefix prefix-chain prefix-guest"
  81. declare -x KERNEL="linux"
  82. declare -x KERNEL_ABI="arm64"
  83. declare -x KEYWORDS="alpha amd64 arm ~arm64 ia64 ~mips ppc ppc64 sparc x86"
  84. declare -x L10N=""
  85. declare -x LANG="en_US.utf8"
  86. declare -x LANGUAGE="en_US.utf8"
  87. declare -x LCD_DEVICES=""
  88. declare -x LC_ADDRESS="en_US.utf8"
  89. declare -x LC_ALL="en_US.utf8"
  90. declare -x LC_COLLATE="en_US.utf8"
  91. declare -x LC_CTYPE="en_US.utf8"
  92. declare -x LC_IDENTIFICATION="en_US.utf8"
  93. declare -x LC_MEASUREMENT="en_US.utf8"
  94. declare -x LC_MESSAGES="C"
  95. declare -x LC_MONETARY="en_US.utf8"
  96. declare -x LC_NAME="en_US.utf8"
  97. declare -x LC_NUMERIC="en_US.utf8"
  98. declare -x LC_PAPER="en_US.utf8"
  99. declare -x LC_TELEPHONE="en_US.utf8"
  100. declare -x LC_TIME="en_US.utf8"
  101. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  102. declare -x LDFLAGS_default
  103. declare -x LIBDIR_arm64="lib64"
  104. declare -x LIBDIR_default="lib"
  105. declare -x LIBOPTIONS="-m0644"
  106. declare -x LIBREOFFICE_EXTENSIONS=""
  107. declare -x LICENSE="ISC"
  108. declare -x LIRC_DEVICES=""
  109. declare -x LLVM_TARGETS=""
  110. declare -x MAIL="/var/mail/Necktwi"
  111. declare -x MAKEOPTS="-j9 -l4"
  112. declare -x MANPAGER="manpager"
  113. declare -x MONKEYD_PLUGINS=""
  114. declare -x MULTILIB_ABIS="arm64"
  115. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  116. 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"
  117. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  118. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  119. declare -x NETBEANS_MODULES=""
  120. declare -x NGINX_MODULES_HTTP=""
  121. declare -x NGINX_MODULES_MAIL=""
  122. declare -x NGINX_MODULES_STREAM=""
  123. declare -x OFED_DRIVERS=""
  124. declare -x OFFICE_IMPLEMENTATION=""
  125. declare -x OPENMPI_FABRICS=""
  126. declare -x OPENMPI_OFED_FEATURES=""
  127. declare -x OPENMPI_RM=""
  128. declare -x PATH="/var/tmp/portage/net-wireless/crda-3.18-r1/temp/python2.7/bin:/usr/lib64/distcc/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/aarch64-RPi3B-linux-musl/gcc-bin/8.2.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  129. declare PDEPEND=""
  130. declare -x PHP_TARGETS=""
  131. declare -x PKG_CONFIG_PATH="/var/tmp/portage/net-wireless/crda-3.18-r1/temp/python2.7/pkgconfig:/usr/lib/pkgconfig/"
  132. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  133. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  134. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  135. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/crda-3.18-r1/html")
  136. declare -a PORTAGE_DOSTRIP=([0]="/")
  137. declare -a PORTAGE_DOSTRIP_SKIP=()
  138. declare -x POSTGRES_TARGETS=""
  139. 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"
  140. declare -x PROPERTIES=""
  141. declare -x PYTHON="/usr/bin/python2.7"
  142. declare -x PYTHONDONTWRITEBYTECODE="1"
  143. declare -a PYTHON_COMPAT=([0]="python2_7")
  144. declare -- PYTHON_DEPS="|| ( >=dev-lang/python-2.7.5-r2:2.7 )"
  145. declare -x PYTHON_SINGLE_TARGET=""
  146. declare -x PYTHON_TARGETS=""
  147. declare -x QEMU_SOFTMMU_TARGETS=""
  148. declare -x QEMU_USER_TARGETS=""
  149. declare RDEPEND="!gcrypt? (
  150. !libressl? ( dev-libs/openssl:0 )
  151. libressl? ( dev-libs/libressl )
  152. )
  153. gcrypt? ( dev-libs/libgcrypt:0 )
  154. dev-libs/libnl:3
  155. net-wireless/wireless-regdb "
  156. declare REPOSITORY
  157. declare REQUIRED_USE=""
  158. declare -x RESTRICT=""
  159. 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}\""
  160. declare -x ROS_MESSAGES=""
  161. declare -x RUBY_TARGETS=""
  162. declare -x S="/var/tmp/portage/net-wireless/crda-3.18-r1/work/crda-3.18"
  163. declare -x SANDBOX_DEBUG="0"
  164. declare -x SANDBOX_DENY=""
  165. declare -x SANDBOX_PREDICT="/var/tmp/portage/net-wireless/crda-3.18-r1/homedir"
  166. declare -x SANDBOX_READ="/:/var/tmp"
  167. declare -x SANDBOX_VERBOSE="1"
  168. 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/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/lib/cf:/usr/lib/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/net-wireless/crda-3.18-r1/homedir/.bash_history:/var/tmp/portage/.distcc/"
  169. declare -x SANE_BACKENDS=""
  170. declare -x SHELL="/bin/bash"
  171. declare -x SLOT="0"
  172. declare SRC_URI="http://linuxwireless.org/download/crda/crda-3.18.tar.xz
  173. mirror://kernel/software/network/crda/crda-3.18.tar.xz"
  174. declare -x SSH_CLIENT="192.168.2.21 57809 22"
  175. declare -x SSH_CONNECTION="192.168.2.21 58333 192.168.2.23 22"
  176. declare -x SSH_TTY="/dev/pts/0"
  177. declare -x TMUX="/tmp/tmux-1000/default,1960,1"
  178. declare -x TMUX_PANE="%1"
  179. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  180. declare -x UNCACHED_ERR_FD=""
  181. declare -x USE="arm64 elibc_glibc kernel_linux libressl userland_GNU"
  182. declare -x USERLAND="GNU"
  183. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  184. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  185. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  186. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  187. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  188. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  189. declare -x UWSGI_PLUGINS=""
  190. declare -x VIDEO_CARDS=""
  191. declare -x VISUAL="emacs"
  192. declare -x VOICEMAIL_STORAGE=""
  193. declare -x XFCE_PLUGINS=""
  194. declare -x XTABLES_ADDONS=""
  195. declare -- _DESKTOP_ECLASS="1"
  196. declare -- _EPATCH_ECLASS="1"
  197. declare -- _ESTACK_ECLASS="1"
  198. declare -- _EUTILS_ECLASS="1"
  199. declare -x _E_DOCDESTTREE_=""
  200. declare -x _E_EXEDESTTREE_=""
  201. declare -- _LTPRUNE_ECLASS="1"
  202. declare -- _MULTILIB_ECLASS="1"
  203. declare -- _PRESERVE_LIBS_ECLASS="1"
  204. declare -a _PYTHON_ALL_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python2_7" [4]="python3_4" [5]="python3_5" [6]="python3_6" [7]="python3_7")
  205. declare -- _PYTHON_ANY_R1="1"
  206. declare -a _PYTHON_SUPPORTED_IMPLS=([0]="python2_7")
  207. declare -a _PYTHON_UNSUPPORTED_IMPLS=([0]="jython2_7" [1]="pypy" [2]="pypy3" [3]="python3_4" [4]="python3_5" [5]="python3_6" [6]="python3_7")
  208. declare -- _PYTHON_UTILS_R1="1"
  209. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  210. declare -- _UDEV_ECLASS="1"
  211. declare -x export
  212. declare -- phase_func
  213. PYTHON ()
  214. {
  215. 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"
  216. }
  217. __eapi6_src_install ()
  218. {
  219. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  220. emake DESTDIR="${D}" install;
  221. fi;
  222. einstalldocs
  223. }
  224. __eapi6_src_prepare ()
  225. {
  226. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  227. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  228. else
  229. if [[ -n ${PATCHES} ]]; then
  230. eapply ${PATCHES};
  231. fi;
  232. fi;
  233. eapply_user
  234. }
  235. _clang_fullversion ()
  236. {
  237. local ver="$1";
  238. shift;
  239. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  240. eval echo "$ver"
  241. }
  242. _emake ()
  243. {
  244. emake PREFIX="${EPREFIX}/usr" SBINDIR='$(PREFIX)/sbin/' LIBDIR='$(PREFIX)/'"$(get_libdir)" UDEV_RULE_DIR="$(get_udevdir)/rules.d" REG_BIN="${SYSROOT}"/usr/lib/crda/regulatory.bin USE_OPENSSL=$(usex gcrypt 0 1) CC="$(tc-getCC)" V=1 WERROR= "$@"
  245. }
  246. _epatch_draw_line ()
  247. {
  248. [[ -z $1 ]] && set "$(printf "%65s" '')";
  249. echo "${1//?/=}"
  250. }
  251. _gcc-install-dir ()
  252. {
  253. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  254. }
  255. _gcc-specs-directive_raw ()
  256. {
  257. local cc=$(tc-getCC);
  258. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  259. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  260. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  261. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  262. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  263. { spec=spec $0 }
  264. END { print spec }';
  265. return 0
  266. }
  267. _gcc-specs-exists ()
  268. {
  269. [[ -f $(_gcc-install-dir)/$1 ]]
  270. }
  271. _gcc_fullversion ()
  272. {
  273. local ver="$1";
  274. shift;
  275. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  276. eval echo "$ver"
  277. }
  278. _iconins ()
  279. {
  280. ( insopts -m 0644;
  281. local funcname=$1;
  282. shift;
  283. local size dir;
  284. local context=apps;
  285. local theme=hicolor;
  286. while [[ $# -gt 0 ]]; do
  287. case $1 in
  288. -s | --size)
  289. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  290. size=${2%%x*};
  291. else
  292. size=${2};
  293. fi;
  294. case ${size} in
  295. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  296. size=${size}x${size}
  297. ;;
  298. scalable)
  299. ;;
  300. *)
  301. eerror "${size} is an unsupported icon size!";
  302. exit 1
  303. ;;
  304. esac;
  305. shift 2
  306. ;;
  307. -t | --theme)
  308. theme=${2};
  309. shift 2
  310. ;;
  311. -c | --context)
  312. context=${2};
  313. shift 2
  314. ;;
  315. *)
  316. if [[ -z ${size} ]]; then
  317. insinto /usr/share/pixmaps;
  318. else
  319. insinto /usr/share/icons/${theme}/${size}/${context};
  320. fi;
  321. if [[ ${funcname} == doicon ]]; then
  322. if [[ -f $1 ]]; then
  323. doins "${1}";
  324. else
  325. if [[ -d $1 ]]; then
  326. shopt -s nullglob;
  327. doins "${1}"/*.{png,svg};
  328. shopt -u nullglob;
  329. else
  330. eerror "${1} is not a valid file/directory!";
  331. exit 1;
  332. fi;
  333. fi;
  334. else
  335. break;
  336. fi;
  337. shift 1
  338. ;;
  339. esac;
  340. done;
  341. if [[ ${funcname} == newicon ]]; then
  342. newins "$@";
  343. fi ) || die
  344. }
  345. _python_EPYTHON_supported ()
  346. {
  347. debug-print-function ${FUNCNAME} "${@}";
  348. local EPYTHON=${1};
  349. local i=${EPYTHON/./_};
  350. case "${i}" in
  351. python* | jython* | pypy*)
  352. ;;
  353. *)
  354. ewarn "Invalid EPYTHON: ${EPYTHON}";
  355. return 1
  356. ;;
  357. esac;
  358. if has "${i}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
  359. if python_is_installed "${i}"; then
  360. if declare -f python_check_deps > /dev/null; then
  361. local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  362. python_check_deps;
  363. return ${?};
  364. fi;
  365. return 0;
  366. fi;
  367. else
  368. if ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
  369. ewarn "Invalid EPYTHON: ${EPYTHON}";
  370. fi;
  371. fi;
  372. return 1
  373. }
  374. _python_check_dead_variables ()
  375. {
  376. local v;
  377. for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS;
  378. do
  379. if [[ -n ${!v} ]]; then
  380. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head";
  381. fi;
  382. done;
  383. for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS};
  384. do
  385. if [[ -n ${!v} ]]; then
  386. die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS";
  387. fi;
  388. done;
  389. for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES;
  390. do
  391. if [[ -n ${!v} ]]; then
  392. die "${v} is invalid for python-r1 suite";
  393. fi;
  394. done;
  395. for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME;
  396. do
  397. if [[ -n ${!v} ]]; then
  398. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}";
  399. fi;
  400. done;
  401. if [[ -n ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
  402. die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST";
  403. fi;
  404. for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS PYTHON_CFFI_MODULES_GENERATION_COMMANDS;
  405. do
  406. if [[ -n ${!v} ]]; then
  407. die "${v} is invalid for python-r1 suite";
  408. fi;
  409. done
  410. }
  411. _python_check_locale_sanity ()
  412. {
  413. local -x LC_ALL=${1};
  414. local IFS=;
  415. local lc=({a..z});
  416. local uc=({A..Z});
  417. local input="${lc[*]}${uc[*]}";
  418. local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}");
  419. [[ ${output} == "${uc[*]}${lc[*]}" ]]
  420. }
  421. _python_impl_matches ()
  422. {
  423. [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters";
  424. local impl=${1} pattern;
  425. shift;
  426. for pattern in "$@";
  427. do
  428. if [[ ${pattern} == -2 ]]; then
  429. ! python_is_python3 "${impl}";
  430. return;
  431. else
  432. if [[ ${pattern} == -3 ]]; then
  433. python_is_python3 "${impl}";
  434. return;
  435. else
  436. if [[ ${impl/./_} == ${pattern/./_} ]]; then
  437. return 0;
  438. fi;
  439. fi;
  440. fi;
  441. done;
  442. return 1
  443. }
  444. _python_impl_supported ()
  445. {
  446. debug-print-function ${FUNCNAME} "${@}";
  447. [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl).";
  448. local impl=${1};
  449. case "${impl}" in
  450. python2_7 | python3_[4567] | jython2_7)
  451. return 0
  452. ;;
  453. pypy1_[89] | pypy2_0 | python2_[56] | python3_[123])
  454. return 1
  455. ;;
  456. pypy | pypy3)
  457. if [[ ${EAPI:-0} == [01234] ]]; then
  458. die "PyPy is supported in EAPI 5 and newer only.";
  459. fi
  460. ;;
  461. *)
  462. [[ -n ${PYTHON_COMPAT_NO_STRICT} ]] && return 1;
  463. die "Invalid implementation in PYTHON_COMPAT: ${impl}"
  464. ;;
  465. esac
  466. }
  467. _python_ln_rel ()
  468. {
  469. debug-print-function ${FUNCNAME} "${@}";
  470. local target=${1};
  471. local symname=${2};
  472. local tgpath=${target%/*}/;
  473. local sympath=${symname%/*}/;
  474. local rel_target=;
  475. while [[ -n ${sympath} ]]; do
  476. local tgseg= symseg=;
  477. while [[ ! -n ${tgseg} && -n ${tgpath} ]]; do
  478. tgseg=${tgpath%%/*};
  479. tgpath=${tgpath#${tgseg}/};
  480. done;
  481. while [[ ! -n ${symseg} && -n ${sympath} ]]; do
  482. symseg=${sympath%%/*};
  483. sympath=${sympath#${symseg}/};
  484. done;
  485. if [[ ${tgseg} != ${symseg} ]]; then
  486. rel_target=../${rel_target}${tgseg:+${tgseg}/};
  487. fi;
  488. done;
  489. rel_target+=${tgpath}${target##*/};
  490. debug-print "${FUNCNAME}: ${symname} -> ${target}";
  491. debug-print "${FUNCNAME}: rel_target = ${rel_target}";
  492. ln -fs "${rel_target}" "${symname}"
  493. }
  494. _python_set_impls ()
  495. {
  496. local i;
  497. if ! declare -p PYTHON_COMPAT &> /dev/null; then
  498. die 'PYTHON_COMPAT not declared.';
  499. fi;
  500. if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
  501. die 'PYTHON_COMPAT must be an array.';
  502. fi;
  503. for i in "${PYTHON_COMPAT[@]}";
  504. do
  505. _python_impl_supported "${i}";
  506. done;
  507. local supp=() unsupp=();
  508. for i in "${_PYTHON_ALL_IMPLS[@]}";
  509. do
  510. if has "${i}" "${PYTHON_COMPAT[@]}"; then
  511. supp+=("${i}");
  512. else
  513. unsupp+=("${i}");
  514. fi;
  515. done;
  516. if [[ ! -n ${supp[@]} ]]; then
  517. die "No supported implementation in PYTHON_COMPAT.";
  518. fi;
  519. if [[ -n ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
  520. if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
  521. eerror "Supported impls (PYTHON_COMPAT) changed between inherits!";
  522. eerror "Before: ${_PYTHON_SUPPORTED_IMPLS[*]}";
  523. eerror "Now : ${supp[*]}";
  524. die "_PYTHON_SUPPORTED_IMPLS integrity check failed";
  525. fi;
  526. if [[ ${_PYTHON_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
  527. eerror "Unsupported impls changed between inherits!";
  528. eerror "Before: ${_PYTHON_UNSUPPORTED_IMPLS[*]}";
  529. eerror "Now : ${unsupp[*]}";
  530. die "_PYTHON_UNSUPPORTED_IMPLS integrity check failed";
  531. fi;
  532. else
  533. _PYTHON_SUPPORTED_IMPLS=("${supp[@]}");
  534. _PYTHON_UNSUPPORTED_IMPLS=("${unsupp[@]}");
  535. readonly _PYTHON_SUPPORTED_IMPLS _PYTHON_UNSUPPORTED_IMPLS;
  536. fi
  537. }
  538. _tc-getPROG ()
  539. {
  540. local tuple=$1;
  541. local v var vars=$2;
  542. local prog=($3);
  543. var=${vars%% *};
  544. for v in ${vars};
  545. do
  546. if [[ -n ${!v} ]]; then
  547. export ${var}="${!v}";
  548. echo "${!v}";
  549. return 0;
  550. fi;
  551. done;
  552. local search=;
  553. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  554. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  555. [[ -n ${search} ]] && prog[0]=${search##*/};
  556. export ${var}="${prog[*]}";
  557. echo "${!var}"
  558. }
  559. _udev_get_udevdir ()
  560. {
  561. if $($(tc-getPKG_CONFIG) --exists udev); then
  562. local udevdir="$($(tc-getPKG_CONFIG) --variable=udevdir udev)";
  563. echo "${udevdir#${EPREFIX%/}}";
  564. else
  565. echo /lib/udev;
  566. fi
  567. }
  568. clang-fullversion ()
  569. {
  570. _clang_fullversion '$1.$2.$3' "$@"
  571. }
  572. clang-major-version ()
  573. {
  574. _clang_fullversion '$1' "$@"
  575. }
  576. clang-micro-version ()
  577. {
  578. _clang_fullversion '$3' "$@"
  579. }
  580. clang-minor-version ()
  581. {
  582. _clang_fullversion '$2' "$@"
  583. }
  584. clang-version ()
  585. {
  586. _clang_fullversion '$1.$2' "$@"
  587. }
  588. doicon ()
  589. {
  590. _iconins ${FUNCNAME} "$@"
  591. }
  592. domenu ()
  593. {
  594. ( local i ret=0;
  595. insopts -m 0644;
  596. insinto /usr/share/applications;
  597. for i in "$@";
  598. do
  599. if [[ -d ${i} ]]; then
  600. doins "${i}"/*.desktop;
  601. ((ret|=$?));
  602. else
  603. doins "${i}";
  604. ((ret|=$?));
  605. fi;
  606. done;
  607. exit ${ret} )
  608. }
  609. ebeep ()
  610. {
  611. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  612. }
  613. econf_build ()
  614. {
  615. local CBUILD=${CBUILD:-${CHOST}};
  616. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  617. }
  618. ecvs_clean ()
  619. {
  620. [[ $# -eq 0 ]] && set -- .;
  621. find "$@" '(' -type d -name 'CVS' -prune -o -type f -name '.cvs*' ')' -exec rm -rf '{}' +
  622. }
  623. edos2unix ()
  624. {
  625. [[ $# -eq 0 ]] && return 0;
  626. sed -i 's/\r$//' -- "$@" || die
  627. }
  628. egit_clean ()
  629. {
  630. [[ $# -eq 0 ]] && set -- .;
  631. find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' +
  632. }
  633. einstalldocs ()
  634. {
  635. debug-print-function ${FUNCNAME} "${@}";
  636. local dodoc_opts=-r;
  637. has ${EAPI} 0 1 2 3 && dodoc_opts=;
  638. if ! declare -p DOCS &> /dev/null; then
  639. local d;
  640. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  641. do
  642. if [[ -s ${d} ]]; then
  643. dodoc "${d}" || die;
  644. fi;
  645. done;
  646. else
  647. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  648. if [[ -n ${DOCS[@]} ]]; then
  649. dodoc ${dodoc_opts} "${DOCS[@]}" || die;
  650. fi;
  651. else
  652. if [[ -n ${DOCS} ]]; then
  653. dodoc ${dodoc_opts} ${DOCS} || die;
  654. fi;
  655. fi;
  656. fi;
  657. if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  658. if [[ -n ${HTML_DOCS[@]} ]]; then
  659. dohtml -r "${HTML_DOCS[@]}" || die;
  660. fi;
  661. else
  662. if [[ -n ${HTML_DOCS} ]]; then
  663. dohtml -r ${HTML_DOCS} || die;
  664. fi;
  665. fi;
  666. return 0
  667. }
  668. emktemp ()
  669. {
  670. local exe="touch";
  671. [[ $1 == -d ]] && exe="mkdir" && shift;
  672. local topdir=$1;
  673. if [[ -z ${topdir} ]]; then
  674. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  675. fi;
  676. if ! type -P mktemp > /dev/null; then
  677. local tmp=/;
  678. while [[ -e ${tmp} ]]; do
  679. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  680. done;
  681. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  682. echo "${tmp}";
  683. else
  684. if [[ ${exe} == "touch" ]]; then
  685. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  686. else
  687. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  688. fi;
  689. fi
  690. }
  691. epatch ()
  692. {
  693. function _epatch_draw_line ()
  694. {
  695. [[ -z $1 ]] && set "$(printf "%65s" '')";
  696. echo "${1//?/=}"
  697. };
  698. unset P4CONFIG P4PORT P4USER;
  699. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  700. while [[ $# -gt 0 ]]; do
  701. case $1 in
  702. -*)
  703. EPATCH_OPTS+=("$1")
  704. ;;
  705. *)
  706. break
  707. ;;
  708. esac;
  709. shift;
  710. done;
  711. if [[ $# -gt 1 ]]; then
  712. local m;
  713. for m in "$@";
  714. do
  715. epatch "${m}";
  716. done;
  717. return 0;
  718. fi;
  719. local SINGLE_PATCH="no";
  720. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  721. if [[ -f $1 ]]; then
  722. SINGLE_PATCH="yes";
  723. set -- "$1";
  724. local EPATCH_SUFFIX=$1;
  725. else
  726. if [[ -d $1 ]]; then
  727. evar_push_set LC_COLLATE C;
  728. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  729. evar_pop;
  730. else
  731. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  732. epatch "${EPATCH_SOURCE}/$1";
  733. return $?;
  734. else
  735. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  736. echo;
  737. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  738. eerror;
  739. eerror " ${EPATCH_SOURCE}";
  740. eerror " ( ${EPATCH_SOURCE##*/} )";
  741. echo;
  742. die "Cannot find \$EPATCH_SOURCE!";
  743. fi;
  744. fi;
  745. fi;
  746. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  747. local PIPE_CMD;
  748. case ${EPATCH_SUFFIX##*\.} in
  749. xz)
  750. PIPE_CMD="xz -dc"
  751. ;;
  752. lzma)
  753. PIPE_CMD="lzma -dc"
  754. ;;
  755. bz2)
  756. PIPE_CMD="bzip2 -dc"
  757. ;;
  758. gz | Z | z)
  759. PIPE_CMD="gzip -dc"
  760. ;;
  761. ZIP | zip)
  762. PIPE_CMD="unzip -p"
  763. ;;
  764. *)
  765. ;;
  766. esac;
  767. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  768. local x;
  769. for x in "$@";
  770. do
  771. [[ ! -f ${x} ]] && continue;
  772. local patchname=${x##*/};
  773. local a=${patchname#*_};
  774. a=${a%%_*};
  775. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  776. continue;
  777. fi;
  778. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  779. local prev_noglob=$(shopt -p -o noglob);
  780. set -o noglob;
  781. local ex;
  782. for ex in ${EPATCH_EXCLUDE};
  783. do
  784. if [[ ${patchname} == ${ex} ]]; then
  785. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  786. ${prev_noglob};
  787. continue 2;
  788. fi;
  789. done;
  790. for ex in ${EPATCH_USER_EXCLUDE};
  791. do
  792. if [[ ${patchname} == ${ex} ]]; then
  793. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  794. ${prev_noglob};
  795. continue 2;
  796. fi;
  797. done;
  798. ${prev_noglob};
  799. fi;
  800. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  801. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  802. einfo "${EPATCH_SINGLE_MSG}";
  803. else
  804. einfo "Applying ${patchname} ...";
  805. fi;
  806. else
  807. einfo " ${patchname} ...";
  808. fi;
  809. local patch="patch";
  810. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  811. local STDERR_TARGET="${T}/${patchname}.out";
  812. if [[ -e ${STDERR_TARGET} ]]; then
  813. STDERR_TARGET="${T}/${patchname}-$$.out";
  814. fi;
  815. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  816. local count=0;
  817. local PATCH_TARGET;
  818. if [[ -n ${PIPE_CMD} ]]; then
  819. PATCH_TARGET="${T}/$$.patch";
  820. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  821. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  822. echo;
  823. eerror "Could not extract patch!";
  824. count=5;
  825. break;
  826. fi;
  827. else
  828. PATCH_TARGET=${x};
  829. fi;
  830. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  831. if [[ -n ${abs_paths} ]]; then
  832. count=1;
  833. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  834. fi;
  835. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  836. if [[ -n ${rel_paths} ]]; then
  837. echo;
  838. eerror "Rejected Patch: ${patchname} !";
  839. eerror " ( ${PATCH_TARGET} )";
  840. eerror;
  841. eerror "Your patch uses relative paths '../':";
  842. eerror "${rel_paths}";
  843. echo;
  844. die "you need to fix the relative paths in patch";
  845. fi;
  846. local patch_cmd;
  847. while [[ ${count} -lt 5 ]]; do
  848. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  849. ( _epatch_draw_line "***** ${patchname} *****";
  850. echo;
  851. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  852. echo;
  853. _epatch_draw_line "***** ${patchname} *****";
  854. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  855. ret=$?;
  856. echo;
  857. echo "patch program exited with status ${ret}";
  858. exit ${ret} ) >> "${STDERR_TARGET}";
  859. if [ $? -eq 0 ]; then
  860. ( _epatch_draw_line "***** ${patchname} *****";
  861. echo;
  862. echo "ACTUALLY APPLYING ${patchname} ...";
  863. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  864. echo;
  865. _epatch_draw_line "***** ${patchname} *****";
  866. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  867. ret=$?;
  868. echo;
  869. echo "patch program exited with status ${ret}";
  870. exit ${ret} ) >> "${STDERR_TARGET}";
  871. if [ $? -ne 0 ]; then
  872. echo;
  873. eerror "A dry-run of patch command succeeded, but actually";
  874. eerror "applying the patch failed!";
  875. count=5;
  876. fi;
  877. break;
  878. fi;
  879. : $(( count++ ));
  880. done;
  881. (( EPATCH_N_APPLIED_PATCHES++ ));
  882. if [[ -n ${PIPE_CMD} ]]; then
  883. rm -f "${PATCH_TARGET}";
  884. fi;
  885. if [[ ${count} -ge 5 ]]; then
  886. echo;
  887. eerror "Failed Patch: ${patchname} !";
  888. eerror " ( ${PATCH_TARGET} )";
  889. eerror;
  890. eerror "Include in your bugreport the contents of:";
  891. eerror;
  892. eerror " ${STDERR_TARGET}";
  893. echo;
  894. die "Failed Patch: ${patchname}!";
  895. fi;
  896. rm -f "${STDERR_TARGET}";
  897. cat >> "${T}/epatch.log" <<-EOF
  898. PATCH: ${x}
  899. CMD: ${patch_cmd}
  900. PWD: ${PWD}
  901. EOF
  902. eend 0;
  903. done;
  904. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  905. :
  906. }
  907. epatch_user ()
  908. {
  909. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  910. local applied="${T}/epatch_user.log";
  911. [[ -e ${applied} ]] && return 2;
  912. local EPATCH_SOURCE check;
  913. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT%/*}};
  914. do
  915. EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CTARGET}/${check};
  916. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${CHOST}/${check};
  917. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${EPATCH_USER_SOURCE}/${check};
  918. if [[ -d ${EPATCH_SOURCE} ]]; then
  919. local old_n_applied_patches=${EPATCH_N_APPLIED_PATCHES:-0};
  920. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  921. echo "${EPATCH_SOURCE}" > "${applied}";
  922. if [[ ${old_n_applied_patches} -lt ${EPATCH_N_APPLIED_PATCHES} ]]; then
  923. has epatch_user_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" epatch_user_death_notice";
  924. fi;
  925. return 0;
  926. fi;
  927. done;
  928. echo "none" > "${applied}";
  929. return 1
  930. }
  931. epatch_user_death_notice ()
  932. {
  933. ewarn "!!! User patches were applied to this build!"
  934. }
  935. epause ()
  936. {
  937. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  938. }
  939. eshopts_pop ()
  940. {
  941. local s;
  942. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  943. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  944. }
  945. eshopts_push ()
  946. {
  947. if [[ $1 == -[su] ]]; then
  948. estack_push eshopts "$(shopt -p)";
  949. [[ $# -eq 0 ]] && return 0;
  950. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  951. else
  952. estack_push eshopts "$(shopt -p -o)";
  953. [[ $# -eq 0 ]] && return 0;
  954. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  955. fi
  956. }
  957. estack_pop ()
  958. {
  959. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  960. local _estack_name="_ESTACK_$1_";
  961. shift;
  962. local _estack_retvar=$1;
  963. shift;
  964. eval local _estack_i=\${#${_estack_name}\[@\]};
  965. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  966. if [[ -n ${_estack_retvar} ]]; then
  967. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  968. fi;
  969. eval unset \"${_estack_name}\[${_estack_i}\]\"
  970. }
  971. estack_push ()
  972. {
  973. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  974. local stack_name="_ESTACK_$1_";
  975. shift;
  976. eval ${stack_name}+=\( \"\$@\" \)
  977. }
  978. esvn_clean ()
  979. {
  980. [[ $# -eq 0 ]] && set -- .;
  981. find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' +
  982. }
  983. eumask_pop ()
  984. {
  985. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  986. local s;
  987. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  988. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  989. }
  990. eumask_push ()
  991. {
  992. estack_push eumask "$(umask)";
  993. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  994. }
  995. evar_pop ()
  996. {
  997. local cnt=${1:-bad};
  998. case $# in
  999. 0)
  1000. cnt=1
  1001. ;;
  1002. 1)
  1003. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  1004. ;;
  1005. *)
  1006. die "${FUNCNAME}: only accepts one arg: $*"
  1007. ;;
  1008. esac;
  1009. local var val;
  1010. while (( cnt-- )); do
  1011. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1012. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1013. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1014. done
  1015. }
  1016. evar_push ()
  1017. {
  1018. local var val;
  1019. for var in "$@";
  1020. do
  1021. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1022. estack_push evar "${var}" "${val}";
  1023. done
  1024. }
  1025. evar_push_set ()
  1026. {
  1027. local var=$1;
  1028. evar_push ${var};
  1029. case $# in
  1030. 1)
  1031. unset ${var}
  1032. ;;
  1033. 2)
  1034. printf -v "${var}" '%s' "$2"
  1035. ;;
  1036. *)
  1037. die "${FUNCNAME}: incorrect # of args: $*"
  1038. ;;
  1039. esac
  1040. }
  1041. gcc-fullversion ()
  1042. {
  1043. _gcc_fullversion '$1.$2.$3' "$@"
  1044. }
  1045. gcc-major-version ()
  1046. {
  1047. _gcc_fullversion '$1' "$@"
  1048. }
  1049. gcc-micro-version ()
  1050. {
  1051. _gcc_fullversion '$3' "$@"
  1052. }
  1053. gcc-minor-version ()
  1054. {
  1055. _gcc_fullversion '$2' "$@"
  1056. }
  1057. gcc-specs-directive ()
  1058. {
  1059. local directive subdname subdirective;
  1060. directive="$(_gcc-specs-directive_raw $1)";
  1061. while [[ ${directive} == *%\(*\)* ]]; do
  1062. subdname=${directive/*%\(};
  1063. subdname=${subdname/\)*};
  1064. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1065. directive="${directive//\%(${subdname})/${subdirective}}";
  1066. done;
  1067. echo "${directive}";
  1068. return 0
  1069. }
  1070. gcc-specs-nostrict ()
  1071. {
  1072. local directive;
  1073. directive=$(gcc-specs-directive cc1);
  1074. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  1075. }
  1076. gcc-specs-now ()
  1077. {
  1078. local directive;
  1079. directive=$(gcc-specs-directive link_command);
  1080. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  1081. }
  1082. gcc-specs-pie ()
  1083. {
  1084. local directive;
  1085. directive=$(gcc-specs-directive cc1);
  1086. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  1087. }
  1088. gcc-specs-relro ()
  1089. {
  1090. local directive;
  1091. directive=$(gcc-specs-directive link_command);
  1092. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  1093. }
  1094. gcc-specs-ssp ()
  1095. {
  1096. local directive;
  1097. directive=$(gcc-specs-directive cc1);
  1098. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  1099. }
  1100. gcc-specs-ssp-to-all ()
  1101. {
  1102. local directive;
  1103. directive=$(gcc-specs-directive cc1);
  1104. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  1105. }
  1106. gcc-specs-stack-check ()
  1107. {
  1108. local directive;
  1109. directive=$(gcc-specs-directive cc1);
  1110. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  1111. }
  1112. gcc-version ()
  1113. {
  1114. _gcc_fullversion '$1.$2' "$@"
  1115. }
  1116. gen_usr_ldscript ()
  1117. {
  1118. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1119. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1120. tc-is-static-only && return;
  1121. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  1122. multilib_is_native_abi || return 0;
  1123. fi;
  1124. case ${CTARGET:-${CHOST}} in
  1125. *-darwin*)
  1126. ;;
  1127. *-android*)
  1128. return 0
  1129. ;;
  1130. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1131. use prefix && return 0
  1132. ;;
  1133. *)
  1134. return 0
  1135. ;;
  1136. esac;
  1137. dodir /usr/${libdir};
  1138. if [[ $1 == "-a" ]]; then
  1139. auto=true;
  1140. shift;
  1141. dodir /${libdir};
  1142. fi;
  1143. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1144. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1145. local d="${T}/bfd-linker";
  1146. mkdir -p "${d}";
  1147. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1148. flags+=(-B"${d}");
  1149. fi;
  1150. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1151. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1152. for lib in "$@";
  1153. do
  1154. local tlib;
  1155. if ${auto}; then
  1156. lib="lib${lib}${suffix}";
  1157. else
  1158. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1159. fi;
  1160. case ${CTARGET:-${CHOST}} in
  1161. *-darwin*)
  1162. if ${auto}; then
  1163. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1164. else
  1165. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1166. fi;
  1167. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1168. tlib=${tlib##*/};
  1169. if ${auto}; then
  1170. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1171. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1172. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1173. fi;
  1174. rm -f "${ED}"/${libdir}/${lib};
  1175. fi;
  1176. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1177. chmod u+w "${ED}${libdir}/${tlib}";
  1178. local nowrite=yes;
  1179. fi;
  1180. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1181. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1182. pushd "${ED}/usr/${libdir}" > /dev/null;
  1183. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1184. popd > /dev/null
  1185. ;;
  1186. *)
  1187. if ${auto}; then
  1188. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1189. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1190. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1191. if [[ ${tlib} != ${lib}* ]]; then
  1192. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1193. fi;
  1194. rm -f "${ED}"/${libdir}/${lib};
  1195. else
  1196. tlib=${lib};
  1197. fi;
  1198. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1199. /* GNU ld script
  1200. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1201. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1202. run into linking problems. This "fake" dynamic lib is a linker script that
  1203. redirects the linker to the real lib. And yes, this works in the cross-
  1204. compiling scenario as the sysroot-ed linker will prepend the real path.
  1205. See bug https://bugs.gentoo.org/4411 for more info.
  1206. */
  1207. ${output_format}
  1208. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1209. END_LDSCRIPT
  1210. ;;
  1211. esac
  1212. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1213. done
  1214. }
  1215. get_abi_CFLAGS ()
  1216. {
  1217. get_abi_var CFLAGS "$@"
  1218. }
  1219. get_abi_CHOST ()
  1220. {
  1221. get_abi_var CHOST "$@"
  1222. }
  1223. get_abi_CTARGET ()
  1224. {
  1225. get_abi_var CTARGET "$@"
  1226. }
  1227. get_abi_FAKE_TARGETS ()
  1228. {
  1229. get_abi_var FAKE_TARGETS "$@"
  1230. }
  1231. get_abi_LDFLAGS ()
  1232. {
  1233. get_abi_var LDFLAGS "$@"
  1234. }
  1235. get_abi_LIBDIR ()
  1236. {
  1237. get_abi_var LIBDIR "$@"
  1238. }
  1239. get_abi_var ()
  1240. {
  1241. local flag=$1;
  1242. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1243. local var="${flag}_${abi}";
  1244. echo ${!var}
  1245. }
  1246. get_all_abis ()
  1247. {
  1248. local x order="" mvar dvar;
  1249. mvar="MULTILIB_ABIS";
  1250. dvar="DEFAULT_ABI";
  1251. if [[ -n $1 ]]; then
  1252. mvar="$1_${mvar}";
  1253. dvar="$1_${dvar}";
  1254. fi;
  1255. if [[ -z ${!mvar} ]]; then
  1256. echo "default";
  1257. return 0;
  1258. fi;
  1259. for x in ${!mvar};
  1260. do
  1261. if [[ ${x} != ${!dvar} ]]; then
  1262. order="${order:+${order} }${x}";
  1263. fi;
  1264. done;
  1265. order="${order:+${order} }${!dvar}";
  1266. echo ${order};
  1267. return 0
  1268. }
  1269. get_all_libdirs ()
  1270. {
  1271. local libdirs abi;
  1272. for abi in ${MULTILIB_ABIS};
  1273. do
  1274. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1275. done;
  1276. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1277. echo "${libdirs}"
  1278. }
  1279. get_exeext ()
  1280. {
  1281. case ${CHOST} in
  1282. *-cygwin* | mingw* | *-mingw*)
  1283. echo ".exe"
  1284. ;;
  1285. esac
  1286. }
  1287. get_install_abis ()
  1288. {
  1289. local x order="";
  1290. if [[ -z ${MULTILIB_ABIS} ]]; then
  1291. echo "default";
  1292. return 0;
  1293. fi;
  1294. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1295. for x in ${MULTILIB_ABIS};
  1296. do
  1297. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1298. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1299. fi;
  1300. done;
  1301. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1302. if [[ -n ${ABI_ALLOW} ]]; then
  1303. local ordera="";
  1304. for x in ${order};
  1305. do
  1306. if has ${x} ${ABI_ALLOW}; then
  1307. ordera="${ordera} ${x}";
  1308. fi;
  1309. done;
  1310. order=${ordera};
  1311. fi;
  1312. else
  1313. order=${DEFAULT_ABI};
  1314. fi;
  1315. if [[ -z ${order} ]]; then
  1316. 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.";
  1317. fi;
  1318. echo ${order};
  1319. return 0
  1320. }
  1321. get_libdir ()
  1322. {
  1323. local CONF_LIBDIR;
  1324. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1325. echo ${CONF_LIBDIR_OVERRIDE};
  1326. else
  1327. get_abi_LIBDIR;
  1328. fi
  1329. }
  1330. get_libname ()
  1331. {
  1332. local libname;
  1333. local ver=$1;
  1334. case ${CHOST} in
  1335. *-cygwin*)
  1336. libname="dll.a"
  1337. ;;
  1338. mingw* | *-mingw*)
  1339. libname="dll"
  1340. ;;
  1341. *-darwin*)
  1342. libname="dylib"
  1343. ;;
  1344. *-mint*)
  1345. libname="irrelevant"
  1346. ;;
  1347. hppa*-hpux*)
  1348. libname="sl"
  1349. ;;
  1350. *)
  1351. libname="so"
  1352. ;;
  1353. esac;
  1354. if [[ -z $* ]]; then
  1355. echo ".${libname}";
  1356. else
  1357. for ver in "$@";
  1358. do
  1359. case ${CHOST} in
  1360. *-cygwin*)
  1361. echo ".${ver}.${libname}"
  1362. ;;
  1363. *-darwin*)
  1364. echo ".${ver}.${libname}"
  1365. ;;
  1366. *-mint*)
  1367. echo ".${libname}"
  1368. ;;
  1369. *)
  1370. echo ".${libname}.${ver}"
  1371. ;;
  1372. esac;
  1373. done;
  1374. fi
  1375. }
  1376. get_modname ()
  1377. {
  1378. local modname;
  1379. local ver=$1;
  1380. case ${CHOST} in
  1381. *-darwin*)
  1382. modname="bundle"
  1383. ;;
  1384. *)
  1385. modname="so"
  1386. ;;
  1387. esac;
  1388. echo ".${modname}"
  1389. }
  1390. get_udevdir ()
  1391. {
  1392. debug-print-function ${FUNCNAME} "${@}";
  1393. echo "$(_udev_get_udevdir)"
  1394. }
  1395. has_multilib_profile ()
  1396. {
  1397. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1398. }
  1399. in_iuse ()
  1400. {
  1401. debug-print-function ${FUNCNAME} "${@}";
  1402. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  1403. local flag=${1};
  1404. local liuse=(${IUSE});
  1405. has "${flag}" "${liuse[@]#[+-]}"
  1406. }
  1407. is_final_abi ()
  1408. {
  1409. has_multilib_profile || return 0;
  1410. set -- $(get_install_abis);
  1411. local LAST_ABI=$#;
  1412. [[ ${!LAST_ABI} == ${ABI} ]]
  1413. }
  1414. isdigit ()
  1415. {
  1416. local d;
  1417. for d in "$@";
  1418. do
  1419. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  1420. done;
  1421. return 0
  1422. }
  1423. make_desktop_entry ()
  1424. {
  1425. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  1426. local exec=${1};
  1427. local name=${2:-${PN}};
  1428. local icon=${3:-${PN}};
  1429. local type=${4};
  1430. local fields=${5};
  1431. if [[ -z ${type} ]]; then
  1432. local catmaj=${CATEGORY%%-*};
  1433. local catmin=${CATEGORY##*-};
  1434. case ${catmaj} in
  1435. app)
  1436. case ${catmin} in
  1437. accessibility)
  1438. type="Utility;Accessibility"
  1439. ;;
  1440. admin)
  1441. type=System
  1442. ;;
  1443. antivirus)
  1444. type=System
  1445. ;;
  1446. arch)
  1447. type="Utility;Archiving"
  1448. ;;
  1449. backup)
  1450. type="Utility;Archiving"
  1451. ;;
  1452. cdr)
  1453. type="AudioVideo;DiscBurning"
  1454. ;;
  1455. dicts)
  1456. type="Office;Dictionary"
  1457. ;;
  1458. doc)
  1459. type=Documentation
  1460. ;;
  1461. editors)
  1462. type="Utility;TextEditor"
  1463. ;;
  1464. emacs)
  1465. type="Development;TextEditor"
  1466. ;;
  1467. emulation)
  1468. type="System;Emulator"
  1469. ;;
  1470. laptop)
  1471. type="Settings;HardwareSettings"
  1472. ;;
  1473. office)
  1474. type=Office
  1475. ;;
  1476. pda)
  1477. type="Office;PDA"
  1478. ;;
  1479. vim)
  1480. type="Development;TextEditor"
  1481. ;;
  1482. xemacs)
  1483. type="Development;TextEditor"
  1484. ;;
  1485. esac
  1486. ;;
  1487. dev)
  1488. type="Development"
  1489. ;;
  1490. games)
  1491. case ${catmin} in
  1492. action | fps)
  1493. type=ActionGame
  1494. ;;
  1495. arcade)
  1496. type=ArcadeGame
  1497. ;;
  1498. board)
  1499. type=BoardGame
  1500. ;;
  1501. emulation)
  1502. type=Emulator
  1503. ;;
  1504. kids)
  1505. type=KidsGame
  1506. ;;
  1507. puzzle)
  1508. type=LogicGame
  1509. ;;
  1510. roguelike)
  1511. type=RolePlaying
  1512. ;;
  1513. rpg)
  1514. type=RolePlaying
  1515. ;;
  1516. simulation)
  1517. type=Simulation
  1518. ;;
  1519. sports)
  1520. type=SportsGame
  1521. ;;
  1522. strategy)
  1523. type=StrategyGame
  1524. ;;
  1525. esac;
  1526. type="Game;${type}"
  1527. ;;
  1528. gnome)
  1529. type="Gnome;GTK"
  1530. ;;
  1531. kde)
  1532. type="KDE;Qt"
  1533. ;;
  1534. mail)
  1535. type="Network;Email"
  1536. ;;
  1537. media)
  1538. case ${catmin} in
  1539. gfx)
  1540. type=Graphics
  1541. ;;
  1542. *)
  1543. case ${catmin} in
  1544. radio)
  1545. type=Tuner
  1546. ;;
  1547. sound)
  1548. type=Audio
  1549. ;;
  1550. tv)
  1551. type=TV
  1552. ;;
  1553. video)
  1554. type=Video
  1555. ;;
  1556. esac;
  1557. type="AudioVideo;${type}"
  1558. ;;
  1559. esac
  1560. ;;
  1561. net)
  1562. case ${catmin} in
  1563. dialup)
  1564. type=Dialup
  1565. ;;
  1566. ftp)
  1567. type=FileTransfer
  1568. ;;
  1569. im)
  1570. type=InstantMessaging
  1571. ;;
  1572. irc)
  1573. type=IRCClient
  1574. ;;
  1575. mail)
  1576. type=Email
  1577. ;;
  1578. news)
  1579. type=News
  1580. ;;
  1581. nntp)
  1582. type=News
  1583. ;;
  1584. p2p)
  1585. type=FileTransfer
  1586. ;;
  1587. voip)
  1588. type=Telephony
  1589. ;;
  1590. esac;
  1591. type="Network;${type}"
  1592. ;;
  1593. sci)
  1594. case ${catmin} in
  1595. astro*)
  1596. type=Astronomy
  1597. ;;
  1598. bio*)
  1599. type=Biology
  1600. ;;
  1601. calc*)
  1602. type=Calculator
  1603. ;;
  1604. chem*)
  1605. type=Chemistry
  1606. ;;
  1607. elec*)
  1608. type=Electronics
  1609. ;;
  1610. geo*)
  1611. type=Geology
  1612. ;;
  1613. math*)
  1614. type=Math
  1615. ;;
  1616. physics)
  1617. type=Physics
  1618. ;;
  1619. visual*)
  1620. type=DataVisualization
  1621. ;;
  1622. esac;
  1623. type="Education;Science;${type}"
  1624. ;;
  1625. sys)
  1626. type="System"
  1627. ;;
  1628. www)
  1629. case ${catmin} in
  1630. client)
  1631. type=WebBrowser
  1632. ;;
  1633. esac;
  1634. type="Network;${type}"
  1635. ;;
  1636. *)
  1637. type=
  1638. ;;
  1639. esac;
  1640. fi;
  1641. local slot=${SLOT%/*};
  1642. if [[ ${slot} == "0" ]]; then
  1643. local desktop_name="${PN}";
  1644. else
  1645. local desktop_name="${PN}-${slot}";
  1646. fi;
  1647. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  1648. type=${type%;}${type:+;};
  1649. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  1650. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  1651. ewarn "allowed in .desktop files if the value is not an absolute path.";
  1652. icon=${icon%.*};
  1653. fi;
  1654. cat > "${desktop}" <<-EOF ||
  1655. [Desktop Entry]
  1656. Name=${name}
  1657. Type=Application
  1658. Comment=${DESCRIPTION}
  1659. Exec=${exec}
  1660. TryExec=${exec%% *}
  1661. Icon=${icon}
  1662. Categories=${type}
  1663. EOF
  1664. die
  1665. if [[ ${fields:-=} != *=* ]]; then
  1666. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  1667. fields="Path=${fields}";
  1668. fi;
  1669. if [[ -n ${fields} ]]; then
  1670. printf '%b\n' "${fields}" >> "${desktop}" || die;
  1671. fi;
  1672. ( insopts -m 0644;
  1673. insinto /usr/share/applications;
  1674. doins "${desktop}" ) || die "installing desktop file failed"
  1675. }
  1676. make_session_desktop ()
  1677. {
  1678. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  1679. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  1680. local title=$1;
  1681. local command=$2;
  1682. local desktop=${T}/${wm:-${PN}}.desktop;
  1683. shift 2;
  1684. cat > "${desktop}" <<-EOF ||
  1685. [Desktop Entry]
  1686. Name=${title}
  1687. Comment=This session logs you into ${title}
  1688. Exec=${command} $*
  1689. TryExec=${command}
  1690. Type=XSession
  1691. EOF
  1692. die
  1693. ( insopts -m 0644;
  1694. insinto /usr/share/xsessions;
  1695. doins "${desktop}" )
  1696. }
  1697. make_wrapper ()
  1698. {
  1699. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  1700. local tmpwrapper=$(emktemp);
  1701. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  1702. ( echo '#!/bin/sh';
  1703. if [[ -n ${libdir} ]]; then
  1704. local var;
  1705. if [[ ${CHOST} == *-darwin* ]]; then
  1706. var=DYLD_LIBRARY_PATH;
  1707. else
  1708. var=LD_LIBRARY_PATH;
  1709. fi;
  1710. cat <<-EOF
  1711. if [ "\${${var}+set}" = "set" ] ; then
  1712. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  1713. else
  1714. export ${var}="${EPREFIX}${libdir}"
  1715. fi
  1716. EOF
  1717. fi
  1718. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  1719. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  1720. chmod go+rx "${tmpwrapper}";
  1721. if [[ -n ${path} ]]; then
  1722. ( exeopts -m 0755;
  1723. exeinto "${path}";
  1724. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  1725. else
  1726. newbin "${tmpwrapper}" "${wrapper}" || die;
  1727. fi
  1728. }
  1729. multilib_env ()
  1730. {
  1731. local CTARGET=${1:-${CTARGET}};
  1732. local cpu=${CTARGET%%*-};
  1733. case ${cpu} in
  1734. aarch64*)
  1735. export CFLAGS_arm=${CFLAGS_arm-};
  1736. case ${cpu} in
  1737. aarch64*be)
  1738. export CHOST_arm="armv8b-${CTARGET#*-}"
  1739. ;;
  1740. *)
  1741. export CHOST_arm="armv8l-${CTARGET#*-}"
  1742. ;;
  1743. esac;
  1744. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1745. export CTARGET_arm=${CHOST_arm};
  1746. export LIBDIR_arm="lib";
  1747. export CFLAGS_arm64=${CFLAGS_arm64-};
  1748. export CHOST_arm64=${CTARGET};
  1749. export CTARGET_arm64=${CHOST_arm64};
  1750. export LIBDIR_arm64="lib64";
  1751. : ${MULTILIB_ABIS=arm64};
  1752. : ${DEFAULT_ABI=arm64}
  1753. ;;
  1754. x86_64*)
  1755. export CFLAGS_x86=${CFLAGS_x86--m32};
  1756. export CHOST_x86=${CTARGET/x86_64/i686};
  1757. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1758. export CTARGET_x86=${CHOST_x86};
  1759. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1760. export LIBDIR_x86="lib32";
  1761. else
  1762. export LIBDIR_x86="lib";
  1763. fi;
  1764. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1765. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1766. export CTARGET_amd64=${CHOST_amd64};
  1767. export LIBDIR_amd64="lib64";
  1768. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1769. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1770. export CTARGET_x32=${CHOST_x32};
  1771. export LIBDIR_x32="libx32";
  1772. case ${CTARGET} in
  1773. *-gnux32)
  1774. : ${MULTILIB_ABIS=x32 amd64 x86};
  1775. : ${DEFAULT_ABI=x32}
  1776. ;;
  1777. *)
  1778. : ${MULTILIB_ABIS=amd64 x86};
  1779. : ${DEFAULT_ABI=amd64}
  1780. ;;
  1781. esac
  1782. ;;
  1783. mips64* | mipsisa64*)
  1784. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1785. export CHOST_o32=${CTARGET/mips64/mips};
  1786. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  1787. export CTARGET_o32=${CHOST_o32};
  1788. export LIBDIR_o32="lib";
  1789. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1790. export CHOST_n32=${CTARGET};
  1791. export CTARGET_n32=${CHOST_n32};
  1792. export LIBDIR_n32="lib32";
  1793. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1794. export CHOST_n64=${CTARGET};
  1795. export CTARGET_n64=${CHOST_n64};
  1796. export LIBDIR_n64="lib64";
  1797. : ${MULTILIB_ABIS=n64 n32 o32};
  1798. : ${DEFAULT_ABI=n32}
  1799. ;;
  1800. powerpc64*)
  1801. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1802. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1803. export CTARGET_ppc=${CHOST_ppc};
  1804. export LIBDIR_ppc="lib";
  1805. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1806. export CHOST_ppc64=${CTARGET};
  1807. export CTARGET_ppc64=${CHOST_ppc64};
  1808. export LIBDIR_ppc64="lib64";
  1809. : ${MULTILIB_ABIS=ppc64 ppc};
  1810. : ${DEFAULT_ABI=ppc64}
  1811. ;;
  1812. s390x*)
  1813. export CFLAGS_s390=${CFLAGS_s390--m31};
  1814. export CHOST_s390=${CTARGET/s390x/s390};
  1815. export CTARGET_s390=${CHOST_s390};
  1816. export LIBDIR_s390="lib";
  1817. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1818. export CHOST_s390x=${CTARGET};
  1819. export CTARGET_s390x=${CHOST_s390x};
  1820. export LIBDIR_s390x="lib64";
  1821. : ${MULTILIB_ABIS=s390x s390};
  1822. : ${DEFAULT_ABI=s390x}
  1823. ;;
  1824. sparc64*)
  1825. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1826. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1827. export CTARGET_sparc32=${CHOST_sparc32};
  1828. export LIBDIR_sparc32="lib";
  1829. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1830. export CHOST_sparc64=${CTARGET};
  1831. export CTARGET_sparc64=${CHOST_sparc64};
  1832. export LIBDIR_sparc64="lib64";
  1833. : ${MULTILIB_ABIS=sparc64 sparc32};
  1834. : ${DEFAULT_ABI=sparc64}
  1835. ;;
  1836. *)
  1837. : ${MULTILIB_ABIS=default};
  1838. : ${DEFAULT_ABI=default}
  1839. ;;
  1840. esac;
  1841. export MULTILIB_ABIS DEFAULT_ABI
  1842. }
  1843. multilib_toolchain_setup ()
  1844. {
  1845. local v vv;
  1846. export ABI=$1;
  1847. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  1848. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1849. do
  1850. vv="_abi_saved_${v}";
  1851. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  1852. unset ${vv};
  1853. done;
  1854. unset _DEFAULT_ABI_SAVED;
  1855. fi;
  1856. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  1857. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  1858. do
  1859. vv="_abi_saved_${v}";
  1860. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  1861. done;
  1862. export _DEFAULT_ABI_SAVED="true";
  1863. if [[ ${CBUILD} == "${CHOST}" ]]; then
  1864. export CBUILD=$(get_abi_CHOST $1);
  1865. fi;
  1866. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  1867. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  1868. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  1869. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  1870. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  1871. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  1872. export CHOST=$(get_abi_CHOST $1);
  1873. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  1874. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  1875. fi
  1876. }
  1877. newicon ()
  1878. {
  1879. _iconins ${FUNCNAME} "$@"
  1880. }
  1881. newmenu ()
  1882. {
  1883. ( insopts -m 0644;
  1884. insinto /usr/share/applications;
  1885. newins "$@" )
  1886. }
  1887. number_abis ()
  1888. {
  1889. set -- `get_install_abis`;
  1890. echo $#
  1891. }
  1892. optfeature ()
  1893. {
  1894. debug-print-function ${FUNCNAME} "$@";
  1895. local i j msg;
  1896. local desc=$1;
  1897. local flag=0;
  1898. shift;
  1899. for i in "$@";
  1900. do
  1901. for j in ${i};
  1902. do
  1903. if has_version "${j}"; then
  1904. flag=1;
  1905. else
  1906. flag=0;
  1907. break;
  1908. fi;
  1909. done;
  1910. if [[ ${flag} -eq 1 ]]; then
  1911. break;
  1912. fi;
  1913. done;
  1914. if [[ ${flag} -eq 0 ]]; then
  1915. for i in "$@";
  1916. do
  1917. msg=" ";
  1918. for j in ${i};
  1919. do
  1920. msg+=" ${j} and";
  1921. done;
  1922. msg="${msg:0: -4} for ${desc}";
  1923. elog "${msg}";
  1924. done;
  1925. fi
  1926. }
  1927. path_exists ()
  1928. {
  1929. eerror "path_exists has been removed. Please see the following post";
  1930. eerror "for a replacement snippet:";
  1931. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  1932. die "path_exists is banned"
  1933. }
  1934. pkg_nofetch ()
  1935. {
  1936. default
  1937. }
  1938. pkg_setup ()
  1939. {
  1940. python-any-r1_pkg_setup "$@"
  1941. }
  1942. preserve_old_lib ()
  1943. {
  1944. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  1945. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  1946. die "Invalid preserve_old_lib() usage";
  1947. fi;
  1948. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  1949. has preserve-libs ${FEATURES} && return 0;
  1950. has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT};
  1951. local lib dir;
  1952. for lib in "$@";
  1953. do
  1954. [[ -e ${EROOT}/${lib} ]] || continue;
  1955. dir=${lib%/*};
  1956. dodir ${dir} || die "dodir ${dir} failed";
  1957. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  1958. touch "${ED}"/${lib};
  1959. done
  1960. }
  1961. preserve_old_lib_notify ()
  1962. {
  1963. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  1964. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  1965. die "Invalid preserve_old_lib_notify() usage";
  1966. fi;
  1967. has preserve-libs ${FEATURES} && return 0;
  1968. has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT};
  1969. local lib notice=0;
  1970. for lib in "$@";
  1971. do
  1972. [[ -e ${EROOT}/${lib} ]] || continue;
  1973. if [[ ${notice} -eq 0 ]]; then
  1974. notice=1;
  1975. ewarn "Old versions of installed libraries were detected on your system.";
  1976. ewarn "In order to avoid breaking packages that depend on these old libs,";
  1977. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  1978. ewarn "in order to remove these old dependencies. If you do not have this";
  1979. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  1980. ewarn;
  1981. fi;
  1982. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  1983. done
  1984. }
  1985. prune_libtool_files ()
  1986. {
  1987. debug-print-function ${FUNCNAME} "$@";
  1988. local removing_all removing_modules opt;
  1989. for opt in "$@";
  1990. do
  1991. case "${opt}" in
  1992. --all)
  1993. removing_all=1;
  1994. removing_modules=1
  1995. ;;
  1996. --modules)
  1997. removing_modules=1
  1998. ;;
  1999. *)
  2000. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2001. ;;
  2002. esac;
  2003. done;
  2004. local f;
  2005. local queue=();
  2006. while IFS= read -r -d '' f; do
  2007. local archivefile=${f/%.la/.a};
  2008. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  2009. continue;
  2010. fi;
  2011. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2012. local reason= pkgconfig_scanned=;
  2013. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  2014. if [[ ${snotlink} == yes ]]; then
  2015. if [[ -f ${archivefile} ]]; then
  2016. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2017. queue+=("${archivefile}");
  2018. fi;
  2019. if [[ -n ${removing_modules} ]]; then
  2020. reason='module';
  2021. fi;
  2022. else
  2023. if [[ -n ${removing_all} ]]; then
  2024. reason='requested';
  2025. else
  2026. if [[ ! -f ${archivefile} ]]; then
  2027. reason='no static archive';
  2028. else
  2029. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2030. reason='no libs & flags';
  2031. else
  2032. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2033. local pc_libs=();
  2034. if [[ ! -n ${removing_all} ]]; then
  2035. local pc;
  2036. local tf=${T}/prune-lt-files.pc;
  2037. local pkgconf=$(tc-getPKG_CONFIG);
  2038. while IFS= read -r -d '' pc; do
  2039. local arg libs;
  2040. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  2041. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2042. libs=$(${pkgconf} --libs "${tf}");
  2043. else
  2044. libs=$(sed -ne 's/^Libs://p' "${pc}");
  2045. fi;
  2046. for arg in ${libs};
  2047. do
  2048. if [[ ${arg} == -l* ]]; then
  2049. if [[ ${arg} == '*$*' ]]; then
  2050. eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2051. eerror "(arg: ${arg})";
  2052. eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2053. die "${FUNCNAME}: unsubstituted variable found in .pc";
  2054. fi;
  2055. pc_libs+=(lib${arg#-l}.la);
  2056. fi;
  2057. done;
  2058. done < <(find "${D}" -type f -name '*.pc' -print0);
  2059. rm -f "${tf}";
  2060. fi;
  2061. pkgconfig_scanned=1;
  2062. fi;
  2063. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2064. fi;
  2065. fi;
  2066. fi;
  2067. fi;
  2068. if [[ -n ${reason} ]]; then
  2069. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2070. queue+=("${f}");
  2071. fi;
  2072. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2073. if [[ -n ${queue[@]} ]]; then
  2074. rm -f "${queue[@]}";
  2075. fi
  2076. }
  2077. python-any-r1_pkg_setup ()
  2078. {
  2079. debug-print-function ${FUNCNAME} "${@}";
  2080. [[ ${MERGE_TYPE} != binary ]] && python_setup
  2081. }
  2082. python_abi_depend ()
  2083. {
  2084. die "${FUNCNAME}() is invalid for python-r1 suite"
  2085. }
  2086. python_byte-compile_modules ()
  2087. {
  2088. die "${FUNCNAME}() is invalid for python-r1 suite"
  2089. }
  2090. python_check_deps ()
  2091. {
  2092. has_version --host-root "dev-python/m2crypto[${PYTHON_USEDEP}]"
  2093. }
  2094. python_clean_byte-compiled_modules ()
  2095. {
  2096. die "${FUNCNAME}() is invalid for python-r1 suite"
  2097. }
  2098. python_clean_installation_image ()
  2099. {
  2100. die "${FUNCNAME}() is invalid for python-r1 suite"
  2101. }
  2102. python_clean_py-compile_files ()
  2103. {
  2104. die "${FUNCNAME}() is invalid for python-r1 suite"
  2105. }
  2106. python_convert_shebangs ()
  2107. {
  2108. 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"
  2109. }
  2110. python_disable_pyc ()
  2111. {
  2112. die "${FUNCNAME}() is invalid for python-r1 suite"
  2113. }
  2114. python_doexe ()
  2115. {
  2116. debug-print-function ${FUNCNAME} "${@}";
  2117. local f;
  2118. for f in "$@";
  2119. do
  2120. python_newexe "${f}" "${f##*/}";
  2121. done
  2122. }
  2123. python_doheader ()
  2124. {
  2125. debug-print-function ${FUNCNAME} "${@}";
  2126. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2127. if [[ ${EAPI:-0} == [0123] ]]; then
  2128. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2129. fi;
  2130. local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR};
  2131. [[ -n ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR;
  2132. d=${PYTHON_INCLUDEDIR#${EPREFIX}};
  2133. ( insopts -m 0644;
  2134. insinto "${d}";
  2135. doins -r "${@}" || return ${?} )
  2136. }
  2137. python_domodule ()
  2138. {
  2139. debug-print-function ${FUNCNAME} "${@}";
  2140. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2141. if [[ ${EAPI:-0} == [0123] ]]; then
  2142. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2143. fi;
  2144. local d;
  2145. if [[ ${python_moduleroot} == /* ]]; then
  2146. d=${python_moduleroot};
  2147. else
  2148. local PYTHON_SITEDIR=${PYTHON_SITEDIR};
  2149. [[ -n ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR;
  2150. d=${PYTHON_SITEDIR#${EPREFIX}}/${python_moduleroot//.//};
  2151. fi;
  2152. ( insopts -m 0644;
  2153. insinto "${d}";
  2154. doins -r "${@}" || return ${?} );
  2155. python_optimize "${ED%/}/${d}"
  2156. }
  2157. python_doscript ()
  2158. {
  2159. debug-print-function ${FUNCNAME} "${@}";
  2160. local _PYTHON_REWRITE_SHEBANG=1;
  2161. python_doexe "${@}"
  2162. }
  2163. python_enable_pyc ()
  2164. {
  2165. die "${FUNCNAME}() is invalid for python-r1 suite"
  2166. }
  2167. python_execute_function ()
  2168. {
  2169. 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"
  2170. }
  2171. python_execute_nosetests ()
  2172. {
  2173. die "${FUNCNAME}() is invalid for python-r1 suite"
  2174. }
  2175. python_execute_py.test ()
  2176. {
  2177. die "${FUNCNAME}() is invalid for python-r1 suite"
  2178. }
  2179. python_execute_trial ()
  2180. {
  2181. die "${FUNCNAME}() is invalid for python-r1 suite"
  2182. }
  2183. python_export ()
  2184. {
  2185. debug-print-function ${FUNCNAME} "${@}";
  2186. local impl var;
  2187. case "${1}" in
  2188. python* | jython*)
  2189. impl=${1/_/.};
  2190. shift
  2191. ;;
  2192. pypy | pypy3)
  2193. impl=${1};
  2194. shift
  2195. ;;
  2196. *)
  2197. impl=${EPYTHON};
  2198. if [[ -z ${impl} ]]; then
  2199. die "python_export called without a python implementation and EPYTHON is unset";
  2200. fi
  2201. ;;
  2202. esac;
  2203. debug-print "${FUNCNAME}: implementation: ${impl}";
  2204. for var in "$@";
  2205. do
  2206. case "${var}" in
  2207. EPYTHON)
  2208. export EPYTHON=${impl};
  2209. debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}"
  2210. ;;
  2211. PYTHON)
  2212. export PYTHON=${EPREFIX}/usr/bin/${impl};
  2213. debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
  2214. ;;
  2215. PYTHON_SITEDIR)
  2216. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2217. PYTHON_SITEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())') || die;
  2218. export PYTHON_SITEDIR;
  2219. debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
  2220. ;;
  2221. PYTHON_INCLUDEDIR)
  2222. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2223. PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') || die;
  2224. export PYTHON_INCLUDEDIR;
  2225. debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}";
  2226. if [[ ! -d ${PYTHON_INCLUDEDIR} ]]; then
  2227. die "${impl} does not install any header files!";
  2228. fi
  2229. ;;
  2230. PYTHON_LIBPATH)
  2231. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2232. 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;
  2233. export PYTHON_LIBPATH;
  2234. debug-print "${FUNCNAME}: PYTHON_LIBPATH = ${PYTHON_LIBPATH}";
  2235. if [[ ! -n ${PYTHON_LIBPATH} ]]; then
  2236. die "${impl} lacks a (usable) dynamic library";
  2237. fi
  2238. ;;
  2239. PYTHON_CFLAGS)
  2240. local val;
  2241. case "${impl}" in
  2242. python*)
  2243. val=$($(tc-getPKG_CONFIG) --cflags ${impl/n/n-}) || die
  2244. ;;
  2245. *)
  2246. die "${impl}: obtaining ${var} not supported"
  2247. ;;
  2248. esac;
  2249. export PYTHON_CFLAGS=${val};
  2250. debug-print "${FUNCNAME}: PYTHON_CFLAGS = ${PYTHON_CFLAGS}"
  2251. ;;
  2252. PYTHON_LIBS)
  2253. local val;
  2254. case "${impl}" in
  2255. python*)
  2256. val=$($(tc-getPKG_CONFIG) --libs ${impl/n/n-}) || die
  2257. ;;
  2258. *)
  2259. die "${impl}: obtaining ${var} not supported"
  2260. ;;
  2261. esac;
  2262. export PYTHON_LIBS=${val};
  2263. debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}"
  2264. ;;
  2265. PYTHON_CONFIG)
  2266. local flags val;
  2267. case "${impl}" in
  2268. python*)
  2269. [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it";
  2270. flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die;
  2271. val=${PYTHON}${flags}-config
  2272. ;;
  2273. *)
  2274. die "${impl}: obtaining ${var} not supported"
  2275. ;;
  2276. esac;
  2277. export PYTHON_CONFIG=${val};
  2278. debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
  2279. ;;
  2280. PYTHON_PKG_DEP)
  2281. local d;
  2282. case ${impl} in
  2283. python2.7)
  2284. PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7'
  2285. ;;
  2286. python3.3)
  2287. PYTHON_PKG_DEP='>=dev-lang/python-3.3.2-r2:3.3'
  2288. ;;
  2289. python*)
  2290. PYTHON_PKG_DEP="dev-lang/python:${impl#python}"
  2291. ;;
  2292. pypy)
  2293. PYTHON_PKG_DEP='>=virtual/pypy-5:0='
  2294. ;;
  2295. pypy3)
  2296. PYTHON_PKG_DEP='>=virtual/pypy3-5:0='
  2297. ;;
  2298. jython2.7)
  2299. PYTHON_PKG_DEP='dev-java/jython:2.7'
  2300. ;;
  2301. *)
  2302. die "Invalid implementation: ${impl}"
  2303. ;;
  2304. esac;
  2305. if [[ -n ${PYTHON_REQ_USE} ]]; then
  2306. PYTHON_PKG_DEP+=[${PYTHON_REQ_USE}];
  2307. fi;
  2308. export PYTHON_PKG_DEP;
  2309. debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
  2310. ;;
  2311. PYTHON_SCRIPTDIR)
  2312. local dir;
  2313. export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl};
  2314. debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
  2315. ;;
  2316. *)
  2317. die "python_export: unknown variable ${var}"
  2318. ;;
  2319. esac;
  2320. done
  2321. }
  2322. python_export_utf8_locale ()
  2323. {
  2324. debug-print-function ${FUNCNAME} "${@}";
  2325. type locale > /dev/null || return 0;
  2326. if [[ $(locale charmap) != UTF-8 ]]; then
  2327. local lang locales="C.UTF-8 en_US.UTF-8 en_GB.UTF-8 $(locale -a)";
  2328. for lang in ${locales};
  2329. do
  2330. if [[ $(LC_ALL=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
  2331. if _python_check_locale_sanity "${lang}"; then
  2332. export LC_CTYPE=${lang};
  2333. if [[ -n ${LC_ALL} ]]; then
  2334. export LC_NUMERIC=${LC_ALL};
  2335. export LC_TIME=${LC_ALL};
  2336. export LC_COLLATE=${LC_ALL};
  2337. export LC_MONETARY=${LC_ALL};
  2338. export LC_MESSAGES=${LC_ALL};
  2339. export LC_PAPER=${LC_ALL};
  2340. export LC_NAME=${LC_ALL};
  2341. export LC_ADDRESS=${LC_ALL};
  2342. export LC_TELEPHONE=${LC_ALL};
  2343. export LC_MEASUREMENT=${LC_ALL};
  2344. export LC_IDENTIFICATION=${LC_ALL};
  2345. export LC_ALL=;
  2346. fi;
  2347. return 0;
  2348. fi;
  2349. fi;
  2350. done;
  2351. ewarn "Could not find a UTF-8 locale. This may trigger build failures in";
  2352. ewarn "some python packages. Please ensure that a UTF-8 locale is listed in";
  2353. ewarn "/etc/locale.gen and run locale-gen.";
  2354. return 1;
  2355. fi;
  2356. return 0
  2357. }
  2358. python_fix_shebang ()
  2359. {
  2360. debug-print-function ${FUNCNAME} "${@}";
  2361. [[ -n ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)";
  2362. local force quiet;
  2363. while [[ -n ${@} ]]; do
  2364. case "${1}" in
  2365. -f | --force)
  2366. force=1;
  2367. shift
  2368. ;;
  2369. -q | --quiet)
  2370. quiet=1;
  2371. shift
  2372. ;;
  2373. --)
  2374. shift;
  2375. break
  2376. ;;
  2377. *)
  2378. break
  2379. ;;
  2380. esac;
  2381. done;
  2382. [[ -n ${1} ]] || die "${FUNCNAME}: no paths given";
  2383. local path f;
  2384. for path in "$@";
  2385. do
  2386. local any_correct any_fixed is_recursive;
  2387. [[ -d ${path} ]] && is_recursive=1;
  2388. while IFS= read -r -d '' f; do
  2389. local shebang i;
  2390. local error= from=;
  2391. IFS= read -r shebang < "${f}";
  2392. if [[ ${shebang} == '#!'* ]]; then
  2393. local split_shebang=();
  2394. read -r -a split_shebang <<< ${shebang} || die;
  2395. for i in "${split_shebang[@]}";
  2396. do
  2397. case "${i}" in
  2398. *"${EPYTHON}")
  2399. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  2400. debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}";
  2401. any_correct=1;
  2402. from=${EPYTHON};
  2403. break
  2404. ;;
  2405. *python | *python[23])
  2406. debug-print "${FUNCNAME}: in file ${f#${D%/}}";
  2407. debug-print "${FUNCNAME}: rewriting shebang: ${shebang}";
  2408. if [[ ${i} == *python2 ]]; then
  2409. from=python2;
  2410. if [[ ! -n ${force} ]]; then
  2411. python_is_python3 "${EPYTHON}" && error=1;
  2412. fi;
  2413. else
  2414. if [[ ${i} == *python3 ]]; then
  2415. from=python3;
  2416. if [[ ! -n ${force} ]]; then
  2417. python_is_python3 "${EPYTHON}" || error=1;
  2418. fi;
  2419. else
  2420. from=python;
  2421. fi;
  2422. fi;
  2423. break
  2424. ;;
  2425. *python[23].[0123456789] | *pypy | *pypy3 | *jython[23].[0123456789])
  2426. if [[ ! -n ${force} ]]; then
  2427. error=1;
  2428. else
  2429. case "${i}" in
  2430. *python[23].[0123456789])
  2431. from="python[23].[0123456789]"
  2432. ;;
  2433. *pypy)
  2434. from="pypy"
  2435. ;;
  2436. *pypy3)
  2437. from="pypy3"
  2438. ;;
  2439. *jython[23].[0123456789])
  2440. from="jython[23].[0123456789]"
  2441. ;;
  2442. *)
  2443. die "${FUNCNAME}: internal error in 2nd pattern match"
  2444. ;;
  2445. esac;
  2446. fi;
  2447. break
  2448. ;;
  2449. esac;
  2450. done;
  2451. fi;
  2452. if [[ ! -n ${error} && ! -n ${from} ]]; then
  2453. [[ -n ${is_recursive} ]] && continue;
  2454. error=1;
  2455. fi;
  2456. if [[ ! -n ${quiet} ]]; then
  2457. einfo "Fixing shebang in ${f#${D%/}}.";
  2458. fi;
  2459. if [[ ! -n ${error} ]]; then
  2460. if [[ ${shebang} == *${from}" "* ]]; then
  2461. sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die;
  2462. else
  2463. sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die;
  2464. fi;
  2465. any_fixed=1;
  2466. else
  2467. eerror "The file has incompatible shebang:";
  2468. eerror " file: ${f#${D%/}}";
  2469. eerror " current shebang: ${shebang}";
  2470. eerror " requested impl: ${EPYTHON}";
  2471. die "${FUNCNAME}: conversion of incompatible shebang requested";
  2472. fi;
  2473. done < <(find -H "${path}" -type f -print0 || die);
  2474. if [[ ! -n ${any_fixed} ]]; then
  2475. local cmd=eerror;
  2476. [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn;
  2477. "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files.";
  2478. if [[ -n ${any_correct} ]]; then
  2479. "${cmd}" "All files have ${EPYTHON} shebang already.";
  2480. else
  2481. "${cmd}" "There are no Python files in specified directory.";
  2482. fi;
  2483. [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})";
  2484. fi;
  2485. done
  2486. }
  2487. python_gen_any_dep ()
  2488. {
  2489. debug-print-function ${FUNCNAME} "${@}";
  2490. local depstr=${1};
  2491. [[ -n ${depstr} ]] || die "No dependency string provided";
  2492. local i PYTHON_PKG_DEP out=;
  2493. for i in "${_PYTHON_SUPPORTED_IMPLS[@]}";
  2494. do
  2495. local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)";
  2496. python_export "${i}" PYTHON_PKG_DEP;
  2497. local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}};
  2498. out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}";
  2499. done;
  2500. echo "|| ( ${out})"
  2501. }
  2502. python_generate_cffi_modules ()
  2503. {
  2504. die "${FUNCNAME}() is invalid for python-r1 suite"
  2505. }
  2506. python_generate_wrapper_scripts ()
  2507. {
  2508. die "${FUNCNAME}() is invalid for python-r1 suite"
  2509. }
  2510. python_get_CFLAGS ()
  2511. {
  2512. debug-print-function ${FUNCNAME} "${@}";
  2513. python_export "${@}" PYTHON_CFLAGS;
  2514. echo "${PYTHON_CFLAGS}"
  2515. }
  2516. python_get_LIBS ()
  2517. {
  2518. debug-print-function ${FUNCNAME} "${@}";
  2519. python_export "${@}" PYTHON_LIBS;
  2520. echo "${PYTHON_LIBS}"
  2521. }
  2522. python_get_PYTHON_CONFIG ()
  2523. {
  2524. debug-print-function ${FUNCNAME} "${@}";
  2525. python_export "${@}" PYTHON_CONFIG;
  2526. echo "${PYTHON_CONFIG}"
  2527. }
  2528. python_get_extension_module_suffix ()
  2529. {
  2530. die "${FUNCNAME}() is invalid for python-r1 suite"
  2531. }
  2532. python_get_implementation ()
  2533. {
  2534. die "${FUNCNAME}() is invalid for python-r1 suite"
  2535. }
  2536. python_get_implementation_and_version ()
  2537. {
  2538. die "${FUNCNAME}() is invalid for python-r1 suite"
  2539. }
  2540. python_get_implementational_package ()
  2541. {
  2542. die "${FUNCNAME}() is invalid for python-r1 suite"
  2543. }
  2544. python_get_includedir ()
  2545. {
  2546. debug-print-function ${FUNCNAME} "${@}";
  2547. python_export "${@}" PYTHON_INCLUDEDIR;
  2548. echo "${PYTHON_INCLUDEDIR}"
  2549. }
  2550. python_get_libdir ()
  2551. {
  2552. die "${FUNCNAME}() is invalid for python-r1 suite"
  2553. }
  2554. python_get_library ()
  2555. {
  2556. die "${FUNCNAME}() is invalid for python-r1 suite"
  2557. }
  2558. python_get_library_path ()
  2559. {
  2560. debug-print-function ${FUNCNAME} "${@}";
  2561. python_export "${@}" PYTHON_LIBPATH;
  2562. echo "${PYTHON_LIBPATH}"
  2563. }
  2564. python_get_scriptdir ()
  2565. {
  2566. debug-print-function ${FUNCNAME} "${@}";
  2567. python_export "${@}" PYTHON_SCRIPTDIR;
  2568. echo "${PYTHON_SCRIPTDIR}"
  2569. }
  2570. python_get_sitedir ()
  2571. {
  2572. debug-print-function ${FUNCNAME} "${@}";
  2573. python_export "${@}" PYTHON_SITEDIR;
  2574. echo "${PYTHON_SITEDIR}"
  2575. }
  2576. python_get_version ()
  2577. {
  2578. die "${FUNCNAME}() is invalid for python-r1 suite"
  2579. }
  2580. python_install_executables ()
  2581. {
  2582. die "${FUNCNAME}() is invalid for python-r1 suite"
  2583. }
  2584. python_is_installed ()
  2585. {
  2586. local impl=${1:-${EPYTHON}};
  2587. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON";
  2588. local hasv_args=();
  2589. case ${EAPI:-0} in
  2590. 0 | 1 | 2 | 3 | 4)
  2591. local -x ROOT=/
  2592. ;;
  2593. 5 | 6)
  2594. hasv_args+=(--host-root)
  2595. ;;
  2596. *)
  2597. hasv_args+=(-b)
  2598. ;;
  2599. esac;
  2600. case "${impl}" in
  2601. pypy | pypy3)
  2602. local append=;
  2603. if [[ -n ${PYTHON_REQ_USE} ]]; then
  2604. append=[${PYTHON_REQ_USE}];
  2605. fi;
  2606. has_version "${hasv_args[@]}" "dev-python/${impl}${append}" || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
  2607. ;;
  2608. *)
  2609. local PYTHON_PKG_DEP;
  2610. python_export "${impl}" PYTHON_PKG_DEP;
  2611. has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
  2612. ;;
  2613. esac
  2614. }
  2615. python_is_python3 ()
  2616. {
  2617. local impl=${1:-${EPYTHON}};
  2618. [[ -n ${impl} ]] || die "python_is_python3: no impl nor EPYTHON";
  2619. [[ ${impl} == python3* || ${impl} == pypy3 ]]
  2620. }
  2621. python_merge_intermediate_installation_images ()
  2622. {
  2623. die "${FUNCNAME}() is invalid for python-r1 suite"
  2624. }
  2625. python_mod_cleanup ()
  2626. {
  2627. 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"
  2628. }
  2629. python_mod_optimize ()
  2630. {
  2631. 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"
  2632. }
  2633. python_moduleinto ()
  2634. {
  2635. debug-print-function ${FUNCNAME} "${@}";
  2636. python_moduleroot=${1}
  2637. }
  2638. python_need_rebuild ()
  2639. {
  2640. die "${FUNCNAME}() is invalid for python-r1 suite"
  2641. }
  2642. python_newexe ()
  2643. {
  2644. debug-print-function ${FUNCNAME} "${@}";
  2645. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2646. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>";
  2647. if [[ ${EAPI:-0} == [0123] ]]; then
  2648. die "python_do* and python_new* helpers are banned in EAPIs older than 4.";
  2649. fi;
  2650. local wrapd=${python_scriptroot:-/usr/bin};
  2651. local f=${1};
  2652. local newfn=${2};
  2653. local PYTHON_SCRIPTDIR d;
  2654. python_export PYTHON_SCRIPTDIR;
  2655. d=${PYTHON_SCRIPTDIR#${EPREFIX}};
  2656. ( dodir "${wrapd}";
  2657. exeopts -m 0755;
  2658. exeinto "${d}";
  2659. newexe "${f}" "${newfn}" || return ${?} );
  2660. _python_ln_rel "${ED%/}"/usr/lib/python-exec/python-exec2 "${ED%/}/${wrapd}/${newfn}" || die;
  2661. if [[ -n ${_PYTHON_REWRITE_SHEBANG} ]]; then
  2662. python_fix_shebang -q "${ED%/}/${d}/${newfn}";
  2663. fi
  2664. }
  2665. python_newscript ()
  2666. {
  2667. debug-print-function ${FUNCNAME} "${@}";
  2668. local _PYTHON_REWRITE_SHEBANG=1;
  2669. python_newexe "${@}"
  2670. }
  2671. python_optimize ()
  2672. {
  2673. debug-print-function ${FUNCNAME} "${@}";
  2674. if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
  2675. eerror "The new Python eclasses expect the compiled Python files to";
  2676. eerror "be controlled by the Package Manager. For this reason,";
  2677. eerror "the python_optimize function can be used only during src_* phases";
  2678. eerror "(src_install most commonly) and not during pkg_* phases.";
  2679. echo;
  2680. die "python_optimize is not to be used in pre/post* phases";
  2681. fi;
  2682. [[ -n ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).';
  2683. local PYTHON=${PYTHON};
  2684. [[ -n ${PYTHON} ]] || python_export PYTHON;
  2685. if [[ ${#} -eq 0 ]]; then
  2686. local f;
  2687. while IFS= read -r -d '' f; do
  2688. if [[ ${f} == /* && -d ${D%/}${f} ]]; then
  2689. set -- "${D%/}${f}" "${@}";
  2690. fi;
  2691. done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die);
  2692. debug-print "${FUNCNAME}: using sys.path: ${*/%/;}";
  2693. fi;
  2694. local d;
  2695. for d in "$@";
  2696. do
  2697. local instpath=${d#${D%/}};
  2698. instpath=/${instpath##/};
  2699. case "${EPYTHON}" in
  2700. python2.7 | python3.[34])
  2701. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  2702. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  2703. ;;
  2704. python* | pypy3)
  2705. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}";
  2706. "${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}";
  2707. "${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
  2708. ;;
  2709. *)
  2710. "${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
  2711. ;;
  2712. esac;
  2713. done
  2714. }
  2715. python_pkg_setup ()
  2716. {
  2717. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  2718. }
  2719. python_scriptinto ()
  2720. {
  2721. debug-print-function ${FUNCNAME} "${@}";
  2722. python_scriptroot=${1}
  2723. }
  2724. python_set_active_version ()
  2725. {
  2726. die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
  2727. }
  2728. python_setup ()
  2729. {
  2730. debug-print-function ${FUNCNAME} "${@}";
  2731. if [[ -n ${PYTHON_COMPAT_OVERRIDE} ]]; then
  2732. local impls=(${PYTHON_COMPAT_OVERRIDE});
  2733. [[ ${#impls[@]} -eq 1 ]] || die "PYTHON_COMPAT_OVERRIDE must name exactly one implementation for python-any-r1";
  2734. ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python";
  2735. ewarn "implementation will be used:";
  2736. ewarn;
  2737. ewarn " ${PYTHON_COMPAT_OVERRIDE}";
  2738. ewarn;
  2739. ewarn "Dependencies won't be satisfied, and EPYTHON/eselect-python will be ignored.";
  2740. python_export "${impls[0]}" EPYTHON PYTHON;
  2741. python_wrapper_setup;
  2742. return;
  2743. fi;
  2744. if [[ -n ${EPYTHON} ]]; then
  2745. if _python_EPYTHON_supported "${EPYTHON}"; then
  2746. python_export EPYTHON PYTHON;
  2747. python_wrapper_setup;
  2748. return;
  2749. fi;
  2750. fi;
  2751. local variant i;
  2752. for variant in '' '--python2' '--python3';
  2753. do
  2754. i=$(eselect python --show ${variant} 2>/dev/null);
  2755. if [[ ! -n ${i} ]]; then
  2756. break;
  2757. else
  2758. if _python_EPYTHON_supported "${i}"; then
  2759. python_export "${i}" EPYTHON PYTHON;
  2760. python_wrapper_setup;
  2761. return;
  2762. fi;
  2763. fi;
  2764. done;
  2765. for ((i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- ))
  2766. do
  2767. python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON;
  2768. if _python_EPYTHON_supported "${EPYTHON}"; then
  2769. python_wrapper_setup;
  2770. return;
  2771. fi;
  2772. done;
  2773. eerror "No Python implementation found for the build. This is usually";
  2774. eerror "a bug in the ebuild. Please report it to bugs.gentoo.org";
  2775. eerror "along with the build log.";
  2776. echo;
  2777. die "No supported Python implementation installed."
  2778. }
  2779. python_wrapper_setup ()
  2780. {
  2781. debug-print-function ${FUNCNAME} "${@}";
  2782. local workdir=${1:-${T}/${EPYTHON}};
  2783. local impl=${2:-${EPYTHON}};
  2784. [[ -n ${workdir} ]] || die "${FUNCNAME}: no workdir specified.";
  2785. [[ -n ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified.";
  2786. if [[ ! -x ${workdir}/bin/python ]]; then
  2787. _python_check_dead_variables;
  2788. mkdir -p "${workdir}"/{bin,pkgconfig} || die;
  2789. rm -f "${workdir}"/bin/python{,2,3}{,-config} || die;
  2790. rm -f "${workdir}"/bin/2to3 || die;
  2791. rm -f "${workdir}"/pkgconfig/python{,2,3}.pc || die;
  2792. local EPYTHON PYTHON;
  2793. python_export "${impl}" EPYTHON PYTHON;
  2794. local pyver pyother;
  2795. if python_is_python3; then
  2796. pyver=3;
  2797. pyother=2;
  2798. else
  2799. pyver=2;
  2800. pyother=3;
  2801. fi;
  2802. cat > "${workdir}/bin/python" <<-_EOF_ ||
  2803. #!/bin/sh
  2804. exec "${PYTHON}" "\${@}"
  2805. _EOF_
  2806. die
  2807. cp "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2808. chmod +x "${workdir}/bin/python" "${workdir}/bin/python${pyver}" || die;
  2809. local nonsupp=("python${pyother}" "python${pyother}-config");
  2810. if [[ ${EPYTHON} == python* ]]; then
  2811. cat > "${workdir}/bin/python-config" <<-_EOF_ ||
  2812. #!/bin/sh
  2813. exec "${PYTHON}-config" "\${@}"
  2814. _EOF_
  2815. die
  2816. cp "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2817. chmod +x "${workdir}/bin/python-config" "${workdir}/bin/python${pyver}-config" || die;
  2818. ln -s "${PYTHON/python/2to3-}" "${workdir}"/bin/2to3 || die;
  2819. ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${EPYTHON/n/n-}.pc "${workdir}"/pkgconfig/python.pc || die;
  2820. ln -s python.pc "${workdir}"/pkgconfig/python${pyver}.pc || die;
  2821. else
  2822. nonsupp+=(2to3 python-config "python${pyver}-config");
  2823. fi;
  2824. local x;
  2825. for x in "${nonsupp[@]}";
  2826. do
  2827. cat > "${workdir}"/bin/${x} <<-_EOF_ ||
  2828. #!/bin/sh
  2829. echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
  2830. exit 127
  2831. _EOF_
  2832. die
  2833. chmod +x "${workdir}"/bin/${x} || die;
  2834. done;
  2835. fi;
  2836. if [[ ${PATH##:*} != ${workdir}/bin ]]; then
  2837. PATH=${workdir}/bin${PATH:+:${PATH}};
  2838. fi;
  2839. if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
  2840. PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}};
  2841. fi;
  2842. export PATH PKG_CONFIG_PATH
  2843. }
  2844. src_compile ()
  2845. {
  2846. _emake all_noverify
  2847. }
  2848. src_configure ()
  2849. {
  2850. default
  2851. }
  2852. src_install ()
  2853. {
  2854. _emake DESTDIR="${D}" install;
  2855. keepdir /etc/wireless-regdb/pubkeys
  2856. }
  2857. src_prepare ()
  2858. {
  2859. epatch "${FILESDIR}"/${PN}-3.18-no-ldconfig.patch;
  2860. epatch "${FILESDIR}"/${PN}-3.18-no-werror.patch;
  2861. epatch "${FILESDIR}"/${PN}-3.18-openssl.patch;
  2862. epatch "${FILESDIR}"/${PN}-3.18-cflags.patch;
  2863. epatch "${FILESDIR}"/${PN}-3.18-libreg-link.patch;
  2864. sed -i -e "s:\<pkg-config\>:$(tc-getPKG_CONFIG):" Makefile || die
  2865. }
  2866. src_test ()
  2867. {
  2868. _emake verify
  2869. }
  2870. src_unpack ()
  2871. {
  2872. default
  2873. }
  2874. strip-linguas ()
  2875. {
  2876. local ls newls nols;
  2877. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2878. local op=$1;
  2879. shift;
  2880. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2881. shift;
  2882. local d f;
  2883. for d in "$@";
  2884. do
  2885. if [[ ${op} == "-u" ]]; then
  2886. newls=${ls};
  2887. else
  2888. newls="";
  2889. fi;
  2890. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2891. do
  2892. if [[ ${op} == "-i" ]]; then
  2893. has ${f} ${ls} && newls="${newls} ${f}";
  2894. else
  2895. has ${f} ${ls} || newls="${newls} ${f}";
  2896. fi;
  2897. done;
  2898. ls=${newls};
  2899. done;
  2900. else
  2901. ls="$@";
  2902. fi;
  2903. nols="";
  2904. newls="";
  2905. for f in ${LINGUAS};
  2906. do
  2907. if has ${f} ${ls}; then
  2908. newls="${newls} ${f}";
  2909. else
  2910. nols="${nols} ${f}";
  2911. fi;
  2912. done;
  2913. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2914. export LINGUAS=${newls:1}
  2915. }
  2916. tc-arch ()
  2917. {
  2918. tc-ninja_magic_to_arch portage "$@"
  2919. }
  2920. tc-arch-kernel ()
  2921. {
  2922. tc-ninja_magic_to_arch kern "$@"
  2923. }
  2924. tc-check-openmp ()
  2925. {
  2926. if ! tc-has-openmp; then
  2927. eerror "Your current compiler does not support OpenMP!";
  2928. if tc-is-gcc; then
  2929. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  2930. else
  2931. if tc-is-clang; then
  2932. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  2933. fi;
  2934. fi;
  2935. die "Active compiler does not have required support for OpenMP";
  2936. fi
  2937. }
  2938. tc-cpp-is-true ()
  2939. {
  2940. local CONDITION=${1};
  2941. shift;
  2942. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  2943. #if ${CONDITION}
  2944. true
  2945. #endif
  2946. EOF
  2947. );
  2948. [[ ${RESULT} == true ]]
  2949. }
  2950. tc-detect-is-softfloat ()
  2951. {
  2952. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  2953. case ${CTARGET:-${CHOST}} in
  2954. *-newlib | *-elf | *-eabi)
  2955. return 1
  2956. ;;
  2957. arm*)
  2958. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  2959. echo "no";
  2960. else
  2961. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  2962. echo "yes";
  2963. else
  2964. echo "softfp";
  2965. fi;
  2966. fi;
  2967. return 0
  2968. ;;
  2969. *)
  2970. return 1
  2971. ;;
  2972. esac
  2973. }
  2974. tc-enables-pie ()
  2975. {
  2976. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  2977. }
  2978. tc-enables-ssp ()
  2979. {
  2980. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2981. }
  2982. tc-enables-ssp-all ()
  2983. {
  2984. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2985. }
  2986. tc-enables-ssp-strong ()
  2987. {
  2988. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  2989. }
  2990. tc-endian ()
  2991. {
  2992. local host=$1;
  2993. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2994. host=${host%%-*};
  2995. case ${host} in
  2996. aarch64*be)
  2997. echo big
  2998. ;;
  2999. aarch64)
  3000. echo little
  3001. ;;
  3002. alpha*)
  3003. echo little
  3004. ;;
  3005. arm*b*)
  3006. echo big
  3007. ;;
  3008. arm*)
  3009. echo little
  3010. ;;
  3011. cris*)
  3012. echo little
  3013. ;;
  3014. hppa*)
  3015. echo big
  3016. ;;
  3017. i?86*)
  3018. echo little
  3019. ;;
  3020. ia64*)
  3021. echo little
  3022. ;;
  3023. m68*)
  3024. echo big
  3025. ;;
  3026. mips*l*)
  3027. echo little
  3028. ;;
  3029. mips*)
  3030. echo big
  3031. ;;
  3032. powerpc*le)
  3033. echo little
  3034. ;;
  3035. powerpc*)
  3036. echo big
  3037. ;;
  3038. s390*)
  3039. echo big
  3040. ;;
  3041. sh*b*)
  3042. echo big
  3043. ;;
  3044. sh*)
  3045. echo little
  3046. ;;
  3047. sparc*)
  3048. echo big
  3049. ;;
  3050. x86_64*)
  3051. echo little
  3052. ;;
  3053. *)
  3054. echo wtf
  3055. ;;
  3056. esac
  3057. }
  3058. tc-env_build ()
  3059. {
  3060. tc-export_build_env;
  3061. 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) "$@"
  3062. }
  3063. tc-export ()
  3064. {
  3065. local var;
  3066. for var in "$@";
  3067. do
  3068. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3069. "tc-get${var}" > /dev/null;
  3070. done
  3071. }
  3072. tc-export_build_env ()
  3073. {
  3074. tc-export "$@";
  3075. if tc-is-cross-compiler; then
  3076. : ${BUILD_CFLAGS:=-O1 -pipe};
  3077. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  3078. : ${BUILD_CPPFLAGS:= };
  3079. : ${BUILD_LDFLAGS:= };
  3080. else
  3081. : ${BUILD_CFLAGS:=${CFLAGS}};
  3082. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  3083. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  3084. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  3085. fi;
  3086. export BUILD_{C,CXX,CPP,LD}FLAGS;
  3087. local v;
  3088. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  3089. do
  3090. export ${v#BUILD_}_FOR_BUILD="${!v}";
  3091. done
  3092. }
  3093. tc-get-compiler-type ()
  3094. {
  3095. local code='
  3096. #if defined(__PATHSCALE__)
  3097. HAVE_PATHCC
  3098. #elif defined(__clang__)
  3099. HAVE_CLANG
  3100. #elif defined(__GNUC__)
  3101. HAVE_GCC
  3102. #endif
  3103. ';
  3104. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  3105. case ${res} in
  3106. *HAVE_PATHCC*)
  3107. echo pathcc
  3108. ;;
  3109. *HAVE_CLANG*)
  3110. echo clang
  3111. ;;
  3112. *HAVE_GCC*)
  3113. echo gcc
  3114. ;;
  3115. *)
  3116. echo unknown
  3117. ;;
  3118. esac
  3119. }
  3120. tc-getAR ()
  3121. {
  3122. tc-getPROG AR ar "$@"
  3123. }
  3124. tc-getAS ()
  3125. {
  3126. tc-getPROG AS as "$@"
  3127. }
  3128. tc-getBUILD_AR ()
  3129. {
  3130. tc-getBUILD_PROG AR ar "$@"
  3131. }
  3132. tc-getBUILD_AS ()
  3133. {
  3134. tc-getBUILD_PROG AS as "$@"
  3135. }
  3136. tc-getBUILD_CC ()
  3137. {
  3138. tc-getBUILD_PROG CC gcc "$@"
  3139. }
  3140. tc-getBUILD_CPP ()
  3141. {
  3142. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  3143. }
  3144. tc-getBUILD_CXX ()
  3145. {
  3146. tc-getBUILD_PROG CXX g++ "$@"
  3147. }
  3148. tc-getBUILD_LD ()
  3149. {
  3150. tc-getBUILD_PROG LD ld "$@"
  3151. }
  3152. tc-getBUILD_NM ()
  3153. {
  3154. tc-getBUILD_PROG NM nm "$@"
  3155. }
  3156. tc-getBUILD_OBJCOPY ()
  3157. {
  3158. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3159. }
  3160. tc-getBUILD_PKG_CONFIG ()
  3161. {
  3162. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3163. }
  3164. tc-getBUILD_PROG ()
  3165. {
  3166. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  3167. tc-is-cross-compiler || vars+=" $1";
  3168. _tc-getPROG CBUILD "${vars}" "${@:2}"
  3169. }
  3170. tc-getBUILD_RANLIB ()
  3171. {
  3172. tc-getBUILD_PROG RANLIB ranlib "$@"
  3173. }
  3174. tc-getBUILD_STRIP ()
  3175. {
  3176. tc-getBUILD_PROG STRIP strip "$@"
  3177. }
  3178. tc-getCC ()
  3179. {
  3180. tc-getPROG CC gcc "$@"
  3181. }
  3182. tc-getCPP ()
  3183. {
  3184. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  3185. }
  3186. tc-getCXX ()
  3187. {
  3188. tc-getPROG CXX g++ "$@"
  3189. }
  3190. tc-getDLLWRAP ()
  3191. {
  3192. tc-getPROG DLLWRAP dllwrap "$@"
  3193. }
  3194. tc-getF77 ()
  3195. {
  3196. tc-getPROG F77 gfortran "$@"
  3197. }
  3198. tc-getFC ()
  3199. {
  3200. tc-getPROG FC gfortran "$@"
  3201. }
  3202. tc-getGCJ ()
  3203. {
  3204. tc-getPROG GCJ gcj "$@"
  3205. }
  3206. tc-getGO ()
  3207. {
  3208. tc-getPROG GO gccgo "$@"
  3209. }
  3210. tc-getLD ()
  3211. {
  3212. tc-getPROG LD ld "$@"
  3213. }
  3214. tc-getNM ()
  3215. {
  3216. tc-getPROG NM nm "$@"
  3217. }
  3218. tc-getOBJCOPY ()
  3219. {
  3220. tc-getPROG OBJCOPY objcopy "$@"
  3221. }
  3222. tc-getOBJDUMP ()
  3223. {
  3224. tc-getPROG OBJDUMP objdump "$@"
  3225. }
  3226. tc-getPKG_CONFIG ()
  3227. {
  3228. tc-getPROG PKG_CONFIG pkg-config "$@"
  3229. }
  3230. tc-getPROG ()
  3231. {
  3232. _tc-getPROG CHOST "$@"
  3233. }
  3234. tc-getRANLIB ()
  3235. {
  3236. tc-getPROG RANLIB ranlib "$@"
  3237. }
  3238. tc-getRC ()
  3239. {
  3240. tc-getPROG RC windres "$@"
  3241. }
  3242. tc-getSTRIP ()
  3243. {
  3244. tc-getPROG STRIP strip "$@"
  3245. }
  3246. tc-getTARGET_CPP ()
  3247. {
  3248. if [[ -n ${CTARGET} ]]; then
  3249. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  3250. else
  3251. tc-getCPP "$@";
  3252. fi
  3253. }
  3254. tc-has-openmp ()
  3255. {
  3256. local base="${T}/test-tc-openmp";
  3257. cat > "${base}.c" <<-EOF
  3258. #include <omp.h>
  3259. int main() {
  3260. int nthreads, tid, ret = 0;
  3261. #pragma omp parallel private(nthreads, tid)
  3262. {
  3263. tid = omp_get_thread_num();
  3264. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3265. }
  3266. return ret;
  3267. }
  3268. EOF
  3269. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  3270. local ret=$?;
  3271. rm -f "${base}"*;
  3272. return ${ret}
  3273. }
  3274. tc-has-tls ()
  3275. {
  3276. local base="${T}/test-tc-tls";
  3277. cat > "${base}.c" <<-EOF
  3278. int foo(int *i) {
  3279. static __thread int j = 0;
  3280. return *i ? j : *i;
  3281. }
  3282. EOF
  3283. local flags;
  3284. case $1 in
  3285. -s)
  3286. flags="-S"
  3287. ;;
  3288. -c)
  3289. flags="-c"
  3290. ;;
  3291. -l)
  3292. ;;
  3293. -*)
  3294. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3295. ;;
  3296. esac;
  3297. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3298. [[ $1 == -* ]] && shift;
  3299. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  3300. local ret=$?;
  3301. rm -f "${base}"*;
  3302. return ${ret}
  3303. }
  3304. tc-is-clang ()
  3305. {
  3306. [[ $(tc-get-compiler-type) == clang ]]
  3307. }
  3308. tc-is-cross-compiler ()
  3309. {
  3310. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  3311. }
  3312. tc-is-gcc ()
  3313. {
  3314. [[ $(tc-get-compiler-type) == gcc ]]
  3315. }
  3316. tc-is-softfloat ()
  3317. {
  3318. tc-detect-is-softfloat || tc-tuple-is-softfloat
  3319. }
  3320. tc-is-static-only ()
  3321. {
  3322. local host=${CTARGET:-${CHOST}};
  3323. [[ ${host} == *-mint* ]]
  3324. }
  3325. tc-ld-disable-gold ()
  3326. {
  3327. if ! tc-ld-is-gold "$@"; then
  3328. return;
  3329. fi;
  3330. ewarn "Forcing usage of the BFD linker instead of GOLD";
  3331. local ld=$(tc-getLD "$@");
  3332. local bfd_ld="${ld%% *}.bfd";
  3333. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  3334. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  3335. local fallback="true";
  3336. if tc-is-gcc; then
  3337. local major=$(gcc-major-version "$@");
  3338. local minor=$(gcc-minor-version "$@");
  3339. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  3340. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3341. fallback="false";
  3342. fi;
  3343. else
  3344. if tc-is-clang; then
  3345. local major=$(clang-major-version "$@");
  3346. local minor=$(clang-minor-version "$@");
  3347. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  3348. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  3349. fallback="false";
  3350. fi;
  3351. fi;
  3352. fi;
  3353. if [[ ${fallback} == "true" ]]; then
  3354. if [[ -e ${path_ld} ]]; then
  3355. local d="${T}/bfd-linker";
  3356. mkdir -p "${d}";
  3357. ln -sf "${path_ld}" "${d}"/ld;
  3358. export LDFLAGS="${LDFLAGS} -B${d}";
  3359. else
  3360. die "unable to locate a BFD linker to bypass gold";
  3361. fi;
  3362. fi
  3363. }
  3364. tc-ld-is-gold ()
  3365. {
  3366. local out;
  3367. out=$($(tc-getLD "$@") --version 2>&1);
  3368. if [[ ${out} == *"GNU gold"* ]]; then
  3369. return 0;
  3370. fi;
  3371. local base="${T}/test-tc-gold";
  3372. cat > "${base}.c" <<-EOF
  3373. int main() { return 0; }
  3374. EOF
  3375. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  3376. rm -f "${base}"*;
  3377. if [[ ${out} == *"GNU gold"* ]]; then
  3378. return 0;
  3379. fi;
  3380. return 1
  3381. }
  3382. tc-ninja_magic_to_arch ()
  3383. {
  3384. function ninj ()
  3385. {
  3386. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3387. };
  3388. local type=$1;
  3389. local host=$2;
  3390. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3391. case ${host} in
  3392. aarch64*)
  3393. echo arm64
  3394. ;;
  3395. alpha*)
  3396. echo alpha
  3397. ;;
  3398. arm*)
  3399. echo arm
  3400. ;;
  3401. avr*)
  3402. ninj avr32 avr
  3403. ;;
  3404. bfin*)
  3405. ninj blackfin bfin
  3406. ;;
  3407. c6x*)
  3408. echo c6x
  3409. ;;
  3410. cris*)
  3411. echo cris
  3412. ;;
  3413. frv*)
  3414. echo frv
  3415. ;;
  3416. hexagon*)
  3417. echo hexagon
  3418. ;;
  3419. hppa*)
  3420. ninj parisc hppa
  3421. ;;
  3422. i?86*)
  3423. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  3424. echo i386;
  3425. else
  3426. echo x86;
  3427. fi
  3428. ;;
  3429. ia64*)
  3430. echo ia64
  3431. ;;
  3432. m68*)
  3433. echo m68k
  3434. ;;
  3435. metag*)
  3436. echo metag
  3437. ;;
  3438. microblaze*)
  3439. echo microblaze
  3440. ;;
  3441. mips*)
  3442. echo mips
  3443. ;;
  3444. nios2*)
  3445. echo nios2
  3446. ;;
  3447. nios*)
  3448. echo nios
  3449. ;;
  3450. or1k | or32*)
  3451. echo openrisc
  3452. ;;
  3453. powerpc*)
  3454. if [[ ${type} == "kern" ]]; then
  3455. echo powerpc;
  3456. else
  3457. if [[ ${host} == powerpc64* ]]; then
  3458. echo ppc64;
  3459. else
  3460. echo ppc;
  3461. fi;
  3462. fi
  3463. ;;
  3464. riscv*)
  3465. echo riscv
  3466. ;;
  3467. s390*)
  3468. echo s390
  3469. ;;
  3470. score*)
  3471. echo score
  3472. ;;
  3473. sh64*)
  3474. ninj sh64 sh
  3475. ;;
  3476. sh*)
  3477. echo sh
  3478. ;;
  3479. sparc64*)
  3480. ninj sparc64 sparc
  3481. ;;
  3482. sparc*)
  3483. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3484. ;;
  3485. tile*)
  3486. echo tile
  3487. ;;
  3488. vax*)
  3489. echo vax
  3490. ;;
  3491. x86_64*freebsd*)
  3492. echo amd64
  3493. ;;
  3494. x86_64*)
  3495. if [[ ${type} == "kern" ]]; then
  3496. echo x86;
  3497. else
  3498. echo amd64;
  3499. fi
  3500. ;;
  3501. xtensa*)
  3502. echo xtensa
  3503. ;;
  3504. *)
  3505. echo unknown
  3506. ;;
  3507. esac
  3508. }
  3509. tc-stack-grows-down ()
  3510. {
  3511. case ${ARCH} in
  3512. hppa | metag)
  3513. return 1
  3514. ;;
  3515. esac;
  3516. return 0
  3517. }
  3518. tc-tuple-is-softfloat ()
  3519. {
  3520. local CTARGET=${CTARGET:-${CHOST}};
  3521. case ${CTARGET//_/-} in
  3522. bfin* | h8300*)
  3523. echo "only"
  3524. ;;
  3525. *-softfloat-*)
  3526. echo "yes"
  3527. ;;
  3528. *-softfp-*)
  3529. echo "softfp"
  3530. ;;
  3531. arm*-hardfloat-* | arm*eabihf)
  3532. echo "no"
  3533. ;;
  3534. *-newlib | *-elf | *-eabi)
  3535. echo "no"
  3536. ;;
  3537. arm*)
  3538. echo "yes"
  3539. ;;
  3540. *)
  3541. echo "no"
  3542. ;;
  3543. esac
  3544. }
  3545. udev_dorules ()
  3546. {
  3547. debug-print-function ${FUNCNAME} "${@}";
  3548. ( insopts -m 0644;
  3549. insinto "$(_udev_get_udevdir)"/rules.d;
  3550. doins "${@}" )
  3551. }
  3552. udev_get_udevdir ()
  3553. {
  3554. debug-print-function ${FUNCNAME} "${@}";
  3555. eerror "This ebuild should be using the get_udevdir() function instead of the deprecated udev_get_udevdir()";
  3556. die "Deprecated function call: udev_get_udevdir(), please report to (overlay) maintainers."
  3557. }
  3558. udev_newrules ()
  3559. {
  3560. debug-print-function ${FUNCNAME} "${@}";
  3561. ( insopts -m 0644;
  3562. insinto "$(_udev_get_udevdir)"/rules.d;
  3563. newins "${@}" )
  3564. }
  3565. udev_reload ()
  3566. {
  3567. if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
  3568. return 0;
  3569. fi;
  3570. if [[ -d ${ROOT}/run/udev ]]; then
  3571. ebegin "Running udev control --reload for reloading rules and databases";
  3572. udevadm control --reload;
  3573. eend $?;
  3574. fi
  3575. }
  3576. use_if_iuse ()
  3577. {
  3578. in_iuse $1 || return 1;
  3579. use $1
  3580. }
  3581.