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