Advertisement
sskeleton

Untitled

Oct 24th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 112.59 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 ANT_HOME="/usr/share/ant"
  5. declare -x APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
  6. declare -x ARCH="amd64"
  7. declare -- BASE_EXPF="src_unpack src_compile src_install src_prepare src_configure"
  8. declare -x BOOTSTRAP_USE="cxx unicode multilib"
  9. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump"
  10. declare -x CAMERAS="ptp2"
  11. declare -x CBUILD="x86_64-pc-linux-gnu"
  12. declare -x CFLAGS="-O3 -march=corei7-avx -pipe"
  13. declare -x CFLAGS_amd64="-m64"
  14. declare -x CFLAGS_default
  15. declare -x CFLAGS_x32="-mx32"
  16. declare -x CFLAGS_x86="-m32"
  17. declare -x CHOST="x86_64-pc-linux-gnu"
  18. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  19. declare -x CHOST_default="x86_64-pc-linux-gnu"
  20. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  21. declare -x CHOST_x86="i686-pc-linux-gnu"
  22. declare -- CMAKE_BINARY="cmake"
  23. declare -- CMAKE_BUILD_DIR="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/work/cairo-dock-2.2.0.4_build"
  24. declare -- CMAKE_BUILD_TYPE="Gentoo"
  25. declare -- CMAKE_EXPF="src_compile src_test src_install src_configure"
  26. declare -- CMAKE_MAKEFILE_GENERATOR="make"
  27. declare -- CMAKE_MIN_VERSION="2.8.4"
  28. declare -- CMAKE_REMOVE_MODULES="yes"
  29. declare -- CMAKE_REMOVE_MODULES_LIST="FindBLAS FindLAPACK"
  30. declare -- CMAKE_USE_DIR="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/work/cairo-dock-2.2.0-4"
  31. declare -- CMAKE_VERBOSE="ON"
  32. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  33. declare -x COLORFGBG="15;0"
  34. declare -x CPPFLAGS=" -DNDEBUG"
  35. declare -x CROSSCOMPILE_OPTS=""
  36. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  37. declare -x CXXFLAGS="-O3 -march=corei7-avx -pipe"
  38. declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-oNwzUboNRY,guid=c5dcc526350fdd049bd7605c5088835d"
  39. declare -x DBUS_SESSION_BUS_PID="16616"
  40. declare -x DBUS_SESSION_BUS_WINDOWID="85983233"
  41. declare -x DEFAULT_ABI="amd64"
  42. declare -x DEFINED_PHASES=" compile configure install postinst prepare test unpack"
  43. declare DEPEND="
  44. dev-libs/dbus-glib
  45. dev-libs/glib:2
  46. dev-libs/libxml2
  47. gnome-base/librsvg
  48. sys-apps/dbus
  49. x11-libs/cairo
  50. x11-libs/gtk+:2
  51. x11-libs/gtkglext
  52. x11-libs/libXrender
  53. xcomposite? (
  54. x11-libs/libXcomposite
  55. x11-libs/libXinerama
  56. x11-libs/libXtst
  57. )
  58.  
  59. dev-util/intltool
  60. dev-util/pkgconfig
  61. sys-devel/gettext
  62. >=dev-util/cmake-2.8.4 userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
  63. declare DESCRIPTION="Cairo-dock is a fast, responsive, Mac OS X-like dock."
  64. declare -x DESKTOP_SESSION="default"
  65. declare -x DESTTREE="/usr"
  66. declare -x DIROPTIONS="-m0755"
  67. declare -x DM_CONTROL="/var/run/xdmctl"
  68. declare -x EAPI="2"
  69. declare -x ELIBC="glibc"
  70. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  71. declare -- EPATCH_EXCLUDE=""
  72. declare -- EPATCH_FORCE="no"
  73. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  74. declare -- EPATCH_OPTS=""
  75. declare -- EPATCH_SINGLE_MSG=""
  76. declare -- EPATCH_SOURCE="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/work/patch"
  77. declare -- EPATCH_SUFFIX="patch.bz2"
  78. declare -- EPREFIX=""
  79. declare -x EXEOPTIONS="-m0755"
  80. declare -x FCFLAGS="-O2 -pipe"
  81. 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}\""
  82. declare -x FFLAGS="-O2 -pipe"
  83. declare -x GCC_SPECS=""
  84. declare -x GDK_USE_XFT="1"
  85. 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"
  86. declare -x GRUB_PLATFORMS=""
  87. declare -x GSETTINGS_BACKEND="gconf"
  88. declare -x GS_LIB="/home/sskel/.fonts"
  89. declare -x GTK2_RC_FILES="/etc/gtk-2.0/gtkrc:/home/sskel/.gtkrc-2.0:/home/sskel/.kde4/share/config/gtkrc-2.0"
  90. declare -x GTK_RC_FILES="/etc/gtk/gtkrc:/home/sskel/.gtkrc:/home/sskel/.kde4/share/config/gtkrc"
  91. declare -x GUILE_LOAD_PATH="/usr/share/guile/1.8"
  92. declare HOMEPAGE="https://launchpad.net/cairo-dock-core/"
  93. declare -x INHERITED=" toolchain-funcs multilib user eutils flag-o-matic base cmake-utils versionator"
  94. declare -x INPUT_DEVICES="evdev"
  95. declare -x INSDESTTREE=""
  96. declare -x INSOPTIONS="-m0644"
  97. declare IUSE="xcomposite "
  98. declare -x IUSE_IMPLICIT="prefix"
  99. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  100. declare -x JAVACC_HOME="/usr/share/javacc/"
  101. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  102. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  103. declare -x KDE_FULL_SESSION="true"
  104. declare -x KDE_MULTIHEAD="false"
  105. declare -x KDE_SESSION_UID="1000"
  106. declare -x KDE_SESSION_VERSION="4"
  107. declare -x KERNEL="linux"
  108. declare -x KERNEL_ABI="amd64"
  109. declare -x KEYWORDS="~amd64"
  110. declare -x KONSOLE_DBUS_SERVICE=":1.67"
  111. declare -x KONSOLE_DBUS_SESSION="/Sessions/1"
  112. declare -x KONSOLE_DBUS_WINDOW="/Windows/1"
  113. declare -x KONSOLE_PROFILE_NAME="Shell"
  114. declare -x KV="3.6.1-gentoo"
  115. declare -x LANG="pl_PL.utf8"
  116. declare -x LANGUAGE=""
  117. declare -x LCD_DEVICES=""
  118. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  119. declare -x LDFLAGS_amd64="-m elf_x86_64"
  120. declare -x LDFLAGS_default
  121. declare -x LDFLAGS_x32="-m elf32_x86_64"
  122. declare -x LDFLAGS_x86="-m elf_i386"
  123. declare -x LIBDIR_amd64="lib64"
  124. declare -x LIBDIR_amd64_fbsd="lib64"
  125. declare -x LIBDIR_default="lib"
  126. declare -x LIBDIR_n32="lib32"
  127. declare -x LIBDIR_n64="lib64"
  128. declare -x LIBDIR_o32="lib"
  129. declare -x LIBDIR_ppc="lib32"
  130. declare -x LIBDIR_ppc64="lib64"
  131. declare -x LIBDIR_s390="lib32"
  132. declare -x LIBDIR_s390x="lib64"
  133. declare -x LIBDIR_sparc32="lib32"
  134. declare -x LIBDIR_sparc64="lib64"
  135. declare -x LIBDIR_x32="libx32"
  136. declare -x LIBDIR_x86="lib32"
  137. declare -x LIBDIR_x86_fbsd="lib32"
  138. declare -x LIBOPTIONS="-m0644"
  139. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  140. declare -x LICENSE="GPL-2"
  141. declare -x LINGUAS="en_US pl"
  142. declare -x MAKEOPTS="-j9"
  143. declare -x MEDIAUSE="aac alsa ape ffmpeg flac gif jpeg jpeg2k lame mad matroska mp3 mp4 nsplugin ogg pdf png real vlc wavpack win32codecs x264 xvid"
  144. declare -- MMD_PV="2.2.0"
  145. declare -- MM_PV="2.2"
  146. declare -x MULTILIB_ABIS="amd64 x86"
  147. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  148. 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"
  149. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  150. declare -- MY_PN="cairo-dock-core"
  151. declare -- MY_PV="2.2.0-4"
  152. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  153. declare -x NOTUSE="-bluetooth -gnome -ieee1394 -ipod -irda -pulseaudio"
  154. declare -x OPENCL_PROFILE="nvidia"
  155. declare -x OPENGL_PROFILE="nvidia"
  156. declare -x OTHERUSE="bash-completion exif gadu gcrypt hddtemp jack joystick lua lua-cairo spell"
  157. 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.6.3"
  158. declare PDEPEND=""
  159. declare -x PHP_TARGETS=""
  160. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  161. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  162. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/cairo-dock-2.2.0.4/html")'
  163. declare -- PREFIX="/usr"
  164. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so"
  165. declare -x PROFILEHOME=""
  166. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  167. declare -x PROPERTIES=""
  168. declare -x PROVIDE=""
  169. declare -x PYTHONDONTWRITEBYTECODE="1"
  170. declare -x PYTHON_TARGETS=""
  171. declare -x QT_GRAPHICSSYSTEM="raster"
  172. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins:/home/sskel/.kde4/lib64/kde4/plugins/:/usr/lib64/kde4/plugins/"
  173. declare -x RDEPEND="
  174. dev-libs/dbus-glib
  175. dev-libs/glib:2
  176. dev-libs/libxml2
  177. gnome-base/librsvg
  178. sys-apps/dbus
  179. x11-libs/cairo
  180. x11-libs/gtk+:2
  181. x11-libs/gtkglext
  182. x11-libs/libXrender
  183. xcomposite? (
  184. x11-libs/libXcomposite
  185. x11-libs/libXinerama
  186. x11-libs/libXtst
  187. )
  188. "
  189. declare REPOSITORY
  190. declare REQUIRED_USE=""
  191. declare -x RESTRICT=""
  192. 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}\""
  193. declare -x RUBY_TARGETS="ruby18 ruby19"
  194. declare -x R_HOME="/usr/lib64/R"
  195. declare -x S="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/work/cairo-dock-2.2.0-4"
  196. declare -x SANDBOX_DEBUG="0"
  197. declare -x SANDBOX_DENY=""
  198. declare -x SANDBOX_PID="16848"
  199. declare -x SANDBOX_PREDICT="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/homedir:/dev/crypto:/var/cache/fontconfig"
  200. declare -x SANDBOX_READ="/:/var/tmp"
  201. declare -x SANDBOX_VERBOSE="1"
  202. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/lib/cf:/usr/lib/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/homedir/.bash_history"
  203. declare -x SESSION_MANAGER="local/Gentoo:@/tmp/.ICE-unix/2195,unix/Gentoo:/tmp/.ICE-unix/2195"
  204. declare -x SHELL_SESSION_ID="0912edf8b1164000950f55ec7038c48a"
  205. declare -x SLOT="0"
  206. declare SRC_URI="http://launchpad.net/cairo-dock-core/2.2/2.2.0/+download/cairo-dock-2.2.0-4.tar.gz"
  207. declare -x SYMLINK_LIB="yes"
  208. declare -x SYSTEMUSE="apm consolekit cxx dbus device-mapper fam hal ipv6 java lto mmx policykit python sasl sse sse2 ssl syslog threads udev udisks usb wifi wireless"
  209. declare -x USE="amd64 consolekit elibc_glibc kernel_linux multilib policykit userland_GNU xcomposite"
  210. declare -x USERLAND="GNU"
  211. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  212. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  213. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
  214. declare -x USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib NetBSD OpenBSD SunOS uclibc Winnt"
  215. declare -x USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
  216. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  217. declare -x VIDEO_CARDS=""
  218. declare -- WANT_CMAKE="always"
  219. declare -x WINDOWID="79691803"
  220. declare -x WINDOWPATH="7"
  221. declare -x XCURSOR_SIZE="0"
  222. declare -x XCURSOR_THEME="Oxygen_Black"
  223. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  224. declare -x XDG_CONFIG_HOME="/var/tmp/portage/x11-misc/cairo-dock-2.2.0.4/temp"
  225. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  226. declare -x XDG_SESSION_COOKIE="e7c12495ff595e15accc11cf5074def5-1351120974.470205-1559500479"
  227. declare -x XDM_MANAGED="method=classic"
  228. 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"
  229. declare -x XUSE="branding libnotify fuse g3dvl gtk gtk3 kde kde4 nvidia opengl plasma qt4 truetype unsupported X xcomposite xinerama xorg xv xvmc"
  230. declare -x _E_DOCDESTTREE_=""
  231. declare -x _E_EXEDESTTREE_=""
  232. declare -- ___ECLASS_ONCE_BASE="recur -_+^+_- spank"
  233. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  234. declare -- ___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
  235. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  236. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  237. declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
  238. declare -- ___ECLASS_ONCE_VERSIONATOR="recur -_+^+_- spank"
  239. declare -- phase_func
  240. _assert_pkg_ebuild_phase ()
  241. {
  242. case ${EBUILD_PHASE} in
  243. setup | preinst | postinst)
  244.  
  245. ;;
  246. *)
  247. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  248. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  249. eerror "Package fails at QA and at life. Please file a bug.";
  250. die "Bad package! $1 is only for use in some pkg_* functions!"
  251. ;;
  252. esac
  253. }
  254. _check_build_dir ()
  255. {
  256. : ${CMAKE_USE_DIR:=${S}};
  257. if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
  258. CMAKE_BUILD_DIR="${CMAKE_USE_DIR}";
  259. else
  260. : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build};
  261. fi;
  262. mkdir -p "${CMAKE_BUILD_DIR}";
  263. echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
  264. }
  265. _epatch_draw_line ()
  266. {
  267. [[ -z $1 ]] && set "$(printf "%65s" '')";
  268. echo "${1//?/=}"
  269. }
  270. _execute_optionaly ()
  271. {
  272. local phase="$1";
  273. shift;
  274. if [[ ${WANT_CMAKE} = always ]]; then
  275. enable_cmake-utils_${phase} "$@";
  276. else
  277. use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@";
  278. fi
  279. }
  280. _filter-hardened ()
  281. {
  282. local f;
  283. for f in "$@";
  284. do
  285. case "${f}" in
  286. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  287. gcc-specs-pie || continue;
  288. is-flagq -nopie || append-flags -nopie
  289. ;;
  290. -fstack-protector)
  291. gcc-specs-ssp || continue;
  292. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  293. ;;
  294. -fstack-protector-all)
  295. gcc-specs-ssp-to-all || continue;
  296. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  297. ;;
  298. -fno-strict-overflow)
  299. gcc-specs-nostrict || continue;
  300. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  301. ;;
  302. esac;
  303. done
  304. }
  305. _filter-var ()
  306. {
  307. local f x var=$1 new=();
  308. shift;
  309. for f in ${!var};
  310. do
  311. for x in "$@";
  312. do
  313. [[ ${f} == ${x} ]] && continue 2;
  314. done;
  315. new+=("${f}");
  316. done;
  317. eval export ${var}=\""${new[*]}"\"
  318. }
  319. _gcc-install-dir ()
  320. {
  321. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  322. }
  323. _gcc-specs-directive_raw ()
  324. {
  325. local cc=$(tc-getCC);
  326. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  327. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  328. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  329. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  330. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  331. { spec=spec $0 }
  332. END { print spec }';
  333. return 0
  334. }
  335. _gcc-specs-exists ()
  336. {
  337. [[ -f $(_gcc-install-dir)/$1 ]]
  338. }
  339. _gcc_fullversion ()
  340. {
  341. local ver="$1";
  342. shift;
  343. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  344. eval echo "$ver"
  345. }
  346. _generator_to_use ()
  347. {
  348. if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then
  349. has_version dev-util/ninja && echo "Ninja" && return;
  350. fi;
  351. echo "Unix Makefiles"
  352. }
  353. _iconins ()
  354. {
  355. ( local funcname=$1;
  356. shift;
  357. local size dir;
  358. local context=apps;
  359. local theme=hicolor;
  360. while [[ $# -gt 0 ]]; do
  361. case $1 in
  362. -s | --size)
  363. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  364. size=${2%%x*};
  365. else
  366. size=${2};
  367. fi;
  368. case ${size} in
  369. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
  370. size=${size}x${size}
  371. ;;
  372. scalable)
  373.  
  374. ;;
  375. *)
  376. eerror "${size} is an unsupported icon size!";
  377. exit 1
  378. ;;
  379. esac;
  380. shift 2
  381. ;;
  382. -t | --theme)
  383. theme=${2};
  384. shift 2
  385. ;;
  386. -c | --context)
  387. context=${2};
  388. shift 2
  389. ;;
  390. *)
  391. if [[ -z ${size} ]]; then
  392. insinto /usr/share/pixmaps;
  393. else
  394. insinto /usr/share/icons/${theme}/${size}/${context};
  395. fi;
  396. if [[ ${funcname} == doicon ]]; then
  397. if [[ -f $1 ]]; then
  398. doins "${1}";
  399. else
  400. if [[ -d $1 ]]; then
  401. shopt -s nullglob;
  402. doins "${1}"/*.{png,svg};
  403. shopt -u nullglob;
  404. else
  405. eerror "${1} is not a valid file/directory!";
  406. exit 1;
  407. fi;
  408. fi;
  409. else
  410. break;
  411. fi;
  412. shift 1
  413. ;;
  414. esac;
  415. done;
  416. if [[ ${funcname} == newicon ]]; then
  417. newins "$@";
  418. fi ) || die
  419. }
  420. _is_flagq ()
  421. {
  422. local x;
  423. for x in ${!1};
  424. do
  425. [[ ${x} == $2 ]] && return 0;
  426. done;
  427. return 1
  428. }
  429. _modify-cmakelists ()
  430. {
  431. debug-print-function ${FUNCNAME} "$@";
  432. grep -qs "<<< Gentoo configuration >>>" CMakeLists.txt && return 0;
  433. find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + || die "${LINENO}: failed to disable hardcoded settings";
  434. cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<-_EOF_
  435.  
  436. MESSAGE(STATUS "<<< Gentoo configuration >>>
  437. Build type \${CMAKE_BUILD_TYPE}
  438. Install path \${CMAKE_INSTALL_PREFIX}
  439. Compiler flags:
  440. C \${CMAKE_C_FLAGS}
  441. C++ \${CMAKE_CXX_FLAGS}
  442. Linker flags:
  443. Executable \${CMAKE_EXE_LINKER_FLAGS}
  444. Module \${CMAKE_MODULE_LINKER_FLAGS}
  445. Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
  446. _EOF_
  447.  
  448. }
  449. _tc-getPROG ()
  450. {
  451. local tuple=$1;
  452. local v var vars=$2;
  453. local prog=$3;
  454. var=${vars%% *};
  455. for v in ${vars};
  456. do
  457. if [[ -n ${!v} ]]; then
  458. export ${var}="${!v}";
  459. echo "${!v}";
  460. return 0;
  461. fi;
  462. done;
  463. local search=;
  464. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  465. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  466. [[ -n ${search} ]] && prog=${search##*/};
  467. export ${var}=${prog};
  468. echo "${!var}"
  469. }
  470. _use_me_now ()
  471. {
  472. debug-print-function ${FUNCNAME} "$@";
  473. local uper capitalised x;
  474. [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  475. if [[ ! -z $3 ]]; then
  476. echo "-D$1$3=$(use $2 && echo ON || echo OFF)";
  477. else
  478. uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  479. capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  480. for x in $2 $uper $capitalised;
  481. do
  482. echo "-D$1$x=$(use $2 && echo ON || echo OFF) ";
  483. done;
  484. fi
  485. }
  486. _use_me_now_inverted ()
  487. {
  488. debug-print-function ${FUNCNAME} "$@";
  489. local uper capitalised x;
  490. [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]";
  491. if [[ ! -z $3 ]]; then
  492. echo "-D$1$3=$(use $2 && echo OFF || echo ON)";
  493. else
  494. uper=$(echo ${2} | tr '[:lower:]' '[:upper:]');
  495. capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g');
  496. for x in $2 $uper $capitalised;
  497. do
  498. echo "-D$1$x=$(use $2 && echo OFF || echo ON) ";
  499. done;
  500. fi
  501. }
  502. all-flag-vars ()
  503. {
  504. echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  505. }
  506. append-cflags ()
  507. {
  508. [[ $# -eq 0 ]] && return 0;
  509. export CFLAGS=$(test-flags-CC ${CFLAGS} "$@");
  510. return 0
  511. }
  512. append-cppflags ()
  513. {
  514. [[ $# -eq 0 ]] && return 0;
  515. export CPPFLAGS="${CPPFLAGS} $*";
  516. return 0
  517. }
  518. append-cxxflags ()
  519. {
  520. [[ $# -eq 0 ]] && return 0;
  521. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS} "$@");
  522. return 0
  523. }
  524. append-fflags ()
  525. {
  526. [[ $# -eq 0 ]] && return 0;
  527. export FFLAGS=$(test-flags-F77 ${FFLAGS} "$@");
  528. export FCFLAGS=$(test-flags-FC ${FCFLAGS} "$@");
  529. return 0
  530. }
  531. append-flags ()
  532. {
  533. [[ $# -eq 0 ]] && return 0;
  534. case " $* " in
  535. *' '-[DIU]*)
  536. eqawarn 'please use append-cppflags for preprocessor flags'
  537. ;;
  538. *' '-L* | *' '-Wl,*)
  539. eqawarn 'please use append-ldflags for linker flags'
  540. ;;
  541. esac;
  542. append-cflags "$@";
  543. append-cxxflags "$@";
  544. append-fflags "$@";
  545. return 0
  546. }
  547. append-ldflags ()
  548. {
  549. [[ $# -eq 0 ]] && return 0;
  550. local flag;
  551. for flag in "$@";
  552. do
  553. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  554. done;
  555. export LDFLAGS="${LDFLAGS} $*";
  556. return 0
  557. }
  558. append-lfs-flags ()
  559. {
  560. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  561. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  562. }
  563. append-libs ()
  564. {
  565. [[ $# -eq 0 ]] && return 0;
  566. local flag;
  567. for flag in "$@";
  568. do
  569. [[ ${flag} == -l* ]] && flag=${flag#-l};
  570. export LIBS="${LIBS} -l${flag}";
  571. done;
  572. return 0
  573. }
  574. base_src_compile ()
  575. {
  576. debug-print-function $FUNCNAME "$@";
  577. has src_configure ${BASE_EXPF} || base_src_configure;
  578. base_src_make "$@"
  579. }
  580. base_src_configure ()
  581. {
  582. debug-print-function $FUNCNAME "$@";
  583. [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
  584. }
  585. base_src_install ()
  586. {
  587. debug-print-function $FUNCNAME "$@";
  588. emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME";
  589. base_src_install_docs
  590. }
  591. base_src_install_docs ()
  592. {
  593. debug-print-function $FUNCNAME "$@";
  594. local x;
  595. pushd "${S}" > /dev/null;
  596. if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  597. for x in "${DOCS[@]}";
  598. do
  599. debug-print "$FUNCNAME: docs: creating document from ${x}";
  600. dodoc "${x}" || die "dodoc failed";
  601. done;
  602. fi;
  603. if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  604. for x in "${HTML_DOCS[@]}";
  605. do
  606. debug-print "$FUNCNAME: docs: creating html document from ${x}";
  607. dohtml -r "${x}" || die "dohtml failed";
  608. done;
  609. fi;
  610. popd > /dev/null
  611. }
  612. base_src_make ()
  613. {
  614. debug-print-function $FUNCNAME "$@";
  615. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  616. emake "$@" || die "died running emake, $FUNCNAME";
  617. fi
  618. }
  619. base_src_prepare ()
  620. {
  621. debug-print-function $FUNCNAME "$@";
  622. debug-print "$FUNCNAME: PATCHES=$PATCHES";
  623. local patches_failed=0;
  624. pushd "${S}" > /dev/null;
  625. if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  626. for x in "${PATCHES[@]}";
  627. do
  628. debug-print "$FUNCNAME: applying patch from ${x}";
  629. if [[ -d "${x}" ]]; then
  630. EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch};
  631. oldval=${EPATCH_SOURCE};
  632. EPATCH_SOURCE=${x};
  633. EPATCH_FORCE=yes;
  634. epatch;
  635. EPATCH_SOURCE=${oldval};
  636. else
  637. if [[ -f "${x}" ]]; then
  638. epatch "${x}";
  639. else
  640. ewarn "QA: File or directory \"${x}\" does not exist.";
  641. ewarn "QA: Check your PATCHES array or add missing file/directory.";
  642. patches_failed=1;
  643. fi;
  644. fi;
  645. done;
  646. [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages.";
  647. else
  648. for x in ${PATCHES};
  649. do
  650. debug-print "$FUNCNAME: patching from ${x}";
  651. epatch "${x}";
  652. done;
  653. fi;
  654. debug-print "$FUNCNAME: applying user patches";
  655. epatch_user;
  656. popd > /dev/null
  657. }
  658. base_src_unpack ()
  659. {
  660. debug-print-function $FUNCNAME "$@";
  661. pushd "${WORKDIR}" > /dev/null;
  662. if [[ $(type -t unpacker_src_unpack) == "function" ]]; then
  663. unpacker_src_unpack;
  664. else
  665. if [[ -n ${A} ]]; then
  666. unpack ${A};
  667. fi;
  668. fi;
  669. has src_prepare ${BASE_EXPF} || base_src_prepare;
  670. popd > /dev/null
  671. }
  672. built_with_use ()
  673. {
  674. local hidden="no";
  675. if [[ $1 == "--hidden" ]]; then
  676. hidden="yes";
  677. shift;
  678. fi;
  679. local missing_action="die";
  680. if [[ $1 == "--missing" ]]; then
  681. missing_action=$2;
  682. shift;
  683. shift;
  684. case ${missing_action} in
  685. true | false | die)
  686.  
  687. ;;
  688. *)
  689. die "unknown action '${missing_action}'"
  690. ;;
  691. esac;
  692. fi;
  693. local opt=$1;
  694. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  695. local PKG=$(best_version $1);
  696. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  697. shift;
  698. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  699. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  700. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  701. case ${missing_action} in
  702. true)
  703. return 0
  704. ;;
  705. false)
  706. return 1
  707. ;;
  708. die)
  709. die "Unable to determine what USE flags $PKG was built with"
  710. ;;
  711. esac;
  712. fi;
  713. if [[ ${hidden} == "no" ]]; then
  714. local IUSE_BUILT=($(<"${IUSEFILE}"));
  715. local expand;
  716. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  717. do
  718. if [[ $1 == ${expand}_* ]]; then
  719. expand="";
  720. break;
  721. fi;
  722. done;
  723. if [[ -n ${expand} ]]; then
  724. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  725. case ${missing_action} in
  726. true)
  727. return 0
  728. ;;
  729. false)
  730. return 1
  731. ;;
  732. die)
  733. die "$PKG does not actually support the $1 USE flag!"
  734. ;;
  735. esac;
  736. fi;
  737. fi;
  738. fi;
  739. local USE_BUILT=$(<${USEFILE});
  740. while [[ $# -gt 0 ]]; do
  741. if [[ ${opt} = "-o" ]]; then
  742. has $1 ${USE_BUILT} && return 0;
  743. else
  744. has $1 ${USE_BUILT} || return 1;
  745. fi;
  746. shift;
  747. done;
  748. [[ ${opt} = "-a" ]]
  749. }
  750. check_license ()
  751. {
  752. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  753. }
  754. cmake-utils_src_compile ()
  755. {
  756. _execute_optionaly "src_compile" "$@"
  757. }
  758. cmake-utils_src_configure ()
  759. {
  760. _execute_optionaly "src_configure" "$@"
  761. }
  762. cmake-utils_src_install ()
  763. {
  764. _execute_optionaly "src_install" "$@"
  765. }
  766. cmake-utils_src_make ()
  767. {
  768. debug-print-function ${FUNCNAME} "$@";
  769. _check_build_dir;
  770. pushd "${CMAKE_BUILD_DIR}" > /dev/null;
  771. if [[ $(_generator_to_use) = Ninja ]]; then
  772. [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage.";
  773. if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
  774. ninja ${MAKEOPTS} -v "$@";
  775. else
  776. ninja "$@";
  777. fi || die "ninja failed!";
  778. else
  779. [[ -e Makefile ]] || die "Makefile not found. Error during configure stage.";
  780. if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
  781. emake VERBOSE=1 "$@" || die "Make failed!";
  782. else
  783. emake "$@" || die "Make failed!";
  784. fi;
  785. fi;
  786. popd > /dev/null
  787. }
  788. cmake-utils_src_test ()
  789. {
  790. _execute_optionaly "src_test" "$@"
  791. }
  792. cmake-utils_use ()
  793. {
  794. _use_me_now "" "$@"
  795. }
  796. cmake-utils_use_build ()
  797. {
  798. _use_me_now BUILD_ "$@"
  799. }
  800. cmake-utils_use_disable ()
  801. {
  802. _use_me_now_inverted DISABLE_ "$@"
  803. }
  804. cmake-utils_use_enable ()
  805. {
  806. _use_me_now ENABLE_ "$@"
  807. }
  808. cmake-utils_use_has ()
  809. {
  810. _use_me_now HAVE_ "$@"
  811. }
  812. cmake-utils_use_no ()
  813. {
  814. _use_me_now_inverted NO_ "$@"
  815. }
  816. cmake-utils_use_use ()
  817. {
  818. _use_me_now USE_ "$@"
  819. }
  820. cmake-utils_use_want ()
  821. {
  822. _use_me_now WANT_ "$@"
  823. }
  824. cmake-utils_use_with ()
  825. {
  826. _use_me_now WITH_ "$@"
  827. }
  828. delete_all_version_separators ()
  829. {
  830. replace_all_version_separators "" "${1}"
  831. }
  832. delete_version_separator ()
  833. {
  834. replace_version_separator "${1}" "" "${2}"
  835. }
  836. doicon ()
  837. {
  838. _iconins ${FUNCNAME} "$@"
  839. }
  840. domenu ()
  841. {
  842. ( local i j ret=0;
  843. insinto /usr/share/applications;
  844. for i in "$@";
  845. do
  846. if [[ -f ${i} ]]; then
  847. doins "${i}";
  848. ((ret+=$?));
  849. else
  850. if [[ -d ${i} ]]; then
  851. for j in "${i}"/*.desktop;
  852. do
  853. doins "${j}";
  854. ((ret+=$?));
  855. done;
  856. else
  857. ((++ret));
  858. fi;
  859. fi;
  860. done;
  861. exit ${ret} )
  862. }
  863. ebeep ()
  864. {
  865. local n;
  866. if [[ -z ${EBEEP_IGNORE} ]]; then
  867. for ((n=1 ; n <= ${1:-5} ; n++))
  868. do
  869. echo -ne "\a";
  870. sleep 0.1 &>/dev/null;
  871. sleep 0,1 &>/dev/null;
  872. echo -ne "\a";
  873. sleep 1;
  874. done;
  875. fi
  876. }
  877. econf_build ()
  878. {
  879. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  880. }
  881. ecvs_clean ()
  882. {
  883. [[ -z $* ]] && set -- .;
  884. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  885. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  886. }
  887. edos2unix ()
  888. {
  889. [[ $# -eq 0 ]] && return 0;
  890. sed -i 's/\r$//' -- "$@" || die
  891. }
  892. egetent ()
  893. {
  894. local db=$1 key=$2;
  895. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  896. case ${db} in
  897. passwd | group)
  898.  
  899. ;;
  900. *)
  901. die "sorry, database '${db}' not yet supported; file a bug"
  902. ;;
  903. esac;
  904. case ${CHOST} in
  905. *-darwin[678])
  906. case ${key} in
  907. *[!0-9]*)
  908. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  909. ;;
  910. *)
  911. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  912. ;;
  913. esac
  914. ;;
  915. *-darwin*)
  916. local mykey;
  917. case ${db} in
  918. passwd)
  919. db="Users" mykey="UniqueID"
  920. ;;
  921. group)
  922. db="Groups" mykey="PrimaryGroupID"
  923. ;;
  924. esac;
  925. case ${key} in
  926. *[!0-9]*)
  927. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  928. ;;
  929. *)
  930. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  931. ;;
  932. esac
  933. ;;
  934. *-freebsd* | *-dragonfly*)
  935. case ${db} in
  936. passwd)
  937. db="user"
  938. ;;
  939. *)
  940.  
  941. ;;
  942. esac;
  943. local opts;
  944. if [[ ${key} == [[:digit:]]* ]]; then
  945. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  946. fi;
  947. pw show ${db} ${opts} "${key}" -q
  948. ;;
  949. *-netbsd* | *-openbsd*)
  950. grep "${key}:\*:" /etc/${db}
  951. ;;
  952. *)
  953. nscd -i "${db}" 2> /dev/null;
  954. getent "${db}" "${key}"
  955. ;;
  956. esac
  957. }
  958. egethome ()
  959. {
  960. local pos;
  961. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  962. case ${CHOST} in
  963. *-darwin* | *-freebsd* | *-dragonfly*)
  964. pos=9
  965. ;;
  966. *)
  967. pos=6
  968. ;;
  969. esac;
  970. egetent passwd "$1" | cut -d: -f${pos}
  971. }
  972. egetshell ()
  973. {
  974. local pos;
  975. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  976. case ${CHOST} in
  977. *-darwin* | *-freebsd* | *-dragonfly*)
  978. pos=10
  979. ;;
  980. *)
  981. pos=7
  982. ;;
  983. esac;
  984. egetent passwd "$1" | cut -d: -f${pos}
  985. }
  986. emktemp ()
  987. {
  988. local exe="touch";
  989. [[ $1 == -d ]] && exe="mkdir" && shift;
  990. local topdir=$1;
  991. if [[ -z ${topdir} ]]; then
  992. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  993. fi;
  994. if ! type -P mktemp > /dev/null; then
  995. local tmp=/;
  996. while [[ -e ${tmp} ]]; do
  997. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  998. done;
  999. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1000. echo "${tmp}";
  1001. else
  1002. if [[ ${exe} == "touch" ]]; then
  1003. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1004. else
  1005. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1006. fi;
  1007. fi
  1008. }
  1009. enable_cmake-utils_src_compile ()
  1010. {
  1011. debug-print-function ${FUNCNAME} "$@";
  1012. has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure;
  1013. cmake-utils_src_make "$@"
  1014. }
  1015. enable_cmake-utils_src_configure ()
  1016. {
  1017. debug-print-function ${FUNCNAME} "$@";
  1018. [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && {
  1019. local name;
  1020. for name in ${CMAKE_REMOVE_MODULES_LIST};
  1021. do
  1022. find "${S}" -name ${name}.cmake -exec rm -v {} +;
  1023. done
  1024. };
  1025. _check_build_dir;
  1026. if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]]; then
  1027. eerror "Unable to locate CMakeLists.txt under:";
  1028. eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"";
  1029. eerror "Consider not inheriting the cmake eclass.";
  1030. die "FATAL: Unable to find CMakeLists.txt";
  1031. fi;
  1032. _modify-cmakelists;
  1033. export XDG_CONFIG_HOME="${T}";
  1034. if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
  1035. if ! has debug ${IUSE//+} || ! use debug; then
  1036. append-cppflags -DNDEBUG;
  1037. fi;
  1038. fi;
  1039. local build_rules=${CMAKE_BUILD_DIR}/gentoo_rules.cmake;
  1040. cat > "${build_rules}" <<-_EOF_
  1041. SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
  1042. SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
  1043. SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
  1044. SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
  1045. SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
  1046. SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
  1047. _EOF_
  1048.  
  1049. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  1050. if [[ -n ${EPREFIX} ]]; then
  1051. cat >> "${build_rules}" <<-_EOF_
  1052. # in Prefix we need rpath and must ensure cmake gets our default linker path
  1053. # right ... except for Darwin hosts
  1054. IF (NOT APPLE)
  1055. SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1056. SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
  1057. CACHE STRING "" FORCE)
  1058.  
  1059. ELSE ()
  1060.  
  1061. SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX}" CACHE STRING ""FORCE)
  1062. SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
  1063. SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
  1064. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "")
  1065. SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
  1066. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
  1067. SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX}/lib" CACHE STRING "" FORCE)
  1068.  
  1069. ENDIF (NOT APPLE)
  1070. _EOF_
  1071.  
  1072. fi
  1073. local common_config=${CMAKE_BUILD_DIR}/gentoo_common_config.cmake;
  1074. local libdir=$(get_libdir);
  1075. cat > "${common_config}" <<-_EOF_
  1076. SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
  1077. SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
  1078. _EOF_
  1079.  
  1080. [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}";
  1081. if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
  1082. local mycmakeargs_local=(${mycmakeargs});
  1083. else
  1084. local mycmakeargs_local=("${mycmakeargs[@]}");
  1085. fi;
  1086. local cmakeargs=(--no-warn-unused-cli -C "${common_config}" -G "$(_generator_to_use)" -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}" "${mycmakeargs_local[@]}" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" -DCMAKE_INSTALL_DO_STRIP=OFF -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" "${MYCMAKEARGS}");
  1087. pushd "${CMAKE_BUILD_DIR}" > /dev/null;
  1088. debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}";
  1089. echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}";
  1090. "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";
  1091. popd > /dev/null
  1092. }
  1093. enable_cmake-utils_src_install ()
  1094. {
  1095. debug-print-function ${FUNCNAME} "$@";
  1096. _check_build_dir;
  1097. pushd "${CMAKE_BUILD_DIR}" > /dev/null;
  1098. if [[ $(_generator_to_use) = Ninja ]]; then
  1099. DESTDIR=${D} ninja install "$@" || die "died running ninja install";
  1100. base_src_install_docs;
  1101. else
  1102. base_src_install "$@";
  1103. fi;
  1104. popd > /dev/null;
  1105. if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
  1106. dodoc ${DOCS} || die "dodoc failed";
  1107. fi;
  1108. if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
  1109. dohtml -r ${HTML_DOCS} || die "dohtml failed";
  1110. fi
  1111. }
  1112. enable_cmake-utils_src_test ()
  1113. {
  1114. debug-print-function ${FUNCNAME} "$@";
  1115. local ctestargs;
  1116. _check_build_dir;
  1117. pushd "${CMAKE_BUILD_DIR}" > /dev/null;
  1118. [[ -e CTestTestfile.cmake ]] || {
  1119. echo "No tests found. Skipping.";
  1120. return 0
  1121. };
  1122. [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure";
  1123. if ctest ${ctestargs} "$@"; then
  1124. einfo "Tests succeeded.";
  1125. popd > /dev/null;
  1126. return 0;
  1127. else
  1128. if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]]; then
  1129. eerror "Tests failed. Test log ${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log follows:";
  1130. eerror "--START TEST LOG--------------------------------------------------------------";
  1131. cat "${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log";
  1132. eerror "--END TEST LOG----------------------------------------------------------------";
  1133. die "Tests failed.";
  1134. else
  1135. die "Tests failed. When you file a bug, please attach the following file: \n\t${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log";
  1136. fi;
  1137. popd > /dev/null;
  1138. return 1;
  1139. fi
  1140. }
  1141. enewgroup ()
  1142. {
  1143. _assert_pkg_ebuild_phase ${FUNCNAME};
  1144. local egroup=$1;
  1145. shift;
  1146. if [[ -z ${egroup} ]]; then
  1147. eerror "No group specified !";
  1148. die "Cannot call enewgroup without a group";
  1149. fi;
  1150. if [[ -n $(egetent group "${egroup}") ]]; then
  1151. return 0;
  1152. fi;
  1153. einfo "Adding group '${egroup}' to your system ...";
  1154. local egid=$1;
  1155. shift;
  1156. if [[ ! -z ${egid} ]]; then
  1157. if [[ ${egid} -gt 0 ]]; then
  1158. if [[ -n $(egetent group ${egid}) ]]; then
  1159. egid="next available; requested gid taken";
  1160. fi;
  1161. else
  1162. eerror "Groupid given but is not greater than 0 !";
  1163. die "${egid} is not a valid GID";
  1164. fi;
  1165. else
  1166. egid="next available";
  1167. fi;
  1168. einfo " - Groupid: ${egid}";
  1169. if [[ $# -gt 0 ]]; then
  1170. die "extra arguments no longer supported; please file a bug";
  1171. fi;
  1172. function _enewgroup_next_gid ()
  1173. {
  1174. if [[ ${egid} == *[!0-9]* ]]; then
  1175. for ((egid = 101; egid <= 999; egid++))
  1176. do
  1177. [[ -z $(egetent group ${egid}) ]] && break;
  1178. done;
  1179. fi
  1180. };
  1181. case ${CHOST} in
  1182. *-darwin*)
  1183. _enewgroup_next_gid;
  1184. dscl . create "/groups/${egroup}" gid ${egid};
  1185. dscl . create "/groups/${egroup}" passwd '*'
  1186. ;;
  1187. *-freebsd* | *-dragonfly*)
  1188. _enewgroup_next_gid;
  1189. pw groupadd "${egroup}" -g ${egid} || die
  1190. ;;
  1191. *-netbsd*)
  1192. _enewgroup_next_gid;
  1193. groupadd -g ${egid} "${egroup}" || die
  1194. ;;
  1195. *)
  1196. local opts;
  1197. if [[ ${egid} == *[!0-9]* ]]; then
  1198. opts="";
  1199. else
  1200. opts="-g ${egid}";
  1201. fi;
  1202. groupadd -r ${opts} "${egroup}" || die
  1203. ;;
  1204. esac
  1205. }
  1206. enewuser ()
  1207. {
  1208. _assert_pkg_ebuild_phase ${FUNCNAME};
  1209. local euser=$1;
  1210. shift;
  1211. if [[ -z ${euser} ]]; then
  1212. eerror "No username specified !";
  1213. die "Cannot call enewuser without a username";
  1214. fi;
  1215. if [[ -n $(egetent passwd "${euser}") ]]; then
  1216. return 0;
  1217. fi;
  1218. einfo "Adding user '${euser}' to your system ...";
  1219. local opts=();
  1220. local euid=$1;
  1221. shift;
  1222. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1223. if [[ ${euid} -gt 0 ]]; then
  1224. if [[ -n $(egetent passwd ${euid}) ]]; then
  1225. euid="next";
  1226. fi;
  1227. else
  1228. eerror "Userid given but is not greater than 0 !";
  1229. die "${euid} is not a valid UID";
  1230. fi;
  1231. else
  1232. euid="next";
  1233. fi;
  1234. if [[ ${euid} == "next" ]]; then
  1235. for ((euid = 101; euid <= 999; euid++))
  1236. do
  1237. [[ -z $(egetent passwd ${euid}) ]] && break;
  1238. done;
  1239. fi;
  1240. opts+=(-u ${euid});
  1241. einfo " - Userid: ${euid}";
  1242. local eshell=$1;
  1243. shift;
  1244. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1245. if [[ ! -e ${ROOT}${eshell} ]]; then
  1246. eerror "A shell was specified but it does not exist !";
  1247. die "${eshell} does not exist in ${ROOT}";
  1248. fi;
  1249. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1250. eerror "Do not specify ${eshell} yourself, use -1";
  1251. die "Pass '-1' as the shell parameter";
  1252. fi;
  1253. else
  1254. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1255. do
  1256. [[ -x ${ROOT}${eshell} ]] && break;
  1257. done;
  1258. if [[ ${eshell} == "/dev/null" ]]; then
  1259. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1260. case ${USERLAND} in
  1261. GNU)
  1262. eshell="/bin/false"
  1263. ;;
  1264. BSD)
  1265. eshell="/sbin/nologin"
  1266. ;;
  1267. Darwin)
  1268. eshell="/usr/sbin/nologin"
  1269. ;;
  1270. *)
  1271. die "Unable to identify the default shell for userland ${USERLAND}"
  1272. ;;
  1273. esac;
  1274. fi;
  1275. fi;
  1276. einfo " - Shell: ${eshell}";
  1277. opts+=(-s "${eshell}");
  1278. local ehome=$1;
  1279. shift;
  1280. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1281. ehome="/dev/null";
  1282. fi;
  1283. einfo " - Home: ${ehome}";
  1284. opts+=(-d "${ehome}");
  1285. local egroups=$1;
  1286. shift;
  1287. local g egroups_arr;
  1288. IFS="," read -r -a egroups_arr <<< "${egroups}";
  1289. shift;
  1290. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  1291. local defgroup exgroups;
  1292. for g in "${egroups_arr[@]}";
  1293. do
  1294. if [[ -z $(egetent group "${g}") ]]; then
  1295. eerror "You must add group ${g} to the system first";
  1296. die "${g} is not a valid GID";
  1297. fi;
  1298. if [[ -z ${defgroup} ]]; then
  1299. defgroup=${g};
  1300. else
  1301. exgroups+=",${g}";
  1302. fi;
  1303. done;
  1304. opts+=(-g "${defgroup}");
  1305. if [[ ! -z ${exgroups} ]]; then
  1306. opts+=(-G "${exgroups:1}");
  1307. fi;
  1308. fi;
  1309. einfo " - Groups: ${egroups:-(none)}";
  1310. if [[ $# -gt 0 ]]; then
  1311. die "extra arguments no longer supported; please file a bug";
  1312. else
  1313. local comment="added by portage for ${PN}";
  1314. opts+=(-c "${comment}");
  1315. einfo " - GECOS: ${comment}";
  1316. fi;
  1317. case ${CHOST} in
  1318. *-darwin*)
  1319. dscl . create "/users/${euser}" uid ${euid};
  1320. dscl . create "/users/${euser}" shell "${eshell}";
  1321. dscl . create "/users/${euser}" home "${ehome}";
  1322. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  1323. for g in "${egroups_arr[@]}";
  1324. do
  1325. dscl . merge "/groups/${g}" users "${euser}";
  1326. done
  1327. ;;
  1328. *-freebsd* | *-dragonfly*)
  1329. pw useradd "${euser}" "${opts[@]}" || die
  1330. ;;
  1331. *-netbsd*)
  1332. useradd "${opts[@]}" "${euser}" || die
  1333. ;;
  1334. *-openbsd*)
  1335. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  1336. ;;
  1337. *)
  1338. useradd -r "${opts[@]}" "${euser}" || die
  1339. ;;
  1340. esac;
  1341. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1342. einfo " - Creating ${ehome} in ${ROOT}";
  1343. mkdir -p "${ROOT}/${ehome}";
  1344. chown "${euser}" "${ROOT}/${ehome}";
  1345. chmod 755 "${ROOT}/${ehome}";
  1346. fi
  1347. }
  1348. epatch ()
  1349. {
  1350. function _epatch_draw_line ()
  1351. {
  1352. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1353. echo "${1//?/=}"
  1354. };
  1355. unset P4CONFIG P4PORT P4USER;
  1356. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1357. while [[ $# -gt 0 ]]; do
  1358. case $1 in
  1359. -*)
  1360. EPATCH_OPTS+=("$1")
  1361. ;;
  1362. *)
  1363. break
  1364. ;;
  1365. esac;
  1366. shift;
  1367. done;
  1368. if [[ $# -gt 1 ]]; then
  1369. local m;
  1370. for m in "$@";
  1371. do
  1372. epatch "${m}";
  1373. done;
  1374. return 0;
  1375. fi;
  1376. local SINGLE_PATCH="no";
  1377. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1378. if [[ -f $1 ]]; then
  1379. SINGLE_PATCH="yes";
  1380. set -- "$1";
  1381. local EPATCH_SUFFIX=$1;
  1382. else
  1383. if [[ -d $1 ]]; then
  1384. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1385. else
  1386. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1387. epatch "${EPATCH_SOURCE}/$1";
  1388. return $?;
  1389. else
  1390. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1391. echo;
  1392. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1393. eerror;
  1394. eerror " ${EPATCH_SOURCE}";
  1395. eerror " ( ${EPATCH_SOURCE##*/} )";
  1396. echo;
  1397. die "Cannot find \$EPATCH_SOURCE!";
  1398. fi;
  1399. fi;
  1400. fi;
  1401. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1402. local PIPE_CMD;
  1403. case ${EPATCH_SUFFIX##*\.} in
  1404. xz)
  1405. PIPE_CMD="xz -dc"
  1406. ;;
  1407. lzma)
  1408. PIPE_CMD="lzma -dc"
  1409. ;;
  1410. bz2)
  1411. PIPE_CMD="bzip2 -dc"
  1412. ;;
  1413. gz | Z | z)
  1414. PIPE_CMD="gzip -dc"
  1415. ;;
  1416. ZIP | zip)
  1417. PIPE_CMD="unzip -p"
  1418. ;;
  1419. *)
  1420.  
  1421. ;;
  1422. esac;
  1423. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1424. local x;
  1425. for x in "$@";
  1426. do
  1427. [[ ! -f ${x} ]] && continue;
  1428. local patchname=${x##*/};
  1429. local a=${patchname#*_};
  1430. a=${a%%_*};
  1431. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1432. continue;
  1433. fi;
  1434. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  1435. eshopts_push -o noglob;
  1436. local ex;
  1437. for ex in ${EPATCH_EXCLUDE};
  1438. do
  1439. if [[ ${patchname} == ${ex} ]]; then
  1440. eshopts_pop;
  1441. continue 2;
  1442. fi;
  1443. done;
  1444. eshopts_pop;
  1445. fi;
  1446. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1447. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1448. einfo "${EPATCH_SINGLE_MSG}";
  1449. else
  1450. einfo "Applying ${patchname} ...";
  1451. fi;
  1452. else
  1453. einfo " ${patchname} ...";
  1454. fi;
  1455. local STDERR_TARGET="${T}/${patchname}.out";
  1456. if [[ -e ${STDERR_TARGET} ]]; then
  1457. STDERR_TARGET="${T}/${patchname}-$$.out";
  1458. fi;
  1459. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  1460. local count=0;
  1461. local PATCH_TARGET;
  1462. if [[ -n ${PIPE_CMD} ]]; then
  1463. PATCH_TARGET="${T}/$$.patch";
  1464. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1465. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1466. echo;
  1467. eerror "Could not extract patch!";
  1468. count=5;
  1469. break;
  1470. fi;
  1471. else
  1472. PATCH_TARGET=${x};
  1473. fi;
  1474. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1475. if [[ -n ${abs_paths} ]]; then
  1476. count=1;
  1477. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1478. fi;
  1479. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1480. if [[ -n ${rel_paths} ]]; then
  1481. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  1482. eqawarn " In the future this will cause a failure.";
  1483. eqawarn "${rel_paths}";
  1484. fi;
  1485. local patch_cmd;
  1486. while [[ ${count} -lt 5 ]]; do
  1487. patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}";
  1488. ( _epatch_draw_line "***** ${patchname} *****";
  1489. echo;
  1490. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1491. echo;
  1492. _epatch_draw_line "***** ${patchname} *****";
  1493. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1494. ret=$?;
  1495. echo;
  1496. echo "patch program exited with status ${ret}";
  1497. exit ${ret} ) >> "${STDERR_TARGET}";
  1498. if [ $? -eq 0 ]; then
  1499. ( _epatch_draw_line "***** ${patchname} *****";
  1500. echo;
  1501. echo "ACTUALLY APPLYING ${patchname} ...";
  1502. echo;
  1503. _epatch_draw_line "***** ${patchname} *****";
  1504. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1505. ret=$?;
  1506. echo;
  1507. echo "patch program exited with status ${ret}";
  1508. exit ${ret} ) >> "${STDERR_TARGET}";
  1509. if [ $? -ne 0 ]; then
  1510. echo;
  1511. eerror "A dry-run of patch command succeeded, but actually";
  1512. eerror "applying the patch failed!";
  1513. count=5;
  1514. fi;
  1515. break;
  1516. fi;
  1517. : $(( count++ ));
  1518. done;
  1519. if [[ -n ${PIPE_CMD} ]]; then
  1520. rm -f "${PATCH_TARGET}";
  1521. fi;
  1522. if [[ ${count} -ge 5 ]]; then
  1523. echo;
  1524. eerror "Failed Patch: ${patchname} !";
  1525. eerror " ( ${PATCH_TARGET} )";
  1526. eerror;
  1527. eerror "Include in your bugreport the contents of:";
  1528. eerror;
  1529. eerror " ${STDERR_TARGET}";
  1530. echo;
  1531. die "Failed Patch: ${patchname}!";
  1532. fi;
  1533. rm -f "${STDERR_TARGET}";
  1534. cat >> "${T}/epatch.log" <<-EOF
  1535. PATCH: ${x}
  1536. CMD: ${patch_cmd}
  1537. PWD: ${PWD}
  1538.  
  1539. EOF
  1540.  
  1541. eend 0;
  1542. done;
  1543. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1544. :
  1545. }
  1546. epatch_user ()
  1547. {
  1548. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1549. local applied="${T}/epatch_user.log";
  1550. [[ -e ${applied} ]] && return 2;
  1551. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1552. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}};
  1553. do
  1554. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1555. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1556. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1557. if [[ -d ${EPATCH_SOURCE} ]]; then
  1558. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1559. echo "${EPATCH_SOURCE}" > "${applied}";
  1560. return 0;
  1561. fi;
  1562. done;
  1563. echo "none" > "${applied}";
  1564. return 1
  1565. }
  1566. epause ()
  1567. {
  1568. [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
  1569. }
  1570. epunt_cxx ()
  1571. {
  1572. local dir=$1;
  1573. [[ -z ${dir} ]] && dir=${S};
  1574. ebegin "Removing useless C++ checks";
  1575. local f;
  1576. find "${dir}" -name configure | while read f; do
  1577. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  1578. done;
  1579. eend 0
  1580. }
  1581. esethome ()
  1582. {
  1583. _assert_pkg_ebuild_phase ${FUNCNAME};
  1584. local euser=$1;
  1585. shift;
  1586. if [[ -z ${euser} ]]; then
  1587. eerror "No username specified !";
  1588. die "Cannot call esethome without a username";
  1589. fi;
  1590. if [[ -z $(egetent passwd "${euser}") ]]; then
  1591. ewarn "User does not exist, cannot set home dir -- skipping.";
  1592. return 1;
  1593. fi;
  1594. local ehome=$1;
  1595. shift;
  1596. if [[ -z ${ehome} ]]; then
  1597. eerror "No home directory specified !";
  1598. die "Cannot call esethome without a home directory or '-1'";
  1599. fi;
  1600. if [[ ${ehome} == "-1" ]]; then
  1601. ehome="/dev/null";
  1602. fi;
  1603. if [[ $(egethome "${euser}") == ${ehome} ]]; then
  1604. return 0;
  1605. fi;
  1606. einfo "Updating home for user '${euser}' ...";
  1607. einfo " - Home: ${ehome}";
  1608. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1609. einfo " - Creating ${ehome} in ${ROOT}";
  1610. mkdir -p "${ROOT}/${ehome}";
  1611. chown "${euser}" "${ROOT}/${ehome}";
  1612. chmod 755 "${ROOT}/${ehome}";
  1613. fi;
  1614. case ${CHOST} in
  1615. *-darwin*)
  1616. dscl . change "/users/${euser}" home "${ehome}"
  1617. ;;
  1618. *-freebsd* | *-dragonfly*)
  1619. pw usermod "${euser}" -d "${ehome}" && return 0;
  1620. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1621. eerror "There was an error when attempting to update the home directory for ${euser}";
  1622. eerror "Please update it manually on your system:";
  1623. eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
  1624. ;;
  1625. *)
  1626. usermod -d "${ehome}" "${euser}" && return 0;
  1627. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1628. eerror "There was an error when attempting to update the home directory for ${euser}";
  1629. eerror "Please update it manually on your system (as root):";
  1630. eerror "\t usermod -d \"${ehome}\" \"${euser}\""
  1631. ;;
  1632. esac
  1633. }
  1634. eshopts_pop ()
  1635. {
  1636. local s;
  1637. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1638. if [[ ${s} == "shopt -"* ]]; then
  1639. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1640. else
  1641. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1642. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1643. fi
  1644. }
  1645. eshopts_push ()
  1646. {
  1647. if [[ $1 == -[su] ]]; then
  1648. estack_push eshopts "$(shopt -p)";
  1649. [[ $# -eq 0 ]] && return 0;
  1650. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1651. else
  1652. estack_push eshopts $-;
  1653. [[ $# -eq 0 ]] && return 0;
  1654. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1655. fi
  1656. }
  1657. estack_pop ()
  1658. {
  1659. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1660. local __estack_name="__ESTACK_$1__";
  1661. shift;
  1662. local __estack_retvar=$1;
  1663. shift;
  1664. eval local __estack_i=\${#${__estack_name}\[@\]};
  1665. [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  1666. if [[ -n ${__estack_retvar} ]]; then
  1667. eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  1668. fi;
  1669. eval unset ${__estack_name}\[${__estack_i}\]
  1670. }
  1671. estack_push ()
  1672. {
  1673. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1674. local stack_name="__ESTACK_$1__";
  1675. shift;
  1676. eval ${stack_name}+=\( \"\$@\" \)
  1677. }
  1678. esvn_clean ()
  1679. {
  1680. [[ -z $* ]] && set -- .;
  1681. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1682. }
  1683. eumask_pop ()
  1684. {
  1685. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1686. local s;
  1687. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1688. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1689. }
  1690. eumask_push ()
  1691. {
  1692. estack_push eumask "$(umask)";
  1693. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1694. }
  1695. filter-flags ()
  1696. {
  1697. _filter-hardened "$@";
  1698. local v;
  1699. for v in $(all-flag-vars);
  1700. do
  1701. _filter-var ${v} "$@";
  1702. done;
  1703. return 0
  1704. }
  1705. filter-ldflags ()
  1706. {
  1707. _filter-var LDFLAGS "$@";
  1708. return 0
  1709. }
  1710. filter-lfs-flags ()
  1711. {
  1712. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1713. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1714. }
  1715. filter-mfpmath ()
  1716. {
  1717. local orig_mfpmath new_math prune_math;
  1718. orig_mfpmath=$(get-flag -mfpmath);
  1719. new_math=$(get-flag mfpmath);
  1720. new_math=" ${new_math//,/ } ";
  1721. prune_math="";
  1722. for prune_math in "$@";
  1723. do
  1724. new_math=${new_math/ ${prune_math} / };
  1725. done;
  1726. new_math=$(echo ${new_math});
  1727. new_math=${new_math// /,};
  1728. if [[ -z ${new_math} ]]; then
  1729. filter-flags ${orig_mfpmath};
  1730. else
  1731. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1732. fi;
  1733. return 0
  1734. }
  1735. gcc-fullversion ()
  1736. {
  1737. _gcc_fullversion '$1.$2.$3' "$@"
  1738. }
  1739. gcc-major-version ()
  1740. {
  1741. _gcc_fullversion '$1' "$@"
  1742. }
  1743. gcc-micro-version ()
  1744. {
  1745. _gcc_fullversion '$3' "$@"
  1746. }
  1747. gcc-minor-version ()
  1748. {
  1749. _gcc_fullversion '$2' "$@"
  1750. }
  1751. gcc-specs-directive ()
  1752. {
  1753. local directive subdname subdirective;
  1754. directive="$(_gcc-specs-directive_raw $1)";
  1755. while [[ ${directive} == *%\(*\)* ]]; do
  1756. subdname=${directive/*%\(};
  1757. subdname=${subdname/\)*};
  1758. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1759. directive="${directive//\%(${subdname})/${subdirective}}";
  1760. done;
  1761. echo "${directive}";
  1762. return 0
  1763. }
  1764. gcc-specs-nostrict ()
  1765. {
  1766. local directive;
  1767. directive=$(gcc-specs-directive cc1);
  1768. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1769. }
  1770. gcc-specs-now ()
  1771. {
  1772. local directive;
  1773. directive=$(gcc-specs-directive link_command);
  1774. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1775. }
  1776. gcc-specs-pie ()
  1777. {
  1778. local directive;
  1779. directive=$(gcc-specs-directive cc1);
  1780. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1781. }
  1782. gcc-specs-relro ()
  1783. {
  1784. local directive;
  1785. directive=$(gcc-specs-directive link_command);
  1786. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1787. }
  1788. gcc-specs-ssp ()
  1789. {
  1790. local directive;
  1791. directive=$(gcc-specs-directive cc1);
  1792. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1793. }
  1794. gcc-specs-ssp-to-all ()
  1795. {
  1796. local directive;
  1797. directive=$(gcc-specs-directive cc1);
  1798. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1799. }
  1800. gcc-version ()
  1801. {
  1802. _gcc_fullversion '$1.$2' "$@"
  1803. }
  1804. gen_usr_ldscript ()
  1805. {
  1806. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1807. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1808. tc-is-static-only && return;
  1809. case ${CTARGET:-${CHOST}} in
  1810. *-darwin*)
  1811.  
  1812. ;;
  1813. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1814. use prefix && return 0
  1815. ;;
  1816. *)
  1817. return 0
  1818. ;;
  1819. esac;
  1820. dodir /usr/${libdir};
  1821. if [[ $1 == "-a" ]]; then
  1822. auto=true;
  1823. shift;
  1824. dodir /${libdir};
  1825. fi;
  1826. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1827. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1828. for lib in "$@";
  1829. do
  1830. local tlib;
  1831. if ${auto}; then
  1832. lib="lib${lib}${suffix}";
  1833. else
  1834. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1835. fi;
  1836. case ${CTARGET:-${CHOST}} in
  1837. *-darwin*)
  1838. if ${auto}; then
  1839. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1840. else
  1841. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1842. fi;
  1843. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1844. tlib=${tlib##*/};
  1845. if ${auto}; then
  1846. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1847. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1848. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1849. fi;
  1850. rm -f "${ED}"/${libdir}/${lib};
  1851. fi;
  1852. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1853. chmod u+w "${ED}${libdir}/${tlib}";
  1854. local nowrite=yes;
  1855. fi;
  1856. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1857. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1858. pushd "${ED}/usr/${libdir}" > /dev/null;
  1859. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1860. popd > /dev/null
  1861. ;;
  1862. *)
  1863. if ${auto}; then
  1864. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1865. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1866. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1867. if [[ ${tlib} != ${lib}* ]]; then
  1868. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1869. fi;
  1870. rm -f "${ED}"/${libdir}/${lib};
  1871. else
  1872. tlib=${lib};
  1873. fi;
  1874. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1875. /* GNU ld script
  1876. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1877. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1878. run into linking problems. This "fake" dynamic lib is a linker script that
  1879. redirects the linker to the real lib. And yes, this works in the cross-
  1880. compiling scenario as the sysroot-ed linker will prepend the real path.
  1881.  
  1882. See bug http://bugs.gentoo.org/4411 for more info.
  1883. */
  1884. ${output_format}
  1885. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1886. END_LDSCRIPT
  1887.  
  1888. ;;
  1889. esac
  1890. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1891. done
  1892. }
  1893. get-flag ()
  1894. {
  1895. local f var findflag="$1";
  1896. for var in $(all-flag-vars);
  1897. do
  1898. for f in ${!var};
  1899. do
  1900. if [ "${f/${findflag}}" != "${f}" ]; then
  1901. printf "%s\n" "${f/-${findflag}=}";
  1902. return 0;
  1903. fi;
  1904. done;
  1905. done;
  1906. return 1
  1907. }
  1908. get_abi_CFLAGS ()
  1909. {
  1910. get_abi_var CFLAGS "$@"
  1911. }
  1912. get_abi_CHOST ()
  1913. {
  1914. get_abi_var CHOST "$@"
  1915. }
  1916. get_abi_CTARGET ()
  1917. {
  1918. get_abi_var CTARGET "$@"
  1919. }
  1920. get_abi_FAKE_TARGETS ()
  1921. {
  1922. get_abi_var FAKE_TARGETS "$@"
  1923. }
  1924. get_abi_LDFLAGS ()
  1925. {
  1926. get_abi_var LDFLAGS "$@"
  1927. }
  1928. get_abi_LIBDIR ()
  1929. {
  1930. get_abi_var LIBDIR "$@"
  1931. }
  1932. get_abi_var ()
  1933. {
  1934. local flag=$1;
  1935. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1936. local var="${flag}_${abi}";
  1937. echo ${!var}
  1938. }
  1939. get_after_major_version ()
  1940. {
  1941. echo $(get_version_component_range 2- "${1:-${PV}}")
  1942. }
  1943. get_all_abis ()
  1944. {
  1945. local x order="" mvar dvar;
  1946. mvar="MULTILIB_ABIS";
  1947. dvar="DEFAULT_ABI";
  1948. if [[ -n $1 ]]; then
  1949. mvar="$1_${mvar}";
  1950. dvar="$1_${dvar}";
  1951. fi;
  1952. if [[ -z ${!mvar} ]]; then
  1953. echo "default";
  1954. return 0;
  1955. fi;
  1956. for x in ${!mvar};
  1957. do
  1958. if [[ ${x} != ${!dvar} ]]; then
  1959. order="${order:+${order} }${x}";
  1960. fi;
  1961. done;
  1962. order="${order:+${order} }${!dvar}";
  1963. echo ${order};
  1964. return 0
  1965. }
  1966. get_all_libdirs ()
  1967. {
  1968. local libdirs abi;
  1969. for abi in ${MULTILIB_ABIS};
  1970. do
  1971. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1972. done;
  1973. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1974. echo "${libdirs}"
  1975. }
  1976. get_all_version_components ()
  1977. {
  1978. eshopts_push -s extglob;
  1979. local ver_str=${1:-${PV}} result;
  1980. result=();
  1981. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  1982. echo ${VERSIONATOR_CACHE_RESULT};
  1983. eshopts_pop;
  1984. return;
  1985. fi;
  1986. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  1987. while [[ -n $ver_str ]]; do
  1988. case "${ver_str::1}" in
  1989. [[:digit:]])
  1990. result+=("${ver_str%%[^[:digit:]]*}");
  1991. ver_str=${ver_str##+([[:digit:]])}
  1992. ;;
  1993. [-_.])
  1994. result+=("${ver_str::1}");
  1995. ver_str=${ver_str:1}
  1996. ;;
  1997. [[:alpha:]])
  1998. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  1999. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2000. ver_str=${not_match}
  2001. ;;
  2002. *)
  2003. result+=("${ver_str::1}");
  2004. ver_str=${ver_str:1}
  2005. ;;
  2006. esac;
  2007. done;
  2008. export VERSIONATOR_CACHE_RESULT=${result[*]};
  2009. echo ${result[@]};
  2010. eshopts_pop
  2011. }
  2012. get_install_abis ()
  2013. {
  2014. local x order="";
  2015. if [[ -z ${MULTILIB_ABIS} ]]; then
  2016. echo "default";
  2017. return 0;
  2018. fi;
  2019. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2020. for x in ${MULTILIB_ABIS};
  2021. do
  2022. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2023. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2024. fi;
  2025. done;
  2026. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2027. if [[ -n ${ABI_ALLOW} ]]; then
  2028. local ordera="";
  2029. for x in ${order};
  2030. do
  2031. if has ${x} ${ABI_ALLOW}; then
  2032. ordera="${ordera} ${x}";
  2033. fi;
  2034. done;
  2035. order=${ordera};
  2036. fi;
  2037. else
  2038. order=${DEFAULT_ABI};
  2039. fi;
  2040. if [[ -z ${order} ]]; then
  2041. 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.";
  2042. fi;
  2043. echo ${order};
  2044. return 0
  2045. }
  2046. get_last_version_component_index ()
  2047. {
  2048. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2049. }
  2050. get_libdir ()
  2051. {
  2052. local CONF_LIBDIR;
  2053. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2054. echo ${CONF_LIBDIR_OVERRIDE};
  2055. else
  2056. get_abi_LIBDIR;
  2057. fi
  2058. }
  2059. get_libname ()
  2060. {
  2061. local libname;
  2062. local ver=$1;
  2063. case ${CHOST} in
  2064. *-cygwin | mingw* | *-mingw*)
  2065. libname="dll"
  2066. ;;
  2067. *-darwin*)
  2068. libname="dylib"
  2069. ;;
  2070. *-mint*)
  2071. libname="irrelevant"
  2072. ;;
  2073. hppa*-hpux*)
  2074. libname="sl"
  2075. ;;
  2076. *)
  2077. libname="so"
  2078. ;;
  2079. esac;
  2080. if [[ -z $* ]]; then
  2081. echo ".${libname}";
  2082. else
  2083. for ver in "$@";
  2084. do
  2085. case ${CHOST} in
  2086. *-darwin*)
  2087. echo ".${ver}.${libname}"
  2088. ;;
  2089. *-mint*)
  2090. echo ".${libname}"
  2091. ;;
  2092. *)
  2093. echo ".${libname}.${ver}"
  2094. ;;
  2095. esac;
  2096. done;
  2097. fi
  2098. }
  2099. get_major_version ()
  2100. {
  2101. local c=($(get_all_version_components "${1:-${PV}}"));
  2102. echo ${c[0]}
  2103. }
  2104. get_modname ()
  2105. {
  2106. local modname;
  2107. local ver=$1;
  2108. case ${CHOST} in
  2109. *-darwin*)
  2110. modname="bundle"
  2111. ;;
  2112. *)
  2113. modname="so"
  2114. ;;
  2115. esac;
  2116. echo ".${modname}"
  2117. }
  2118. get_version_component_count ()
  2119. {
  2120. local a=($(get_version_components "${1:-${PV}}"));
  2121. echo ${#a[@]}
  2122. }
  2123. get_version_component_range ()
  2124. {
  2125. eshopts_push -s extglob;
  2126. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2127. local -i i=-1 j=0;
  2128. c=($(get_all_version_components "${v}"));
  2129. range_start=${range%-*};
  2130. range_start=${range_start:-1};
  2131. range_end=${range#*-};
  2132. range_end=${range_end:-${#c[@]}};
  2133. while ((j < range_start)); do
  2134. i+=1;
  2135. ((i > ${#c[@]})) && eshopts_pop && return;
  2136. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2137. done;
  2138. while ((j <= range_end)); do
  2139. echo -n ${c[i]};
  2140. ((i > ${#c[@]})) && eshopts_pop && return;
  2141. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2142. i+=1;
  2143. done;
  2144. eshopts_pop
  2145. }
  2146. get_version_components ()
  2147. {
  2148. local c=$(get_all_version_components "${1:-${PV}}");
  2149. echo ${c//[-._]/ }
  2150. }
  2151. has_m32 ()
  2152. {
  2153. die "${FUNCNAME}: don't use this anymore"
  2154. }
  2155. has_m64 ()
  2156. {
  2157. eqawarn "${FUNCNAME}: don't use this anymore";
  2158. local temp="$(emktemp)";
  2159. echo "int main() { return(0); }" > "${temp}".c;
  2160. MY_CC=$(tc-getCC);
  2161. ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  2162. local ret=$?;
  2163. rm -f "${temp}".c;
  2164. [[ ${ret} != 1 ]] && return 0;
  2165. return 1
  2166. }
  2167. has_multilib_profile ()
  2168. {
  2169. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2170. }
  2171. in_iuse ()
  2172. {
  2173. debug-print-function ${FUNCNAME} "${@}";
  2174. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2175. local flag=${1};
  2176. local liuse=(${IUSE});
  2177. has "${flag}" "${liuse[@]#[+-]}"
  2178. }
  2179. is-flag ()
  2180. {
  2181. is-flagq "$@" && echo true
  2182. }
  2183. is-flagq ()
  2184. {
  2185. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2186. local var;
  2187. for var in $(all-flag-vars);
  2188. do
  2189. _is_flagq ${var} "$1" && return 0;
  2190. done;
  2191. return 1
  2192. }
  2193. is-ldflag ()
  2194. {
  2195. is-ldflagq "$@" && echo true
  2196. }
  2197. is-ldflagq ()
  2198. {
  2199. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2200. _is_flagq LDFLAGS $1
  2201. }
  2202. is_final_abi ()
  2203. {
  2204. has_multilib_profile || return 0;
  2205. set -- $(get_install_abis);
  2206. local LAST_ABI=$#;
  2207. [[ ${!LAST_ABI} == ${ABI} ]]
  2208. }
  2209. make_desktop_entry ()
  2210. {
  2211. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2212. local exec=${1};
  2213. local name=${2:-${PN}};
  2214. local icon=${3:-${PN}};
  2215. local type=${4};
  2216. local fields=${5};
  2217. if [[ -z ${type} ]]; then
  2218. local catmaj=${CATEGORY%%-*};
  2219. local catmin=${CATEGORY##*-};
  2220. case ${catmaj} in
  2221. app)
  2222. case ${catmin} in
  2223. accessibility)
  2224. type="Utility;Accessibility"
  2225. ;;
  2226. admin)
  2227. type=System
  2228. ;;
  2229. antivirus)
  2230. type=System
  2231. ;;
  2232. arch)
  2233. type="Utility;Archiving"
  2234. ;;
  2235. backup)
  2236. type="Utility;Archiving"
  2237. ;;
  2238. cdr)
  2239. type="AudioVideo;DiscBurning"
  2240. ;;
  2241. dicts)
  2242. type="Office;Dictionary"
  2243. ;;
  2244. doc)
  2245. type=Documentation
  2246. ;;
  2247. editors)
  2248. type="Utility;TextEditor"
  2249. ;;
  2250. emacs)
  2251. type="Development;TextEditor"
  2252. ;;
  2253. emulation)
  2254. type="System;Emulator"
  2255. ;;
  2256. laptop)
  2257. type="Settings;HardwareSettings"
  2258. ;;
  2259. office)
  2260. type=Office
  2261. ;;
  2262. pda)
  2263. type="Office;PDA"
  2264. ;;
  2265. vim)
  2266. type="Development;TextEditor"
  2267. ;;
  2268. xemacs)
  2269. type="Development;TextEditor"
  2270. ;;
  2271. esac
  2272. ;;
  2273. dev)
  2274. type="Development"
  2275. ;;
  2276. games)
  2277. case ${catmin} in
  2278. action | fps)
  2279. type=ActionGame
  2280. ;;
  2281. arcade)
  2282. type=ArcadeGame
  2283. ;;
  2284. board)
  2285. type=BoardGame
  2286. ;;
  2287. emulation)
  2288. type=Emulator
  2289. ;;
  2290. kids)
  2291. type=KidsGame
  2292. ;;
  2293. puzzle)
  2294. type=LogicGame
  2295. ;;
  2296. roguelike)
  2297. type=RolePlaying
  2298. ;;
  2299. rpg)
  2300. type=RolePlaying
  2301. ;;
  2302. simulation)
  2303. type=Simulation
  2304. ;;
  2305. sports)
  2306. type=SportsGame
  2307. ;;
  2308. strategy)
  2309. type=StrategyGame
  2310. ;;
  2311. esac;
  2312. type="Game;${type}"
  2313. ;;
  2314. gnome)
  2315. type="Gnome;GTK"
  2316. ;;
  2317. kde)
  2318. type="KDE;Qt"
  2319. ;;
  2320. mail)
  2321. type="Network;Email"
  2322. ;;
  2323. media)
  2324. case ${catmin} in
  2325. gfx)
  2326. type=Graphics
  2327. ;;
  2328. *)
  2329. case ${catmin} in
  2330. radio)
  2331. type=Tuner
  2332. ;;
  2333. sound)
  2334. type=Audio
  2335. ;;
  2336. tv)
  2337. type=TV
  2338. ;;
  2339. video)
  2340. type=Video
  2341. ;;
  2342. esac;
  2343. type="AudioVideo;${type}"
  2344. ;;
  2345. esac
  2346. ;;
  2347. net)
  2348. case ${catmin} in
  2349. dialup)
  2350. type=Dialup
  2351. ;;
  2352. ftp)
  2353. type=FileTransfer
  2354. ;;
  2355. im)
  2356. type=InstantMessaging
  2357. ;;
  2358. irc)
  2359. type=IRCClient
  2360. ;;
  2361. mail)
  2362. type=Email
  2363. ;;
  2364. news)
  2365. type=News
  2366. ;;
  2367. nntp)
  2368. type=News
  2369. ;;
  2370. p2p)
  2371. type=FileTransfer
  2372. ;;
  2373. voip)
  2374. type=Telephony
  2375. ;;
  2376. esac;
  2377. type="Network;${type}"
  2378. ;;
  2379. sci)
  2380. case ${catmin} in
  2381. astro*)
  2382. type=Astronomy
  2383. ;;
  2384. bio*)
  2385. type=Biology
  2386. ;;
  2387. calc*)
  2388. type=Calculator
  2389. ;;
  2390. chem*)
  2391. type=Chemistry
  2392. ;;
  2393. elec*)
  2394. type=Electronics
  2395. ;;
  2396. geo*)
  2397. type=Geology
  2398. ;;
  2399. math*)
  2400. type=Math
  2401. ;;
  2402. physics)
  2403. type=Physics
  2404. ;;
  2405. visual*)
  2406. type=DataVisualization
  2407. ;;
  2408. esac;
  2409. type="Education;Science;${type}"
  2410. ;;
  2411. sys)
  2412. type="System"
  2413. ;;
  2414. www)
  2415. case ${catmin} in
  2416. client)
  2417. type=WebBrowser
  2418. ;;
  2419. esac;
  2420. type="Network;${type}"
  2421. ;;
  2422. *)
  2423. type=
  2424. ;;
  2425. esac;
  2426. fi;
  2427. if [ "${SLOT}" == "0" ]; then
  2428. local desktop_name="${PN}";
  2429. else
  2430. local desktop_name="${PN}-${SLOT}";
  2431. fi;
  2432. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2433. type=${type%;}${type:+;};
  2434. eshopts_push -s extglob;
  2435. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2436. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2437. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2438. icon=${icon%.@(xpm|png|svg)};
  2439. fi;
  2440. eshopts_pop;
  2441. cat > "${desktop}" <<-EOF
  2442. [Desktop Entry]
  2443. Name=${name}
  2444. Type=Application
  2445. Comment=${DESCRIPTION}
  2446. Exec=${exec}
  2447. TryExec=${exec%% *}
  2448. Icon=${icon}
  2449. Categories=${type}
  2450. EOF
  2451.  
  2452. if [[ ${fields:-=} != *=* ]]; then
  2453. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2454. fields="Path=${fields}";
  2455. fi;
  2456. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  2457. ( insinto /usr/share/applications;
  2458. doins "${desktop}" ) || die "installing desktop file failed"
  2459. }
  2460. make_session_desktop ()
  2461. {
  2462. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2463. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2464. local title=$1;
  2465. local command=$2;
  2466. local desktop=${T}/${wm:-${PN}}.desktop;
  2467. shift 2;
  2468. cat > "${desktop}" <<-EOF
  2469. [Desktop Entry]
  2470. Name=${title}
  2471. Comment=This session logs you into ${title}
  2472. Exec=${command} $*
  2473. TryExec=${command}
  2474. Type=XSession
  2475. EOF
  2476.  
  2477. ( insinto /usr/share/xsessions;
  2478. doins "${desktop}" )
  2479. }
  2480. make_wrapper ()
  2481. {
  2482. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2483. local tmpwrapper=$(emktemp);
  2484. cat > "${tmpwrapper}" <<EOF
  2485. #!/bin/sh
  2486. cd "${chdir:-.}"
  2487. if [ -n "${libdir}" ] ; then
  2488. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  2489. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  2490. else
  2491. export LD_LIBRARY_PATH="${libdir}"
  2492. fi
  2493. fi
  2494. exec ${bin} "\$@"
  2495. EOF
  2496.  
  2497. chmod go+rx "${tmpwrapper}";
  2498. if [[ -n ${path} ]]; then
  2499. ( exeinto "${path}";
  2500. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2501. else
  2502. newbin "${tmpwrapper}" "${wrapper}" || die;
  2503. fi
  2504. }
  2505. multilib_env ()
  2506. {
  2507. local CTARGET=${1:-${CTARGET}};
  2508. case ${CTARGET} in
  2509. x86_64*)
  2510. export CFLAGS_x86=${CFLAGS_x86--m32};
  2511. export CHOST_x86=${CTARGET/x86_64/i686};
  2512. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2513. export CTARGET_x86=${CHOST_x86};
  2514. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2515. export LIBDIR_x86="lib32";
  2516. else
  2517. export LIBDIR_x86="lib";
  2518. fi;
  2519. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2520. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2521. export CTARGET_amd64=${CHOST_amd64};
  2522. export LIBDIR_amd64="lib64";
  2523. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2524. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2525. export CTARGET_x32=${CHOST_x32};
  2526. export LIBDIR_x32="libx32";
  2527. case ${CTARGET} in
  2528. *-gnux32)
  2529. : ${MULTILIB_ABIS=x32 amd64 x86};
  2530. : ${DEFAULT_ABI=x32}
  2531. ;;
  2532. *)
  2533. : ${MULTILIB_ABIS=amd64 x86};
  2534. : ${DEFAULT_ABI=amd64}
  2535. ;;
  2536. esac
  2537. ;;
  2538. mips64*)
  2539. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2540. export CHOST_o32=${CTARGET/mips64/mips};
  2541. export CTARGET_o32=${CHOST_o32};
  2542. export LIBDIR_o32="lib";
  2543. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2544. export CHOST_n32=${CTARGET};
  2545. export CTARGET_n32=${CHOST_n32};
  2546. export LIBDIR_n32="lib32";
  2547. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2548. export CHOST_n64=${CTARGET};
  2549. export CTARGET_n64=${CHOST_n64};
  2550. export LIBDIR_n64="lib64";
  2551. : ${MULTILIB_ABIS=n64 n32 o32};
  2552. : ${DEFAULT_ABI=n32}
  2553. ;;
  2554. powerpc64*)
  2555. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2556. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2557. export CTARGET_ppc=${CHOST_ppc};
  2558. export LIBDIR_ppc="lib";
  2559. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2560. export CHOST_ppc64=${CTARGET};
  2561. export CTARGET_ppc64=${CHOST_ppc64};
  2562. export LIBDIR_ppc64="lib64";
  2563. : ${MULTILIB_ABIS=ppc64 ppc};
  2564. : ${DEFAULT_ABI=ppc64}
  2565. ;;
  2566. s390x*)
  2567. export CFLAGS_s390=${CFLAGS_s390--m31};
  2568. export CHOST_s390=${CTARGET/s390x/s390};
  2569. export CTARGET_s390=${CHOST_s390};
  2570. export LIBDIR_s390="lib";
  2571. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2572. export CHOST_s390x=${CTARGET};
  2573. export CTARGET_s390x=${CHOST_s390x};
  2574. export LIBDIR_s390x="lib64";
  2575. : ${MULTILIB_ABIS=s390x s390};
  2576. : ${DEFAULT_ABI=s390x}
  2577. ;;
  2578. sparc64*)
  2579. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2580. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2581. export CTARGET_sparc32=${CHOST_sparc32};
  2582. export LIBDIR_sparc32="lib";
  2583. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2584. export CHOST_sparc64=${CTARGET};
  2585. export CTARGET_sparc64=${CHOST_sparc64};
  2586. export LIBDIR_sparc64="lib64";
  2587. : ${MULTILIB_ABIS=sparc64 sparc32};
  2588. : ${DEFAULT_ABI=sparc64}
  2589. ;;
  2590. *)
  2591. : ${MULTILIB_ABIS=default};
  2592. : ${DEFAULT_ABI=default}
  2593. ;;
  2594. esac;
  2595. export MULTILIB_ABIS DEFAULT_ABI
  2596. }
  2597. multilib_toolchain_setup ()
  2598. {
  2599. local v vv;
  2600. export ABI=$1;
  2601. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  2602. for v in CHOST CBUILD AS CC CXX LD;
  2603. do
  2604. vv="__abi_saved_${v}";
  2605. export ${v}="${!vv}";
  2606. unset ${vv};
  2607. done;
  2608. unset __DEFAULT_ABI_SAVED;
  2609. fi;
  2610. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2611. for v in CHOST CBUILD AS CC CXX LD;
  2612. do
  2613. export __abi_saved_${v}="${!v}";
  2614. done;
  2615. export __DEFAULT_ABI_SAVED="true";
  2616. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2617. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2618. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2619. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2620. export CHOST=$(get_abi_CHOST $1);
  2621. export CBUILD=$(get_abi_CHOST $1);
  2622. fi
  2623. }
  2624. newicon ()
  2625. {
  2626. _iconins ${FUNCNAME} "$@"
  2627. }
  2628. newmenu ()
  2629. {
  2630. ( insinto /usr/share/applications;
  2631. newins "$@" )
  2632. }
  2633. no-as-needed ()
  2634. {
  2635. case $($(tc-getLD) -v 2>&1 </dev/null) in
  2636. *GNU*)
  2637. echo "-Wl,--no-as-needed"
  2638. ;;
  2639. esac
  2640. }
  2641. number_abis ()
  2642. {
  2643. set -- `get_install_abis`;
  2644. echo $#
  2645. }
  2646. path_exists ()
  2647. {
  2648. local opt=$1;
  2649. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  2650. [[ $# -eq 0 ]] && return 1;
  2651. local p r=0;
  2652. for p in "$@";
  2653. do
  2654. [[ -e ${p} ]];
  2655. : $(( r += $? ));
  2656. done;
  2657. case ${opt} in
  2658. -a)
  2659. return $(( r != 0 ))
  2660. ;;
  2661. -o)
  2662. return $(( r == $# ))
  2663. ;;
  2664. esac
  2665. }
  2666. pkg_nofetch ()
  2667. {
  2668. _eapi0_pkg_nofetch "$@"
  2669. }
  2670. pkg_postinst ()
  2671. {
  2672. elog "Cairo-Dock is an app that draws on a RGBA GLX visual.";
  2673. elog "Some users have noticed that if the dock is launched,";
  2674. elog "severals qt4-based applications could crash, like skype or vlc.";
  2675. elog "If you have this problem, add the following line into your bashrc :";
  2676. echo;
  2677. elog "alias vlc='export XLIB_SKIP_ARGB_VISUALS=1; vlc; unset XLIB_SKIP_ARGB_VISUALS'";
  2678. elog "see http://www.qtforum.org/article/26669/qt4-mess-up-the-opengl-context.html for more details."
  2679. }
  2680. preserve_old_lib ()
  2681. {
  2682. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2683. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2684. die "Invalid preserve_old_lib() usage";
  2685. fi;
  2686. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2687. has preserve-libs ${FEATURES} && return 0;
  2688. local lib dir;
  2689. for lib in "$@";
  2690. do
  2691. [[ -e ${ROOT}/${lib} ]] || continue;
  2692. dir=${lib%/*};
  2693. dodir ${dir} || die "dodir ${dir} failed";
  2694. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  2695. touch "${D}"/${lib};
  2696. done
  2697. }
  2698. preserve_old_lib_notify ()
  2699. {
  2700. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2701. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2702. die "Invalid preserve_old_lib_notify() usage";
  2703. fi;
  2704. has preserve-libs ${FEATURES} && return 0;
  2705. local lib notice=0;
  2706. for lib in "$@";
  2707. do
  2708. [[ -e ${ROOT}/${lib} ]] || continue;
  2709. if [[ ${notice} -eq 0 ]]; then
  2710. notice=1;
  2711. ewarn "Old versions of installed libraries were detected on your system.";
  2712. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2713. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2714. ewarn "in order to remove these old dependencies. If you do not have this";
  2715. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2716. ewarn;
  2717. fi;
  2718. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2719. done
  2720. }
  2721. prune_libtool_files ()
  2722. {
  2723. debug-print-function ${FUNCNAME} "$@";
  2724. local removing_all removing_modules opt;
  2725. for opt in "$@";
  2726. do
  2727. case "${opt}" in
  2728. --all)
  2729. removing_all=1;
  2730. removing_modules=1
  2731. ;;
  2732. --modules)
  2733. removing_modules=1
  2734. ;;
  2735. *)
  2736. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2737. ;;
  2738. esac;
  2739. done;
  2740. local f;
  2741. local queue=();
  2742. while IFS= read -r -d '' f; do
  2743. local archivefile=${f/%.la/.a};
  2744. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2745. local reason pkgconfig_scanned;
  2746. if grep -q '^shouldnotlink=yes$' "${f}"; then
  2747. if [[ -f ${archivefile} ]]; then
  2748. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2749. queue+=("${archivefile}");
  2750. fi;
  2751. if [[ -n ${removing_modules} ]]; then
  2752. reason='module';
  2753. fi;
  2754. else
  2755. if [[ -n ${removing_all} ]]; then
  2756. reason='requested';
  2757. else
  2758. if [[ ! -f ${archivefile} ]]; then
  2759. reason='no static archive';
  2760. else
  2761. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2762. reason='no libs & flags';
  2763. else
  2764. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2765. local pc_libs=();
  2766. if [[ ! -n ${removing_all} ]]; then
  2767. local pc;
  2768. local tf=${T}/prune-lt-files.pc;
  2769. local pkgconf=$(tc-getPKG_CONFIG);
  2770. while IFS= read -r -d '' pc; do
  2771. local arg;
  2772. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2773. for arg in $("${pkgconf}" --libs "${tf}");
  2774. do
  2775. [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la);
  2776. done;
  2777. done < <(find "${D}" -type f -name '*.pc' -print0);
  2778. rm -f "${tf}";
  2779. fi;
  2780. pkgconfig_scanned=1;
  2781. fi;
  2782. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2783. fi;
  2784. fi;
  2785. fi;
  2786. fi;
  2787. if [[ -n ${reason} ]]; then
  2788. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2789. queue+=("${f}");
  2790. fi;
  2791. done < <(find "${D}" -xtype f -name '*.la' -print0);
  2792. if [[ -n ${queue[@]} ]]; then
  2793. rm -f "${queue[@]}";
  2794. fi
  2795. }
  2796. raw-ldflags ()
  2797. {
  2798. local x input="$@";
  2799. [[ -z ${input} ]] && input=${LDFLAGS};
  2800. set --;
  2801. for x in ${input};
  2802. do
  2803. x=${x#-Wl,};
  2804. set -- "$@" ${x//,/ };
  2805. done;
  2806. echo "$@"
  2807. }
  2808. replace-cpu-flags ()
  2809. {
  2810. local newcpu="$#";
  2811. newcpu="${!newcpu}";
  2812. while [ $# -gt 1 ]; do
  2813. replace-flags "-march=${1}" "-march=${newcpu}";
  2814. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2815. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2816. shift;
  2817. done;
  2818. return 0
  2819. }
  2820. replace-flags ()
  2821. {
  2822. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2823. local f var new;
  2824. for var in $(all-flag-vars);
  2825. do
  2826. new=();
  2827. for f in ${!var};
  2828. do
  2829. [[ ${f} == ${1} ]] && f=${2};
  2830. new+=("${f}");
  2831. done;
  2832. eval export ${var}=\""${new[*]}"\";
  2833. done;
  2834. return 0
  2835. }
  2836. replace-sparc64-flags ()
  2837. {
  2838. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2839. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2840. for x in ${SPARC64_CPUS};
  2841. do
  2842. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2843. done;
  2844. else
  2845. for x in ${SPARC64_CPUS};
  2846. do
  2847. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2848. done;
  2849. fi;
  2850. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2851. for x in ${SPARC64_CPUS};
  2852. do
  2853. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2854. done;
  2855. else
  2856. for x in ${SPARC64_CPUS};
  2857. do
  2858. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2859. done;
  2860. fi;
  2861. export CFLAGS CXXFLAGS
  2862. }
  2863. replace_all_version_separators ()
  2864. {
  2865. local c=($(get_all_version_components "${2:-${PV}}"));
  2866. c=${c[@]//[-._]/$1};
  2867. echo ${c// }
  2868. }
  2869. replace_version_separator ()
  2870. {
  2871. eshopts_push -s extglob;
  2872. local w c v="${3:-${PV}}";
  2873. declare -i i found=0;
  2874. w=${1:-1};
  2875. c=($(get_all_version_components ${v}));
  2876. if [[ ${w} != *[[:digit:]]* ]]; then
  2877. for ((i = 0; i < ${#c[@]}; i++))
  2878. do
  2879. if [[ ${c[i]} == ${w} ]]; then
  2880. c[i]=${2};
  2881. break;
  2882. fi;
  2883. done;
  2884. else
  2885. for ((i = 0; i < ${#c[@]}; i++))
  2886. do
  2887. if [[ -n "${c[i]//[^-._]}" ]]; then
  2888. found+=1;
  2889. if ((found == w)); then
  2890. c[i]=${2};
  2891. break;
  2892. fi;
  2893. fi;
  2894. done;
  2895. fi;
  2896. c=${c[*]};
  2897. echo ${c// };
  2898. eshopts_pop
  2899. }
  2900. setup-allowed-flags ()
  2901. {
  2902. ALLOWED_FLAGS="-pipe";
  2903. ALLOWED_FLAGS+=" -O -O1 -O2 -Os -mcpu -march -mtune";
  2904. ALLOWED_FLAGS+=" -fstack-protector -fstack-protector-all";
  2905. ALLOWED_FLAGS+=" -fbounds-checking -fno-strict-overflow";
  2906. ALLOWED_FLAGS+=" -fno-PIE -fno-pie -fno-unit-at-a-time";
  2907. ALLOWED_FLAGS+=" -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+";
  2908. ALLOWED_FLAGS+=" -fno-ident -fpermissive";
  2909. ALLOWED_FLAGS+=" -W* -w";
  2910. ALLOWED_FLAGS+=" -fno-stack-protector -fno-stack-protector-all -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer";
  2911. ALLOWED_FLAGS+=" -mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -mfloat-abi=* -D* -U*";
  2912. ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
  2913. ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
  2914. ALLOWED_FLAGS+=" -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt";
  2915. ALLOWED_FLAGS+=" -I* -L* -R* -Wl,*";
  2916. export ALLOWED_FLAGS;
  2917. return 0
  2918. }
  2919. src_compile ()
  2920. {
  2921. cmake-utils_src_compile "$@"
  2922. }
  2923. src_configure ()
  2924. {
  2925. cmake-utils_src_configure "$@"
  2926. }
  2927. src_install ()
  2928. {
  2929. cmake-utils_src_install "$@"
  2930. }
  2931. src_prepare ()
  2932. {
  2933. epatch "${FILESDIR}/${P}-rpath.patch" || die
  2934. }
  2935. src_test ()
  2936. {
  2937. cmake-utils_src_test "$@"
  2938. }
  2939. src_unpack ()
  2940. {
  2941. base_src_unpack "$@"
  2942. }
  2943. strip-flags ()
  2944. {
  2945. local x y var;
  2946. setup-allowed-flags;
  2947. set -f;
  2948. for var in $(all-flag-vars);
  2949. do
  2950. local new=();
  2951. for x in ${!var};
  2952. do
  2953. local flag=${x%%=*};
  2954. for y in ${ALLOWED_FLAGS};
  2955. do
  2956. if [[ -z ${flag%%${y}} ]]; then
  2957. new+=("${x}");
  2958. break;
  2959. fi;
  2960. done;
  2961. done;
  2962. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2963. new+=(-O2);
  2964. fi;
  2965. eval export ${var}=\""${new[*]}"\";
  2966. done;
  2967. set +f;
  2968. return 0
  2969. }
  2970. strip-linguas ()
  2971. {
  2972. local ls newls nols;
  2973. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2974. local op=$1;
  2975. shift;
  2976. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2977. shift;
  2978. local d f;
  2979. for d in "$@";
  2980. do
  2981. if [[ ${op} == "-u" ]]; then
  2982. newls=${ls};
  2983. else
  2984. newls="";
  2985. fi;
  2986. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2987. do
  2988. if [[ ${op} == "-i" ]]; then
  2989. has ${f} ${ls} && newls="${newls} ${f}";
  2990. else
  2991. has ${f} ${ls} || newls="${newls} ${f}";
  2992. fi;
  2993. done;
  2994. ls=${newls};
  2995. done;
  2996. else
  2997. ls="$@";
  2998. fi;
  2999. nols="";
  3000. newls="";
  3001. for f in ${LINGUAS};
  3002. do
  3003. if has ${f} ${ls}; then
  3004. newls="${newls} ${f}";
  3005. else
  3006. nols="${nols} ${f}";
  3007. fi;
  3008. done;
  3009. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  3010. export LINGUAS=${newls:1}
  3011. }
  3012. strip-unsupported-flags ()
  3013. {
  3014. export CFLAGS=$(test-flags-CC ${CFLAGS});
  3015. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3016. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3017. export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  3018. }
  3019. tc-arch ()
  3020. {
  3021. tc-ninja_magic_to_arch portage "$@"
  3022. }
  3023. tc-arch-kernel ()
  3024. {
  3025. tc-ninja_magic_to_arch kern "$@"
  3026. }
  3027. tc-endian ()
  3028. {
  3029. local host=$1;
  3030. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3031. host=${host%%-*};
  3032. case ${host} in
  3033. aarch64*be)
  3034. echo big
  3035. ;;
  3036. aarch64)
  3037. echo little
  3038. ;;
  3039. alpha*)
  3040. echo big
  3041. ;;
  3042. arm*b*)
  3043. echo big
  3044. ;;
  3045. arm*)
  3046. echo little
  3047. ;;
  3048. cris*)
  3049. echo little
  3050. ;;
  3051. hppa*)
  3052. echo big
  3053. ;;
  3054. i?86*)
  3055. echo little
  3056. ;;
  3057. ia64*)
  3058. echo little
  3059. ;;
  3060. m68*)
  3061. echo big
  3062. ;;
  3063. mips*l*)
  3064. echo little
  3065. ;;
  3066. mips*)
  3067. echo big
  3068. ;;
  3069. powerpc*)
  3070. echo big
  3071. ;;
  3072. s390*)
  3073. echo big
  3074. ;;
  3075. sh*b*)
  3076. echo big
  3077. ;;
  3078. sh*)
  3079. echo little
  3080. ;;
  3081. sparc*)
  3082. echo big
  3083. ;;
  3084. x86_64*)
  3085. echo little
  3086. ;;
  3087. *)
  3088. echo wtf
  3089. ;;
  3090. esac
  3091. }
  3092. tc-env_build ()
  3093. {
  3094. tc-export_build_env;
  3095. CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
  3096. }
  3097. tc-export ()
  3098. {
  3099. local var;
  3100. for var in "$@";
  3101. do
  3102. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3103. eval tc-get${var} > /dev/null;
  3104. done
  3105. }
  3106. tc-export_build_env ()
  3107. {
  3108. tc-export "$@";
  3109. : ${BUILD_CFLAGS:=-O1 -pipe};
  3110. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  3111. : ${BUILD_CPPFLAGS:=};
  3112. : ${BUILD_LDFLAGS:=};
  3113. export BUILD_{C,CXX,CPP,LD}FLAGS
  3114. }
  3115. tc-getAR ()
  3116. {
  3117. tc-getPROG AR ar "$@"
  3118. }
  3119. tc-getAS ()
  3120. {
  3121. tc-getPROG AS as "$@"
  3122. }
  3123. tc-getBUILD_AR ()
  3124. {
  3125. tc-getBUILD_PROG AR ar "$@"
  3126. }
  3127. tc-getBUILD_AS ()
  3128. {
  3129. tc-getBUILD_PROG AS as "$@"
  3130. }
  3131. tc-getBUILD_CC ()
  3132. {
  3133. tc-getBUILD_PROG CC gcc "$@"
  3134. }
  3135. tc-getBUILD_CPP ()
  3136. {
  3137. tc-getBUILD_PROG CPP cpp "$@"
  3138. }
  3139. tc-getBUILD_CXX ()
  3140. {
  3141. tc-getBUILD_PROG CXX g++ "$@"
  3142. }
  3143. tc-getBUILD_LD ()
  3144. {
  3145. tc-getBUILD_PROG LD ld "$@"
  3146. }
  3147. tc-getBUILD_NM ()
  3148. {
  3149. tc-getBUILD_PROG NM nm "$@"
  3150. }
  3151. tc-getBUILD_OBJCOPY ()
  3152. {
  3153. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3154. }
  3155. tc-getBUILD_PKG_CONFIG ()
  3156. {
  3157. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3158. }
  3159. tc-getBUILD_PROG ()
  3160. {
  3161. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  3162. }
  3163. tc-getBUILD_RANLIB ()
  3164. {
  3165. tc-getBUILD_PROG RANLIB ranlib "$@"
  3166. }
  3167. tc-getBUILD_STRIP ()
  3168. {
  3169. tc-getBUILD_PROG STRIP strip "$@"
  3170. }
  3171. tc-getCC ()
  3172. {
  3173. tc-getPROG CC gcc "$@"
  3174. }
  3175. tc-getCPP ()
  3176. {
  3177. tc-getPROG CPP cpp "$@"
  3178. }
  3179. tc-getCXX ()
  3180. {
  3181. tc-getPROG CXX g++ "$@"
  3182. }
  3183. tc-getDLLWRAP ()
  3184. {
  3185. tc-getPROG DLLWRAP dllwrap "$@"
  3186. }
  3187. tc-getF77 ()
  3188. {
  3189. tc-getPROG F77 gfortran "$@"
  3190. }
  3191. tc-getFC ()
  3192. {
  3193. tc-getPROG FC gfortran "$@"
  3194. }
  3195. tc-getGCJ ()
  3196. {
  3197. tc-getPROG GCJ gcj "$@"
  3198. }
  3199. tc-getLD ()
  3200. {
  3201. tc-getPROG LD ld "$@"
  3202. }
  3203. tc-getNM ()
  3204. {
  3205. tc-getPROG NM nm "$@"
  3206. }
  3207. tc-getOBJCOPY ()
  3208. {
  3209. tc-getPROG OBJCOPY objcopy "$@"
  3210. }
  3211. tc-getPKG_CONFIG ()
  3212. {
  3213. tc-getPROG PKG_CONFIG pkg-config "$@"
  3214. }
  3215. tc-getPROG ()
  3216. {
  3217. _tc-getPROG CHOST "$@"
  3218. }
  3219. tc-getRANLIB ()
  3220. {
  3221. tc-getPROG RANLIB ranlib "$@"
  3222. }
  3223. tc-getRC ()
  3224. {
  3225. tc-getPROG RC windres "$@"
  3226. }
  3227. tc-getSTRIP ()
  3228. {
  3229. tc-getPROG STRIP strip "$@"
  3230. }
  3231. tc-has-openmp ()
  3232. {
  3233. local base="${T}/test-tc-openmp";
  3234. cat > "${base}.c" <<-EOF
  3235. #include <omp.h>
  3236. int main() {
  3237. int nthreads, tid, ret = 0;
  3238. #pragma omp parallel private(nthreads, tid)
  3239. {
  3240. tid = omp_get_thread_num();
  3241. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3242. }
  3243. return ret;
  3244. }
  3245. EOF
  3246.  
  3247. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  3248. local ret=$?;
  3249. rm -f "${base}"*;
  3250. return ${ret}
  3251. }
  3252. tc-has-tls ()
  3253. {
  3254. local base="${T}/test-tc-tls";
  3255. cat > "${base}.c" <<-EOF
  3256. int foo(int *i) {
  3257. static __thread int j = 0;
  3258. return *i ? j : *i;
  3259. }
  3260. EOF
  3261.  
  3262. local flags;
  3263. case $1 in
  3264. -s)
  3265. flags="-S"
  3266. ;;
  3267. -c)
  3268. flags="-c"
  3269. ;;
  3270. -l)
  3271.  
  3272. ;;
  3273. -*)
  3274. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3275. ;;
  3276. esac;
  3277. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3278. [[ $1 == -* ]] && shift;
  3279. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  3280. local ret=$?;
  3281. rm -f "${base}"*;
  3282. return ${ret}
  3283. }
  3284. tc-is-cross-compiler ()
  3285. {
  3286. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  3287. }
  3288. tc-is-softfloat ()
  3289. {
  3290. local CTARGET=${CTARGET:-${CHOST}};
  3291. case ${CTARGET} in
  3292. bfin* | h8300*)
  3293. echo "only"
  3294. ;;
  3295. *)
  3296. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  3297. echo "yes";
  3298. else
  3299. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  3300. echo "softfp";
  3301. else
  3302. echo "no";
  3303. fi;
  3304. fi
  3305. ;;
  3306. esac
  3307. }
  3308. tc-is-static-only ()
  3309. {
  3310. local host=${CTARGET:-${CHOST}};
  3311. return $([[ ${host} == *-mint* ]])
  3312. }
  3313. tc-ninja_magic_to_arch ()
  3314. {
  3315. function ninj ()
  3316. {
  3317. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3318. };
  3319. local type=$1;
  3320. local host=$2;
  3321. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3322. local KV=${KV:-${KV_FULL}};
  3323. [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info";
  3324. case ${host} in
  3325. aarch64*)
  3326. ninj aarch64 arm
  3327. ;;
  3328. alpha*)
  3329. echo alpha
  3330. ;;
  3331. arm*)
  3332. echo arm
  3333. ;;
  3334. avr*)
  3335. ninj avr32 avr
  3336. ;;
  3337. bfin*)
  3338. ninj blackfin bfin
  3339. ;;
  3340. cris*)
  3341. echo cris
  3342. ;;
  3343. hppa*)
  3344. ninj parisc hppa
  3345. ;;
  3346. i?86*)
  3347. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  3348. echo i386;
  3349. else
  3350. echo x86;
  3351. fi
  3352. ;;
  3353. ia64*)
  3354. echo ia64
  3355. ;;
  3356. m68*)
  3357. echo m68k
  3358. ;;
  3359. mips*)
  3360. echo mips
  3361. ;;
  3362. nios2*)
  3363. echo nios2
  3364. ;;
  3365. nios*)
  3366. echo nios
  3367. ;;
  3368. powerpc*)
  3369. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  3370. echo powerpc;
  3371. else
  3372. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  3373. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3374. echo powerpc;
  3375. else
  3376. echo ppc;
  3377. fi;
  3378. else
  3379. if [[ ${host} == powerpc64* ]]; then
  3380. echo ppc64;
  3381. else
  3382. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3383. ninj ppc64 ppc;
  3384. else
  3385. echo ppc;
  3386. fi;
  3387. fi;
  3388. fi;
  3389. fi
  3390. ;;
  3391. s390*)
  3392. echo s390
  3393. ;;
  3394. sh64*)
  3395. ninj sh64 sh
  3396. ;;
  3397. sh*)
  3398. echo sh
  3399. ;;
  3400. sparc64*)
  3401. ninj sparc64 sparc
  3402. ;;
  3403. sparc*)
  3404. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3405. ;;
  3406. vax*)
  3407. echo vax
  3408. ;;
  3409. x86_64*freebsd*)
  3410. echo amd64
  3411. ;;
  3412. x86_64*)
  3413. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  3414. echo x86;
  3415. else
  3416. ninj x86_64 amd64;
  3417. fi
  3418. ;;
  3419. *)
  3420. echo unknown
  3421. ;;
  3422. esac
  3423. }
  3424. test-flag-CC ()
  3425. {
  3426. test-flag-PROG "CC" "$1"
  3427. }
  3428. test-flag-CXX ()
  3429. {
  3430. test-flag-PROG "CXX" "$1"
  3431. }
  3432. test-flag-F77 ()
  3433. {
  3434. test-flag-PROG "F77" "$1"
  3435. }
  3436. test-flag-FC ()
  3437. {
  3438. test-flag-PROG "FC" "$1"
  3439. }
  3440. test-flag-PROG ()
  3441. {
  3442. local comp=$1;
  3443. local flag=$2;
  3444. [[ -z ${comp} || -z ${flag} ]] && return 1;
  3445. local PROG=$(tc-get${comp});
  3446. ${PROG} "${flag}" -c -o /dev/null -xc /dev/null > /dev/null 2>&1
  3447. }
  3448. test-flags ()
  3449. {
  3450. test-flags-CC "$@"
  3451. }
  3452. test-flags-CC ()
  3453. {
  3454. test-flags-PROG "CC" "$@"
  3455. }
  3456. test-flags-CXX ()
  3457. {
  3458. test-flags-PROG "CXX" "$@"
  3459. }
  3460. test-flags-F77 ()
  3461. {
  3462. test-flags-PROG "F77" "$@"
  3463. }
  3464. test-flags-FC ()
  3465. {
  3466. test-flags-PROG "FC" "$@"
  3467. }
  3468. test-flags-PROG ()
  3469. {
  3470. local comp=$1;
  3471. local flags;
  3472. local x;
  3473. shift;
  3474. [[ -z ${comp} ]] && return 1;
  3475. for x in "$@";
  3476. do
  3477. test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}";
  3478. done;
  3479. echo "${flags}";
  3480. [[ -n ${flags} ]]
  3481. }
  3482. test_version_info ()
  3483. {
  3484. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  3485. return 0;
  3486. else
  3487. return 1;
  3488. fi
  3489. }
  3490. use_if_iuse ()
  3491. {
  3492. in_iuse $1 || return 1;
  3493. use $1
  3494. }
  3495. usex ()
  3496. {
  3497. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  3498. }
  3499. validate_desktop_entries ()
  3500. {
  3501. if [[ -x /usr/bin/desktop-file-validate ]]; then
  3502. einfo "Checking desktop entry validity";
  3503. local directories="";
  3504. for d in /usr/share/applications $@;
  3505. do
  3506. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  3507. done;
  3508. if [[ -n ${directories} ]]; then
  3509. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  3510. do
  3511. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  3512. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  3513. done;
  3514. fi;
  3515. echo "";
  3516. else
  3517. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  3518. fi
  3519. }
  3520. version_compare ()
  3521. {
  3522. eshopts_push -s extglob;
  3523. local ver_a=${1} ver_b=${2} parts_a parts_b;
  3524. local cur_tok_a cur_tok_b num_part_a num_part_b;
  3525. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  3526. parts_a=($(get_all_version_components "${ver_a}" ));
  3527. parts_b=($(get_all_version_components "${ver_b}" ));
  3528. local -i inf_loop=0;
  3529. while true; do
  3530. inf_loop+=1;
  3531. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3532. prev_idx_a=cur_idx_a;
  3533. prev_idx_b=cur_idx_b;
  3534. cur_tok_a=${parts_a[cur_idx_a]};
  3535. cur_tok_b=${parts_b[cur_idx_b]};
  3536. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  3537. cur_idx_a+=1;
  3538. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  3539. else
  3540. cur_tok_a=;
  3541. fi;
  3542. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  3543. cur_idx_b+=1;
  3544. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  3545. else
  3546. cur_tok_b=;
  3547. fi;
  3548. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  3549. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  3550. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  3551. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  3552. cur_tok_a=${cur_tok_a%%+(0)};
  3553. cur_tok_b=${cur_tok_b%%+(0)};
  3554. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  3555. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  3556. else
  3557. cur_tok_a=${cur_tok_a##+(0)};
  3558. cur_tok_b=${cur_tok_b##+(0)};
  3559. : ${cur_tok_a:=0};
  3560. : ${cur_tok_b:=0};
  3561. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  3562. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  3563. fi;
  3564. done;
  3565. local letter_a=;
  3566. letter_a=${parts_a[cur_idx_a]};
  3567. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  3568. cur_idx_a+=1;
  3569. else
  3570. letter_a=@;
  3571. fi;
  3572. local letter_b=;
  3573. letter_b=${parts_b[cur_idx_b]};
  3574. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  3575. cur_idx_b+=1;
  3576. else
  3577. letter_b=@;
  3578. fi;
  3579. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  3580. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  3581. inf_loop=0;
  3582. while true; do
  3583. inf_loop+=1;
  3584. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3585. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  3586. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  3587. cur_tok_a=${parts_a[cur_idx_a]};
  3588. cur_tok_b=${parts_b[cur_idx_b]};
  3589. num_part_a=0;
  3590. num_part_b=0;
  3591. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  3592. cur_idx_a+=1;
  3593. num_part_a=${cur_tok_a##+([a-z])};
  3594. num_part_a=${num_part_a##+(0)};
  3595. : ${num_part_a:=0};
  3596. cur_tok_a=${cur_tok_a%%+([0-9])};
  3597. else
  3598. cur_tok_a=;
  3599. fi;
  3600. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  3601. cur_idx_b+=1;
  3602. num_part_b=${cur_tok_b##+([a-z])};
  3603. num_part_b=${num_part_b##+(0)};
  3604. : ${num_part_b:=0};
  3605. cur_tok_b=${cur_tok_b%%+([0-9])};
  3606. else
  3607. cur_tok_b=;
  3608. fi;
  3609. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  3610. local suffix;
  3611. for suffix in alpha beta pre rc "" p;
  3612. do
  3613. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  3614. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  3615. done;
  3616. else
  3617. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  3618. break;
  3619. else
  3620. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3621. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3622. fi;
  3623. fi;
  3624. done;
  3625. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  3626. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  3627. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  3628. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  3629. fi;
  3630. num_part_a=${parts_a[cur_idx_a]#r};
  3631. num_part_a=${num_part_a##+(0)};
  3632. : ${num_part_a:=0};
  3633. num_part_b=${parts_b[cur_idx_b]#r};
  3634. num_part_b=${num_part_b##+(0)};
  3635. : ${num_part_b:=0};
  3636. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3637. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3638. eshopts_pop;
  3639. return 2
  3640. }
  3641. version_format_string ()
  3642. {
  3643. local fstr=$1;
  3644. shift;
  3645. set -- $(get_version_components "$@");
  3646. eval echo "${fstr}"
  3647. }
  3648. version_is_at_least ()
  3649. {
  3650. local want_s="$1" have_s="${2:-${PVR}}" r;
  3651. version_compare "${want_s}" "${have_s}";
  3652. r=$?;
  3653. case $r in
  3654. 1 | 2)
  3655. return 0
  3656. ;;
  3657. 3)
  3658. return 1
  3659. ;;
  3660. *)
  3661. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  3662. ;;
  3663. esac
  3664. }
  3665. version_sort ()
  3666. {
  3667. eshopts_push -s extglob;
  3668. local items=;
  3669. local -i left=0;
  3670. items=("$@");
  3671. while ((left < ${#items[@]})); do
  3672. local -i lowest_idx=left;
  3673. local -i idx=lowest_idx+1;
  3674. while ((idx < ${#items[@]})); do
  3675. version_compare "${items[lowest_idx]}" "${items[idx]}";
  3676. [[ $? -eq 3 ]] && lowest_idx=idx;
  3677. idx+=1;
  3678. done;
  3679. local tmp=${items[lowest_idx]};
  3680. items[lowest_idx]=${items[left]};
  3681. items[left]=${tmp};
  3682. left+=1;
  3683. done;
  3684. echo ${items[@]};
  3685. eshopts_pop
  3686. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement