Advertisement
Guest User

sabayon-2.30 build

a guest
Aug 2nd, 2010
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 198.86 KB | None | 0 0
  1. ### cat /var/tmp/portage/app-admin/sabayon-2.30.0/temp/environment
  2.  
  3.  
  4. declare -x ALSA_CARDS=""
  5. declare -x ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
  6. declare -x APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
  7. declare -x ARCH="x86"
  8. declare -x CBUILD="i686-pc-linux-gnu"
  9. declare -x CDEFINE_default="__unix__"
  10. declare -x CFLAGS="-O2 -march=pentium4 -pipe"
  11. declare -x CFLAGS_default=""
  12. declare -x CHOST="i686-pc-linux-gnu"
  13. declare -x CHOST_default="i686-pc-linux-gnu"
  14. declare -- COMMON_DEPEND=">=dev-lang/python-2.4
  15. >=x11-libs/gtk+-2.6.0
  16. >=dev-python/pygtk-2.16
  17. >=dev-python/pygobject-2.15
  18. x11-libs/pango
  19. dev-python/python-ldap
  20. x11-base/xorg-server[kdrive]"
  21. declare -x CROSSCOMPILE_OPTS=""
  22. declare -x CTARGET_default="i686-pc-linux-gnu"
  23. declare -x CVS_RSH="ssh"
  24. declare -x CXXFLAGS="-O2 -march=pentium4 -pipe"
  25. declare -x DEFAULT_ABI="default"
  26. declare -- DEFINED_PHASES=" compile configure install postinst postrm preinst prepare setup unpack"
  27. declare -- DEPEND=">=dev-lang/python-2.4
  28. >=x11-libs/gtk+-2.6.0
  29. >=dev-python/pygtk-2.16
  30. >=dev-python/pygobject-2.15
  31. x11-libs/pango
  32. dev-python/python-ldap
  33. x11-base/xorg-server[kdrive]
  34. >=dev-util/intltool-0.40 >=sys-apps/sed-4 >=app-admin/eselect-python-20091230"
  35. declare -- DESCRIPTION="Tool to maintain user profiles in a GNOME desktop"
  36. declare -x DESTTREE="/usr"
  37. declare -x DIROPTIONS="-m0755"
  38. declare -- DOCS="AUTHORS ChangeLog ISSUES NEWS README TODO"
  39. declare -x EAPI="2"
  40. declare -x ELIBC="glibc"
  41. declare -- ELIBTOOL_VERSION="2.0.2"
  42. declare -- ELTCONF=""
  43. declare -x ELT_APPLIED_PATCHES=" 2.2 1.5.6 2.2.6"
  44. declare -x ELT_LTMAIN_SH="/var/tmp/portage/app-admin/sabayon-2.30.0/work/sabayon-2.30.0/ltmain.sh"
  45. declare -- ELT_PATCH_DIR="/usr/portage/eclass/ELT-patches"
  46. declare -- EPATCH_EXCLUDE=""
  47. declare -- EPATCH_FORCE="no"
  48. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  49. declare -- EPATCH_OPTS="-g0 -E --no-backup-if-mismatch"
  50. declare -- EPATCH_SINGLE_MSG=""
  51. declare -- EPATCH_SOURCE="/var/tmp/portage/app-admin/sabayon-2.30.0/work/patch"
  52. declare -- EPATCH_SUFFIX="patch.bz2"
  53. declare -x EXEOPTIONS="-m0755"
  54. declare -x FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
  55. declare -- G2CONF="
  56. --disable-static
  57. --with-distro=gentoo
  58. --with-prototype-user=sabayon-admin
  59. --enable-console-helper=no"
  60. declare -x GCC_SPECS=""
  61. declare -- GCONFTOOL_BIN="/usr/bin/gconftool-2"
  62. declare -- GCONF_DEBUG="no"
  63. declare -x GDK_USE_XFT="1"
  64. declare -x GNOME_TARBALL_SUFFIX="bz2"
  65. declare -- HOMEPAGE="http://www.gnome.org/projects/sabayon/"
  66. declare -x INHERITED="gnome2 toolchain-funcs portability python multilib gnome2-utils libtool gnome.org fdo-mime eutils"
  67. declare -x INPUT_DEVICES="evdev"
  68. declare -x INSDESTTREE=""
  69. declare -x INSOPTIONS="-m0644"
  70. declare -- IUSE=" "
  71. declare -x KERNEL="linux"
  72. declare -x KERNEL_ABI="default"
  73. declare -x KEYWORDS="~alpha amd64 ~ia64 ~ppc ~ppc64 ~sparc x86"
  74. declare -x KV="2.6.34-gentoo-r1"
  75. declare -x LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
  76. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  77. declare -x LDFLAGS_default=""
  78. declare -x LIBDIR_default="lib"
  79. declare -x LIBOPTIONS="-m0644"
  80. declare -x LICENSE="GPL-2"
  81. declare -x MAIL="/var/mail/root"
  82. declare -x MAKEOPTS="-j2"
  83. declare -x MULTILIB_ABIS="default"
  84. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  85. declare -x OPENGL_PROFILE="xorg-x11"
  86. declare -x PATH="/usr/lib/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.4.3"
  87. declare -- PDEPEND=" "
  88. declare -x PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
  89. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
  90. declare -x PROPERTIES=""
  91. declare -x PROVIDE=""
  92. declare -a PVP='([0]="2" [1]="30" [2]="0")'
  93. declare -x PYTHONDONTWRITEBYTECODE="1"
  94. declare -- PYTHON_COLORS="0"
  95. declare -- PYTHON_TEST_VERBOSITY="1"
  96. declare -x RDEPEND=">=dev-lang/python-2.4
  97. >=x11-libs/gtk+-2.6.0
  98. >=dev-python/pygtk-2.16
  99. >=dev-python/pygobject-2.15
  100. x11-libs/pango
  101. dev-python/python-ldap
  102. x11-base/xorg-server[kdrive]
  103. dev-python/pyxdg
  104. dev-libs/libxml2[python]
  105. >=gnome-base/gconf-2.8.1
  106. >=dev-python/libbonobo-python-2.6
  107. >=dev-python/gconf-python-2.6
  108. x11-libs/gksu >=app-admin/eselect-python-20091230"
  109. declare -x RESTRICT=""
  110. declare -x RUBY_TARGETS=""
  111. declare -x S="/var/tmp/portage/app-admin/sabayon-2.30.0/work/sabayon-2.30.0"
  112. declare -x SANDBOX_DEBUG="0"
  113. declare -x SANDBOX_DENY="/etc/ld.so.preload"
  114. declare -x SANDBOX_PID="18033"
  115. declare -x SANDBOX_PREDICT="/var/tmp/portage/app-admin/sabayon-2.30.0/homedir:/dev/crypto:/var/cache/fontconfig"
  116. declare -x SANDBOX_READ="/:/dev/stdin:/var/tmp"
  117. declare -x SANDBOX_VERBOSE="1"
  118. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/stderr:/dev/stdout:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/app-admin/sabayon-2.30.0/homedir/.bash_history"
  119. declare -- SCROLLKEEPER_DIR="/var/lib/scrollkeeper"
  120. declare -- SCROLLKEEPER_UPDATE="1"
  121. declare -- SCROLLKEEPER_UPDATE_BIN="/usr/bin/scrollkeeper-update"
  122. declare -x SLOT="0"
  123. declare -- SRC_URI="mirror://gnome/sources/sabayon/2.30/sabayon-2.30.0.tar.bz2"
  124. declare -x SSH_CLIENT="192.168.1.146 56081 22"
  125. declare -x SSH_CONNECTION="192.168.1.146 56081 192.168.1.132 22"
  126. declare -x SSH_TTY="/dev/pts/1"
  127. declare -x USE="elibc_glibc kernel_linux userland_GNU x86"
  128. declare -x USERLAND="GNU"
  129. declare -- USE_EINSTALL=""
  130. declare -x VIDEO_CARDS=""
  131. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  132. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  133. declare -x XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
  134. declare -x XZ_OPT="--memory=max"
  135. declare -- _="PKG_INSTALL_MASK"
  136. declare -a _CPYTHON2_SUPPORTED_ABIS='([0]="2.4" [1]="2.5" [2]="2.6" [3]="2.7")'
  137. declare -a _CPYTHON3_SUPPORTED_ABIS='([0]="3.0" [1]="3.1" [2]="3.2")'
  138. declare -x _E_DOCDESTTREE_=""
  139. declare -x _E_EXEDESTTREE_=""
  140. declare -a _JYTHON_SUPPORTED_ABIS='([0]="2.5-jython")'
  141. declare -- _PYTHON_ABI_EXTRACTION_COMMAND="import platform
  142. import sys
  143. sys.stdout.write(\".\".join(str(x) for x in sys.version_info[:2]))
  144. if platform.system()[:4] == \"Java\":
  145. sys.stdout.write(\"-jython\")"
  146. declare -- ___ECLASS_RECUR_MULTILIB="yes"
  147. declare -- ___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes"
  148. declare -- filter_opts=""
  149. declare -- omf="./man/Makefile.in"
  150. ELT_find_ltmain_sh ()
  151. {
  152. local x=;
  153. local dirlist=;
  154. for x in $(find "${S}" -name 'ltmain.sh');
  155. do
  156. dirlist="${dirlist} ${x%/*}";
  157. done;
  158. echo "${dirlist}"
  159. }
  160. ELT_libtool_version ()
  161. {
  162. local ltmain_sh=$1;
  163. local version=;
  164. version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}"); echo "${VERSION}");
  165. [[ -z ${version} ]] && version="0";
  166. echo "${version}"
  167. }
  168. ELT_try_and_apply_patch ()
  169. {
  170. local ret=0;
  171. local file=$1;
  172. local patch=$2;
  173. if patch -p0 --dry-run "${file}" "${patch}" &>"${T}/elibtool.log"; then
  174. einfo " Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ...";
  175. patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" &>"${T}/elibtool.log";
  176. ret=$?;
  177. export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}";
  178. else
  179. ret=1;
  180. fi;
  181. return "${ret}"
  182. }
  183. ELT_walk_patches ()
  184. {
  185. local patch;
  186. local ret=1;
  187. local file=$1;
  188. local patch_set=$2;
  189. local patch_dir="${ELT_PATCH_DIR}/${patch_set}";
  190. local rem_int_dep=$3;
  191. [[ -z ${patch_set} ]] && return 1;
  192. [[ ! -d ${patch_dir} ]] && return 1;
  193. pushd "${ELT_PATCH_DIR}" > /dev/null;
  194. for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r);
  195. do
  196. if [[ -n ${rem_int_dep} ]]; then
  197. local tmp="${T}/$$.rem_int_deps.patch";
  198. sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" "${patch}" > "${tmp}";
  199. patch=${tmp};
  200. fi;
  201. if ELT_try_and_apply_patch "${file}" "${patch}"; then
  202. ret=0;
  203. break;
  204. fi;
  205. done;
  206. popd > /dev/null;
  207. return ${ret}
  208. }
  209. PYTHON ()
  210. {
  211. _python_check_python_pkg_setup_execution;
  212. local ABI_output="0" absolute_path_output="0" final_ABI="0" PYTHON_ABI="${PYTHON_ABI}" python_interpreter python2="0" python3="0";
  213. while (($#)); do
  214. case "$1" in
  215. -2)
  216. python2="1"
  217. ;;
  218. -3)
  219. python3="1"
  220. ;;
  221. --ABI)
  222. ABI_output="1"
  223. ;;
  224. -a | --absolute-path)
  225. absolute_path_output="1"
  226. ;;
  227. -f | --final-ABI)
  228. final_ABI="1"
  229. ;;
  230. --)
  231. shift;
  232. break
  233. ;;
  234. -*)
  235. die "${FUNCNAME}(): Unrecognized option '$1'"
  236. ;;
  237. *)
  238. break
  239. ;;
  240. esac;
  241. shift;
  242. done;
  243. if [[ "${ABI_output}" == "1" && "${absolute_path_output}" == "1" ]]; then
  244. die "${FUNCNAME}(): '--ABI' and '--absolute-path' options cannot be specified simultaneously";
  245. fi;
  246. if [[ "$((${python2} + ${python3} + ${final_ABI}))" -gt 1 ]]; then
  247. die "${FUNCNAME}(): '-2', '-3' or '--final-ABI' options cannot be specified simultaneously";
  248. fi;
  249. if [[ "$#" -eq 0 ]]; then
  250. if [[ "${final_ABI}" == "1" ]]; then
  251. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  252. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  253. fi;
  254. _python_calculate_PYTHON_ABIS;
  255. PYTHON_ABI="${PYTHON_ABIS##* }";
  256. else
  257. if [[ "${python2}" == "1" ]]; then
  258. PYTHON_ABI="$(eselect python show --python2 --ABI)";
  259. if [[ -z "${PYTHON_ABI}" ]]; then
  260. die "${FUNCNAME}(): Active version of Python 2 not set";
  261. else
  262. if [[ "${PYTHON_ABI}" != "2."* ]]; then
  263. die "${FUNCNAME}(): Internal error in \`eselect python show --python2\`";
  264. fi;
  265. fi;
  266. else
  267. if [[ "${python3}" == "1" ]]; then
  268. PYTHON_ABI="$(eselect python show --python3 --ABI)";
  269. if [[ -z "${PYTHON_ABI}" ]]; then
  270. die "${FUNCNAME}(): Active version of Python 3 not set";
  271. else
  272. if [[ "${PYTHON_ABI}" != "3."* ]]; then
  273. die "${FUNCNAME}(): Internal error in \`eselect python show --python3\`";
  274. fi;
  275. fi;
  276. else
  277. if _python_package_supporting_installation_for_multiple_python_abis; then
  278. if ! _python_abi-specific_local_scope; then
  279. die "${FUNCNAME}() should be used in ABI-specific local scope";
  280. fi;
  281. else
  282. PYTHON_ABI="$("${EPREFIX}/usr/bin/python" -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")";
  283. if [[ -z "${PYTHON_ABI}" ]]; then
  284. die "${FUNCNAME}(): Failure of extraction of locally active version of Python";
  285. fi;
  286. fi;
  287. fi;
  288. fi;
  289. fi;
  290. else
  291. if [[ "$#" -eq 1 ]]; then
  292. if [[ "${final_ABI}" == "1" ]]; then
  293. die "${FUNCNAME}(): '--final-ABI' option and Python ABI cannot be specified simultaneously";
  294. fi;
  295. if [[ "${python2}" == "1" ]]; then
  296. die "${FUNCNAME}(): '-2' option and Python ABI cannot be specified simultaneously";
  297. fi;
  298. if [[ "${python3}" == "1" ]]; then
  299. die "${FUNCNAME}(): '-3' option and Python ABI cannot be specified simultaneously";
  300. fi;
  301. PYTHON_ABI="$1";
  302. else
  303. die "${FUNCNAME}(): Invalid usage";
  304. fi;
  305. fi;
  306. if [[ "${ABI_output}" == "1" ]]; then
  307. echo -n "${PYTHON_ABI}";
  308. return;
  309. else
  310. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  311. python_interpreter="python${PYTHON_ABI}";
  312. else
  313. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  314. python_interpreter="jython-${PYTHON_ABI%-jython}";
  315. fi;
  316. fi;
  317. if [[ "${absolute_path_output}" == "1" ]]; then
  318. echo -n "${EPREFIX}/usr/bin/${python_interpreter}";
  319. else
  320. echo -n "${python_interpreter}";
  321. fi;
  322. fi;
  323. if [[ -n "${ABI}" && "${ABI}" != "${DEFAULT_ABI}" && "${DEFAULT_ABI}" != "default" ]]; then
  324. echo -n "-${ABI}";
  325. fi
  326. }
  327. VER_major ()
  328. {
  329. [[ -z $1 ]] && return 1;
  330. local VER=$@;
  331. echo "${VER%%[^[:digit:]]*}"
  332. }
  333. VER_micro ()
  334. {
  335. [[ -z $1 ]] && return 1;
  336. local VER=$@;
  337. VER=${VER#*.*.};
  338. echo "${VER%%[^[:digit:]]*}"
  339. }
  340. VER_minor ()
  341. {
  342. [[ -z $1 ]] && return 1;
  343. local VER=$@;
  344. VER=${VER#*.};
  345. echo "${VER%%[^[:digit:]]*}"
  346. }
  347. VER_to_int ()
  348. {
  349. [[ -z $1 ]] && return 1;
  350. local VER_MAJOR=$(VER_major "$1");
  351. local VER_MINOR=$(VER_minor "$1");
  352. local VER_MICRO=$(VER_micro "$1");
  353. local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ));
  354. if [[ ${VER_int} -ge 65536 ]]; then
  355. echo "${VER_int}";
  356. return 0;
  357. fi;
  358. echo 1;
  359. return 1
  360. }
  361. _cdrom_locate_file_on_cd ()
  362. {
  363. local mline="";
  364. local showedmsg=0 showjolietmsg=0;
  365. while [[ -z ${CDROM_ROOT} ]]; do
  366. local i=0;
  367. local -a cdset=(${*//:/ });
  368. if [[ -n ${CDROM_SET} ]]; then
  369. cdset=(${cdset[${CDROM_SET}]});
  370. fi;
  371. while [[ -n ${cdset[${i}]} ]]; do
  372. local dir=$(dirname ${cdset[${i}]});
  373. local file=$(basename ${cdset[${i}]});
  374. local point= node= fs= foo=;
  375. while read point node fs foo; do
  376. [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] && continue;
  377. point=${point//\040/ };
  378. [[ ! -d ${point}/${dir} ]] && continue;
  379. [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue;
  380. export CDROM_ROOT=${point};
  381. export CDROM_SET=${i};
  382. export CDROM_MATCH=${cdset[${i}]};
  383. return;
  384. done <<< "$(get_mounts)";
  385. ((++i));
  386. done;
  387. echo;
  388. if [[ ${showedmsg} -eq 0 ]]; then
  389. if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
  390. if [[ -z ${CDROM_NAME} ]]; then
  391. einfo "Please insert+mount the cdrom for ${PN} now !";
  392. else
  393. einfo "Please insert+mount the ${CDROM_NAME} cdrom now !";
  394. fi;
  395. else
  396. if [[ -z ${CDROM_NAME_1} ]]; then
  397. einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !";
  398. else
  399. local var="CDROM_NAME_${CDROM_CURRENT_CD}";
  400. einfo "Please insert+mount the ${!var} cdrom now !";
  401. fi;
  402. fi;
  403. showedmsg=1;
  404. fi;
  405. einfo "Press return to scan for the cd again";
  406. einfo "or hit CTRL+C to abort the emerge.";
  407. echo;
  408. if [[ ${showjolietmsg} -eq 0 ]]; then
  409. showjolietmsg=1;
  410. else
  411. ewarn "If you are having trouble with the detection";
  412. ewarn "of your CD, it is possible that you do not have";
  413. ewarn "Joliet support enabled in your kernel. Please";
  414. ewarn "check that CONFIG_JOLIET is enabled in your kernel.";
  415. ebeep 5;
  416. fi;
  417. read || die "something is screwed with your system";
  418. done
  419. }
  420. _gcc-install-dir ()
  421. {
  422. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  423. }
  424. _gcc-specs-directive_raw ()
  425. {
  426. local cc=$(tc-getCC);
  427. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  428. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  429. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  430. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  431. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  432. { spec=spec $0 }
  433. END { print spec }';
  434. return 0
  435. }
  436. _gcc-specs-exists ()
  437. {
  438. [[ -f $(_gcc-install-dir)/$1 ]]
  439. }
  440. _parse_PYTHON_DEPEND ()
  441. {
  442. local major_version maximal_version minimal_version python_all="0" python_maximal_version python_minimal_version python_versions=() python2="0" python2_maximal_version python2_minimal_version python3="0" python3_maximal_version python3_minimal_version USE_flag= version_components_group version_components_group_regex version_components_groups;
  443. version_components_group_regex="(2|3|\*)(:([[:digit:]]+\.[[:digit:]]+)?(:([[:digit:]]+\.[[:digit:]]+)?)?)?";
  444. version_components_groups="${PYTHON_DEPEND}";
  445. if [[ "${version_components_groups}" =~ ^((\!)?[[:alnum:]_-]+\?\ )?${version_components_group_regex}(\ ${version_components_group_regex})?$ ]]; then
  446. if [[ "${version_components_groups}" =~ ^(\!)?[[:alnum:]_-]+\? ]]; then
  447. USE_flag="${version_components_groups%\? *}";
  448. version_components_groups="${version_components_groups#* }";
  449. fi;
  450. if [[ "${version_components_groups}" =~ ("*".*" "|" *"|^2.*\ (2|\*)|^3.*\ (3|\*)) ]]; then
  451. die "Invalid syntax of PYTHON_DEPEND: Incorrectly specified groups of versions";
  452. fi;
  453. version_components_groups="${version_components_groups// /
  454. }";
  455. while read version_components_group; do
  456. major_version="${version_components_group:0:1}";
  457. minimal_version="${version_components_group:2}";
  458. minimal_version="${minimal_version%:*}";
  459. maximal_version="${version_components_group:$((3 + ${#minimal_version}))}";
  460. if [[ "${major_version}" =~ ^(2|3)$ ]]; then
  461. if [[ -n "${minimal_version}" && "${major_version}" != "${minimal_version:0:1}" ]]; then
  462. die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' not in specified group of versions";
  463. fi;
  464. if [[ -n "${maximal_version}" && "${major_version}" != "${maximal_version:0:1}" ]]; then
  465. die "Invalid syntax of PYTHON_DEPEND: Maximal version '${maximal_version}' not in specified group of versions";
  466. fi;
  467. fi;
  468. if [[ "${major_version}" == "2" ]]; then
  469. python2="1";
  470. python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}");
  471. python2_minimal_version="${minimal_version}";
  472. python2_maximal_version="${maximal_version}";
  473. else
  474. if [[ "${major_version}" == "3" ]]; then
  475. python3="1";
  476. python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}");
  477. python3_minimal_version="${minimal_version}";
  478. python3_maximal_version="${maximal_version}";
  479. else
  480. python_all="1";
  481. python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}");
  482. python_minimal_version="${minimal_version}";
  483. python_maximal_version="${maximal_version}";
  484. fi;
  485. fi;
  486. if [[ -n "${minimal_version}" ]] && ! has "${minimal_version}" "${python_versions[@]}"; then
  487. die "Invalid syntax of PYTHON_DEPEND: Unrecognized minimal version '${minimal_version}'";
  488. fi;
  489. if [[ -n "${maximal_version}" ]] && ! has "${maximal_version}" "${python_versions[@]}"; then
  490. die "Invalid syntax of PYTHON_DEPEND: Unrecognized maximal version '${maximal_version}'";
  491. fi;
  492. if [[ -n "${minimal_version}" && -n "${maximal_version}" && "${minimal_version}" > "${maximal_version}" ]]; then
  493. die "Invalid syntax of PYTHON_DEPEND: Minimal version '${minimal_version}' greater than maximal version '${maximal_version}'";
  494. fi;
  495. done <<< "${version_components_groups}";
  496. _PYTHON_ATOMS=();
  497. function _append_accepted_versions_range ()
  498. {
  499. local accepted_version="0" i;
  500. for ((i = "${#python_versions[@]}"; i >= 0; i--))
  501. do
  502. if [[ "${python_versions[${i}]}" == "${python_maximal_version}" ]]; then
  503. accepted_version="1";
  504. fi;
  505. if [[ "${accepted_version}" == "1" ]]; then
  506. _PYTHON_ATOMS+=("=dev-lang/python-${python_versions[${i}]}*");
  507. fi;
  508. if [[ "${python_versions[${i}]}" == "${python_minimal_version}" ]]; then
  509. accepted_version="0";
  510. fi;
  511. done
  512. };
  513. if [[ "${python_all}" == "1" ]]; then
  514. if [[ -z "${python_minimal_version}" && -z "${python_maximal_version}" ]]; then
  515. _PYTHON_ATOMS+=("dev-lang/python");
  516. else
  517. python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}");
  518. python_minimal_version="${python_minimal_version:-${python_versions[0]}}";
  519. python_maximal_version="${python_maximal_version:-${python_versions[${#python_versions[@]}-1]}}";
  520. _append_accepted_versions_range;
  521. fi;
  522. else
  523. if [[ "${python3}" == "1" ]]; then
  524. if [[ -z "${python3_minimal_version}" && -z "${python3_maximal_version}" ]]; then
  525. _PYTHON_ATOMS+=("=dev-lang/python-3*");
  526. else
  527. python_versions=("${_CPYTHON3_SUPPORTED_ABIS[@]}");
  528. python_minimal_version="${python3_minimal_version:-${python_versions[0]}}";
  529. python_maximal_version="${python3_maximal_version:-${python_versions[${#python_versions[@]}-1]}}";
  530. _append_accepted_versions_range;
  531. fi;
  532. fi;
  533. if [[ "${python2}" == "1" ]]; then
  534. if [[ -z "${python2_minimal_version}" && -z "${python2_maximal_version}" ]]; then
  535. _PYTHON_ATOMS+=("=dev-lang/python-2*");
  536. else
  537. python_versions=("${_CPYTHON2_SUPPORTED_ABIS[@]}");
  538. python_minimal_version="${python2_minimal_version:-${python_versions[0]}}";
  539. python_maximal_version="${python2_maximal_version:-${python_versions[${#python_versions[@]}-1]}}";
  540. _append_accepted_versions_range;
  541. fi;
  542. fi;
  543. fi;
  544. unset -f _append_accepted_versions_range;
  545. if [[ "${#_PYTHON_ATOMS[@]}" -gt 1 ]]; then
  546. DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}";
  547. RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }|| ( ${_PYTHON_ATOMS[@]} )${USE_flag:+ )}";
  548. else
  549. DEPEND+="${DEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}";
  550. RDEPEND+="${RDEPEND:+ }${USE_flag}${USE_flag:+? ( }${_PYTHON_ATOMS[@]}${USE_flag:+ )}";
  551. fi;
  552. else
  553. die "Invalid syntax of PYTHON_DEPEND";
  554. fi
  555. }
  556. _python_abi-specific_local_scope ()
  557. {
  558. [[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]]
  559. }
  560. _python_calculate_PYTHON_ABIS ()
  561. {
  562. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  563. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  564. fi;
  565. _python_initial_sanity_checks;
  566. if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3 4; then
  567. local PYTHON_ABI restricted_ABI support_ABI supported_PYTHON_ABIS=;
  568. PYTHON_ABI_SUPPORTED_VALUES="${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}";
  569. if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then
  570. local cpython_enabled="0";
  571. if [[ -z "${USE_PYTHON}" ]]; then
  572. die "USE_PYTHON variable is empty";
  573. fi;
  574. for PYTHON_ABI in ${USE_PYTHON};
  575. do
  576. if ! has "${PYTHON_ABI}" ${PYTHON_ABI_SUPPORTED_VALUES}; then
  577. die "USE_PYTHON variable contains invalid value '${PYTHON_ABI}'";
  578. fi;
  579. if has "${PYTHON_ABI}" "${_CPYTHON2_SUPPORTED_ABIS[@]}" "${_CPYTHON3_SUPPORTED_ABIS[@]}"; then
  580. cpython_enabled="1";
  581. fi;
  582. support_ABI="1";
  583. for restricted_ABI in ${RESTRICT_PYTHON_ABIS};
  584. do
  585. if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
  586. support_ABI="0";
  587. break;
  588. fi;
  589. done;
  590. [[ "${support_ABI}" == "1" ]] && export PYTHON_ABIS+="${PYTHON_ABIS:+ }${PYTHON_ABI}";
  591. done;
  592. if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then
  593. die "USE_PYTHON variable does not enable any Python ABI supported by ${CATEGORY}/${PF}";
  594. fi;
  595. if [[ "${cpython_enabled}" == "0" ]]; then
  596. die "USE_PYTHON variable does not enable any CPython ABI";
  597. fi;
  598. else
  599. local python_version python2_version= python3_version= support_python_major_version;
  600. if ! has_version "dev-lang/python"; then
  601. die "${FUNCNAME}(): 'dev-lang/python' is not installed";
  602. fi;
  603. python_version="$("${EPREFIX}/usr/bin/python" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')";
  604. if has_version "=dev-lang/python-2*"; then
  605. if [[ "$(readlink "${EPREFIX}/usr/bin/python2")" != "python2."* ]]; then
  606. die "'${EPREFIX}/usr/bin/python2' is not valid symlink";
  607. fi;
  608. python2_version="$("${EPREFIX}/usr/bin/python2" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')";
  609. for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}";
  610. do
  611. support_python_major_version="1";
  612. for restricted_ABI in ${RESTRICT_PYTHON_ABIS};
  613. do
  614. if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
  615. support_python_major_version="0";
  616. fi;
  617. done;
  618. [[ "${support_python_major_version}" == "1" ]] && break;
  619. done;
  620. if [[ "${support_python_major_version}" == "1" ]]; then
  621. for restricted_ABI in ${RESTRICT_PYTHON_ABIS};
  622. do
  623. if [[ "${python2_version}" == ${restricted_ABI} ]]; then
  624. die "Active version of Python 2 is not supported by ${CATEGORY}/${PF}";
  625. fi;
  626. done;
  627. else
  628. python2_version="";
  629. fi;
  630. fi;
  631. if has_version "=dev-lang/python-3*"; then
  632. if [[ "$(readlink "${EPREFIX}/usr/bin/python3")" != "python3."* ]]; then
  633. die "'${EPREFIX}/usr/bin/python3' is not valid symlink";
  634. fi;
  635. python3_version="$("${EPREFIX}/usr/bin/python3" -c 'from sys import version_info; print(".".join(str(x) for x in version_info[:2]))')";
  636. for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}";
  637. do
  638. support_python_major_version="1";
  639. for restricted_ABI in ${RESTRICT_PYTHON_ABIS};
  640. do
  641. if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
  642. support_python_major_version="0";
  643. fi;
  644. done;
  645. [[ "${support_python_major_version}" == "1" ]] && break;
  646. done;
  647. if [[ "${support_python_major_version}" == "1" ]]; then
  648. for restricted_ABI in ${RESTRICT_PYTHON_ABIS};
  649. do
  650. if [[ "${python3_version}" == ${restricted_ABI} ]]; then
  651. die "Active version of Python 3 is not supported by ${CATEGORY}/${PF}";
  652. fi;
  653. done;
  654. else
  655. python3_version="";
  656. fi;
  657. fi;
  658. if [[ -n "${python2_version}" && "${python_version}" == "2."* && "${python_version}" != "${python2_version}" ]]; then
  659. eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python2' symlink";
  660. eerror "is set incorrectly. Use \`eselect python\` to fix configuration.";
  661. die "Incorrect configuration of Python";
  662. fi;
  663. if [[ -n "${python3_version}" && "${python_version}" == "3."* && "${python_version}" != "${python3_version}" ]]; then
  664. eerror "Python wrapper is configured incorrectly or '${EPREFIX}/usr/bin/python3' symlink";
  665. eerror "is set incorrectly. Use \`eselect python\` to fix configuration.";
  666. die "Incorrect configuration of Python";
  667. fi;
  668. PYTHON_ABIS="${python2_version} ${python3_version}";
  669. PYTHON_ABIS="${PYTHON_ABIS# }";
  670. export PYTHON_ABIS="${PYTHON_ABIS% }";
  671. fi;
  672. fi;
  673. _python_final_sanity_checks
  674. }
  675. _python_check_python_pkg_setup_execution ()
  676. {
  677. [[ " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " ]] && return;
  678. if ! has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_PKG_SETUP_EXECUTED}" ]]; then
  679. die "python_pkg_setup() not called";
  680. fi
  681. }
  682. _python_clean_compiled_modules ()
  683. {
  684. _python_initialize_prefix_variables;
  685. _python_set_color_variables;
  686. [[ "${FUNCNAME[1]}" =~ ^(python_mod_optimize|python_mod_compile|python_mod_cleanup)$ ]] || die "${FUNCNAME}(): Invalid usage";
  687. local base_module_name compiled_file compiled_files=() dir path py_file root;
  688. root="${EROOT%/}";
  689. for path in "$@";
  690. do
  691. compiled_files=();
  692. if [[ -d "${path}" ]]; then
  693. while read -d '' -r compiled_file; do
  694. compiled_files+=("${compiled_file}");
  695. done < <(find "${path}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -print0);
  696. if [[ "${EBUILD_PHASE}" == "postrm" ]]; then
  697. find "${path}" -type d | sort -r | while read -r dir; do
  698. if rmdir "${dir}" 2> /dev/null; then
  699. echo "${_CYAN}<<< ${dir}${_NORMAL}";
  700. fi;
  701. done;
  702. fi;
  703. else
  704. if [[ "${path}" == *.py ]]; then
  705. base_module_name="${path##*/}";
  706. base_module_name="${base_module_name%.py}";
  707. if [[ -d "${path%/*}/__pycache__" ]]; then
  708. while read -d '' -r compiled_file; do
  709. compiled_files+=("${compiled_file}");
  710. done < <(find "${path%/*}/__pycache__" "(" -name "${base_module_name}.*.py[co]" -o -name "${base_module_name}\$py.class" ")" -print0);
  711. fi;
  712. compiled_files+=("${path}c" "${path}o" "${path%.py}\$py.class");
  713. fi;
  714. fi;
  715. for compiled_file in "${compiled_files[@]}";
  716. do
  717. [[ ! -f "${compiled_file}" ]] && continue;
  718. dir="${compiled_file%/*}";
  719. dir="${dir##*/}";
  720. if [[ "${compiled_file}" == *.py[co] ]]; then
  721. if [[ "${dir}" == "__pycache__" ]]; then
  722. base_module_name="${compiled_file##*/}";
  723. base_module_name="${base_module_name%.*py[co]}";
  724. base_module_name="${base_module_name%.*}";
  725. py_file="${compiled_file%__pycache__/*}${base_module_name}.py";
  726. else
  727. py_file="${compiled_file%[co]}";
  728. fi;
  729. if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
  730. [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue;
  731. else
  732. [[ -f "${py_file}" ]] && continue;
  733. fi;
  734. echo "${_BLUE}<<< ${compiled_file%[co]}[co]${_NORMAL}";
  735. rm -f "${compiled_file%[co]}"[co];
  736. else
  737. if [[ "${compiled_file}" == *\$py.class ]]; then
  738. if [[ "${dir}" == "__pycache__" ]]; then
  739. base_module_name="${compiled_file##*/}";
  740. base_module_name="${base_module_name%\$py.class}";
  741. py_file="${compiled_file%__pycache__/*}${base_module_name}.py";
  742. else
  743. py_file="${compiled_file%\$py.class}";
  744. fi;
  745. if [[ "${EBUILD_PHASE}" == "postinst" ]]; then
  746. [[ -f "${py_file}" && "${compiled_file}" -nt "${py_file}" ]] && continue;
  747. else
  748. [[ -f "${py_file}" ]] && continue;
  749. fi;
  750. echo "${_BLUE}<<< ${compiled_file}${_NORMAL}";
  751. rm -f "${compiled_file}";
  752. else
  753. die "${FUNCNAME}(): Unrecognized file type: '${compiled_file}'";
  754. fi;
  755. fi;
  756. dir="${compiled_file%/*}";
  757. while [[ "${dir}" != "${root}" ]]; do
  758. if rmdir "${dir}" 2> /dev/null; then
  759. echo "${_CYAN}<<< ${dir}${_NORMAL}";
  760. else
  761. break;
  762. fi;
  763. dir="${dir%/*}";
  764. done;
  765. done;
  766. done
  767. }
  768. _python_final_sanity_checks ()
  769. {
  770. if ! _python_implementation && [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
  771. local PYTHON_ABI="${PYTHON_ABI}";
  772. for PYTHON_ABI in ${PYTHON_ABIS-${PYTHON_ABI}};
  773. do
  774. if ! has_version "$(python_get_implementational_package)"; then
  775. die "$(python_get_implementational_package) is not installed";
  776. fi;
  777. if [[ "$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")" != "${PYTHON_ABI}" ]]; then
  778. eerror "Path to 'python': '$(type -p python)'";
  779. eerror "ABI: '${ABI}'";
  780. eerror "DEFAULT_ABI: '${DEFAULT_ABI}'";
  781. eerror "EPYTHON: '$(PYTHON)'";
  782. eerror "PYTHON_ABI: '${PYTHON_ABI}'";
  783. eerror "Locally active version of Python: '$(EPYTHON="$(PYTHON)" python -c "${_PYTHON_ABI_EXTRACTION_COMMAND}")'";
  784. die "'python' does not respect EPYTHON variable";
  785. fi;
  786. done;
  787. fi;
  788. PYTHON_SANITY_CHECKS_EXECUTED="1"
  789. }
  790. _python_get_implementation ()
  791. {
  792. if [[ "$#" -ne 1 ]]; then
  793. die "${FUNCNAME}() requires 1 argument";
  794. fi;
  795. if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
  796. echo "CPython";
  797. else
  798. if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+-jython$ ]]; then
  799. echo "Jython";
  800. else
  801. die "${FUNCNAME}(): Unrecognized Python ABI '$1'";
  802. fi;
  803. fi
  804. }
  805. _python_implementation ()
  806. {
  807. if [[ "${CATEGORY}/${PN}" == "dev-lang/python" ]]; then
  808. return 0;
  809. else
  810. if [[ "${CATEGORY}/${PN}" == "dev-java/jython" ]]; then
  811. return 0;
  812. else
  813. return 1;
  814. fi;
  815. fi
  816. }
  817. _python_initial_sanity_checks ()
  818. {
  819. if [[ "$(declare -p PYTHON_SANITY_CHECKS_EXECUTED 2> /dev/null)" != "declare -- PYTHON_SANITY_CHECKS_EXECUTED="* || " ${FUNCNAME[@]:1} " =~ " "(python_set_active_version|python_pkg_setup)" " && -z "${PYTHON_SKIP_SANITY_CHECKS}" ]]; then
  820. if [[ "$(readlink "${EPREFIX}/usr/bin/python")" != "python-wrapper" ]]; then
  821. eerror "'${EPREFIX}/usr/bin/python' is not valid symlink.";
  822. eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem.";
  823. die "'${EPREFIX}/usr/bin/python' is not valid symlink";
  824. fi;
  825. if [[ "$(<"${EPREFIX}/usr/bin/python-config")" != *"Gentoo python-config wrapper script"* ]]; then
  826. eerror "'${EPREFIX}/usr/bin/python-config' is not valid script";
  827. eerror "Use \`eselect python set \${python_interpreter}\` to fix this problem.";
  828. die "'${EPREFIX}/usr/bin/python-config' is not valid script";
  829. fi;
  830. fi
  831. }
  832. _python_initialize_prefix_variables ()
  833. {
  834. if has "${EAPI:-0}" 0 1 2; then
  835. if [[ -n "${ROOT}" && -z "${EROOT}" ]]; then
  836. EROOT="${ROOT%/}${EPREFIX}/";
  837. fi;
  838. if [[ -n "${D}" && -z "${ED}" ]]; then
  839. ED="${D%/}${EPREFIX}/";
  840. fi;
  841. fi
  842. }
  843. _python_package_supporting_installation_for_multiple_python_abis ()
  844. {
  845. if [[ "${EBUILD_PHASE}" == "depend" ]]; then
  846. die "${FUNCNAME}() cannot be used in global scope";
  847. fi;
  848. if has "${EAPI:-0}" 0 1 2 3 4; then
  849. if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
  850. return 0;
  851. else
  852. return 1;
  853. fi;
  854. else
  855. die "${FUNCNAME}(): Support for EAPI=\"${EAPI}\" not implemented";
  856. fi
  857. }
  858. _python_prepare_flags ()
  859. {
  860. local array=() deleted_flag element flags new_value old_flag old_value operator pattern prefix variable;
  861. for variable in CPPFLAGS CFLAGS CXXFLAGS LDFLAGS;
  862. do
  863. eval "_PYTHON_SAVED_${variable}=\"\${!variable}\"";
  864. for prefix in PYTHON_USER_ PYTHON_;
  865. do
  866. if [[ "$(declare -p ${prefix}${variable} 2> /dev/null)" == "declare -a ${prefix}${variable}="* ]]; then
  867. eval "array=(\"\${${prefix}${variable}[@]}\")";
  868. for element in "${array[@]}";
  869. do
  870. if [[ "${element}" =~ ^([[:alnum:]]|\.|-|\*|\[|\])+\ (\+|-)\ .+ ]]; then
  871. pattern="${element%% *}";
  872. element="${element#* }";
  873. operator="${element%% *}";
  874. flags="${element#* }";
  875. if [[ "${PYTHON_ABI}" == ${pattern} ]]; then
  876. if [[ "${operator}" == "+" ]]; then
  877. eval "export ${variable}+=\"\${variable:+ }${flags}\"";
  878. else
  879. if [[ "${operator}" == "-" ]]; then
  880. flags="${flags// /
  881. }";
  882. old_value="${!variable// /
  883. }";
  884. new_value="";
  885. while read old_flag; do
  886. while read deleted_flag; do
  887. if [[ "${old_flag}" == ${deleted_flag} ]]; then
  888. continue 2;
  889. fi;
  890. done <<< "${flags}";
  891. new_value+="${new_value:+ }${old_flag}";
  892. done <<< "${old_value}";
  893. eval "export ${variable}=\"\${new_value}\"";
  894. fi;
  895. fi;
  896. fi;
  897. else
  898. die "Element '${element}' of ${prefix}${variable} array has invalid syntax";
  899. fi;
  900. done;
  901. else
  902. if [[ -n "$(declare -p ${prefix}${variable} 2> /dev/null)" ]]; then
  903. die "${prefix}${variable} should be indexed array";
  904. fi;
  905. fi;
  906. done;
  907. done
  908. }
  909. _python_restore_flags ()
  910. {
  911. local variable;
  912. for variable in CPPFLAGS CFLAGS CXXFLAGS LDFLAGS;
  913. do
  914. eval "${variable}=\"\${_PYTHON_SAVED_${variable}}\"";
  915. unset _PYTHON_SAVED_${variable};
  916. done
  917. }
  918. _python_set_color_variables ()
  919. {
  920. if [[ "${PYTHON_COLORS}" != "0" && "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
  921. _BOLD='';
  922. _RED='';
  923. _GREEN='';
  924. _BLUE='';
  925. _CYAN='';
  926. _NORMAL='';
  927. else
  928. _BOLD=;
  929. _RED=;
  930. _GREEN=;
  931. _BLUE=;
  932. _CYAN=;
  933. _NORMAL=;
  934. fi
  935. }
  936. _python_test_hook ()
  937. {
  938. if [[ "$#" -ne 1 ]]; then
  939. die "${FUNCNAME}() requires 1 argument";
  940. fi;
  941. if _python_package_supporting_installation_for_multiple_python_abis && [[ "$(type -t "${FUNCNAME[3]}_$1_hook")" == "function" ]]; then
  942. "${FUNCNAME[3]}_$1_hook";
  943. fi
  944. }
  945. _unpack_tar ()
  946. {
  947. if [ "${y}" == "tar" ]; then
  948. $1 -dc "$srcdir$x" | tar xof -;
  949. assert "$myfail";
  950. else
  951. $1 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail";
  952. fi
  953. }
  954. built_with_use ()
  955. {
  956. local hidden="no";
  957. if [[ $1 == "--hidden" ]]; then
  958. hidden="yes";
  959. shift;
  960. fi;
  961. local missing_action="die";
  962. if [[ $1 == "--missing" ]]; then
  963. missing_action=$2;
  964. shift;
  965. shift;
  966. case ${missing_action} in
  967. true | false | die)
  968.  
  969. ;;
  970. *)
  971. die "unknown action '${missing_action}'"
  972. ;;
  973. esac;
  974. fi;
  975. local opt=$1;
  976. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  977. local PKG=$(best_version $1);
  978. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  979. shift;
  980. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  981. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  982. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  983. case ${missing_action} in
  984. true)
  985. return 0
  986. ;;
  987. false)
  988. return 1
  989. ;;
  990. die)
  991. die "Unable to determine what USE flags $PKG was built with"
  992. ;;
  993. esac;
  994. fi;
  995. if [[ ${hidden} == "no" ]]; then
  996. local IUSE_BUILT=($(<"${IUSEFILE}"));
  997. local expand;
  998. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  999. do
  1000. if [[ $1 == ${expand}_* ]]; then
  1001. expand="";
  1002. break;
  1003. fi;
  1004. done;
  1005. if [[ -n ${expand} ]]; then
  1006. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  1007. case ${missing_action} in
  1008. true)
  1009. return 0
  1010. ;;
  1011. false)
  1012. return 1
  1013. ;;
  1014. die)
  1015. die "$PKG does not actually support the $1 USE flag!"
  1016. ;;
  1017. esac;
  1018. fi;
  1019. fi;
  1020. fi;
  1021. local USE_BUILT=$(<${USEFILE});
  1022. while [[ $# -gt 0 ]]; do
  1023. if [[ ${opt} = "-o" ]]; then
  1024. has $1 ${USE_BUILT} && return 0;
  1025. else
  1026. has $1 ${USE_BUILT} || return 1;
  1027. fi;
  1028. shift;
  1029. done;
  1030. [[ ${opt} = "-a" ]]
  1031. }
  1032. cdrom_get_cds ()
  1033. {
  1034. local cdcnt=0;
  1035. local f=;
  1036. for f in "$@";
  1037. do
  1038. ((++cdcnt));
  1039. export CDROM_CHECK_${cdcnt}="$f";
  1040. done;
  1041. export CDROM_TOTAL_CDS=${cdcnt};
  1042. export CDROM_CURRENT_CD=1;
  1043. if [[ -n ${CD_ROOT}${CD_ROOT_1} ]]; then
  1044. local var=;
  1045. cdcnt=0;
  1046. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  1047. ((++cdcnt));
  1048. var="CD_ROOT_${cdcnt}";
  1049. [[ -z ${!var} ]] && var="CD_ROOT";
  1050. if [[ -z ${!var} ]]; then
  1051. eerror "You must either use just the CD_ROOT";
  1052. eerror "or specify ALL the CD_ROOT_X variables.";
  1053. eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables.";
  1054. die "could not locate CD_ROOT_${cdcnt}";
  1055. fi;
  1056. done;
  1057. export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}};
  1058. einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}";
  1059. export CDROM_SET=-1;
  1060. for f in ${CDROM_CHECK_1//:/ };
  1061. do
  1062. ((++CDROM_SET));
  1063. [[ -e ${CDROM_ROOT}/${f} ]] && break;
  1064. done;
  1065. export CDROM_MATCH=${f};
  1066. return;
  1067. fi;
  1068. if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
  1069. einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}";
  1070. echo;
  1071. einfo "If you do not have the CD, but have the data files";
  1072. einfo "mounted somewhere on your filesystem, just export";
  1073. einfo "the variable CD_ROOT so that it points to the";
  1074. einfo "directory containing the files.";
  1075. echo;
  1076. einfo "For example:";
  1077. einfo "export CD_ROOT=/mnt/cdrom";
  1078. echo;
  1079. else
  1080. if [[ -n ${CDROM_NAME_SET} ]]; then
  1081. cdcnt=0;
  1082. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  1083. ((++cdcnt));
  1084. export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}";
  1085. done;
  1086. fi;
  1087. einfo "This package will need access to ${CDROM_TOTAL_CDS} cds.";
  1088. cdcnt=0;
  1089. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  1090. ((++cdcnt));
  1091. var="CDROM_NAME_${cdcnt}";
  1092. [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}";
  1093. done;
  1094. echo;
  1095. einfo "If you do not have the CDs, but have the data files";
  1096. einfo "mounted somewhere on your filesystem, just export";
  1097. einfo "the following variables so they point to the right place:";
  1098. einfon "";
  1099. cdcnt=0;
  1100. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  1101. ((++cdcnt));
  1102. echo -n " CD_ROOT_${cdcnt}";
  1103. done;
  1104. echo;
  1105. einfo "Or, if you have all the files in the same place, or";
  1106. einfo "you only have one cdrom, you can export CD_ROOT";
  1107. einfo "and that place will be used as the same data source";
  1108. einfo "for all the CDs.";
  1109. echo;
  1110. einfo "For example:";
  1111. einfo "export CD_ROOT_1=/mnt/cdrom";
  1112. echo;
  1113. fi;
  1114. export CDROM_SET="";
  1115. export CDROM_CURRENT_CD=0;
  1116. cdrom_load_next_cd
  1117. }
  1118. cdrom_load_next_cd ()
  1119. {
  1120. local var;
  1121. ((++CDROM_CURRENT_CD));
  1122. unset CDROM_ROOT;
  1123. var=CD_ROOT_${CDROM_CURRENT_CD};
  1124. [[ -z ${!var} ]] && var="CD_ROOT";
  1125. if [[ -z ${!var} ]]; then
  1126. var="CDROM_CHECK_${CDROM_CURRENT_CD}";
  1127. _cdrom_locate_file_on_cd ${!var};
  1128. else
  1129. export CDROM_ROOT=${!var};
  1130. fi;
  1131. einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
  1132. }
  1133. check_license ()
  1134. {
  1135. local lic=$1;
  1136. if [ -z "${lic}" ]; then
  1137. lic="${PORTDIR}/licenses/${LICENSE}";
  1138. else
  1139. if [ -e "${PORTDIR}/licenses/${lic}" ]; then
  1140. lic="${PORTDIR}/licenses/${lic}";
  1141. else
  1142. if [ -e "${PWD}/${lic}" ]; then
  1143. lic="${PWD}/${lic}";
  1144. else
  1145. if [ -e "${lic}" ]; then
  1146. lic="${lic}";
  1147. fi;
  1148. fi;
  1149. fi;
  1150. fi;
  1151. local l="`basename ${lic}`";
  1152. local alic;
  1153. eshopts_push -o noglob;
  1154. for alic in ${ACCEPT_LICENSE};
  1155. do
  1156. if [[ ${alic} == ${l} ]]; then
  1157. eshopts_pop;
  1158. return 0;
  1159. fi;
  1160. done;
  1161. eshopts_pop;
  1162. [ ! -f "${lic}" ] && die "Could not find requested license ${lic}";
  1163. local licmsg=$(emktemp);
  1164. cat > ${licmsg} <<-EOF
  1165. **********************************************************
  1166. The following license outlines the terms of use of this
  1167. package. You MUST accept this license for installation to
  1168. continue. When you are done viewing, hit 'q'. If you
  1169. CTRL+C out of this, the install will not run!
  1170. **********************************************************
  1171.  
  1172. EOF
  1173.  
  1174. cat ${lic} >> ${licmsg};
  1175. ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}";
  1176. einfon "Do you accept the terms of this license (${l})? [yes/no] ";
  1177. read alic;
  1178. case ${alic} in
  1179. yes | Yes | y | Y)
  1180. return 0
  1181. ;;
  1182. *)
  1183. echo;
  1184. echo;
  1185. echo;
  1186. eerror "You MUST accept the license to continue! Exiting!";
  1187. die "Failed to accept license"
  1188. ;;
  1189. esac
  1190. }
  1191. create_ml_includes ()
  1192. {
  1193. local dest=$1;
  1194. shift;
  1195. local basedirs=$(create_ml_includes-listdirs "$@");
  1196. create_ml_includes-makedestdirs ${dest} ${basedirs};
  1197. local file;
  1198. for file in $(create_ml_includes-allfiles ${basedirs});
  1199. do
  1200. ( echo "/* Autogenerated by create_ml_includes() in multilib.eclass */";
  1201. local dir;
  1202. for dir in ${basedirs};
  1203. do
  1204. if [[ -f ${D}/${dir}/${file} ]]; then
  1205. echo "";
  1206. local sym=$(create_ml_includes-sym_for_dir ${dir} "$@");
  1207. if [[ ${sym/=} != "${sym}" ]]; then
  1208. echo "#if ${sym}";
  1209. else
  1210. if [[ ${sym::1} == "!" ]]; then
  1211. echo "#ifndef ${sym:1}";
  1212. else
  1213. echo "#ifdef ${sym}";
  1214. fi;
  1215. fi;
  1216. echo "# include <$(create_ml_includes-absolute ${dir}/${file})>";
  1217. echo "#endif /* ${sym} */";
  1218. fi;
  1219. done ) > "${D}/${dest}/${file}";
  1220. done
  1221. }
  1222. create_ml_includes-absolute ()
  1223. {
  1224. local dst="$(create_ml_includes-tidy_path $1)";
  1225. dst=(${dst//\// });
  1226. local i;
  1227. for ((i=0; i<${#dst[*]}; i++))
  1228. do
  1229. [ "${dst[i]}" == "include" ] && break;
  1230. done;
  1231. local strip_upto=$i;
  1232. for ((i=strip_upto+1; i<${#dst[*]}-1; i++))
  1233. do
  1234. echo -n ${dst[i]}/;
  1235. done;
  1236. echo -n ${dst[i]}
  1237. }
  1238. create_ml_includes-allfiles ()
  1239. {
  1240. [[ -z ${ED} ]] && local ED=${D};
  1241. local basedir file;
  1242. for basedir in "$@";
  1243. do
  1244. for file in $(find "${ED}"/${basedir} -type f);
  1245. do
  1246. echo ${file/${ED}\/${basedir}\//};
  1247. done;
  1248. done | sort | uniq
  1249. }
  1250. create_ml_includes-listdirs ()
  1251. {
  1252. local dirs;
  1253. local data;
  1254. for data in "$@";
  1255. do
  1256. dirs="${dirs} ${data/*:/}";
  1257. done;
  1258. echo ${dirs:1}
  1259. }
  1260. create_ml_includes-makedestdirs ()
  1261. {
  1262. local dest=$1;
  1263. shift;
  1264. local basedirs=$@;
  1265. [[ -z ${ED} ]] && local ED=${D};
  1266. dodir ${dest};
  1267. local basedir;
  1268. for basedir in ${basedirs};
  1269. do
  1270. local dir;
  1271. for dir in $(find "${ED}"/${basedir} -type d);
  1272. do
  1273. dodir ${dest}/${dir/${ED}\/${basedir}/};
  1274. done;
  1275. done
  1276. }
  1277. create_ml_includes-sym_for_dir ()
  1278. {
  1279. local dir=$1;
  1280. shift;
  1281. local data;
  1282. for data in "$@";
  1283. do
  1284. if [[ ${data} == *:${dir} ]]; then
  1285. echo ${data/:*/};
  1286. return 0;
  1287. fi;
  1288. done;
  1289. echo "Shouldn't be here -- create_ml_includes-sym_for_dir $1 $@";
  1290. exit 1
  1291. }
  1292. create_ml_includes-tidy_path ()
  1293. {
  1294. local removed=$1;
  1295. if [ -n "${removed}" ]; then
  1296. while [ "${removed}" != "${removed/\/\//\/}" ]; do
  1297. removed=${removed/\/\//\/};
  1298. done;
  1299. while [ "${removed}" != "${removed//\/.\//\/}" ]; do
  1300. removed=${removed//\/.\//\/};
  1301. done;
  1302. [ "${removed##*/}" = "." ] && removed=${removed%/*};
  1303. while [ "${removed}" != "${removed//\/..\/}" ]; do
  1304. local p1="${removed%%\/..\/*}";
  1305. local p2="${removed#*\/..\/}";
  1306. removed="${p1%\/*}/${p2}";
  1307. done;
  1308. [ "${removed##*/}" = ".." ] && removed=${removed%/*/*};
  1309. [ "${removed##*/}" = "" ] && removed=${removed%/*};
  1310. echo ${removed};
  1311. fi
  1312. }
  1313. darwintoolize ()
  1314. {
  1315. ewarn "darwintoolize() is deprecated, please just use elibtoolize()!";
  1316. elibtoolize
  1317. }
  1318. dlopen_lib ()
  1319. {
  1320. case "${CHOST}" in
  1321. *-linux-gnu* | *-linux-uclibc | *-interix*)
  1322. echo "-ldl"
  1323. ;;
  1324. esac
  1325. }
  1326. doicon ()
  1327. {
  1328. ( local i j ret;
  1329. insinto /usr/share/pixmaps;
  1330. for i in "$@";
  1331. do
  1332. if [[ -f ${i} ]]; then
  1333. doins "${i}";
  1334. ((ret+=$?));
  1335. else
  1336. if [[ -d ${i} ]]; then
  1337. for j in "${i}"/*.png;
  1338. do
  1339. doins "${j}";
  1340. ((ret+=$?));
  1341. done;
  1342. else
  1343. ((++ret));
  1344. fi;
  1345. fi;
  1346. done;
  1347. exit ${ret} )
  1348. }
  1349. domenu ()
  1350. {
  1351. ( local i j ret=0;
  1352. insinto /usr/share/applications;
  1353. for i in "$@";
  1354. do
  1355. if [[ -f ${i} ]]; then
  1356. doins "${i}";
  1357. ((ret+=$?));
  1358. else
  1359. if [[ -d ${i} ]]; then
  1360. for j in "${i}"/*.desktop;
  1361. do
  1362. doins "${j}";
  1363. ((ret+=$?));
  1364. done;
  1365. else
  1366. ((++ret));
  1367. fi;
  1368. fi;
  1369. done;
  1370. exit ${ret} )
  1371. }
  1372. dyn_pretend ()
  1373. {
  1374. ebuild_phase_with_hooks pkg_pretend
  1375. }
  1376. ebeep ()
  1377. {
  1378. local n;
  1379. if [[ -z ${EBEEP_IGNORE} ]]; then
  1380. for ((n=1 ; n <= ${1:-5} ; n++))
  1381. do
  1382. echo -ne "\a";
  1383. sleep 0.1 &>/dev/null;
  1384. sleep 0,1 &>/dev/null;
  1385. echo -ne "\a";
  1386. sleep 1;
  1387. done;
  1388. fi
  1389. }
  1390. ecvs_clean ()
  1391. {
  1392. [[ -z $* ]] && set -- .;
  1393. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  1394. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  1395. }
  1396. edos2unix ()
  1397. {
  1398. echo "$@" | xargs sed -i 's/\r$//'
  1399. }
  1400. egetent ()
  1401. {
  1402. case ${CHOST} in
  1403. *-darwin[678])
  1404. case "$2" in
  1405. *[!0-9]*)
  1406. nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
  1407. ;;
  1408. *)
  1409. nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
  1410. ;;
  1411. esac
  1412. ;;
  1413. *-darwin*)
  1414. local mytype=$1;
  1415. [[ "passwd" == $mytype ]] && mytype="Users";
  1416. [[ "group" == $mytype ]] && mytype="Groups";
  1417. case "$2" in
  1418. *[!0-9]*)
  1419. dscl . -read /$mytype/$2 2> /dev/null | grep RecordName
  1420. ;;
  1421. *)
  1422. local mykey="UniqueID";
  1423. [[ $mytype == "Groups" ]] && mykey="PrimaryGroupID";
  1424. dscl . -search /$mytype $mykey $2 2> /dev/null
  1425. ;;
  1426. esac
  1427. ;;
  1428. *-freebsd* | *-dragonfly*)
  1429. local opts action="user";
  1430. [[ $1 == "passwd" ]] || action="group";
  1431. if [[ $2 == [[:digit:]]* ]]; then
  1432. [[ ${action} == "user" ]] && opts="-u" || opts="-g";
  1433. fi;
  1434. pw show ${action} ${opts} "$2" -q
  1435. ;;
  1436. *-netbsd* | *-openbsd*)
  1437. grep "$2:\*:" /etc/$1
  1438. ;;
  1439. *)
  1440. type -p nscd &>/dev/null && nscd -i "$1";
  1441. getent "$1" "$2"
  1442. ;;
  1443. esac
  1444. }
  1445. egethome ()
  1446. {
  1447. ent=$(egetent passwd $1);
  1448. case ${CHOST} in
  1449. *-darwin* | *-freebsd* | *-dragonfly*)
  1450. echo ${ent} | cut -d: -f9
  1451. ;;
  1452. *)
  1453. echo ${ent} | cut -d: -f6
  1454. ;;
  1455. esac
  1456. }
  1457. egetshell ()
  1458. {
  1459. ent=$(egetent passwd "$1");
  1460. case ${CHOST} in
  1461. *-darwin* | *-freebsd* | *-dragonfly*)
  1462. echo ${ent} | cut -d: -f10
  1463. ;;
  1464. *)
  1465. echo ${ent} cut -d: -f7
  1466. ;;
  1467. esac
  1468. }
  1469. elibtoolize ()
  1470. {
  1471. local x=;
  1472. local y=;
  1473. local do_portage="no";
  1474. local do_reversedeps="no";
  1475. local do_only_patches="no";
  1476. local do_uclibc="yes";
  1477. local deptoremove=;
  1478. local my_dirlist=;
  1479. local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed";
  1480. local start_dir=${PWD};
  1481. my_dirlist=$(ELT_find_ltmain_sh);
  1482. for x in "$@";
  1483. do
  1484. case "${x}" in
  1485. "--portage")
  1486. do_portage="yes"
  1487. ;;
  1488. "--reverse-deps")
  1489. do_reversedeps="yes";
  1490. elt_patches="${elt_patches} fix-relink"
  1491. ;;
  1492. "--patch-only")
  1493. do_only_patches="yes"
  1494. ;;
  1495. "^--remove-internal-dep="*)
  1496. deptoremove=$(echo "${x}" | sed -e 's|--remove-internal-dep=||');
  1497. [[ -n ${deptoremove} ]] && elt_patches="${elt_patches} rem-int-dep"
  1498. ;;
  1499. "--shallow")
  1500. if [[ -f ${S}/ltmain.sh ]]; then
  1501. my_dirlist=${S};
  1502. else
  1503. my_dirlist=;
  1504. fi
  1505. ;;
  1506. "--no-uclibc")
  1507. do_uclibc="no"
  1508. ;;
  1509. *)
  1510. eerror "Invalid elibtoolize option: ${x}";
  1511. die "elibtoolize called with ${x} ??"
  1512. ;;
  1513. esac;
  1514. done;
  1515. [[ ${do_uclibc} == "yes" ]] && elt_patches="${elt_patches} uclibc-conf uclibc-ltconf";
  1516. case "${CHOST}" in
  1517. *-aix*)
  1518. elt_patches="${elt_patches} hardcode aixrtl aix-noundef"
  1519. ;;
  1520. *-darwin*)
  1521. elt_patches="${elt_patches} darwin-ltconf darwin-ltmain darwin-conf"
  1522. ;;
  1523. *-freebsd*)
  1524. elt_patches="${elt_patches} fbsd-conf fbsd-ltconf"
  1525. ;;
  1526. *-hpux*)
  1527. elt_patches="${elt_patches} hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc"
  1528. ;;
  1529. *-irix*)
  1530. elt_patches="${elt_patches} irix-ltmain"
  1531. ;;
  1532. *-mint*)
  1533. elt_patches="${elt_patches} mint-conf"
  1534. ;;
  1535. esac;
  1536. for x in ${my_dirlist};
  1537. do
  1538. local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||");
  1539. export ELT_APPLIED_PATCHES=;
  1540. export ELT_LTMAIN_SH="${x}/ltmain.sh";
  1541. [[ -f ${x}/.elibtoolized ]] && continue;
  1542. cd ${x};
  1543. einfo "Running elibtoolize in: $(echo "/${tmp}" | sed -e 's|//|/|g; s|^/||')";
  1544. for y in ${elt_patches};
  1545. do
  1546. local ret=0;
  1547. case "${y}" in
  1548. "portage")
  1549. if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
  1550. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1551. ret=$?;
  1552. fi
  1553. ;;
  1554. "rem-int-dep")
  1555. ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}";
  1556. ret=$?
  1557. ;;
  1558. "fix-relink")
  1559. if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]]; then
  1560. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1561. ret=$?;
  1562. fi
  1563. ;;
  1564. "max_cmd_len")
  1565. if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]]; then
  1566. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1567. ret=$?;
  1568. fi
  1569. ;;
  1570. "as-needed")
  1571. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1572. ret=$?
  1573. ;;
  1574. "uclibc-conf")
  1575. if [[ -e ${x}/configure && -n $(grep 'Transform linux' "${x}/configure") ]]; then
  1576. ELT_walk_patches "${x}/configure" "${y}";
  1577. ret=$?;
  1578. else
  1579. if [[ ! -e ${x}/configure && -e ${x}/../configure && -n $(grep 'Transform linux' "${x}/../configure") ]]; then
  1580. ELT_walk_patches "${x}/../configure" "${y}";
  1581. ret=$?;
  1582. fi;
  1583. fi
  1584. ;;
  1585. "uclibc-ltconf")
  1586. if [[ -s ${x}/ltconfig ]]; then
  1587. ELT_walk_patches "${x}/ltconfig" "${y}";
  1588. ret=$?;
  1589. fi
  1590. ;;
  1591. "fbsd-conf")
  1592. if [[ -e ${x}/configure && -n $(grep 'version_type=freebsd-' "${x}/configure") ]]; then
  1593. ELT_walk_patches "${x}/configure" "${y}";
  1594. ret=$?;
  1595. else
  1596. if [[ ! -e ${x}/configure && -e ${x}/../configure && -n $(grep 'version_type=freebsd-' "${x}/../configure") ]]; then
  1597. ELT_walk_patches "${x}/../configure" "${y}";
  1598. ret=$?;
  1599. fi;
  1600. fi
  1601. ;;
  1602. "fbsd-ltconf")
  1603. if [[ -s ${x}/ltconfig ]]; then
  1604. ELT_walk_patches "${x}/ltconfig" "${y}";
  1605. ret=$?;
  1606. fi
  1607. ;;
  1608. "darwin-conf")
  1609. if [[ -e ${x}/configure && -n $(grep '&& echo \.so ||' "${x}/configure") ]]; then
  1610. ELT_walk_patches "${x}/configure" "${y}";
  1611. ret=$?;
  1612. else
  1613. if [[ ! -e ${x}/configure && -e ${x}/../configure && -n $(grep '&& echo \.so ||' "${x}/../configure") ]]; then
  1614. ELT_walk_patches "${x}/../configure" "${y}";
  1615. ret=$?;
  1616. fi;
  1617. fi
  1618. ;;
  1619. "darwin-ltconf")
  1620. if [[ -s ${x}/ltconfig ]]; then
  1621. ELT_walk_patches "${x}/ltconfig" "${y}";
  1622. ret=$?;
  1623. fi
  1624. ;;
  1625. "darwin-ltmain")
  1626. if [[ -e ${x}/ltmain.sh && -z $(grep 'verstring="-compatibility_version' "${x}/ltmain.sh") ]]; then
  1627. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1628. ret=$?;
  1629. fi
  1630. ;;
  1631. "aixrtl" | "hpux-conf")
  1632. ret=1;
  1633. local subret=0;
  1634. while [[ $subret -eq 0 ]]; do
  1635. subret=1;
  1636. if [[ -e ${x}/configure ]]; then
  1637. ELT_walk_patches "${x}/configure" "${y}";
  1638. subret=$?;
  1639. else
  1640. if [[ ! -e ${x}/configure && -e ${x}/../configure ]]; then
  1641. ELT_walk_patches "${x}/../configure" "${y}";
  1642. subret=$?;
  1643. fi;
  1644. fi;
  1645. if [[ $subret -eq 0 ]]; then
  1646. ret=0;
  1647. fi;
  1648. done
  1649. ;;
  1650. "mint-conf")
  1651. ret=1;
  1652. local subret=1;
  1653. if [[ -e ${x}/configure ]]; then
  1654. ELT_walk_patches "${x}/configure" "${y}";
  1655. subret=$?;
  1656. else
  1657. if [[ ! -e ${x}/configure && -e ${x}/../configure ]]; then
  1658. ELT_walk_patches "${x}/../configure" "${y}";
  1659. subret=$?;
  1660. fi;
  1661. fi;
  1662. if [[ $subret -eq 0 ]]; then
  1663. ret=0;
  1664. fi
  1665. ;;
  1666. "install-sh")
  1667. ELT_walk_patches "${x}/install-sh" "${y}";
  1668. ret=$?
  1669. ;;
  1670. "cross")
  1671. if tc-is-cross-compiler; then
  1672. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1673. ret=$?;
  1674. fi
  1675. ;;
  1676. *)
  1677. ELT_walk_patches "${x}/ltmain.sh" "${y}";
  1678. ret=$?
  1679. ;;
  1680. esac;
  1681. if [[ ${ret} -ne 0 ]]; then
  1682. case ${y} in
  1683. "relink")
  1684. local version=$(ELT_libtool_version "${x}/ltmain.sh");
  1685. if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") && $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]]; then
  1686. ewarn " Could not apply relink.patch!";
  1687. fi
  1688. ;;
  1689. "portage")
  1690. if [[ ${do_portage} == "yes" ]]; then
  1691. if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
  1692. echo;
  1693. eerror "Portage patch requested, but failed to apply!";
  1694. eerror "Please file a bug report to add a proper patch.";
  1695. die "Portage patch requested, but failed to apply!";
  1696. fi;
  1697. else
  1698. if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
  1699. :;
  1700. else
  1701. local version=$( eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh"); echo "${VERSION}");
  1702. echo;
  1703. eerror "Portage patch failed to apply (ltmain.sh version ${version})!";
  1704. eerror "Please file a bug report to add a proper patch.";
  1705. die "Portage patch failed to apply!";
  1706. fi;
  1707. ELT_APPLIED_PATCHES="portage";
  1708. fi
  1709. ;;
  1710. "uclibc-"*)
  1711. [[ ${CHOST} == *"-uclibc" ]] && ewarn " uClibc patch set '${y}' failed to apply!"
  1712. ;;
  1713. "fbsd-"*)
  1714. if [[ ${CHOST} == *"-freebsd"* ]]; then
  1715. if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' "${x}/configure" "${x}/../configure" 2>/dev/null) ]]; then
  1716. eerror " FreeBSD patch set '${y}' failed to apply!";
  1717. die "FreeBSD patch set '${y}' failed to apply!";
  1718. fi;
  1719. fi
  1720. ;;
  1721. "darwin-"*)
  1722. [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${y}' failed to apply!"
  1723. ;;
  1724. esac;
  1725. fi;
  1726. done;
  1727. if [[ -z ${ELT_APPLIED_PATCHES} ]]; then
  1728. if [[ ${do_portage} == "no" && ${do_reversedeps} == "no" && ${do_only_patches} == "no" && ${deptoremove} == "" ]]; then
  1729. ewarn "Cannot apply any patches, please file a bug about this";
  1730. die;
  1731. fi;
  1732. fi;
  1733. [[ -f ${x}/libtool ]] && rm -f "${x}/libtool";
  1734. >> "${x}/.elibtoolized";
  1735. done;
  1736. cd "${start_dir}"
  1737. }
  1738. emktemp ()
  1739. {
  1740. local exe="touch";
  1741. [[ $1 == -d ]] && exe="mkdir" && shift;
  1742. local topdir=$1;
  1743. if [[ -z ${topdir} ]]; then
  1744. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1745. fi;
  1746. if ! type -P mktemp > /dev/null; then
  1747. local tmp=/;
  1748. while [[ -e ${tmp} ]]; do
  1749. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1750. done;
  1751. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1752. echo "${tmp}";
  1753. else
  1754. if [[ ${exe} == "touch" ]]; then
  1755. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1756. else
  1757. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1758. fi;
  1759. fi
  1760. }
  1761. enewgroup ()
  1762. {
  1763. case ${EBUILD_PHASE} in
  1764. unpack | compile | test | install)
  1765. eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
  1766. eerror "Package fails at QA and at life. Please file a bug.";
  1767. die "Bad package! enewgroup is only for use in pkg_* functions!"
  1768. ;;
  1769. esac;
  1770. local egroup="$1";
  1771. shift;
  1772. if [ -z "${egroup}" ]; then
  1773. eerror "No group specified !";
  1774. die "Cannot call enewgroup without a group";
  1775. fi;
  1776. if [[ -n $(egetent group "${egroup}") ]]; then
  1777. return 0;
  1778. fi;
  1779. einfo "Adding group '${egroup}' to your system ...";
  1780. local opts=;
  1781. local egid="$1";
  1782. shift;
  1783. if [ ! -z "${egid}" ]; then
  1784. if [ "${egid}" -gt 0 ]; then
  1785. if [ -z "`egetent group ${egid}`" ]; then
  1786. if [[ "${CHOST}" == *-darwin* ]]; then
  1787. opts="${opts} ${egid}";
  1788. else
  1789. opts="${opts} -g ${egid}";
  1790. fi;
  1791. else
  1792. egid="next available; requested gid taken";
  1793. fi;
  1794. else
  1795. eerror "Groupid given but is not greater than 0 !";
  1796. die "${egid} is not a valid GID";
  1797. fi;
  1798. else
  1799. egid="next available";
  1800. fi;
  1801. einfo " - Groupid: ${egid}";
  1802. local eextra="$@";
  1803. opts="${opts} ${eextra}";
  1804. local oldsandbox="${SANDBOX_ON}";
  1805. export SANDBOX_ON="0";
  1806. case ${CHOST} in
  1807. *-darwin*)
  1808. if [ ! -z "${eextra}" ]; then
  1809. einfo "Extra options are not supported on Darwin/OS X yet";
  1810. einfo "Please report the ebuild along with the info below";
  1811. einfo "eextra: ${eextra}";
  1812. die "Required function missing";
  1813. fi;
  1814. case ${egid} in
  1815. *[!0-9]*)
  1816. for ((egid = 101; egid <= 999; egid++))
  1817. do
  1818. [[ -z $(egetent group ${egid}) ]] && break;
  1819. done
  1820. ;;
  1821. esac;
  1822. dscl . create /groups/${egroup} gid ${egid};
  1823. dscl . create /groups/${egroup} passwd '*'
  1824. ;;
  1825. *-freebsd* | *-dragonfly*)
  1826. case ${egid} in
  1827. *[!0-9]*)
  1828. for ((egid = 101; egid <= 999; egid++))
  1829. do
  1830. [[ -z $(egetent group ${egid}) ]] && break;
  1831. done
  1832. ;;
  1833. esac;
  1834. pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
  1835. ;;
  1836. *-netbsd*)
  1837. case ${egid} in
  1838. *[!0-9]*)
  1839. for ((egid = 101; egid <= 999; egid++))
  1840. do
  1841. [[ -z $(egetent group ${egid}) ]] && break;
  1842. done
  1843. ;;
  1844. esac;
  1845. groupadd -g ${egid} ${egroup} || die "enewgroup failed"
  1846. ;;
  1847. *)
  1848. groupadd -r ${opts} ${egroup} || die "enewgroup failed"
  1849. ;;
  1850. esac;
  1851. export SANDBOX_ON="${oldsandbox}"
  1852. }
  1853. enewuser ()
  1854. {
  1855. case ${EBUILD_PHASE} in
  1856. unpack | compile | test | install)
  1857. eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
  1858. eerror "Package fails at QA and at life. Please file a bug.";
  1859. die "Bad package! enewuser is only for use in pkg_* functions!"
  1860. ;;
  1861. esac;
  1862. local euser=$1;
  1863. shift;
  1864. if [[ -z ${euser} ]]; then
  1865. eerror "No username specified !";
  1866. die "Cannot call enewuser without a username";
  1867. fi;
  1868. if [[ -n $(egetent passwd "${euser}") ]]; then
  1869. return 0;
  1870. fi;
  1871. einfo "Adding user '${euser}' to your system ...";
  1872. local opts=;
  1873. local euid=$1;
  1874. shift;
  1875. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1876. if [[ ${euid} -gt 0 ]]; then
  1877. if [[ -n $(egetent passwd ${euid}) ]]; then
  1878. euid="next";
  1879. fi;
  1880. else
  1881. eerror "Userid given but is not greater than 0 !";
  1882. die "${euid} is not a valid UID";
  1883. fi;
  1884. else
  1885. euid="next";
  1886. fi;
  1887. if [[ ${euid} == "next" ]]; then
  1888. for ((euid = 101; euid <= 999; euid++))
  1889. do
  1890. [[ -z $(egetent passwd ${euid}) ]] && break;
  1891. done;
  1892. fi;
  1893. opts="${opts} -u ${euid}";
  1894. einfo " - Userid: ${euid}";
  1895. local eshell=$1;
  1896. shift;
  1897. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1898. if [[ ! -e ${ROOT}${eshell} ]]; then
  1899. eerror "A shell was specified but it does not exist !";
  1900. die "${eshell} does not exist in ${ROOT}";
  1901. fi;
  1902. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1903. eerror "Do not specify ${eshell} yourself, use -1";
  1904. die "Pass '-1' as the shell parameter";
  1905. fi;
  1906. else
  1907. for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1908. do
  1909. [[ -x ${ROOT}${shell} ]] && break;
  1910. done;
  1911. if [[ ${shell} == "/dev/null" ]]; then
  1912. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1913. case ${USERLAND} in
  1914. GNU)
  1915. shell="/bin/false"
  1916. ;;
  1917. BSD)
  1918. shell="/sbin/nologin"
  1919. ;;
  1920. Darwin)
  1921. shell="/usr/sbin/nologin"
  1922. ;;
  1923. *)
  1924. die "Unable to identify the default shell for userland ${USERLAND}"
  1925. ;;
  1926. esac;
  1927. fi;
  1928. eshell=${shell};
  1929. fi;
  1930. einfo " - Shell: ${eshell}";
  1931. opts="${opts} -s ${eshell}";
  1932. local ehome=$1;
  1933. shift;
  1934. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1935. ehome="/dev/null";
  1936. fi;
  1937. einfo " - Home: ${ehome}";
  1938. opts="${opts} -d ${ehome}";
  1939. local egroups=$1;
  1940. shift;
  1941. if [[ ! -z ${egroups} ]]; then
  1942. local oldifs=${IFS};
  1943. local defgroup="" exgroups="";
  1944. export IFS=",";
  1945. for g in ${egroups};
  1946. do
  1947. export IFS=${oldifs};
  1948. if [[ -z $(egetent group "${g}") ]]; then
  1949. eerror "You must add group ${g} to the system first";
  1950. die "${g} is not a valid GID";
  1951. fi;
  1952. if [[ -z ${defgroup} ]]; then
  1953. defgroup=${g};
  1954. else
  1955. exgroups="${exgroups},${g}";
  1956. fi;
  1957. export IFS=",";
  1958. done;
  1959. export IFS=${oldifs};
  1960. opts="${opts} -g ${defgroup}";
  1961. if [[ ! -z ${exgroups} ]]; then
  1962. opts="${opts} -G ${exgroups:1}";
  1963. fi;
  1964. else
  1965. egroups="(none)";
  1966. fi;
  1967. einfo " - Groups: ${egroups}";
  1968. local oldsandbox=${SANDBOX_ON};
  1969. export SANDBOX_ON="0";
  1970. case ${CHOST} in
  1971. *-darwin*)
  1972. if [[ -z $@ ]]; then
  1973. dscl . create /users/${euser} uid ${euid};
  1974. dscl . create /users/${euser} shell ${eshell};
  1975. dscl . create /users/${euser} home ${ehome};
  1976. dscl . create /users/${euser} realname "added by portage for ${PN}";
  1977. local oldifs=${IFS};
  1978. export IFS=",";
  1979. for g in ${egroups};
  1980. do
  1981. dscl . merge /groups/${g} users ${euser};
  1982. done;
  1983. export IFS=${oldifs};
  1984. else
  1985. einfo "Extra options are not supported on Darwin yet";
  1986. einfo "Please report the ebuild along with the info below";
  1987. einfo "eextra: $@";
  1988. die "Required function missing";
  1989. fi
  1990. ;;
  1991. *-freebsd* | *-dragonfly*)
  1992. if [[ -z $@ ]]; then
  1993. pw useradd ${euser} ${opts} -c "added by portage for ${PN}" die "enewuser failed";
  1994. else
  1995. einfo " - Extra: $@";
  1996. pw useradd ${euser} ${opts} "$@" || die "enewuser failed";
  1997. fi
  1998. ;;
  1999. *-netbsd*)
  2000. if [[ -z $@ ]]; then
  2001. useradd ${opts} ${euser} || die "enewuser failed";
  2002. else
  2003. einfo " - Extra: $@";
  2004. useradd ${opts} ${euser} "$@" || die "enewuser failed";
  2005. fi
  2006. ;;
  2007. *-openbsd*)
  2008. if [[ -z $@ ]]; then
  2009. useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} || die "enewuser failed";
  2010. else
  2011. einfo " - Extra: $@";
  2012. useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} "$@" || die "enewuser failed";
  2013. fi
  2014. ;;
  2015. *)
  2016. if [[ -z $@ ]]; then
  2017. useradd -r ${opts} -c "added by portage for ${PN}" ${euser} || die "enewuser failed";
  2018. else
  2019. einfo " - Extra: $@";
  2020. useradd -r ${opts} "$@" ${euser} || die "enewuser failed";
  2021. fi
  2022. ;;
  2023. esac;
  2024. if [[ ! -e ${ROOT}/${ehome} ]]; then
  2025. einfo " - Creating ${ehome} in ${ROOT}";
  2026. mkdir -p "${ROOT}/${ehome}";
  2027. chown ${euser} "${ROOT}/${ehome}";
  2028. chmod 755 "${ROOT}/${ehome}";
  2029. fi;
  2030. export SANDBOX_ON=${oldsandbox}
  2031. }
  2032. epatch ()
  2033. {
  2034. function _epatch_draw_line ()
  2035. {
  2036. [[ -z $1 ]] && set "$(printf "%65s" '')";
  2037. echo "${1//?/=}"
  2038. };
  2039. unset P4CONFIG P4PORT P4USER;
  2040. if [[ $# -gt 1 ]]; then
  2041. local m;
  2042. for m in "$@";
  2043. do
  2044. epatch "${m}";
  2045. done;
  2046. return 0;
  2047. fi;
  2048. local SINGLE_PATCH="no";
  2049. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  2050. if [[ -f $1 ]]; then
  2051. SINGLE_PATCH="yes";
  2052. set -- "$1";
  2053. local EPATCH_SUFFIX=$1;
  2054. else
  2055. if [[ -d $1 ]]; then
  2056. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  2057. else
  2058. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  2059. echo;
  2060. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  2061. eerror;
  2062. eerror " ${EPATCH_SOURCE}";
  2063. eerror " ( ${EPATCH_SOURCE##*/} )";
  2064. echo;
  2065. die "Cannot find \$EPATCH_SOURCE!";
  2066. fi;
  2067. fi;
  2068. local PIPE_CMD;
  2069. case ${EPATCH_SUFFIX##*\.} in
  2070. xz)
  2071. PIPE_CMD="xz -dc"
  2072. ;;
  2073. lzma)
  2074. PIPE_CMD="lzma -dc"
  2075. ;;
  2076. bz2)
  2077. PIPE_CMD="bzip2 -dc"
  2078. ;;
  2079. gz | Z | z)
  2080. PIPE_CMD="gzip -dc"
  2081. ;;
  2082. ZIP | zip)
  2083. PIPE_CMD="unzip -p"
  2084. ;;
  2085. *)
  2086.  
  2087. ;;
  2088. esac;
  2089. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  2090. local x;
  2091. for x in "$@";
  2092. do
  2093. [[ ! -f ${x} ]] && continue;
  2094. local patchname=${x##*/};
  2095. local a=${patchname#*_};
  2096. a=${a%%_*};
  2097. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  2098. continue;
  2099. fi;
  2100. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  2101. eshopts_push -o noglob;
  2102. local ex;
  2103. for ex in ${EPATCH_EXCLUDE};
  2104. do
  2105. if [[ ${patchname} == ${ex} ]]; then
  2106. eshopts_pop;
  2107. continue 2;
  2108. fi;
  2109. done;
  2110. eshopts_pop;
  2111. fi;
  2112. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  2113. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  2114. einfo "${EPATCH_SINGLE_MSG}";
  2115. else
  2116. einfo "Applying ${patchname} ...";
  2117. fi;
  2118. else
  2119. einfo " ${patchname} ...";
  2120. fi;
  2121. local STDERR_TARGET="${T}/${patchname}.out";
  2122. if [[ -e ${STDERR_TARGET} ]]; then
  2123. STDERR_TARGET="${T}/${patchname}-$$.out";
  2124. fi;
  2125. printf "***** %s *****\n\n" "${patchname}" > "${STDERR_TARGET}";
  2126. local count=0;
  2127. local PATCH_TARGET;
  2128. if [[ -n ${PIPE_CMD} ]]; then
  2129. PATCH_TARGET="${T}/$$.patch";
  2130. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  2131. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  2132. echo;
  2133. eerror "Could not extract patch!";
  2134. count=5;
  2135. break;
  2136. fi;
  2137. else
  2138. PATCH_TARGET=${x};
  2139. fi;
  2140. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  2141. if [[ -n ${abs_paths} ]]; then
  2142. count=1;
  2143. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  2144. fi;
  2145. while [[ ${count} -lt 5 ]]; do
  2146. ( _epatch_draw_line "***** ${patchname} *****";
  2147. echo;
  2148. echo "PATCH COMMAND: patch -p${count} ${EPATCH_OPTS} < '${PATCH_TARGET}'";
  2149. echo;
  2150. _epatch_draw_line "***** ${patchname} *****" ) >> "${STDERR_TARGET}";
  2151. if ( patch -p${count} ${EPATCH_OPTS} --dry-run -f < "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  2152. ( _epatch_draw_line "***** ${patchname} *****";
  2153. echo;
  2154. echo "ACTUALLY APPLYING ${patchname} ...";
  2155. echo;
  2156. _epatch_draw_line "***** ${patchname} *****";
  2157. patch -p${count} ${EPATCH_OPTS} < "${PATCH_TARGET}" 2>&1 ) >> "${STDERR_TARGET}";
  2158. if [ $? -ne 0 ]; then
  2159. echo;
  2160. eerror "A dry-run of patch command succeeded, but actually";
  2161. eerror "applying the patch failed!";
  2162. count=5;
  2163. fi;
  2164. break;
  2165. fi;
  2166. : $(( count++ ));
  2167. done;
  2168. if [[ -n ${PIPE_CMD} ]]; then
  2169. rm -f "${PATCH_TARGET}";
  2170. fi;
  2171. if [[ ${count} -ge 5 ]]; then
  2172. echo;
  2173. eerror "Failed Patch: ${patchname} !";
  2174. eerror " ( ${PATCH_TARGET} )";
  2175. eerror;
  2176. eerror "Include in your bugreport the contents of:";
  2177. eerror;
  2178. eerror " ${STDERR_TARGET}";
  2179. echo;
  2180. die "Failed Patch: ${patchname}!";
  2181. fi;
  2182. rm -f "${STDERR_TARGET}";
  2183. eend 0;
  2184. done;
  2185. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  2186. :
  2187. }
  2188. epatch_user ()
  2189. {
  2190. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  2191. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  2192. for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}};
  2193. do
  2194. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  2195. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  2196. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  2197. if [[ -d ${EPATCH_SOURCE} ]]; then
  2198. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  2199. break;
  2200. fi;
  2201. done
  2202. }
  2203. epause ()
  2204. {
  2205. [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
  2206. }
  2207. epunt_cxx ()
  2208. {
  2209. local dir=$1;
  2210. [[ -z ${dir} ]] && dir=${S};
  2211. ebegin "Removing useless C++ checks";
  2212. local f;
  2213. find "${dir}" -name configure | while read f; do
  2214. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  2215. done;
  2216. eend 0
  2217. }
  2218. eshopts_pop ()
  2219. {
  2220. [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments";
  2221. local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ));
  2222. [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair";
  2223. local s=${__ESHOPTS_SAVE__[$i]};
  2224. unset __ESHOPTS_SAVE__[$i];
  2225. if [[ ${s} == "shopt -"* ]]; then
  2226. eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}";
  2227. else
  2228. set +$- || die "eshopts_pop: sanity: invalid shell settings: $-";
  2229. set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}";
  2230. fi
  2231. }
  2232. eshopts_push ()
  2233. {
  2234. local i=${#__ESHOPTS_SAVE__[@]};
  2235. if [[ $1 == -[su] ]]; then
  2236. __ESHOPTS_SAVE__[$i]=$(shopt -p);
  2237. [[ $# -eq 0 ]] && return 0;
  2238. shopt "$@" || die "eshopts_push: bad options to shopt: $*";
  2239. else
  2240. __ESHOPTS_SAVE__[$i]=$-;
  2241. [[ $# -eq 0 ]] && return 0;
  2242. set "$@" || die "eshopts_push: bad options to set: $*";
  2243. fi
  2244. }
  2245. esvn_clean ()
  2246. {
  2247. [[ -z $* ]] && set -- .;
  2248. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  2249. }
  2250. fdo-mime_desktop_database_update ()
  2251. {
  2252. if [ -x "/usr/bin/update-desktop-database" ]; then
  2253. einfo "Updating desktop mime database ...";
  2254. "/usr/bin/update-desktop-database" -q "${ROOT}/usr/share/applications";
  2255. fi
  2256. }
  2257. fdo-mime_mime_database_update ()
  2258. {
  2259. if [ -x "/usr/bin/update-mime-database" ]; then
  2260. einfo "Updating shared mime info database ...";
  2261. "/usr/bin/update-mime-database" "${ROOT}/usr/share/mime";
  2262. fi
  2263. }
  2264. find_unpackable_file ()
  2265. {
  2266. local src=$1;
  2267. if [[ -z ${src} ]]; then
  2268. src=${DISTDIR}/${A};
  2269. else
  2270. if [[ -e ${DISTDIR}/${src} ]]; then
  2271. src=${DISTDIR}/${src};
  2272. else
  2273. if [[ -e ${PWD}/${src} ]]; then
  2274. src=${PWD}/${src};
  2275. else
  2276. if [[ -e ${src} ]]; then
  2277. src=${src};
  2278. fi;
  2279. fi;
  2280. fi;
  2281. fi;
  2282. [[ ! -e ${src} ]] && return 1;
  2283. echo "${src}"
  2284. }
  2285. gcc-fullversion ()
  2286. {
  2287. $(tc-getCC "$@") -dumpversion
  2288. }
  2289. gcc-major-version ()
  2290. {
  2291. gcc-version "$@" | cut -f1 -d.
  2292. }
  2293. gcc-micro-version ()
  2294. {
  2295. gcc-fullversion "$@" | cut -f3 -d. | cut -f1 -d-
  2296. }
  2297. gcc-minor-version ()
  2298. {
  2299. gcc-version "$@" | cut -f2 -d.
  2300. }
  2301. gcc-specs-directive ()
  2302. {
  2303. local directive subdname subdirective;
  2304. directive="$(_gcc-specs-directive_raw $1)";
  2305. while [[ ${directive} == *%\(*\)* ]]; do
  2306. subdname=${directive/*%\(};
  2307. subdname=${subdname/\)*};
  2308. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2309. directive="${directive//\%(${subdname})/${subdirective}}";
  2310. done;
  2311. echo "${directive}";
  2312. return 0
  2313. }
  2314. gcc-specs-nostrict ()
  2315. {
  2316. local directive;
  2317. directive=$(gcc-specs-directive cc1);
  2318. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  2319. }
  2320. gcc-specs-now ()
  2321. {
  2322. local directive;
  2323. directive=$(gcc-specs-directive link_command);
  2324. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  2325. }
  2326. gcc-specs-pie ()
  2327. {
  2328. local directive;
  2329. directive=$(gcc-specs-directive cc1);
  2330. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  2331. }
  2332. gcc-specs-relro ()
  2333. {
  2334. local directive;
  2335. directive=$(gcc-specs-directive link_command);
  2336. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  2337. }
  2338. gcc-specs-ssp ()
  2339. {
  2340. local directive;
  2341. directive=$(gcc-specs-directive cc1);
  2342. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  2343. }
  2344. gcc-specs-ssp-to-all ()
  2345. {
  2346. local directive;
  2347. directive=$(gcc-specs-directive cc1);
  2348. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  2349. }
  2350. gcc-version ()
  2351. {
  2352. gcc-fullversion "$@" | cut -f1,2 -d.
  2353. }
  2354. gen_usr_ldscript ()
  2355. {
  2356. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2357. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2358. tc-is-static-only && return;
  2359. dodir /usr/${libdir};
  2360. if [[ $1 == "-a" ]]; then
  2361. auto=true;
  2362. shift;
  2363. dodir /${libdir};
  2364. fi;
  2365. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2366. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2367. for lib in "$@";
  2368. do
  2369. local tlib;
  2370. if ${auto}; then
  2371. lib="lib${lib}${suffix}";
  2372. else
  2373. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2374. fi;
  2375. case ${CTARGET:-${CHOST}} in
  2376. *-darwin*)
  2377. if ${auto}; then
  2378. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2379. else
  2380. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2381. fi;
  2382. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2383. tlib=${tlib##*/};
  2384. if ${auto}; then
  2385. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2386. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2387. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2388. fi;
  2389. rm -f "${ED}"/${libdir}/${lib};
  2390. fi;
  2391. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2392. chmod u+w "${ED}${libdir}/${tlib}";
  2393. local nowrite=yes;
  2394. fi;
  2395. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2396. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2397. pushd "${ED}/usr/${libdir}" > /dev/null;
  2398. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2399. popd > /dev/null
  2400. ;;
  2401. *-aix* | *-irix* | *64*-hpux* | *-interix* | *-winnt*)
  2402. if ${auto}; then
  2403. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2404. tlib=$(readlink "${ED}"/${libdir}/${lib});
  2405. tlib=${tlib##*/};
  2406. if [[ -z ${tlib} ]]; then
  2407. tlib=${lib};
  2408. else
  2409. rm -f "${ED}"/${libdir}/${lib};
  2410. fi;
  2411. else
  2412. tlib=${lib};
  2413. fi;
  2414. pushd "${ED}/usr/${libdir}" > /dev/null;
  2415. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2416. popd > /dev/null
  2417. ;;
  2418. hppa*-hpux*)
  2419. if ${auto}; then
  2420. tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  2421. [[ -z ${tlib} ]] && tlib=${lib};
  2422. tlib=${tlib##*/};
  2423. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2424. if [[ ${tlib} != ${lib}* ]]; then
  2425. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2426. fi;
  2427. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  2428. else
  2429. tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  2430. [[ -z ${tlib} ]] && tlib=${lib};
  2431. tlib=${tlib##*/};
  2432. fi;
  2433. pushd "${ED}"/usr/${libdir} > /dev/null;
  2434. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2435. [[ ${tlib} != ${lib} ]] && ln -snf "../../${libdir}/${tlib}" "${tlib}";
  2436. popd > /dev/null
  2437. ;;
  2438. *)
  2439. if ${auto}; then
  2440. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2441. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2442. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2443. if [[ ${tlib} != ${lib}* ]]; then
  2444. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2445. fi;
  2446. rm -f "${ED}"/${libdir}/${lib};
  2447. else
  2448. tlib=${lib};
  2449. fi;
  2450. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2451. /* GNU ld script
  2452. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2453. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2454. run into linking problems. This "fake" dynamic lib is a linker script that
  2455. redirects the linker to the real lib. And yes, this works in the cross-
  2456. compiling scenario as the sysroot-ed linker will prepend the real path.
  2457.  
  2458. See bug http://bugs.gentoo.org/4411 for more info.
  2459. */
  2460. ${output_format}
  2461. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2462. END_LDSCRIPT
  2463.  
  2464. ;;
  2465. esac
  2466. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2467. done
  2468. }
  2469. get_abi_ASFLAGS ()
  2470. {
  2471. get_abi_var ASFLAGS "$@"
  2472. }
  2473. get_abi_CDEFINE ()
  2474. {
  2475. get_abi_var CDEFINE "$@"
  2476. }
  2477. get_abi_CFLAGS ()
  2478. {
  2479. get_abi_var CFLAGS "$@"
  2480. }
  2481. get_abi_CHOST ()
  2482. {
  2483. get_abi_var CHOST "$@"
  2484. }
  2485. get_abi_CTARGET ()
  2486. {
  2487. get_abi_var CTARGET "$@"
  2488. }
  2489. get_abi_FAKE_TARGETS ()
  2490. {
  2491. get_abi_var FAKE_TARGETS "$@"
  2492. }
  2493. get_abi_LDFLAGS ()
  2494. {
  2495. get_abi_var LDFLAGS "$@"
  2496. }
  2497. get_abi_LIBDIR ()
  2498. {
  2499. get_abi_var LIBDIR "$@"
  2500. }
  2501. get_abi_var ()
  2502. {
  2503. local flag=$1;
  2504. local abi;
  2505. if [ $# -gt 1 ]; then
  2506. abi=${2};
  2507. else
  2508. if [ -n "${ABI}" ]; then
  2509. abi=${ABI};
  2510. else
  2511. if [ -n "${DEFAULT_ABI}" ]; then
  2512. abi=${DEFAULT_ABI};
  2513. else
  2514. abi="default";
  2515. fi;
  2516. fi;
  2517. fi;
  2518. local var="${flag}_${abi}";
  2519. echo ${!var}
  2520. }
  2521. get_all_abis ()
  2522. {
  2523. local order="";
  2524. if [[ -z ${MULTILIB_ABIS} ]]; then
  2525. echo "default";
  2526. return 0;
  2527. fi;
  2528. for x in ${MULTILIB_ABIS};
  2529. do
  2530. if [[ ${x} != ${DEFAULT_ABI} ]]; then
  2531. order="${order:+${order} }${x}";
  2532. fi;
  2533. done;
  2534. order="${order:+${order} }${DEFAULT_ABI}";
  2535. echo ${order};
  2536. return 0
  2537. }
  2538. get_all_libdirs ()
  2539. {
  2540. local libdirs="lib";
  2541. local abi;
  2542. local dir;
  2543. for abi in ${MULTILIB_ABIS};
  2544. do
  2545. [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})";
  2546. done;
  2547. echo "${libdirs}"
  2548. }
  2549. get_bmake ()
  2550. {
  2551. if [[ ${USERLAND} == *BSD ]]; then
  2552. echo make;
  2553. else
  2554. if [[ ${USERLAND} == "Darwin" ]]; then
  2555. echo bsdmake;
  2556. else
  2557. echo pmake;
  2558. fi;
  2559. fi
  2560. }
  2561. get_install_abis ()
  2562. {
  2563. local order="";
  2564. if [[ -z ${MULTILIB_ABIS} ]]; then
  2565. echo "default";
  2566. return 0;
  2567. fi;
  2568. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2569. for x in ${MULTILIB_ABIS};
  2570. do
  2571. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2572. hasq ${x} ${ABI_DENY} || ordera="${ordera} ${x}";
  2573. fi;
  2574. done;
  2575. hasq ${DEFAULT_ABI} ${ABI_DENY} || order="${ordera} ${DEFAULT_ABI}";
  2576. if [[ -n ${ABI_ALLOW} ]]; then
  2577. local ordera="";
  2578. for x in ${order};
  2579. do
  2580. if hasq ${x} ${ABI_ALLOW}; then
  2581. ordera="${ordera} ${x}";
  2582. fi;
  2583. done;
  2584. order=${ordera};
  2585. fi;
  2586. else
  2587. order=${DEFAULT_ABI};
  2588. fi;
  2589. if [[ -z ${order} ]]; then
  2590. 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.";
  2591. fi;
  2592. echo ${order};
  2593. return 0
  2594. }
  2595. get_libdir ()
  2596. {
  2597. local CONF_LIBDIR;
  2598. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2599. echo ${CONF_LIBDIR_OVERRIDE};
  2600. else
  2601. get_abi_LIBDIR;
  2602. fi
  2603. }
  2604. get_libdir_override ()
  2605. {
  2606. if has_multilib_profile; then
  2607. eerror "get_libdir_override called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org";
  2608. exit 1;
  2609. fi;
  2610. CONF_LIBDIR="$1";
  2611. CONF_LIBDIR_OVERRIDE="$1";
  2612. LIBDIR_default="$1"
  2613. }
  2614. get_libname ()
  2615. {
  2616. local libname;
  2617. local ver=$1;
  2618. case ${CHOST} in
  2619. *-cygwin | mingw* | *-mingw*)
  2620. libname="dll"
  2621. ;;
  2622. *-darwin*)
  2623. libname="dylib"
  2624. ;;
  2625. *-mint*)
  2626. libname="irrelevant"
  2627. ;;
  2628. hppa*-hpux*)
  2629. libname="sl"
  2630. ;;
  2631. *)
  2632. libname="so"
  2633. ;;
  2634. esac;
  2635. if [[ -z $* ]]; then
  2636. echo ".${libname}";
  2637. else
  2638. for ver in "$@";
  2639. do
  2640. case ${CHOST} in
  2641. *-darwin*)
  2642. echo ".${ver}.${libname}"
  2643. ;;
  2644. *-mint*)
  2645. echo ".${libname}"
  2646. ;;
  2647. *)
  2648. echo ".${libname}.${ver}"
  2649. ;;
  2650. esac;
  2651. done;
  2652. fi
  2653. }
  2654. get_ml_incdir ()
  2655. {
  2656. local dir=/usr/include;
  2657. if [[ $# -gt 0 ]]; then
  2658. incdir=$1;
  2659. shift;
  2660. fi;
  2661. if [[ -z "${MULTILIB_ABIS}" ]]; then
  2662. echo ${incdir};
  2663. return 0;
  2664. fi;
  2665. local abi=${ABI-${DEFAULT_ABI}};
  2666. if [[ $# -gt 0 ]]; then
  2667. abi=$1;
  2668. shift;
  2669. fi;
  2670. if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then
  2671. echo ${dir}/gentoo-multilib/${abi};
  2672. else
  2673. echo ${dir};
  2674. fi
  2675. }
  2676. get_modname ()
  2677. {
  2678. local modname;
  2679. local ver=$1;
  2680. case ${CHOST} in
  2681. *-darwin*)
  2682. modname="bundle"
  2683. ;;
  2684. *)
  2685. modname="so"
  2686. ;;
  2687. esac;
  2688. echo ".${modname}"
  2689. }
  2690. get_mounts ()
  2691. {
  2692. local point= node= fs= opts= foo=;
  2693. if [[ $(uname -s) == "Linux" ]]; then
  2694. while read node point fs opts foo; do
  2695. echo "${point} ${node} ${fs} ${opts}";
  2696. done < /proc/mounts;
  2697. return;
  2698. fi;
  2699. local IFS=' ';
  2700. LC_ALL=C mount -p | while read node point fs foo; do
  2701. opts=${fs#* };
  2702. fs=${fs%% *};
  2703. echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}";
  2704. done
  2705. }
  2706. get_multilibdir ()
  2707. {
  2708. if has_multilib_profile; then
  2709. eerror "get_multilibdir called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org";
  2710. exit 1;
  2711. fi;
  2712. echo ${CONF_MULTILIBDIR:=lib32}
  2713. }
  2714. gnome2_gconf_install ()
  2715. {
  2716. local F;
  2717. if [[ ! -x "${GCONFTOOL_BIN}" ]]; then
  2718. return;
  2719. fi;
  2720. if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2721. einfo "No GNOME 2 GConf schemas found";
  2722. return;
  2723. fi;
  2724. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2725. export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")";
  2726. einfo "Installing GNOME 2 GConf schemas";
  2727. for F in ${GNOME2_ECLASS_SCHEMAS};
  2728. do
  2729. if [[ -e "${ROOT}${F}" ]]; then
  2730. "${GCONFTOOL_BIN}" --makefile-install-rule "${ROOT}${F}" > /dev/null;
  2731. fi;
  2732. done;
  2733. pids=$(pgrep -x gconfd-2);
  2734. if [[ $? == 0 ]]; then
  2735. ebegin "Reloading GConf schemas";
  2736. kill -HUP ${pids};
  2737. eend $?;
  2738. fi
  2739. }
  2740. gnome2_gconf_savelist ()
  2741. {
  2742. pushd "${D}" &>/dev/null;
  2743. export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null);
  2744. popd &>/dev/null
  2745. }
  2746. gnome2_gconf_uninstall ()
  2747. {
  2748. local F;
  2749. if [[ ! -x "${GCONFTOOL_BIN}" ]]; then
  2750. return;
  2751. fi;
  2752. if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2753. einfo "No GNOME 2 GConf schemas found";
  2754. return;
  2755. fi;
  2756. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2757. export GCONF_CONFIG_SOURCE="$("${GCONFTOOL_BIN}" --get-default-source | sed "s;:/;:${ROOT};")";
  2758. einfo "Uninstalling GNOME 2 GConf schemas";
  2759. for F in ${GNOME2_ECLASS_SCHEMAS};
  2760. do
  2761. if [[ -e "${ROOT}${F}" ]]; then
  2762. "${GCONFTOOL_BIN}" --makefile-uninstall-rule "${ROOT}${F}" > /dev/null;
  2763. fi;
  2764. done;
  2765. pids=$(pgrep -x gconfd-2);
  2766. if [[ $? == 0 ]]; then
  2767. ebegin "Reloading GConf schemas";
  2768. kill -HUP ${pids};
  2769. eend $?;
  2770. fi
  2771. }
  2772. gnome2_icon_cache_update ()
  2773. {
  2774. local updater="$(type -p gtk-update-icon-cache 2> /dev/null)";
  2775. if [[ ! -x "${updater}" ]]; then
  2776. debug-print "${updater} is not executable";
  2777. return;
  2778. fi;
  2779. if [[ -z "${GNOME2_ECLASS_ICONS}" ]]; then
  2780. return;
  2781. fi;
  2782. ebegin "Updating icons cache";
  2783. local retval=0;
  2784. local fails=();
  2785. for dir in ${GNOME2_ECLASS_ICONS};
  2786. do
  2787. if [[ -f "${ROOT}${dir}/index.theme" ]]; then
  2788. local rv=0;
  2789. "${updater}" -qf "${ROOT}${dir}";
  2790. rv=$?;
  2791. if [[ ! $rv -eq 0 ]]; then
  2792. debug-print "Updating cache failed on ${ROOT}${dir}";
  2793. fails[$(( ${#fails[@]} + 1 ))]="${ROOT}${dir}";
  2794. retval=2;
  2795. fi;
  2796. fi;
  2797. done;
  2798. eend ${retval};
  2799. for f in "${fails[@]}";
  2800. do
  2801. eerror "Failed to update cache with icon $f";
  2802. done
  2803. }
  2804. gnome2_icon_savelist ()
  2805. {
  2806. pushd "${D}" &>/dev/null;
  2807. export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null);
  2808. popd &>/dev/null
  2809. }
  2810. gnome2_omf_fix ()
  2811. {
  2812. local omf_makefiles filename;
  2813. omf_makefiles="$@";
  2814. if [[ -f ${S}/omf.make ]]; then
  2815. omf_makefiles="${omf_makefiles} ${S}/omf.make";
  2816. fi;
  2817. for filename in $(find ./ -name "Makefile.in" -o -name "Makefile.am" |sort);
  2818. do
  2819. omf_makefiles="${omf_makefiles} ${filename}";
  2820. done;
  2821. ebegin "Fixing OMF Makefiles";
  2822. local retval=0;
  2823. local fails=();
  2824. for omf in ${omf_makefiles};
  2825. do
  2826. local rv=0;
  2827. sed -i -e 's:scrollkeeper-update:true:' "${omf}";
  2828. retval=$?;
  2829. if [[ ! $rv -eq 0 ]]; then
  2830. debug-print "updating of ${omf} failed";
  2831. fails[$(( ${#fails[@]} + 1 ))]=$omf;
  2832. retval=2;
  2833. fi;
  2834. done;
  2835. eend $retval;
  2836. for f in "${fails[@]}";
  2837. do
  2838. eerror "Failed to update OMF Makefile $f";
  2839. done
  2840. }
  2841. gnome2_pkg_postinst ()
  2842. {
  2843. gnome2_gconf_install;
  2844. fdo-mime_desktop_database_update;
  2845. fdo-mime_mime_database_update;
  2846. gnome2_icon_cache_update;
  2847. if [[ "${SCROLLKEEPER_UPDATE}" = "1" ]]; then
  2848. gnome2_scrollkeeper_update;
  2849. fi
  2850. }
  2851. gnome2_pkg_postrm ()
  2852. {
  2853. fdo-mime_desktop_database_update;
  2854. fdo-mime_mime_database_update;
  2855. gnome2_icon_cache_update;
  2856. if [[ "${SCROLLKEEPER_UPDATE}" = "1" ]]; then
  2857. gnome2_scrollkeeper_update;
  2858. fi
  2859. }
  2860. gnome2_pkg_preinst ()
  2861. {
  2862. gnome2_gconf_savelist;
  2863. gnome2_icon_savelist
  2864. }
  2865. gnome2_scrollkeeper_update ()
  2866. {
  2867. if [[ -x "${SCROLLKEEPER_UPDATE_BIN}" ]]; then
  2868. einfo "Updating scrollkeeper database ...";
  2869. "${SCROLLKEEPER_UPDATE_BIN}" -q -p "${SCROLLKEEPER_DIR}";
  2870. fi
  2871. }
  2872. gnome2_src_compile ()
  2873. {
  2874. has ${EAPI:-0} 0 1 && gnome2_src_configure "$@";
  2875. emake || die "compile failure"
  2876. }
  2877. gnome2_src_configure ()
  2878. {
  2879. if [[ ${GCONF_DEBUG} != 'no' ]]; then
  2880. if use debug; then
  2881. G2CONF="${G2CONF} --enable-debug=yes";
  2882. fi;
  2883. fi;
  2884. if hasq doc ${IUSE}; then
  2885. G2CONF="${G2CONF} $(use_enable doc gtk-doc)";
  2886. fi;
  2887. addwrite "/root/.gnome2";
  2888. GST_REGISTRY="${S}/registry.xml" econf "$@" ${G2CONF} || die "configure failed"
  2889. }
  2890. gnome2_src_install ()
  2891. {
  2892. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2893. local sk_tmp_dir="/var/lib/scrollkeeper";
  2894. dodir "${sk_tmp_dir}";
  2895. export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1";
  2896. if [[ -z "${USE_EINSTALL}" || "${USE_EINSTALL}" = "0" ]]; then
  2897. debug-print "Installing with 'make install'";
  2898. emake DESTDIR="${D}" "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" install || die "install failed";
  2899. else
  2900. debug-print "Installing with 'einstall'";
  2901. einstall "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" || die "einstall failed";
  2902. fi;
  2903. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2904. [[ -n "${DOCS}" ]] && dodoc ${DOCS};
  2905. if [[ -z "$(find "${D}" -name '*.omf')" ]]; then
  2906. export SCROLLKEEPER_UPDATE="0";
  2907. fi;
  2908. rm -rf "${ED}${sk_tmp_dir}";
  2909. rm -fr "${ED}/usr/share/applications/mimeinfo.cache"
  2910. }
  2911. gnome2_src_prepare ()
  2912. {
  2913. gnome2_omf_fix;
  2914. elibtoolize ${ELTCONF}
  2915. }
  2916. gnome2_src_unpack ()
  2917. {
  2918. unpack ${A};
  2919. cd "${S}";
  2920. has ${EAPI:-0} 0 1 && gnome2_src_prepare
  2921. }
  2922. has_multilib_profile ()
  2923. {
  2924. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2925. }
  2926. is-login-disabled ()
  2927. {
  2928. shell=$(egetshell "$1");
  2929. case ${shell} in
  2930. /bin/false | /usr/bin/false | /sbin/nologin | /usr/sbin/nologin)
  2931. return 0
  2932. ;;
  2933. *)
  2934. return 1
  2935. ;;
  2936. esac
  2937. }
  2938. is_final_abi ()
  2939. {
  2940. has_multilib_profile || return 0;
  2941. local ALL_ABIS=$(get_install_abis);
  2942. local LAST_ABI=${ALL_ABIS/* /};
  2943. [[ ${LAST_ABI} == ${ABI} ]]
  2944. }
  2945. make_desktop_entry ()
  2946. {
  2947. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2948. local exec=${1};
  2949. local name=${2:-${PN}};
  2950. local icon=${3:-${PN}};
  2951. local type=${4};
  2952. local fields=${5};
  2953. if [[ -z ${type} ]]; then
  2954. local catmaj=${CATEGORY%%-*};
  2955. local catmin=${CATEGORY##*-};
  2956. case ${catmaj} in
  2957. app)
  2958. case ${catmin} in
  2959. accessibility)
  2960. type=Accessibility
  2961. ;;
  2962. admin)
  2963. type=System
  2964. ;;
  2965. antivirus)
  2966. type=System
  2967. ;;
  2968. arch)
  2969. type=Archiving
  2970. ;;
  2971. backup)
  2972. type=Archiving
  2973. ;;
  2974. cdr)
  2975. type=DiscBurning
  2976. ;;
  2977. dicts)
  2978. type=Dictionary
  2979. ;;
  2980. doc)
  2981. type=Documentation
  2982. ;;
  2983. editors)
  2984. type=TextEditor
  2985. ;;
  2986. emacs)
  2987. type=TextEditor
  2988. ;;
  2989. emulation)
  2990. type=Emulator
  2991. ;;
  2992. laptop)
  2993. type=HardwareSettings
  2994. ;;
  2995. office)
  2996. type=Office
  2997. ;;
  2998. pda)
  2999. type=PDA
  3000. ;;
  3001. vim)
  3002. type=TextEditor
  3003. ;;
  3004. xemacs)
  3005. type=TextEditor
  3006. ;;
  3007. esac
  3008. ;;
  3009. dev)
  3010. type="Development"
  3011. ;;
  3012. games)
  3013. case ${catmin} in
  3014. action | fps)
  3015. type=ActionGame
  3016. ;;
  3017. arcade)
  3018. type=ArcadeGame
  3019. ;;
  3020. board)
  3021. type=BoardGame
  3022. ;;
  3023. emulation)
  3024. type=Emulator
  3025. ;;
  3026. kids)
  3027. type=KidsGame
  3028. ;;
  3029. puzzle)
  3030. type=LogicGame
  3031. ;;
  3032. roguelike)
  3033. type=RolePlaying
  3034. ;;
  3035. rpg)
  3036. type=RolePlaying
  3037. ;;
  3038. simulation)
  3039. type=Simulation
  3040. ;;
  3041. sports)
  3042. type=SportsGame
  3043. ;;
  3044. strategy)
  3045. type=StrategyGame
  3046. ;;
  3047. esac;
  3048. type="Game;${type}"
  3049. ;;
  3050. gnome)
  3051. type="Gnome;GTK"
  3052. ;;
  3053. kde)
  3054. type="KDE;Qt"
  3055. ;;
  3056. mail)
  3057. type="Network;Email"
  3058. ;;
  3059. media)
  3060. case ${catmin} in
  3061. gfx)
  3062. type=Graphics
  3063. ;;
  3064. *)
  3065. case ${catmin} in
  3066. radio)
  3067. type=Tuner
  3068. ;;
  3069. sound)
  3070. type=Audio
  3071. ;;
  3072. tv)
  3073. type=TV
  3074. ;;
  3075. video)
  3076. type=Video
  3077. ;;
  3078. esac;
  3079. type="AudioVideo;${type}"
  3080. ;;
  3081. esac
  3082. ;;
  3083. net)
  3084. case ${catmin} in
  3085. dialup)
  3086. type=Dialup
  3087. ;;
  3088. ftp)
  3089. type=FileTransfer
  3090. ;;
  3091. im)
  3092. type=InstantMessaging
  3093. ;;
  3094. irc)
  3095. type=IRCClient
  3096. ;;
  3097. mail)
  3098. type=Email
  3099. ;;
  3100. news)
  3101. type=News
  3102. ;;
  3103. nntp)
  3104. type=News
  3105. ;;
  3106. p2p)
  3107. type=FileTransfer
  3108. ;;
  3109. voip)
  3110. type=Telephony
  3111. ;;
  3112. esac;
  3113. type="Network;${type}"
  3114. ;;
  3115. sci)
  3116. case ${catmin} in
  3117. astro*)
  3118. type=Astronomy
  3119. ;;
  3120. bio*)
  3121. type=Biology
  3122. ;;
  3123. calc*)
  3124. type=Calculator
  3125. ;;
  3126. chem*)
  3127. type=Chemistry
  3128. ;;
  3129. elec*)
  3130. type=Electronics
  3131. ;;
  3132. geo*)
  3133. type=Geology
  3134. ;;
  3135. math*)
  3136. type=Math
  3137. ;;
  3138. physics)
  3139. type=Physics
  3140. ;;
  3141. visual*)
  3142. type=DataVisualization
  3143. ;;
  3144. esac;
  3145. type="Education;Science;${type}"
  3146. ;;
  3147. sys)
  3148. type="System"
  3149. ;;
  3150. www)
  3151. case ${catmin} in
  3152. client)
  3153. type=WebBrowser
  3154. ;;
  3155. esac;
  3156. type="Network;${type}"
  3157. ;;
  3158. *)
  3159. type=
  3160. ;;
  3161. esac;
  3162. fi;
  3163. if [ "${SLOT}" == "0" ]; then
  3164. local desktop_name="${PN}";
  3165. else
  3166. local desktop_name="${PN}-${SLOT}";
  3167. fi;
  3168. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  3169. type=${type%;}${type:+;};
  3170. eshopts_push -s extglob;
  3171. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  3172. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  3173. ewarn "allowed in .desktop files if the value is not an absolute path.";
  3174. icon=${icon%.@(xpm|png|svg)};
  3175. fi;
  3176. eshopts_pop;
  3177. cat > "${desktop}" <<-EOF
  3178. [Desktop Entry]
  3179. Name=${name}
  3180. Type=Application
  3181. Comment=${DESCRIPTION}
  3182. Exec=${exec}
  3183. TryExec=${exec%% *}
  3184. Icon=${icon}
  3185. Categories=${type}
  3186. EOF
  3187.  
  3188. if [[ ${fields:-=} != *=* ]]; then
  3189. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  3190. fields="Path=${fields}";
  3191. fi;
  3192. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  3193. ( insinto /usr/share/applications;
  3194. doins "${desktop}" ) || die "installing desktop file failed"
  3195. }
  3196. make_session_desktop ()
  3197. {
  3198. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  3199. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  3200. local title=$1;
  3201. local command=$2;
  3202. local desktop=${T}/${wm:-${PN}}.desktop;
  3203. shift 2;
  3204. cat > "${desktop}" <<-EOF
  3205. [Desktop Entry]
  3206. Name=${title}
  3207. Comment=This session logs you into ${title}
  3208. Exec=${command} $*
  3209. TryExec=${command}
  3210. Type=XSession
  3211. EOF
  3212.  
  3213. ( insinto /usr/share/xsessions;
  3214. doins "${desktop}" )
  3215. }
  3216. make_wrapper ()
  3217. {
  3218. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  3219. local tmpwrapper=$(emktemp);
  3220. cat > "${tmpwrapper}" <<EOF
  3221. #!/bin/sh
  3222. cd "${chdir:-.}"
  3223. if [ -n "${libdir}" ] ; then
  3224. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  3225. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  3226. else
  3227. export LD_LIBRARY_PATH="${libdir}"
  3228. fi
  3229. fi
  3230. exec ${bin} "\$@"
  3231. EOF
  3232.  
  3233. chmod go+rx "${tmpwrapper}";
  3234. if [[ -n ${path} ]]; then
  3235. ( exeinto "${path}";
  3236. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  3237. else
  3238. newbin "${tmpwrapper}" "${wrapper}" || die;
  3239. fi
  3240. }
  3241. multilib_env ()
  3242. {
  3243. local CTARGET=${1:-${CTARGET}};
  3244. case ${CTARGET} in
  3245. x86_64*)
  3246. export CFLAGS_x86=${CFLAGS_x86--m32};
  3247. export CHOST_x86=${CTARGET/x86_64/i686};
  3248. export CTARGET_x86=${CHOST_x86};
  3249. export CDEFINE_x86="__i386__";
  3250. export LIBDIR_x86="lib";
  3251. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  3252. export CHOST_amd64=${CTARGET};
  3253. export CTARGET_amd64=${CHOST_amd64};
  3254. export CDEFINE_amd64="__x86_64__";
  3255. export LIBDIR_amd64="lib64";
  3256. export MULTILIB_ABIS="amd64 x86";
  3257. export DEFAULT_ABI="amd64"
  3258. ;;
  3259. mips64*)
  3260. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3261. export CHOST_o32=${CTARGET/mips64/mips};
  3262. export CTARGET_o32=${CHOST_o32};
  3263. export CDEFINE_o32="_MIPS_SIM == _ABIO32";
  3264. export LIBDIR_o32="lib";
  3265. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3266. export CHOST_n32=${CTARGET};
  3267. export CTARGET_n32=${CHOST_n32};
  3268. export CDEFINE_n32="_MIPS_SIM == _ABIN32";
  3269. export LIBDIR_n32="lib32";
  3270. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3271. export CHOST_n64=${CTARGET};
  3272. export CTARGET_n64=${CHOST_n64};
  3273. export CDEFINE_n64="_MIPS_SIM == _ABI64";
  3274. export LIBDIR_n64="lib64";
  3275. export MULTILIB_ABIS="n64 n32 o32";
  3276. export DEFAULT_ABI="n32"
  3277. ;;
  3278. powerpc64*)
  3279. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3280. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3281. export CTARGET_ppc=${CHOST_ppc};
  3282. export CDEFINE_ppc="!__powerpc64__";
  3283. export LIBDIR_ppc="lib";
  3284. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3285. export CHOST_ppc64=${CTARGET};
  3286. export CTARGET_ppc64=${CHOST_ppc64};
  3287. export CDEFINE_ppc64="__powerpc64__";
  3288. export LIBDIR_ppc64="lib64";
  3289. export MULTILIB_ABIS="ppc64 ppc";
  3290. export DEFAULT_ABI="ppc64"
  3291. ;;
  3292. s390x*)
  3293. export CFLAGS_s390=${CFLAGS_s390--m31};
  3294. export CHOST_s390=${CTARGET/s390x/s390};
  3295. export CTARGET_s390=${CHOST_s390};
  3296. export CDEFINE_s390="!__s390x__";
  3297. export LIBDIR_s390="lib";
  3298. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3299. export CHOST_s390x=${CTARGET};
  3300. export CTARGET_s390x=${CHOST_s390x};
  3301. export CDEFINE_s390x="__s390x__";
  3302. export LIBDIR_s390x="lib64";
  3303. export MULTILIB_ABIS="s390x s390";
  3304. export DEFAULT_ABI="s390x"
  3305. ;;
  3306. sparc*)
  3307. export CFLAGS_sparc32=${CFLAGS_sparc32};
  3308. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3309. export CTARGET_sparc32=${CHOST_sparc32};
  3310. export CDEFINE_sparc32="!__arch64__";
  3311. export LIBDIR_sparc32="lib";
  3312. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3313. export CHOST_sparc64=${CTARGET};
  3314. export CTARGET_sparc64=${CHOST_sparc64};
  3315. export CDEFINE_sparc64="__arch64__";
  3316. export LIBDIR_sparc64="lib64";
  3317. export MULTILIB_ABIS="${MULTILIB_ABIS-sparc64 sparc32}";
  3318. export DEFAULT_ABI="${DEFAULT_ABI-sparc64}"
  3319. ;;
  3320. *)
  3321. export MULTILIB_ABIS="default";
  3322. export DEFAULT_ABI="default"
  3323. ;;
  3324. esac
  3325. }
  3326. multilib_toolchain_setup ()
  3327. {
  3328. local v vv;
  3329. export ABI=$1;
  3330. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3331. if [[ ${DEFAULT_ABI_SAVED} != "true" ]]; then
  3332. for v in CHOST CBUILD AS CC CXX LD;
  3333. do
  3334. export __abi_saved_${v}="${!v}";
  3335. done;
  3336. export DEFAULT_ABI_SAVED="true";
  3337. fi;
  3338. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3339. export AS="$(tc-getAS) $(get_abi_ASFLAGS)";
  3340. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3341. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3342. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3343. export CHOST=$(get_abi_CHOST $1);
  3344. export CBUILD=$(get_abi_CHOST $1);
  3345. else
  3346. if [[ ${DEFAULT_ABI_SAVED} == "true" ]]; then
  3347. for v in CHOST CBUILD AS CC CXX LD;
  3348. do
  3349. vv="__abi_saved_${v}";
  3350. export ${v}=${!vv};
  3351. done;
  3352. fi;
  3353. fi
  3354. }
  3355. newicon ()
  3356. {
  3357. ( insinto /usr/share/pixmaps;
  3358. newins "$@" )
  3359. }
  3360. newmenu ()
  3361. {
  3362. ( insinto /usr/share/applications;
  3363. newins "$@" )
  3364. }
  3365. nonfatal ()
  3366. {
  3367. if has "${EAPI:-0}" 0 1 2 3 3_pre2; then
  3368. die "$FUNCNAME() not supported in this EAPI";
  3369. fi;
  3370. if [[ $# -lt 1 ]]; then
  3371. die "$FUNCNAME(): Missing argument";
  3372. fi;
  3373. PORTAGE_NONFATAL=1 "$@"
  3374. }
  3375. number_abis ()
  3376. {
  3377. get_install_abis | wc -w
  3378. }
  3379. pkg_nofetch ()
  3380. {
  3381. _eapi0_pkg_nofetch "$@"
  3382. }
  3383. pkg_postinst ()
  3384. {
  3385. gnome2_pkg_postinst;
  3386. python_mod_optimize $(python_get_sitedir)/sabayon;
  3387. elog "To apply Sabayon defaults and mandatory settings to all users, put";
  3388. elog ' include "$(HOME)/.gconf.path.mandatory"';
  3389. elog "in /etc/gconf/2/local-mandatory.path and put";
  3390. elog ' include "$(HOME)/.gconf.path.defaults"';
  3391. elog "in /etc/gconf/2/local-defaults.path.";
  3392. elog "You can safely create these files if they do not already exist."
  3393. }
  3394. pkg_postrm ()
  3395. {
  3396. gnome2_pkg_postrm;
  3397. python_mod_cleanup /usr/$(get_libdir)/python*/site-packages/sabayon
  3398. }
  3399. pkg_preinst ()
  3400. {
  3401. gnome2_pkg_preinst "$@"
  3402. }
  3403. pkg_setup ()
  3404. {
  3405. G2CONF="${G2CONF}
  3406. --disable-static
  3407. --with-distro=gentoo
  3408. --with-prototype-user=${PN}-admin
  3409. --enable-console-helper=no";
  3410. einfo "Adding user '${PN}-admin' as the prototype user";
  3411. enewgroup ${PN}-admin;
  3412. enewuser ${PN}-admin -1 -1 "/var/lib/sabayon" "${PN}-admin"
  3413. }
  3414. prep_ml_includes ()
  3415. {
  3416. if [[ $(number_abis) -gt 1 ]]; then
  3417. local dir;
  3418. local dirs;
  3419. local base;
  3420. if [[ $# -eq 0 ]]; then
  3421. dirs=/usr/include;
  3422. else
  3423. dirs="$@";
  3424. fi;
  3425. for dir in ${dirs};
  3426. do
  3427. base=${T}/gentoo-multilib/${dir}/gentoo-multilib;
  3428. mkdir -p "${base}";
  3429. [[ -d ${base}/${ABI} ]] && rm -rf "${base}/${ABI}";
  3430. mv "${D}/${dir}" "${base}/${ABI}";
  3431. done;
  3432. if is_final_abi; then
  3433. base=${T}/gentoo-multilib;
  3434. pushd "${base}";
  3435. find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C "${D}";
  3436. popd;
  3437. set --;
  3438. for dir in ${dirs};
  3439. do
  3440. set -- "$@" "${dir}";
  3441. local abi;
  3442. for abi in $(get_install_abis);
  3443. do
  3444. set -- "$@" "$(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}";
  3445. done;
  3446. create_ml_includes "$@";
  3447. done;
  3448. fi;
  3449. fi
  3450. }
  3451. preserve_old_lib ()
  3452. {
  3453. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  3454. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  3455. die "Invalid preserve_old_lib() usage";
  3456. fi;
  3457. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  3458. has preserve-libs ${FEATURES} && return 0;
  3459. local lib dir;
  3460. for lib in "$@";
  3461. do
  3462. [[ -e ${ROOT}/${lib} ]] || continue;
  3463. dir=${lib%/*};
  3464. dodir ${dir} || die "dodir ${dir} failed";
  3465. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  3466. touch "${D}"/${lib};
  3467. done
  3468. }
  3469. preserve_old_lib_notify ()
  3470. {
  3471. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  3472. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  3473. die "Invalid preserve_old_lib_notify() usage";
  3474. fi;
  3475. has preserve-libs ${FEATURES} && return 0;
  3476. local lib notice=0;
  3477. for lib in "$@";
  3478. do
  3479. [[ -e ${ROOT}/${lib} ]] || continue;
  3480. if [[ ${notice} -eq 0 ]]; then
  3481. notice=1;
  3482. ewarn "Old versions of installed libraries were detected on your system.";
  3483. ewarn "In order to avoid breaking packages that depend on these old libs,";
  3484. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  3485. ewarn "in order to remove these old dependencies. If you do not have this";
  3486. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  3487. ewarn;
  3488. fi;
  3489. ewarn " # revdep-rebuild --library ${lib##*/}";
  3490. done;
  3491. if [[ ${notice} -eq 1 ]]; then
  3492. ewarn;
  3493. ewarn "Once you've finished running revdep-rebuild, it should be safe to";
  3494. ewarn "delete the old libraries. Here is a copy & paste for the lazy:";
  3495. for lib in "$@";
  3496. do
  3497. ewarn " # rm '${lib}'";
  3498. done;
  3499. fi
  3500. }
  3501. python_clean_installation_image ()
  3502. {
  3503. _python_check_python_pkg_setup_execution;
  3504. _python_initialize_prefix_variables;
  3505. local file files=() quiet="0";
  3506. [[ "${EBUILD_PHASE}" != "install" ]] && die "${FUNCNAME}() can be used only in src_install() phase";
  3507. while (($#)); do
  3508. case "$1" in
  3509. -q | --quiet)
  3510. quiet="1"
  3511. ;;
  3512. -*)
  3513. die "${FUNCNAME}(): Unrecognized option '$1'"
  3514. ;;
  3515. *)
  3516. die "${FUNCNAME}(): Invalid usage"
  3517. ;;
  3518. esac;
  3519. shift;
  3520. done;
  3521. while read -d '' -r file; do
  3522. files+=("${file}");
  3523. done < <(find "${ED}" "(" -name "*.py[co]" -o -name "*\$py.class" ")" -type f -print0);
  3524. if [[ "${#files[@]}" -gt 0 ]]; then
  3525. if [[ "${quiet}" == "0" ]]; then
  3526. ewarn "Deleting byte-compiled Python modules needlessly generated by build system:";
  3527. fi;
  3528. for file in "${files[@]}";
  3529. do
  3530. if [[ "${quiet}" == "0" ]]; then
  3531. ewarn " ${file}";
  3532. fi;
  3533. rm -f "${file}";
  3534. if [[ "${file%/*}" == *"/__pycache__" ]]; then
  3535. rmdir "${file%/*}" 2> /dev/null;
  3536. fi;
  3537. done;
  3538. fi;
  3539. function python_clean_sitedirs ()
  3540. {
  3541. if [[ -d "${ED}$(python_get_sitedir)" ]]; then
  3542. find "${ED}$(python_get_sitedir)" "(" -name "*.c" -o -name "*.h" -o -name "*.la" ")" -type f -print0 | xargs -0 rm -f;
  3543. fi
  3544. };
  3545. if _python_package_supporting_installation_for_multiple_python_abis; then
  3546. python_execute_function -q python_clean_sitedirs;
  3547. else
  3548. python_clean_sitedirs;
  3549. fi;
  3550. unset -f python_clean_sitedirs
  3551. }
  3552. python_convert_shebangs ()
  3553. {
  3554. _python_check_python_pkg_setup_execution;
  3555. local argument file files=() only_executables="0" python_version quiet="0" recursive="0";
  3556. while (($#)); do
  3557. case "$1" in
  3558. -r | --recursive)
  3559. recursive="1"
  3560. ;;
  3561. -q | --quiet)
  3562. quiet="1"
  3563. ;;
  3564. -x | --only-executables)
  3565. only_executables="1"
  3566. ;;
  3567. --)
  3568. shift;
  3569. break
  3570. ;;
  3571. -*)
  3572. die "${FUNCNAME}(): Unrecognized option '$1'"
  3573. ;;
  3574. *)
  3575. break
  3576. ;;
  3577. esac;
  3578. shift;
  3579. done;
  3580. if [[ "$#" -eq 0 ]]; then
  3581. die "${FUNCNAME}(): Missing Python version and files or directories";
  3582. else
  3583. if [[ "$#" -eq 1 ]]; then
  3584. die "${FUNCNAME}(): Missing files or directories";
  3585. fi;
  3586. fi;
  3587. python_version="$1";
  3588. shift;
  3589. for argument in "$@";
  3590. do
  3591. if [[ ! -e "${argument}" ]]; then
  3592. die "${FUNCNAME}(): '${argument}' does not exist";
  3593. else
  3594. if [[ -f "${argument}" ]]; then
  3595. files+=("${argument}");
  3596. else
  3597. if [[ -d "${argument}" ]]; then
  3598. if [[ "${recursive}" == "1" ]]; then
  3599. while read -d '' -r file; do
  3600. files+=("${file}");
  3601. done < <(find "${argument}" $([[ "${only_executables}" == "1" ]] && echo -perm /111) -type f -print0);
  3602. else
  3603. die "${FUNCNAME}(): '${argument}' is not a regular file";
  3604. fi;
  3605. else
  3606. die "${FUNCNAME}(): '${argument}' is not a regular file or a directory";
  3607. fi;
  3608. fi;
  3609. fi;
  3610. done;
  3611. for file in "${files[@]}";
  3612. do
  3613. file="${file#./}";
  3614. [[ "${only_executables}" == "1" && ! -x "${file}" ]] && continue;
  3615. if [[ "$(head -n1 "${file}")" =~ ^'#!'.*python ]]; then
  3616. [[ "$(sed -ne "2p" "${file}")" =~ ^"# Gentoo '".*"' wrapper script generated by python_generate_wrapper_scripts()"$ ]] && continue;
  3617. if [[ "${quiet}" == "0" ]]; then
  3618. einfo "Converting shebang in '${file}'";
  3619. fi;
  3620. sed -e "1s/python\([[:digit:]]\+\(\.[[:digit:]]\+\)\?\)\?/python${python_version}/" -i "${file}" || die "Conversion of shebang in '${file}' failed";
  3621. sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed";
  3622. fi;
  3623. done
  3624. }
  3625. python_copy_sources ()
  3626. {
  3627. _python_check_python_pkg_setup_execution;
  3628. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  3629. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  3630. fi;
  3631. local dir dirs=() PYTHON_ABI;
  3632. if [[ "$#" -eq 0 ]]; then
  3633. if [[ "${WORKDIR}" == "${S}" ]]; then
  3634. die "${FUNCNAME}() cannot be used with current value of S variable";
  3635. fi;
  3636. dirs=("${S%/}");
  3637. else
  3638. dirs=("$@");
  3639. fi;
  3640. _python_calculate_PYTHON_ABIS;
  3641. for PYTHON_ABI in ${PYTHON_ABIS};
  3642. do
  3643. for dir in "${dirs[@]}";
  3644. do
  3645. cp -pr "${dir}" "${dir}-${PYTHON_ABI}" > /dev/null || die "Copying of sources failed";
  3646. done;
  3647. done
  3648. }
  3649. python_disable_pyc ()
  3650. {
  3651. _python_check_python_pkg_setup_execution;
  3652. if [[ "$#" -ne 0 ]]; then
  3653. die "${FUNCNAME}() does not accept arguments";
  3654. fi;
  3655. export PYTHONDONTWRITEBYTECODE="1"
  3656. }
  3657. python_enable_pyc ()
  3658. {
  3659. _python_check_python_pkg_setup_execution;
  3660. if [[ "$#" -ne 0 ]]; then
  3661. die "${FUNCNAME}() does not accept arguments";
  3662. fi;
  3663. unset PYTHONDONTWRITEBYTECODE
  3664. }
  3665. python_execute_function ()
  3666. {
  3667. _python_check_python_pkg_setup_execution;
  3668. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  3669. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  3670. fi;
  3671. _python_set_color_variables;
  3672. local action action_message action_message_template= default_function="0" failure_message failure_message_template= final_ABI="0" function iterated_PYTHON_ABIS nonfatal="0" previous_directory previous_directory_stack previous_directory_stack_length PYTHON_ABI quiet="0" return_code separate_build_dirs="0" source_dir=;
  3673. while (($#)); do
  3674. case "$1" in
  3675. --action-message)
  3676. action_message_template="$2";
  3677. shift
  3678. ;;
  3679. -d | --default-function)
  3680. default_function="1"
  3681. ;;
  3682. --failure-message)
  3683. failure_message_template="$2";
  3684. shift
  3685. ;;
  3686. -f | --final-ABI)
  3687. final_ABI="1"
  3688. ;;
  3689. --nonfatal)
  3690. nonfatal="1"
  3691. ;;
  3692. -q | --quiet)
  3693. quiet="1"
  3694. ;;
  3695. -s | --separate-build-dirs)
  3696. separate_build_dirs="1"
  3697. ;;
  3698. --source-dir)
  3699. source_dir="$2";
  3700. shift
  3701. ;;
  3702. --)
  3703. shift;
  3704. break
  3705. ;;
  3706. -*)
  3707. die "${FUNCNAME}(): Unrecognized option '$1'"
  3708. ;;
  3709. *)
  3710. break
  3711. ;;
  3712. esac;
  3713. shift;
  3714. done;
  3715. if [[ -n "${source_dir}" && "${separate_build_dirs}" == 0 ]]; then
  3716. die "${FUNCNAME}(): '--source-dir' option can be specified only with '--separate-build-dirs' option";
  3717. fi;
  3718. if [[ "${default_function}" == "0" ]]; then
  3719. if [[ "$#" -eq 0 ]]; then
  3720. die "${FUNCNAME}(): Missing function name";
  3721. fi;
  3722. function="$1";
  3723. shift;
  3724. if [[ -z "$(type -t "${function}")" ]]; then
  3725. die "${FUNCNAME}(): '${function}' function is not defined";
  3726. fi;
  3727. else
  3728. if has "${EAPI:-0}" 0 1; then
  3729. die "${FUNCNAME}(): '--default-function' option cannot be used in this EAPI";
  3730. fi;
  3731. if [[ "${EBUILD_PHASE}" == "configure" ]]; then
  3732. if has "${EAPI}" 2 3; then
  3733. function python_default_function ()
  3734. {
  3735. econf "$@"
  3736. };
  3737. else
  3738. function python_default_function ()
  3739. {
  3740. nonfatal econf "$@"
  3741. };
  3742. fi;
  3743. else
  3744. if [[ "${EBUILD_PHASE}" == "compile" ]]; then
  3745. function python_default_function ()
  3746. {
  3747. emake "$@"
  3748. };
  3749. else
  3750. if [[ "${EBUILD_PHASE}" == "test" ]]; then
  3751. function python_default_function ()
  3752. {
  3753. if emake -j1 -n check &>/dev/null; then
  3754. emake -j1 check "$@";
  3755. else
  3756. if emake -j1 -n test &>/dev/null; then
  3757. emake -j1 test "$@";
  3758. fi;
  3759. fi
  3760. };
  3761. else
  3762. if [[ "${EBUILD_PHASE}" == "install" ]]; then
  3763. function python_default_function ()
  3764. {
  3765. emake DESTDIR="${D}" install "$@"
  3766. };
  3767. else
  3768. die "${FUNCNAME}(): '--default-function' option cannot be used in this ebuild phase";
  3769. fi;
  3770. fi;
  3771. fi;
  3772. fi;
  3773. function="python_default_function";
  3774. fi;
  3775. if _python_abi-specific_local_scope; then
  3776. die "${FUNCNAME}(): Invalid call stack";
  3777. fi;
  3778. if [[ "${quiet}" == "0" ]]; then
  3779. [[ "${EBUILD_PHASE}" == "setup" ]] && action="Setting up";
  3780. [[ "${EBUILD_PHASE}" == "unpack" ]] && action="Unpacking";
  3781. [[ "${EBUILD_PHASE}" == "prepare" ]] && action="Preparation";
  3782. [[ "${EBUILD_PHASE}" == "configure" ]] && action="Configuration";
  3783. [[ "${EBUILD_PHASE}" == "compile" ]] && action="Building";
  3784. [[ "${EBUILD_PHASE}" == "test" ]] && action="Testing";
  3785. [[ "${EBUILD_PHASE}" == "install" ]] && action="Installation";
  3786. [[ "${EBUILD_PHASE}" == "preinst" ]] && action="Preinstallation";
  3787. [[ "${EBUILD_PHASE}" == "postinst" ]] && action="Postinstallation";
  3788. [[ "${EBUILD_PHASE}" == "prerm" ]] && action="Preuninstallation";
  3789. [[ "${EBUILD_PHASE}" == "postrm" ]] && action="Postuninstallation";
  3790. fi;
  3791. _python_calculate_PYTHON_ABIS;
  3792. if [[ "${final_ABI}" == "1" ]]; then
  3793. iterated_PYTHON_ABIS="$(PYTHON -f --ABI)";
  3794. else
  3795. iterated_PYTHON_ABIS="${PYTHON_ABIS}";
  3796. fi;
  3797. for PYTHON_ABI in ${iterated_PYTHON_ABIS};
  3798. do
  3799. _python_prepare_flags;
  3800. if [[ "${quiet}" == "0" ]]; then
  3801. if [[ -n "${action_message_template}" ]]; then
  3802. action_message="$(eval echo -n "${action_message_template}")";
  3803. else
  3804. action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)...";
  3805. fi;
  3806. echo " ${_GREEN}*${_NORMAL} ${_BLUE}${action_message}${_NORMAL}";
  3807. fi;
  3808. if [[ "${separate_build_dirs}" == "1" ]]; then
  3809. if [[ -n "${source_dir}" ]]; then
  3810. export BUILDDIR="${S}/${source_dir}-${PYTHON_ABI}";
  3811. else
  3812. export BUILDDIR="${S}-${PYTHON_ABI}";
  3813. fi;
  3814. pushd "${BUILDDIR}" > /dev/null || die "pushd failed";
  3815. else
  3816. export BUILDDIR="${S}";
  3817. fi;
  3818. previous_directory="$(pwd)";
  3819. previous_directory_stack="$(dirs -p)";
  3820. previous_directory_stack_length="$(dirs -p | wc -l)";
  3821. if ! has "${EAPI}" 0 1 2 3 && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
  3822. EPYTHON="$(PYTHON)" nonfatal "${function}" "$@";
  3823. else
  3824. EPYTHON="$(PYTHON)" "${function}" "$@";
  3825. fi;
  3826. return_code="$?";
  3827. _python_restore_flags;
  3828. if [[ "${return_code}" -ne 0 ]]; then
  3829. if [[ -n "${failure_message_template}" ]]; then
  3830. failure_message="$(eval echo -n "${failure_message_template}")";
  3831. else
  3832. failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function";
  3833. fi;
  3834. if [[ "${nonfatal}" == "1" ]]; then
  3835. if [[ "${quiet}" == "0" ]]; then
  3836. ewarn "${failure_message}";
  3837. fi;
  3838. else
  3839. if [[ "${final_ABI}" == "0" ]] && has "${PYTHON_ABI}" ${FAILURE_TOLERANT_PYTHON_ABIS}; then
  3840. if [[ "${EBUILD_PHASE}" != "test" ]] || ! has test-fail-continue ${FEATURES}; then
  3841. local enabled_PYTHON_ABIS= other_PYTHON_ABI;
  3842. for other_PYTHON_ABI in ${PYTHON_ABIS};
  3843. do
  3844. [[ "${other_PYTHON_ABI}" != "${PYTHON_ABI}" ]] && enabled_PYTHON_ABIS+="${enabled_PYTHON_ABIS:+ }${other_PYTHON_ABI}";
  3845. done;
  3846. export PYTHON_ABIS="${enabled_PYTHON_ABIS}";
  3847. fi;
  3848. if [[ "${quiet}" == "0" ]]; then
  3849. ewarn "${failure_message}";
  3850. fi;
  3851. if [[ -z "${PYTHON_ABIS}" ]]; then
  3852. die "${function}() function failed with all enabled Python ABIs";
  3853. fi;
  3854. else
  3855. die "${failure_message}";
  3856. fi;
  3857. fi;
  3858. fi;
  3859. if [[ "$(dirs -p | wc -l)" -lt "${previous_directory_stack_length}" ]]; then
  3860. die "Directory stack decreased illegally";
  3861. fi;
  3862. while [[ "$(dirs -p | wc -l)" -gt "${previous_directory_stack_length}" ]]; do
  3863. popd > /dev/null || die "popd failed";
  3864. done;
  3865. cd "${previous_directory}";
  3866. if [[ "$(dirs -p)" != "${previous_directory_stack}" ]]; then
  3867. die "Directory stack changed illegally";
  3868. fi;
  3869. if [[ "${separate_build_dirs}" == "1" ]]; then
  3870. popd > /dev/null || die "popd failed";
  3871. fi;
  3872. unset BUILDDIR;
  3873. done;
  3874. if [[ "${default_function}" == "1" ]]; then
  3875. unset -f python_default_function;
  3876. fi
  3877. }
  3878. python_execute_nosetests ()
  3879. {
  3880. _python_check_python_pkg_setup_execution;
  3881. _python_set_color_variables;
  3882. local PYTHONPATH_template= separate_build_dirs=;
  3883. while (($#)); do
  3884. case "$1" in
  3885. -P | --PYTHONPATH)
  3886. PYTHONPATH_template="$2";
  3887. shift
  3888. ;;
  3889. -s | --separate-build-dirs)
  3890. separate_build_dirs="1"
  3891. ;;
  3892. --)
  3893. shift;
  3894. break
  3895. ;;
  3896. -*)
  3897. die "${FUNCNAME}(): Unrecognized option '$1'"
  3898. ;;
  3899. *)
  3900. break
  3901. ;;
  3902. esac;
  3903. shift;
  3904. done;
  3905. function python_test_function ()
  3906. {
  3907. local evaluated_PYTHONPATH;
  3908. evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")";
  3909. _python_test_hook pre;
  3910. if [[ -n "${evaluated_PYTHONPATH}" ]]; then
  3911. echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL};
  3912. PYTHONPATH="${evaluated_PYTHONPATH}" nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?";
  3913. else
  3914. echo ${_BOLD}nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@"${_NORMAL};
  3915. nosetests --verbosity="${PYTHON_TEST_VERBOSITY}" "$@" || return "$?";
  3916. fi;
  3917. _python_test_hook post
  3918. };
  3919. if _python_package_supporting_installation_for_multiple_python_abis; then
  3920. python_execute_function ${separate_build_dirs:+-s} python_test_function "$@";
  3921. else
  3922. if [[ -n "${separate_build_dirs}" ]]; then
  3923. die "${FUNCNAME}(): Invalid usage";
  3924. fi;
  3925. python_test_function "$@" || die "Testing failed";
  3926. fi;
  3927. unset -f python_test_function
  3928. }
  3929. python_execute_py.test ()
  3930. {
  3931. _python_check_python_pkg_setup_execution;
  3932. _python_set_color_variables;
  3933. local PYTHONPATH_template= separate_build_dirs=;
  3934. while (($#)); do
  3935. case "$1" in
  3936. -P | --PYTHONPATH)
  3937. PYTHONPATH_template="$2";
  3938. shift
  3939. ;;
  3940. -s | --separate-build-dirs)
  3941. separate_build_dirs="1"
  3942. ;;
  3943. --)
  3944. shift;
  3945. break
  3946. ;;
  3947. -*)
  3948. die "${FUNCNAME}(): Unrecognized option '$1'"
  3949. ;;
  3950. *)
  3951. break
  3952. ;;
  3953. esac;
  3954. shift;
  3955. done;
  3956. function python_test_function ()
  3957. {
  3958. local evaluated_PYTHONPATH;
  3959. evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")";
  3960. _python_test_hook pre;
  3961. if [[ -n "${evaluated_PYTHONPATH}" ]]; then
  3962. echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@"${_NORMAL};
  3963. PYTHONPATH="${evaluated_PYTHONPATH}" py.test $([[ "${PYTHON_TEST_VERBOSITY}" -ge 2 ]] && echo -v) "$@" || return "$?";
  3964. else
  3965. echo ${_BOLD}py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@"${_NORMAL};
  3966. py.test $([[ "${PYTHON_TEST_VERBOSITY}" -gt 1 ]] && echo -v) "$@" || return "$?";
  3967. fi;
  3968. _python_test_hook post
  3969. };
  3970. if _python_package_supporting_installation_for_multiple_python_abis; then
  3971. python_execute_function ${separate_build_dirs:+-s} python_test_function "$@";
  3972. else
  3973. if [[ -n "${separate_build_dirs}" ]]; then
  3974. die "${FUNCNAME}(): Invalid usage";
  3975. fi;
  3976. python_test_function "$@" || die "Testing failed";
  3977. fi;
  3978. unset -f python_test_function
  3979. }
  3980. python_execute_trial ()
  3981. {
  3982. _python_check_python_pkg_setup_execution;
  3983. _python_set_color_variables;
  3984. local PYTHONPATH_template= separate_build_dirs=;
  3985. while (($#)); do
  3986. case "$1" in
  3987. -P | --PYTHONPATH)
  3988. PYTHONPATH_template="$2";
  3989. shift
  3990. ;;
  3991. -s | --separate-build-dirs)
  3992. separate_build_dirs="1"
  3993. ;;
  3994. --)
  3995. shift;
  3996. break
  3997. ;;
  3998. -*)
  3999. die "${FUNCNAME}(): Unrecognized option '$1'"
  4000. ;;
  4001. *)
  4002. break
  4003. ;;
  4004. esac;
  4005. shift;
  4006. done;
  4007. function python_test_function ()
  4008. {
  4009. local evaluated_PYTHONPATH;
  4010. evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")";
  4011. _python_test_hook pre;
  4012. if [[ -n "${evaluated_PYTHONPATH}" ]]; then
  4013. echo ${_BOLD}PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL};
  4014. PYTHONPATH="${evaluated_PYTHONPATH}" trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?";
  4015. else
  4016. echo ${_BOLD}trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@"${_NORMAL};
  4017. trial $([[ "${PYTHON_TEST_VERBOSITY}" -ge 4 ]] && echo --spew) "$@" || return "$?";
  4018. fi;
  4019. _python_test_hook post
  4020. };
  4021. if _python_package_supporting_installation_for_multiple_python_abis; then
  4022. python_execute_function ${separate_build_dirs:+-s} python_test_function "$@";
  4023. else
  4024. if [[ -n "${separate_build_dirs}" ]]; then
  4025. die "${FUNCNAME}(): Invalid usage";
  4026. fi;
  4027. python_test_function "$@" || die "Testing failed";
  4028. fi;
  4029. unset -f python_test_function
  4030. }
  4031. python_generate_wrapper_scripts ()
  4032. {
  4033. _python_check_python_pkg_setup_execution;
  4034. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4035. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4036. fi;
  4037. _python_initialize_prefix_variables;
  4038. local eselect_python_option file force="0" quiet="0" PYTHON_ABI python2_enabled="0" python3_enabled="0" respect_EPYTHON="0";
  4039. while (($#)); do
  4040. case "$1" in
  4041. -E | --respect-EPYTHON)
  4042. respect_EPYTHON="1"
  4043. ;;
  4044. -f | --force)
  4045. force="1"
  4046. ;;
  4047. -q | --quiet)
  4048. quiet="1"
  4049. ;;
  4050. --)
  4051. shift;
  4052. break
  4053. ;;
  4054. -*)
  4055. die "${FUNCNAME}(): Unrecognized option '$1'"
  4056. ;;
  4057. *)
  4058. break
  4059. ;;
  4060. esac;
  4061. shift;
  4062. done;
  4063. if [[ "$#" -eq 0 ]]; then
  4064. die "${FUNCNAME}(): Missing arguments";
  4065. fi;
  4066. _python_calculate_PYTHON_ABIS;
  4067. for PYTHON_ABI in "${_CPYTHON2_SUPPORTED_ABIS[@]}";
  4068. do
  4069. if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
  4070. python2_enabled="1";
  4071. fi;
  4072. done;
  4073. for PYTHON_ABI in "${_CPYTHON3_SUPPORTED_ABIS[@]}";
  4074. do
  4075. if has "${PYTHON_ABI}" ${PYTHON_ABIS}; then
  4076. python3_enabled="1";
  4077. fi;
  4078. done;
  4079. if [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "1" ]]; then
  4080. eselect_python_option=;
  4081. else
  4082. if [[ "${python2_enabled}" == "1" && "${python3_enabled}" == "0" ]]; then
  4083. eselect_python_option="--python2";
  4084. else
  4085. if [[ "${python2_enabled}" == "0" && "${python3_enabled}" == "1" ]]; then
  4086. eselect_python_option="--python3";
  4087. else
  4088. die "${FUNCNAME}(): Unsupported environment";
  4089. fi;
  4090. fi;
  4091. fi;
  4092. for file in "$@";
  4093. do
  4094. if [[ -f "${file}" && "${force}" == "0" ]]; then
  4095. die "${FUNCNAME}(): '$1' already exists";
  4096. fi;
  4097. if [[ "${quiet}" == "0" ]]; then
  4098. einfo "Generating '${file#${ED%/}}' wrapper script";
  4099. fi;
  4100. cat > "${file}" <<EOF
  4101. #!/usr/bin/env python
  4102. # Gentoo '${file##*/}' wrapper script generated by python_generate_wrapper_scripts()
  4103.  
  4104. import os
  4105. import re
  4106. import subprocess
  4107. import sys
  4108.  
  4109. EPYTHON_re = re.compile(r"^python(\d+\.\d+)$")
  4110. python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)")
  4111. python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$")
  4112.  
  4113. EOF
  4114.  
  4115. if [[ "$?" != "0" ]]; then
  4116. die "${FUNCNAME}(): Generation of '$1' failed";
  4117. fi;
  4118. if [[ "${respect_EPYTHON}" == "1" ]]; then
  4119. cat >> "${file}" <<EOF
  4120. EPYTHON = os.environ.get("EPYTHON")
  4121. if EPYTHON:
  4122. EPYTHON_matched = EPYTHON_re.match(EPYTHON)
  4123. if EPYTHON_matched:
  4124. PYTHON_ABI = EPYTHON_matched.group(1)
  4125. else:
  4126. sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON)
  4127. sys.exit(1)
  4128. else:
  4129. try:
  4130. eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
  4131. if eselect_process.wait() != 0:
  4132. raise ValueError
  4133. except (OSError, ValueError):
  4134. sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
  4135. sys.exit(1)
  4136.  
  4137. EPYTHON = eselect_process.stdout.read()
  4138. if not isinstance(EPYTHON, str):
  4139. # Python 3
  4140. EPYTHON = EPYTHON.decode()
  4141. EPYTHON = EPYTHON.rstrip("\n")
  4142.  
  4143. EPYTHON_matched = EPYTHON_re.match(EPYTHON)
  4144. if EPYTHON_matched:
  4145. PYTHON_ABI = EPYTHON_matched.group(1)
  4146. else:
  4147. sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
  4148. sys.exit(1)
  4149. EOF
  4150.  
  4151. if [[ "$?" != "0" ]]; then
  4152. die "${FUNCNAME}(): Generation of '$1' failed";
  4153. fi;
  4154. else
  4155. cat >> "${file}" <<EOF
  4156. try:
  4157. eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE)
  4158. if eselect_process.wait() != 0:
  4159. raise ValueError
  4160. except (OSError, ValueError):
  4161. sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n")
  4162. sys.exit(1)
  4163.  
  4164. EPYTHON = eselect_process.stdout.read()
  4165. if not isinstance(EPYTHON, str):
  4166. # Python 3
  4167. EPYTHON = EPYTHON.decode()
  4168. EPYTHON = EPYTHON.rstrip("\n")
  4169.  
  4170. EPYTHON_matched = EPYTHON_re.match(EPYTHON)
  4171. if EPYTHON_matched:
  4172. PYTHON_ABI = EPYTHON_matched.group(1)
  4173. else:
  4174. sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON)
  4175. sys.exit(1)
  4176. EOF
  4177.  
  4178. if [[ "$?" != "0" ]]; then
  4179. die "${FUNCNAME}(): Generation of '$1' failed";
  4180. fi;
  4181. fi
  4182. cat >> "${file}" <<EOF
  4183.  
  4184. wrapper_script_path = os.path.realpath(sys.argv[0])
  4185. target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI)
  4186. os.environ["GENTOO_PYTHON_PROCESS_NAME"] = os.path.basename(sys.argv[0])
  4187. os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0]
  4188. os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path
  4189. if not os.path.exists(target_executable_path):
  4190. sys.stderr.write("'%s' does not exist\n" % target_executable_path)
  4191. sys.exit(1)
  4192.  
  4193. target_executable = open(target_executable_path, "rb")
  4194. target_executable_first_line = target_executable.readline()
  4195. if not isinstance(target_executable_first_line, str):
  4196. # Python 3
  4197. target_executable_first_line = target_executable_first_line.decode("utf_8", "replace")
  4198.  
  4199. python_shebang_matched = python_shebang_re.match(target_executable_first_line)
  4200. target_executable.close()
  4201.  
  4202. if python_shebang_matched:
  4203. try:
  4204. python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON
  4205. os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1"
  4206. python_verification_process = subprocess.Popen([python_interpreter_path, "-c", "pass"], stdout=subprocess.PIPE)
  4207. del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
  4208. if python_verification_process.wait() != 0:
  4209. raise ValueError
  4210.  
  4211. python_verification_output = python_verification_process.stdout.read()
  4212. if not isinstance(python_verification_output, str):
  4213. # Python 3
  4214. python_verification_output = python_verification_output.decode()
  4215.  
  4216. if not python_verification_output_re.match(python_verification_output):
  4217. raise ValueError
  4218.  
  4219. os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv)
  4220. except:
  4221. pass
  4222. if "GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION" in os.environ:
  4223. del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
  4224.  
  4225. os.execv(target_executable_path, sys.argv)
  4226. EOF
  4227.  
  4228. if [[ "$?" != "0" ]]; then
  4229. die "${FUNCNAME}(): Generation of '$1' failed";
  4230. fi;
  4231. fperms +x "${file#${ED%/}}" || die "fperms '${file}' failed";
  4232. done
  4233. }
  4234. python_get_implementation ()
  4235. {
  4236. _python_check_python_pkg_setup_execution;
  4237. local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}";
  4238. while (($#)); do
  4239. case "$1" in
  4240. -f | --final-ABI)
  4241. final_ABI="1"
  4242. ;;
  4243. -*)
  4244. die "${FUNCNAME}(): Unrecognized option '$1'"
  4245. ;;
  4246. *)
  4247. die "${FUNCNAME}(): Invalid usage"
  4248. ;;
  4249. esac;
  4250. shift;
  4251. done;
  4252. if [[ "${final_ABI}" == "1" ]]; then
  4253. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4254. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4255. fi;
  4256. PYTHON_ABI="$(PYTHON -f --ABI)";
  4257. else
  4258. if _python_package_supporting_installation_for_multiple_python_abis; then
  4259. if ! _python_abi-specific_local_scope; then
  4260. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4261. fi;
  4262. else
  4263. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4264. fi;
  4265. fi;
  4266. echo "$(_python_get_implementation "${PYTHON_ABI}")"
  4267. }
  4268. python_get_implementational_package ()
  4269. {
  4270. _python_check_python_pkg_setup_execution;
  4271. local final_ABI="0" PYTHON_ABI="${PYTHON_ABI}";
  4272. while (($#)); do
  4273. case "$1" in
  4274. -f | --final-ABI)
  4275. final_ABI="1"
  4276. ;;
  4277. -*)
  4278. die "${FUNCNAME}(): Unrecognized option '$1'"
  4279. ;;
  4280. *)
  4281. die "${FUNCNAME}(): Invalid usage"
  4282. ;;
  4283. esac;
  4284. shift;
  4285. done;
  4286. if [[ "${final_ABI}" == "1" ]]; then
  4287. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4288. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4289. fi;
  4290. PYTHON_ABI="$(PYTHON -f --ABI)";
  4291. else
  4292. if _python_package_supporting_installation_for_multiple_python_abis; then
  4293. if ! _python_abi-specific_local_scope; then
  4294. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4295. fi;
  4296. else
  4297. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4298. fi;
  4299. fi;
  4300. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  4301. echo "dev-lang/python:${PYTHON_ABI}";
  4302. else
  4303. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  4304. echo "dev-java/jython:${PYTHON_ABI%-jython}";
  4305. fi;
  4306. fi
  4307. }
  4308. python_get_includedir ()
  4309. {
  4310. _python_check_python_pkg_setup_execution;
  4311. local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}";
  4312. while (($#)); do
  4313. case "$1" in
  4314. -b | --base-path)
  4315. base_path="1"
  4316. ;;
  4317. -f | --final-ABI)
  4318. final_ABI="1"
  4319. ;;
  4320. -*)
  4321. die "${FUNCNAME}(): Unrecognized option '$1'"
  4322. ;;
  4323. *)
  4324. die "${FUNCNAME}(): Invalid usage"
  4325. ;;
  4326. esac;
  4327. shift;
  4328. done;
  4329. if [[ "${base_path}" == "0" ]]; then
  4330. prefix="/";
  4331. fi;
  4332. if [[ "${final_ABI}" == "1" ]]; then
  4333. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4334. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4335. fi;
  4336. PYTHON_ABI="$(PYTHON -f --ABI)";
  4337. else
  4338. if _python_package_supporting_installation_for_multiple_python_abis; then
  4339. if ! _python_abi-specific_local_scope; then
  4340. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4341. fi;
  4342. else
  4343. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4344. fi;
  4345. fi;
  4346. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  4347. echo "${prefix}usr/include/python${PYTHON_ABI}";
  4348. else
  4349. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  4350. echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Include";
  4351. fi;
  4352. fi
  4353. }
  4354. python_get_libdir ()
  4355. {
  4356. _python_check_python_pkg_setup_execution;
  4357. local base_path="0" final_ABI="0" prefix PYTHON_ABI="${PYTHON_ABI}";
  4358. while (($#)); do
  4359. case "$1" in
  4360. -b | --base-path)
  4361. base_path="1"
  4362. ;;
  4363. -f | --final-ABI)
  4364. final_ABI="1"
  4365. ;;
  4366. -*)
  4367. die "${FUNCNAME}(): Unrecognized option '$1'"
  4368. ;;
  4369. *)
  4370. die "${FUNCNAME}(): Invalid usage"
  4371. ;;
  4372. esac;
  4373. shift;
  4374. done;
  4375. if [[ "${base_path}" == "0" ]]; then
  4376. prefix="/";
  4377. fi;
  4378. if [[ "${final_ABI}" == "1" ]]; then
  4379. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4380. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4381. fi;
  4382. PYTHON_ABI="$(PYTHON -f --ABI)";
  4383. else
  4384. if _python_package_supporting_installation_for_multiple_python_abis; then
  4385. if ! _python_abi-specific_local_scope; then
  4386. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4387. fi;
  4388. else
  4389. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4390. fi;
  4391. fi;
  4392. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  4393. echo "${prefix}usr/$(get_libdir)/python${PYTHON_ABI}";
  4394. else
  4395. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  4396. echo "${prefix}usr/share/jython-${PYTHON_ABI%-jython}/Lib";
  4397. fi;
  4398. fi
  4399. }
  4400. python_get_library ()
  4401. {
  4402. _python_check_python_pkg_setup_execution;
  4403. local base_path="0" final_ABI="0" linker_option="0" prefix PYTHON_ABI="${PYTHON_ABI}";
  4404. while (($#)); do
  4405. case "$1" in
  4406. -b | --base-path)
  4407. base_path="1"
  4408. ;;
  4409. -f | --final-ABI)
  4410. final_ABI="1"
  4411. ;;
  4412. -l | --linker-option)
  4413. linker_option="1"
  4414. ;;
  4415. -*)
  4416. die "${FUNCNAME}(): Unrecognized option '$1'"
  4417. ;;
  4418. *)
  4419. die "${FUNCNAME}(): Invalid usage"
  4420. ;;
  4421. esac;
  4422. shift;
  4423. done;
  4424. if [[ "${base_path}" == "0" ]]; then
  4425. prefix="/";
  4426. fi;
  4427. if [[ "${base_path}" == "1" && "${linker_option}" == "1" ]]; then
  4428. die "${FUNCNAME}(): '--base-path' and '--linker-option' options cannot be specified simultaneously";
  4429. fi;
  4430. if [[ "${final_ABI}" == "1" ]]; then
  4431. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4432. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4433. fi;
  4434. PYTHON_ABI="$(PYTHON -f --ABI)";
  4435. else
  4436. if _python_package_supporting_installation_for_multiple_python_abis; then
  4437. if ! _python_abi-specific_local_scope; then
  4438. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4439. fi;
  4440. else
  4441. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4442. fi;
  4443. fi;
  4444. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  4445. if [[ "${linker_option}" == "1" ]]; then
  4446. echo "-lpython${PYTHON_ABI}";
  4447. else
  4448. echo "${prefix}usr/$(get_libdir)/libpython${PYTHON_ABI}$(get_libname)";
  4449. fi;
  4450. else
  4451. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  4452. die "${FUNCNAME}(): Jython does not have shared library";
  4453. fi;
  4454. fi
  4455. }
  4456. python_get_sitedir ()
  4457. {
  4458. _python_check_python_pkg_setup_execution;
  4459. local final_ABI="0" options=();
  4460. while (($#)); do
  4461. case "$1" in
  4462. -b | --base-path)
  4463. options+=("$1")
  4464. ;;
  4465. -f | --final-ABI)
  4466. final_ABI="1";
  4467. options+=("$1")
  4468. ;;
  4469. -*)
  4470. die "${FUNCNAME}(): Unrecognized option '$1'"
  4471. ;;
  4472. *)
  4473. die "${FUNCNAME}(): Invalid usage"
  4474. ;;
  4475. esac;
  4476. shift;
  4477. done;
  4478. if [[ "${final_ABI}" == "1" ]]; then
  4479. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4480. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4481. fi;
  4482. else
  4483. if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
  4484. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4485. fi;
  4486. fi;
  4487. echo "$(python_get_libdir "${options[@]}")/site-packages"
  4488. }
  4489. python_get_version ()
  4490. {
  4491. _python_check_python_pkg_setup_execution;
  4492. local final_ABI="0" full="0" major="0" minor="0" micro="0" python_command;
  4493. while (($#)); do
  4494. case "$1" in
  4495. -f | --final-ABI)
  4496. final_ABI="1"
  4497. ;;
  4498. --full)
  4499. full="1"
  4500. ;;
  4501. --major)
  4502. major="1"
  4503. ;;
  4504. --minor)
  4505. minor="1"
  4506. ;;
  4507. --micro)
  4508. micro="1"
  4509. ;;
  4510. -*)
  4511. die "${FUNCNAME}(): Unrecognized option '$1'"
  4512. ;;
  4513. *)
  4514. die "${FUNCNAME}(): Invalid usage"
  4515. ;;
  4516. esac;
  4517. shift;
  4518. done;
  4519. if [[ "$((${full} + ${major} + ${minor} + ${micro}))" -gt 1 ]]; then
  4520. die "${FUNCNAME}(): '--full', '--major', '--minor' or '--micro' options cannot be specified simultaneously";
  4521. fi;
  4522. if [[ "${full}" == "1" ]]; then
  4523. python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:3]))";
  4524. else
  4525. if [[ "${major}" == "1" ]]; then
  4526. python_command="from sys import version_info; print(version_info[0])";
  4527. else
  4528. if [[ "${minor}" == "1" ]]; then
  4529. python_command="from sys import version_info; print(version_info[1])";
  4530. else
  4531. if [[ "${micro}" == "1" ]]; then
  4532. python_command="from sys import version_info; print(version_info[2])";
  4533. else
  4534. if [[ -n "${PYTHON_ABI}" && "${final_ABI}" == "0" ]]; then
  4535. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "CPython" ]]; then
  4536. echo "${PYTHON_ABI}";
  4537. else
  4538. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" == "Jython" ]]; then
  4539. echo "${PYTHON_ABI%-jython}";
  4540. fi;
  4541. fi;
  4542. return;
  4543. fi;
  4544. python_command="from sys import version_info; print('.'.join(str(x) for x in version_info[:2]))";
  4545. fi;
  4546. fi;
  4547. fi;
  4548. fi;
  4549. if [[ "${final_ABI}" == "1" ]]; then
  4550. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4551. die "${FUNCNAME}(): '--final-ABI' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4552. fi;
  4553. "$(PYTHON -f)" -c "${python_command}";
  4554. else
  4555. if _python_package_supporting_installation_for_multiple_python_abis && ! _python_abi-specific_local_scope; then
  4556. die "${FUNCNAME}() should be used in ABI-specific local scope";
  4557. fi;
  4558. "$(PYTHON ${PYTHON_ABI})" -c "${python_command}";
  4559. fi
  4560. }
  4561. python_mod_cleanup ()
  4562. {
  4563. _python_check_python_pkg_setup_execution;
  4564. _python_initialize_prefix_variables;
  4565. local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir;
  4566. [[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase";
  4567. if _python_package_supporting_installation_for_multiple_python_abis; then
  4568. if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
  4569. die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called";
  4570. fi;
  4571. iterated_PYTHON_ABIS="${PYTHON_ABIS}";
  4572. else
  4573. if has "${EAPI:-0}" 0 1 2 3; then
  4574. iterated_PYTHON_ABIS="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4575. else
  4576. iterated_PYTHON_ABIS="${PYTHON_ABI}";
  4577. fi;
  4578. fi;
  4579. root="${EROOT%/}";
  4580. if [[ "$#" -gt 0 ]]; then
  4581. if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
  4582. while (($#)); do
  4583. if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
  4584. die "${FUNCNAME}(): Invalid argument '$1'";
  4585. else
  4586. if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
  4587. die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories";
  4588. else
  4589. if [[ "$1" =~ ^/ ]]; then
  4590. if _python_package_supporting_installation_for_multiple_python_abis; then
  4591. die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs";
  4592. fi;
  4593. search_paths+=("${root}$1");
  4594. else
  4595. for PYTHON_ABI in ${iterated_PYTHON_ABIS};
  4596. do
  4597. search_paths+=("${root}$(python_get_sitedir)/$1");
  4598. done;
  4599. fi;
  4600. fi;
  4601. fi;
  4602. shift;
  4603. done;
  4604. else
  4605. search_paths=("${@#/}");
  4606. search_paths=("${search_paths[@]/#/${root}/}");
  4607. fi;
  4608. else
  4609. ewarn;
  4610. ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be";
  4611. ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.";
  4612. ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported.";
  4613. ewarn;
  4614. for dir in "${root}"/usr/lib*;
  4615. do
  4616. if [[ -d "${dir}" && ! -L "${dir}" ]]; then
  4617. for sitedir in "${dir}"/python*/site-packages;
  4618. do
  4619. if [[ -d "${sitedir}" ]]; then
  4620. search_paths+=("${sitedir}");
  4621. fi;
  4622. done;
  4623. fi;
  4624. done;
  4625. for sitedir in "${root}"/usr/share/jython-*/Lib/site-packages;
  4626. do
  4627. if [[ -d "${sitedir}" ]]; then
  4628. search_paths+=("${sitedir}");
  4629. fi;
  4630. done;
  4631. fi;
  4632. _python_clean_compiled_modules "${search_paths[@]}"
  4633. }
  4634. python_mod_compile ()
  4635. {
  4636. if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
  4637. eerror "Use python_mod_optimize() instead of ${FUNCNAME}().";
  4638. die "${FUNCNAME}() cannot be used in this EAPI";
  4639. fi;
  4640. _python_initialize_prefix_variables;
  4641. _python_set_color_variables;
  4642. if [[ "${FUNCNAME[1]}" != "python_mod_optimize" ]]; then
  4643. ewarn;
  4644. ewarn "Deprecation Warning: ${FUNCNAME}() is deprecated and will be banned on 2010-09-01.";
  4645. ewarn "Use python_mod_optimize() instead of ${FUNCNAME}().";
  4646. ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported.";
  4647. ewarn;
  4648. fi;
  4649. local f myroot myfiles=();
  4650. [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase";
  4651. myroot="${EROOT%/}";
  4652. for f in "$@";
  4653. do
  4654. [[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}");
  4655. done;
  4656. PYTHON_ABI="$(PYTHON --ABI)";
  4657. if ((${#myfiles[@]})); then
  4658. "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}";
  4659. "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/py_compile.py" "${myfiles[@]}" &>/dev/null;
  4660. _python_clean_compiled_modules "${myfiles[@]}";
  4661. else
  4662. ewarn "No files to compile!";
  4663. fi
  4664. }
  4665. python_mod_exists ()
  4666. {
  4667. eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}().";
  4668. die "${FUNCNAME}() is banned"
  4669. }
  4670. python_mod_optimize ()
  4671. {
  4672. _python_check_python_pkg_setup_execution;
  4673. _python_initialize_prefix_variables;
  4674. [[ "${EBUILD_PHASE}" != "postinst" ]] && die "${FUNCNAME}() can be used only in pkg_postinst() phase";
  4675. if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
  4676. local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=();
  4677. if _python_package_supporting_installation_for_multiple_python_abis; then
  4678. if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
  4679. die "${FUNCNAME}(): python_pkg_setup() or python_execute_function() not called";
  4680. fi;
  4681. iterated_PYTHON_ABIS="${PYTHON_ABIS}";
  4682. else
  4683. if has "${EAPI:-0}" 0 1 2 3; then
  4684. iterated_PYTHON_ABIS="${PYTHON_ABI:=$(PYTHON --ABI)}";
  4685. else
  4686. iterated_PYTHON_ABIS="${PYTHON_ABI}";
  4687. fi;
  4688. fi;
  4689. root="${EROOT%/}";
  4690. while (($#)); do
  4691. case "$1" in
  4692. -l | -f | -q)
  4693. options+=("$1")
  4694. ;;
  4695. -d | -x)
  4696. options+=("$1" "$2");
  4697. shift
  4698. ;;
  4699. --)
  4700. shift;
  4701. break
  4702. ;;
  4703. -*)
  4704. die "${FUNCNAME}(): Unrecognized option '$1'"
  4705. ;;
  4706. *)
  4707. break
  4708. ;;
  4709. esac;
  4710. shift;
  4711. done;
  4712. if [[ "$#" -eq 0 ]]; then
  4713. ewarn;
  4714. ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be";
  4715. ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.";
  4716. ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported.";
  4717. ewarn;
  4718. fi;
  4719. while (($#)); do
  4720. if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
  4721. die "${FUNCNAME}(): Invalid argument '$1'";
  4722. else
  4723. if ! _python_implementation && [[ "$1" =~ ^/usr/lib(32|64)?/python[[:digit:]]+\.[[:digit:]]+ ]]; then
  4724. die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories";
  4725. else
  4726. if [[ "$1" =~ ^/ ]]; then
  4727. if _python_package_supporting_installation_for_multiple_python_abis; then
  4728. die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs";
  4729. fi;
  4730. if [[ -d "${root}$1" ]]; then
  4731. other_dirs+=("${root}$1");
  4732. else
  4733. if [[ -f "${root}$1" ]]; then
  4734. other_files+=("${root}$1");
  4735. else
  4736. if [[ -e "${root}$1" ]]; then
  4737. eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory";
  4738. else
  4739. eerror "${FUNCNAME}(): '${root}$1' does not exist";
  4740. fi;
  4741. fi;
  4742. fi;
  4743. else
  4744. for PYTHON_ABI in ${iterated_PYTHON_ABIS};
  4745. do
  4746. if [[ -d "${root}$(python_get_sitedir)/$1" ]]; then
  4747. site_packages_dirs+=("$1");
  4748. break;
  4749. else
  4750. if [[ -f "${root}$(python_get_sitedir)/$1" ]]; then
  4751. site_packages_files+=("$1");
  4752. break;
  4753. else
  4754. if [[ -e "${root}$(python_get_sitedir)/$1" ]]; then
  4755. eerror "${FUNCNAME}(): '$1' is not a regular file or a directory";
  4756. else
  4757. eerror "${FUNCNAME}(): '$1' does not exist";
  4758. fi;
  4759. fi;
  4760. fi;
  4761. done;
  4762. fi;
  4763. fi;
  4764. fi;
  4765. shift;
  4766. done;
  4767. options+=("-q");
  4768. for PYTHON_ABI in ${iterated_PYTHON_ABIS};
  4769. do
  4770. if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
  4771. return_code="0";
  4772. ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)";
  4773. if ((${#site_packages_dirs[@]})); then
  4774. for dir in "${site_packages_dirs[@]}";
  4775. do
  4776. site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}");
  4777. done;
  4778. "$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1";
  4779. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
  4780. "$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &>/dev/null || return_code="1";
  4781. fi;
  4782. _python_clean_compiled_modules "${site_packages_absolute_dirs[@]}";
  4783. fi;
  4784. if ((${#site_packages_files[@]})); then
  4785. for file in "${site_packages_files[@]}";
  4786. do
  4787. site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}");
  4788. done;
  4789. "$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1";
  4790. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
  4791. "$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &>/dev/null || return_code="1";
  4792. fi;
  4793. _python_clean_compiled_modules "${site_packages_absolute_files[@]}";
  4794. fi;
  4795. eend "${return_code}";
  4796. fi;
  4797. unset site_packages_absolute_dirs site_packages_absolute_files;
  4798. done;
  4799. if _python_package_supporting_installation_for_multiple_python_abis; then
  4800. if [[ -n "${previous_PYTHON_ABI}" ]]; then
  4801. PYTHON_ABI="${previous_PYTHON_ABI}";
  4802. else
  4803. unset PYTHON_ABI;
  4804. fi;
  4805. fi;
  4806. if ((${#other_dirs[@]})) || ((${#other_files[@]})); then
  4807. return_code="0";
  4808. ebegin "Compilation and optimization of Python modules placed outside of site-packages directories for $(python_get_implementation) $(python_get_version)";
  4809. if ((${#other_dirs[@]})); then
  4810. "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" || return_code="1";
  4811. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
  4812. "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${other_dirs[@]}" &>/dev/null || return_code="1";
  4813. fi;
  4814. _python_clean_compiled_modules "${other_dirs[@]}";
  4815. fi;
  4816. if ((${#other_files[@]})); then
  4817. "$(PYTHON ${PYTHON_ABI})" "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" || return_code="1";
  4818. if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
  4819. "$(PYTHON ${PYTHON_ABI})" -O "${root}$(python_get_libdir)/py_compile.py" "${other_files[@]}" &>/dev/null || return_code="1";
  4820. fi;
  4821. _python_clean_compiled_modules "${other_dirs[@]}";
  4822. fi;
  4823. eend "${return_code}";
  4824. fi;
  4825. else
  4826. local myroot mydirs=() myfiles=() myopts=() return_code="0";
  4827. myroot="${EROOT%/}";
  4828. while (($#)); do
  4829. case "$1" in
  4830. -l | -f | -q)
  4831. myopts+=("$1")
  4832. ;;
  4833. -d | -x)
  4834. myopts+=("$1" "$2");
  4835. shift
  4836. ;;
  4837. --)
  4838. shift;
  4839. break
  4840. ;;
  4841. -*)
  4842. die "${FUNCNAME}(): Unrecognized option '$1'"
  4843. ;;
  4844. *)
  4845. break
  4846. ;;
  4847. esac;
  4848. shift;
  4849. done;
  4850. if [[ "$#" -eq 0 ]]; then
  4851. ewarn;
  4852. ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be";
  4853. ewarn "disallowed on 2010-09-01. Call ${FUNCNAME}() with paths to Python modules.";
  4854. ewarn "The ebuild needs to be fixed. Please report a bug, if it has not been already reported.";
  4855. ewarn;
  4856. fi;
  4857. while (($#)); do
  4858. if [[ "$1" =~ ^($|(\.|\.\.|/)($|/)) ]]; then
  4859. die "${FUNCNAME}(): Invalid argument '$1'";
  4860. else
  4861. if [[ -d "${myroot}/${1#/}" ]]; then
  4862. mydirs+=("${myroot}/${1#/}");
  4863. else
  4864. if [[ -f "${myroot}/${1#/}" ]]; then
  4865. myfiles+=("$1");
  4866. else
  4867. if [[ -e "${myroot}/${1#/}" ]]; then
  4868. eerror "${FUNCNAME}(): ${myroot}/${1#/} is not a regular file or directory";
  4869. else
  4870. eerror "${FUNCNAME}(): ${myroot}/${1#/} does not exist";
  4871. fi;
  4872. fi;
  4873. fi;
  4874. fi;
  4875. shift;
  4876. done;
  4877. myopts+=(-q);
  4878. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4879. ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)";
  4880. if ((${#mydirs[@]})); then
  4881. "$(PYTHON ${PYTHON_ABI})" "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" || return_code="1";
  4882. "$(PYTHON ${PYTHON_ABI})" -O "${myroot}$(python_get_libdir)/compileall.py" "${myopts[@]}" "${mydirs[@]}" &>/dev/null || return_code="1";
  4883. _python_clean_compiled_modules "${mydirs[@]}";
  4884. fi;
  4885. if ((${#myfiles[@]})); then
  4886. python_mod_compile "${myfiles[@]}";
  4887. fi;
  4888. eend "${return_code}";
  4889. fi
  4890. }
  4891. python_need_rebuild ()
  4892. {
  4893. _python_check_python_pkg_setup_execution;
  4894. if _python_package_supporting_installation_for_multiple_python_abis; then
  4895. die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs";
  4896. fi;
  4897. if [[ "$#" -ne 0 ]]; then
  4898. die "${FUNCNAME}() does not accept arguments";
  4899. fi;
  4900. export PYTHON_NEED_REBUILD="$(PYTHON --ABI)"
  4901. }
  4902. python_pkg_setup ()
  4903. {
  4904. [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase";
  4905. if [[ "$#" -ne 0 ]]; then
  4906. die "${FUNCNAME}() does not accept arguments";
  4907. fi;
  4908. if _python_package_supporting_installation_for_multiple_python_abis; then
  4909. _python_calculate_PYTHON_ABIS;
  4910. export EPYTHON="$(PYTHON -f)";
  4911. else
  4912. PYTHON_ABI="${PYTHON_ABI:-$(PYTHON --ABI)}";
  4913. fi;
  4914. if ! has "${EAPI:-0}" 0 1 && [[ -n "${PYTHON_USE_WITH}" || -n "${PYTHON_USE_WITH_OR}" ]]; then
  4915. if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then
  4916. if [[ "${PYTHON_USE_WITH_OPT}" == !* ]]; then
  4917. use ${PYTHON_USE_WITH_OPT#!} && return;
  4918. else
  4919. use !${PYTHON_USE_WITH_OPT} && return;
  4920. fi;
  4921. fi;
  4922. function python_pkg_setup_check_USE_flags ()
  4923. {
  4924. local python_atom USE_flag;
  4925. python_atom="$(python_get_implementational_package)";
  4926. for USE_flag in ${PYTHON_USE_WITH};
  4927. do
  4928. if ! has_version "${python_atom}[${USE_flag}]"; then
  4929. eerror "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}";
  4930. die "Please rebuild ${python_atom} with the following USE flags enabled: ${PYTHON_USE_WITH}";
  4931. fi;
  4932. done;
  4933. for USE_flag in ${PYTHON_USE_WITH_OR};
  4934. do
  4935. if has_version "${python_atom}[${USE_flag}]"; then
  4936. return;
  4937. fi;
  4938. done;
  4939. if [[ -n ${PYTHON_USE_WITH_OR} ]]; then
  4940. eerror "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}";
  4941. die "Please rebuild ${python_atom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}";
  4942. fi
  4943. };
  4944. if _python_package_supporting_installation_for_multiple_python_abis; then
  4945. PYTHON_SKIP_SANITY_CHECKS="1" python_execute_function -q python_pkg_setup_check_USE_flags;
  4946. else
  4947. python_pkg_setup_check_USE_flags;
  4948. fi;
  4949. unset -f python_pkg_setup_check_USE_flags;
  4950. fi;
  4951. PYTHON_PKG_SETUP_EXECUTED="1"
  4952. }
  4953. python_set_active_version ()
  4954. {
  4955. [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase";
  4956. if _python_package_supporting_installation_for_multiple_python_abis; then
  4957. die "${FUNCNAME}() cannot be used in ebuilds of packages supporting installation for multiple Python ABIs";
  4958. fi;
  4959. if [[ "$#" -ne 1 ]]; then
  4960. die "${FUNCNAME}() requires 1 argument";
  4961. fi;
  4962. _python_initial_sanity_checks;
  4963. if [[ -z "${PYTHON_ABI}" ]]; then
  4964. if [[ "$1" =~ ^[[:digit:]]+\.[[:digit:]]+$ ]]; then
  4965. if ! _python_implementation && ! has_version "dev-lang/python:$1"; then
  4966. die "${FUNCNAME}(): 'dev-lang/python:$1' is not installed";
  4967. fi;
  4968. export EPYTHON="$(PYTHON "$1")";
  4969. else
  4970. if [[ "$1" == "2" ]]; then
  4971. if ! _python_implementation && ! has_version "=dev-lang/python-2*"; then
  4972. die "${FUNCNAME}(): '=dev-lang/python-2*' is not installed";
  4973. fi;
  4974. export EPYTHON="$(PYTHON -2)";
  4975. else
  4976. if [[ "$1" == "3" ]]; then
  4977. if ! _python_implementation && ! has_version "=dev-lang/python-3*"; then
  4978. die "${FUNCNAME}(): '=dev-lang/python-3*' is not installed";
  4979. fi;
  4980. export EPYTHON="$(PYTHON -3)";
  4981. else
  4982. die "${FUNCNAME}(): Unrecognized argument '$1'";
  4983. fi;
  4984. fi;
  4985. fi;
  4986. PYTHON_ABI="${EPYTHON#python}";
  4987. PYTHON_ABI="${PYTHON_ABI%%-*}";
  4988. fi;
  4989. _python_final_sanity_checks;
  4990. PYTHON_REQUESTED_ACTIVE_VERSION="$1"
  4991. }
  4992. python_src_compile ()
  4993. {
  4994. _python_check_python_pkg_setup_execution;
  4995. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  4996. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  4997. fi;
  4998. python_execute_function -d -s -- "$@"
  4999. }
  5000. python_src_configure ()
  5001. {
  5002. _python_check_python_pkg_setup_execution;
  5003. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  5004. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  5005. fi;
  5006. python_execute_function -d -s -- "$@"
  5007. }
  5008. python_src_install ()
  5009. {
  5010. _python_check_python_pkg_setup_execution;
  5011. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  5012. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  5013. fi;
  5014. python_execute_function -d -s -- "$@"
  5015. }
  5016. python_src_prepare ()
  5017. {
  5018. _python_check_python_pkg_setup_execution;
  5019. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  5020. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  5021. fi;
  5022. if [[ "$#" -ne 0 ]]; then
  5023. die "${FUNCNAME}() does not accept arguments";
  5024. fi;
  5025. python_copy_sources
  5026. }
  5027. python_src_test ()
  5028. {
  5029. _python_check_python_pkg_setup_execution;
  5030. if ! _python_package_supporting_installation_for_multiple_python_abis; then
  5031. die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs";
  5032. fi;
  5033. python_execute_function -d -s -- "$@"
  5034. }
  5035. python_tkinter_exists ()
  5036. {
  5037. eerror "Use PYTHON_USE_WITH=\"xml\" and python_pkg_setup() instead of ${FUNCNAME}().";
  5038. die "${FUNCNAME}() is banned"
  5039. }
  5040. python_version ()
  5041. {
  5042. eerror "Use PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.";
  5043. die "${FUNCNAME}() is banned"
  5044. }
  5045. register_success_hook ()
  5046. {
  5047. local x;
  5048. for x in $*;
  5049. do
  5050. hasq $x $EBUILD_SUCCESS_HOOKS || export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x";
  5051. done
  5052. }
  5053. seq ()
  5054. {
  5055. local p=$(type -P seq);
  5056. case $# in
  5057. 1)
  5058. min=1 max=$1 step=1
  5059. ;;
  5060. 2)
  5061. min=$1 max=$2 step=1
  5062. ;;
  5063. 3)
  5064. min=$1 max=$3 step=$2
  5065. ;;
  5066. *)
  5067. die "seq called with wrong number of arguments"
  5068. ;;
  5069. esac;
  5070. if [[ -z ${p} ]]; then
  5071. local reps;
  5072. if [[ ${step} != 0 ]]; then
  5073. reps=$(( ($max-$min) / $step +1 ));
  5074. else
  5075. reps=0;
  5076. fi;
  5077. jot $reps $min $max $step;
  5078. else
  5079. "${p}" $min $step $max;
  5080. fi
  5081. }
  5082. src_compile ()
  5083. {
  5084. gnome2_src_compile "$@"
  5085. }
  5086. src_configure ()
  5087. {
  5088. gnome2_src_configure "$@"
  5089. }
  5090. src_install ()
  5091. {
  5092. gnome2_src_install "$@"
  5093. }
  5094. src_prepare ()
  5095. {
  5096. gnome2_src_prepare;
  5097. sed -i 's/Exec=/Exec=gksu /' admin-tool/sabayon.desktop || die "gksu sed failed";
  5098. sed -i 's/Exec=/Exec=gksu /' admin-tool/sabayon.desktop.in || die "gksu sed failed";
  5099. sed "s:'\^\$\$lang\$\$':\^\$\$lang\$\$:g" -i po/Makefile.in.in || die "sed failed";
  5100. mv py-compile py-compile.orig;
  5101. ln -s $(type -P true) py-compile
  5102. }
  5103. src_test ()
  5104. {
  5105. _eapi0_src_test "$@"
  5106. }
  5107. src_unpack ()
  5108. {
  5109. gnome2_src_unpack "$@"
  5110. }
  5111. strip-linguas ()
  5112. {
  5113. local ls newls nols;
  5114. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  5115. local op=$1;
  5116. shift;
  5117. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  5118. shift;
  5119. local d f;
  5120. for d in "$@";
  5121. do
  5122. if [[ ${op} == "-u" ]]; then
  5123. newls=${ls};
  5124. else
  5125. newls="";
  5126. fi;
  5127. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  5128. do
  5129. if [[ ${op} == "-i" ]]; then
  5130. hasq ${f} ${ls} && newls="${newls} ${f}";
  5131. else
  5132. hasq ${f} ${ls} || newls="${newls} ${f}";
  5133. fi;
  5134. done;
  5135. ls=${newls};
  5136. done;
  5137. else
  5138. ls="$@";
  5139. fi;
  5140. nols="";
  5141. newls="";
  5142. for f in ${LINGUAS};
  5143. do
  5144. if hasq ${f} ${ls}; then
  5145. newls="${newls} ${f}";
  5146. else
  5147. nols="${nols} ${f}";
  5148. fi;
  5149. done;
  5150. [[ -n ${nols} ]] && ewarn "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  5151. export LINGUAS=${newls:1}
  5152. }
  5153. tc-arch ()
  5154. {
  5155. tc-ninja_magic_to_arch portage "$@"
  5156. }
  5157. tc-arch-kernel ()
  5158. {
  5159. tc-ninja_magic_to_arch kern "$@"
  5160. }
  5161. tc-endian ()
  5162. {
  5163. local host=$1;
  5164. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  5165. host=${host%%-*};
  5166. case ${host} in
  5167. alpha*)
  5168. echo big
  5169. ;;
  5170. arm*b*)
  5171. echo big
  5172. ;;
  5173. arm*)
  5174. echo little
  5175. ;;
  5176. cris*)
  5177. echo little
  5178. ;;
  5179. hppa*)
  5180. echo big
  5181. ;;
  5182. i?86*)
  5183. echo little
  5184. ;;
  5185. ia64*)
  5186. echo little
  5187. ;;
  5188. m68*)
  5189. echo big
  5190. ;;
  5191. mips*l*)
  5192. echo little
  5193. ;;
  5194. mips*)
  5195. echo big
  5196. ;;
  5197. powerpc*)
  5198. echo big
  5199. ;;
  5200. s390*)
  5201. echo big
  5202. ;;
  5203. sh*b*)
  5204. echo big
  5205. ;;
  5206. sh*)
  5207. echo little
  5208. ;;
  5209. sparc*)
  5210. echo big
  5211. ;;
  5212. x86_64*)
  5213. echo little
  5214. ;;
  5215. *)
  5216. echo wtf
  5217. ;;
  5218. esac
  5219. }
  5220. tc-export ()
  5221. {
  5222. local var;
  5223. for var in "$@";
  5224. do
  5225. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  5226. eval tc-get${var} > /dev/null;
  5227. done
  5228. }
  5229. tc-getAR ()
  5230. {
  5231. tc-getPROG AR ar "$@"
  5232. }
  5233. tc-getAS ()
  5234. {
  5235. tc-getPROG AS as "$@"
  5236. }
  5237. tc-getBUILD_CC ()
  5238. {
  5239. local v;
  5240. for v in CC_FOR_BUILD BUILD_CC HOSTCC;
  5241. do
  5242. if [[ -n ${!v} ]]; then
  5243. export BUILD_CC=${!v};
  5244. echo "${!v}";
  5245. return 0;
  5246. fi;
  5247. done;
  5248. local search=;
  5249. if [[ -n ${CBUILD} ]]; then
  5250. search=$(type -p ${CBUILD}-gcc);
  5251. search=${search##*/};
  5252. fi;
  5253. search=${search:-gcc};
  5254. export BUILD_CC=${search};
  5255. echo "${search}"
  5256. }
  5257. tc-getCC ()
  5258. {
  5259. tc-getPROG CC gcc "$@"
  5260. }
  5261. tc-getCPP ()
  5262. {
  5263. tc-getPROG CPP cpp "$@"
  5264. }
  5265. tc-getCXX ()
  5266. {
  5267. tc-getPROG CXX g++ "$@"
  5268. }
  5269. tc-getDLLWRAP ()
  5270. {
  5271. tc-getPROG DLLWRAP dllwrap "$@"
  5272. }
  5273. tc-getF77 ()
  5274. {
  5275. tc-getPROG F77 f77 "$@"
  5276. }
  5277. tc-getFC ()
  5278. {
  5279. tc-getPROG FC gfortran "$@"
  5280. }
  5281. tc-getGCJ ()
  5282. {
  5283. tc-getPROG GCJ gcj "$@"
  5284. }
  5285. tc-getLD ()
  5286. {
  5287. tc-getPROG LD ld "$@"
  5288. }
  5289. tc-getNM ()
  5290. {
  5291. tc-getPROG NM nm "$@"
  5292. }
  5293. tc-getOBJCOPY ()
  5294. {
  5295. tc-getPROG OBJCOPY objcopy "$@"
  5296. }
  5297. tc-getPKG_CONFIG ()
  5298. {
  5299. tc-getPROG PKG_CONFIG pkg-config "$@"
  5300. }
  5301. tc-getPROG ()
  5302. {
  5303. local var=$1;
  5304. local prog=$2;
  5305. if [[ -n ${!var} ]]; then
  5306. echo "${!var}";
  5307. return 0;
  5308. fi;
  5309. local search=;
  5310. [[ -n $3 ]] && search=$(type -p "$3-${prog}");
  5311. [[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}");
  5312. [[ -n ${search} ]] && prog=${search##*/};
  5313. export ${var}=${prog};
  5314. echo "${!var}"
  5315. }
  5316. tc-getRANLIB ()
  5317. {
  5318. tc-getPROG RANLIB ranlib "$@"
  5319. }
  5320. tc-getRC ()
  5321. {
  5322. tc-getPROG RC windres "$@"
  5323. }
  5324. tc-getSTRIP ()
  5325. {
  5326. tc-getPROG STRIP strip "$@"
  5327. }
  5328. tc-has-openmp ()
  5329. {
  5330. local base="${T}/test-tc-openmp";
  5331. cat > "${base}.c" <<-EOF
  5332. #include <omp.h>
  5333. int main() {
  5334. int nthreads, tid, ret = 0;
  5335. #pragma omp parallel private(nthreads, tid)
  5336. {
  5337. tid = omp_get_thread_num();
  5338. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  5339. }
  5340. return ret;
  5341. }
  5342. EOF
  5343.  
  5344. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  5345. local ret=$?;
  5346. rm -f "${base}"*;
  5347. return ${ret}
  5348. }
  5349. tc-has-tls ()
  5350. {
  5351. local base="${T}/test-tc-tls";
  5352. cat > "${base}.c" <<-EOF
  5353. int foo(int *i) {
  5354. static __thread int j = 0;
  5355. return *i ? j : *i;
  5356. }
  5357. EOF
  5358.  
  5359. local flags;
  5360. case $1 in
  5361. -s)
  5362. flags="-S"
  5363. ;;
  5364. -c)
  5365. flags="-c"
  5366. ;;
  5367. -l)
  5368.  
  5369. ;;
  5370. -*)
  5371. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  5372. ;;
  5373. esac;
  5374. : ${flags:=-fPIC -shared -Wl,-z,defs};
  5375. [[ $1 == -* ]] && shift;
  5376. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  5377. local ret=$?;
  5378. rm -f "${base}"*;
  5379. return ${ret}
  5380. }
  5381. tc-is-cross-compiler ()
  5382. {
  5383. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  5384. }
  5385. tc-is-hardfloat ()
  5386. {
  5387. [[ ${CTARGET//_/-} == *-hardfloat-* ]] && echo "yes" || echo "no"
  5388. }
  5389. tc-is-softfloat ()
  5390. {
  5391. case ${CTARGET} in
  5392. bfin* | h8300*)
  5393. echo "only"
  5394. ;;
  5395. *)
  5396. [[ ${CTARGET//_/-} == *-softfloat-* ]] && echo "yes" || echo "no"
  5397. ;;
  5398. esac
  5399. }
  5400. tc-is-static-only ()
  5401. {
  5402. local host=${CTARGET:-${CHOST}};
  5403. return $([[ ${host} == *-mint* ]])
  5404. }
  5405. tc-ninja_magic_to_arch ()
  5406. {
  5407. function ninj ()
  5408. {
  5409. [[ ${type} == "kern" ]] && echo $1 || echo $2
  5410. };
  5411. local type=$1;
  5412. local host=$2;
  5413. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  5414. case ${host} in
  5415. alpha*)
  5416. echo alpha
  5417. ;;
  5418. arm*)
  5419. echo arm
  5420. ;;
  5421. avr*)
  5422. ninj avr32 avr
  5423. ;;
  5424. bfin*)
  5425. ninj blackfin bfin
  5426. ;;
  5427. cris*)
  5428. echo cris
  5429. ;;
  5430. hppa*)
  5431. ninj parisc hppa
  5432. ;;
  5433. i?86*)
  5434. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  5435. echo i386;
  5436. else
  5437. echo x86;
  5438. fi
  5439. ;;
  5440. ia64*)
  5441. echo ia64
  5442. ;;
  5443. m68*)
  5444. echo m68k
  5445. ;;
  5446. mips*)
  5447. echo mips
  5448. ;;
  5449. nios2*)
  5450. echo nios2
  5451. ;;
  5452. nios*)
  5453. echo nios
  5454. ;;
  5455. powerpc*)
  5456. if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] && [[ ${type} == "kern" ]]; then
  5457. echo powerpc;
  5458. else
  5459. if [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] && [[ ${type} == "kern" ]]; then
  5460. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  5461. echo powerpc;
  5462. else
  5463. echo ppc;
  5464. fi;
  5465. else
  5466. if [[ ${host} == powerpc64* ]]; then
  5467. echo ppc64;
  5468. else
  5469. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  5470. ninj ppc64 ppc;
  5471. else
  5472. echo ppc;
  5473. fi;
  5474. fi;
  5475. fi;
  5476. fi
  5477. ;;
  5478. s390*)
  5479. echo s390
  5480. ;;
  5481. sh64*)
  5482. ninj sh64 sh
  5483. ;;
  5484. sh*)
  5485. echo sh
  5486. ;;
  5487. sparc64*)
  5488. ninj sparc64 sparc
  5489. ;;
  5490. sparc*)
  5491. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  5492. ;;
  5493. vax*)
  5494. echo vax
  5495. ;;
  5496. x86_64*)
  5497. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  5498. echo x86;
  5499. else
  5500. ninj x86_64 amd64;
  5501. fi
  5502. ;;
  5503. *)
  5504. echo unknown
  5505. ;;
  5506. esac
  5507. }
  5508. treecopy ()
  5509. {
  5510. dest=${!#};
  5511. files_count=$#;
  5512. while (( $# > 1 )); do
  5513. dirstruct=$(dirname "$1");
  5514. mkdir -p "${dest}/${dirstruct}";
  5515. cp -pPR "$1" "${dest}/${dirstruct}";
  5516. shift;
  5517. done
  5518. }
  5519. uclibctoolize ()
  5520. {
  5521. ewarn "uclibctoolize() is deprecated, please just use elibtoolize()!";
  5522. elibtoolize
  5523. }
  5524. unpack_makeself ()
  5525. {
  5526. local src_input=${1:-${A}};
  5527. local src=$(find_unpackable_file "${src_input}");
  5528. local skip=$2;
  5529. local exe=$3;
  5530. [[ -z ${src} ]] && die "Could not locate source for '${src_input}'";
  5531. local shrtsrc=$(basename "${src}");
  5532. echo ">>> Unpacking ${shrtsrc} to ${PWD}";
  5533. if [[ -z ${skip} ]]; then
  5534. local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}');
  5535. local skip=0;
  5536. exe=tail;
  5537. case ${ver} in
  5538. 1.5.* | 1.6.0-nv)
  5539. skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
  5540. ;;
  5541. 2.0 | 2.0.1)
  5542. skip=$(grep -a ^' 'tail "${src}" | awk '{print $2}' | cut -b2-)
  5543. ;;
  5544. 2.1.1)
  5545. skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-);
  5546. (( skip++ ))
  5547. ;;
  5548. 2.1.2)
  5549. skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1);
  5550. (( skip++ ))
  5551. ;;
  5552. 2.1.3)
  5553. skip=`grep -a ^offset= "${src}" | awk '{print $3}'`;
  5554. (( skip++ ))
  5555. ;;
  5556. 2.1.4 | 2.1.5)
  5557. skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1);
  5558. skip=$(head -n ${skip} "${src}" | wc -c);
  5559. exe="dd"
  5560. ;;
  5561. *)
  5562. eerror "I'm sorry, but I was unable to support the Makeself file.";
  5563. eerror "The version I detected was '${ver}'.";
  5564. eerror "Please file a bug about the file ${shrtsrc} at";
  5565. eerror "http://bugs.gentoo.org/ so that support can be added.";
  5566. die "makeself version '${ver}' not supported"
  5567. ;;
  5568. esac;
  5569. debug-print "Detected Makeself version ${ver} ... using ${skip} as offset";
  5570. fi;
  5571. case ${exe} in
  5572. tail)
  5573. exe="tail -n +${skip} '${src}'"
  5574. ;;
  5575. dd)
  5576. exe="dd ibs=${skip} skip=1 if='${src}'"
  5577. ;;
  5578. *)
  5579. die "makeself cant handle exe '${exe}'"
  5580. ;;
  5581. esac;
  5582. local tmpfile=$(emktemp);
  5583. eval ${exe} 2> /dev/null | head -c 512 > "${tmpfile}";
  5584. local filetype=$(file -b "${tmpfile}");
  5585. case ${filetype} in
  5586. *tar\ archive*)
  5587. eval ${exe} | tar --no-same-owner -xf -
  5588. ;;
  5589. bzip2*)
  5590. eval ${exe} | bzip2 -dc | tar --no-same-owner -xf -
  5591. ;;
  5592. gzip*)
  5593. eval ${exe} | tar --no-same-owner -xzf -
  5594. ;;
  5595. compress*)
  5596. eval ${exe} | gunzip | tar --no-same-owner -xf -
  5597. ;;
  5598. *)
  5599. eerror "Unknown filetype \"${filetype}\" ?";
  5600. false
  5601. ;;
  5602. esac;
  5603. assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
  5604. }
  5605. unpack_pdv ()
  5606. {
  5607. local src=$(find_unpackable_file "$1");
  5608. local sizeoff_t=$2;
  5609. [[ -z ${src} ]] && die "Could not locate source for '$1'";
  5610. [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(";
  5611. local shrtsrc=$(basename "${src}");
  5612. echo ">>> Unpacking ${shrtsrc} to ${PWD}";
  5613. local metaskip=$(tail -c ${sizeoff_t} "${src}" | hexdump -e \"%i\");
  5614. local tailskip=$(tail -c $((${sizeoff_t}*2)) "${src}" | head -c ${sizeoff_t} | hexdump -e \"%i\");
  5615. local metafile=$(emktemp);
  5616. tail -c +$((${metaskip}+1)) "${src}" > "${metafile}";
  5617. local datafile=$(tail -c +$((${metaskip}+1)) "${src}" | strings | head -n 1);
  5618. datafile=$(basename "${datafile}");
  5619. local tmpfile=$(emktemp);
  5620. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c 512 > ${tmpfile};
  5621. local iscompressed=$(file -b "${tmpfile}");
  5622. if [[ ${iscompressed:0:8} == "compress" ]]; then
  5623. iscompressed=1;
  5624. mv ${tmpfile}{,.Z};
  5625. gunzip ${tmpfile};
  5626. else
  5627. iscompressed=0;
  5628. fi;
  5629. local istar=$(file -b "${tmpfile}");
  5630. if [[ ${istar:0:9} == "POSIX tar" ]]; then
  5631. istar=1;
  5632. else
  5633. istar=0;
  5634. fi;
  5635. if [ ${iscompressed} -eq 1 ]; then
  5636. if [ ${istar} -eq 1 ]; then
  5637. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar -xzf -;
  5638. else
  5639. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | gzip -dc > ${datafile};
  5640. fi;
  5641. else
  5642. if [ ${istar} -eq 1 ]; then
  5643. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar --no-same-owner -xf -;
  5644. else
  5645. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) > ${datafile};
  5646. fi;
  5647. fi;
  5648. true
  5649. }
  5650. validate_desktop_entries ()
  5651. {
  5652. if [[ -x /usr/bin/desktop-file-validate ]]; then
  5653. einfo "Checking desktop entry validity";
  5654. local directories="";
  5655. for d in /usr/share/applications $@;
  5656. do
  5657. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  5658. done;
  5659. if [[ -n ${directories} ]]; then
  5660. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  5661. do
  5662. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  5663. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  5664. done;
  5665. fi;
  5666. echo "";
  5667. else
  5668. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  5669. fi
  5670. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement