Advertisement
Guest User

environment

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