Advertisement
Robert_s

Environment

Dec 9th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 141.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 APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
  5. declare -x ARCH="amd64"
  6. declare -- BACKPORTS="2"
  7. declare -x BOOTSTRAP_USE="cxx unicode multilib"
  8. declare -x CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump"
  9. declare -x CAMERAS="ptp2"
  10. declare -x CBUILD="x86_64-pc-linux-gnu"
  11. declare -x CFLAGS="-O2 -pipe"
  12. declare -x CFLAGS_amd64="-m64"
  13. declare -x CFLAGS_default
  14. declare -x CFLAGS_x32="-mx32"
  15. declare -x CFLAGS_x86="-m32"
  16. declare -x CHOST="x86_64-pc-linux-gnu"
  17. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  18. declare -x CHOST_default="x86_64-pc-linux-gnu"
  19. declare -x CHOST_x32="x86_64-pc-linux-gnu"
  20. declare -x CHOST_x86="i686-pc-linux-gnu"
  21. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  22. declare -- COMMON_TARGETS="i386 x86_64 arm cris m68k microblaze mips mipsel ppc ppc64 sh4 sh4eb sparc sparc64"
  23. declare -x CROSSCOMPILE_OPTS=""
  24. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  25. declare -x CXXFLAGS="-O2 -pipe"
  26. declare -x DEFAULT_ABI="amd64"
  27. declare -x DEFINED_PHASES=" configure install postinst prepare setup"
  28. declare DEPEND="
  29. !app-emulation/kqemu
  30. !app-emulation/qemu
  31. !app-emulation/qemu-softmmu
  32. !app-emulation/qemu-user
  33. !app-emulation/qemu-kvm-spice
  34. sys-apps/pciutils
  35. >=sys-apps/util-linux-2.16.0
  36. sys-libs/zlib
  37. aio? ( dev-libs/libaio )
  38. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  39. bluetooth? ( net-wireless/bluez )
  40. brltty? ( app-accessibility/brltty )
  41. curl? ( net-misc/curl )
  42. esd? ( media-sound/esound )
  43. fdt? ( >=sys-apps/dtc-1.2.0 )
  44. jpeg? ( virtual/jpeg )
  45. ncurses? ( sys-libs/ncurses )
  46. png? ( media-libs/libpng )
  47. pulseaudio? ( media-sound/pulseaudio )
  48. qemu-ifup? ( sys-apps/iproute2 net-misc/bridge-utils )
  49. rbd? ( sys-cluster/ceph )
  50. sasl? ( dev-libs/cyrus-sasl )
  51. sdl? ( >=media-libs/libsdl-1.2.11[X] )
  52. spice? ( app-emulation/spice )
  53. ssl? ( net-libs/gnutls )
  54. vde? ( net-misc/vde )
  55. xen? ( app-emulation/xen )
  56.  
  57. app-text/texi2html
  58. >=sys-kernel/linux-headers-2.6.35
  59. ssl? ( dev-util/pkgconfig )
  60. "
  61. declare DESCRIPTION="QEMU + Kernel-based Virtual Machine userland tools"
  62. declare -x DESTTREE="/usr"
  63. declare -x DIROPTIONS="-m0755"
  64. declare -x EAPI="2"
  65. declare -x ELIBC="glibc"
  66. declare -- EPATCH_EXCLUDE=""
  67. declare -- EPATCH_FORCE="no"
  68. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  69. declare -- EPATCH_OPTS="-g0 -E --no-backup-if-mismatch"
  70. declare -- EPATCH_SINGLE_MSG=""
  71. declare -- EPATCH_SOURCE="/var/tmp/portage/app-emulation/qemu-kvm-0.14.1-r2/work/patch"
  72. declare -- EPATCH_SUFFIX="patch.bz2"
  73. declare -x EXEOPTIONS="-m0755"
  74. declare -x FCFLAGS=""
  75. 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}\""
  76. declare -x FFLAGS=""
  77. declare -x GCC_SPECS=""
  78. 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"
  79. declare -x GRUB_PLATFORMS=""
  80. declare -x GTK2_RC_FILES="/home/robert/.gtkrc-2.0:/home/robert/.kde/share/config/gtkrc-2.0:/etc/gtk-2.0/gtkrc"
  81. declare HOMEPAGE="http://www.linux-kvm.org"
  82. declare -x INHERITED=" toolchain-funcs multilib portability user eutils flag-o-matic versionator linux-info"
  83. declare -x INPUT_DEVICES="keyboard mouse evdev"
  84. declare -x INSDESTTREE=""
  85. declare -x INSOPTIONS="-m0644"
  86. declare IUSE="+aio alsa bluetooth brltty curl debug esd fdt hardened jpeg ncurses png pulseaudio qemu-ifup rbd sasl sdl spice ssl threads vde +vhost-net xen +qemu_softmmu_targets_x86_64 qemu_softmmu_targets_i386 qemu_softmmu_targets_arm qemu_softmmu_targets_cris qemu_softmmu_targets_m68k qemu_softmmu_targets_microblaze qemu_softmmu_targets_mips qemu_softmmu_targets_mipsel qemu_softmmu_targets_ppc qemu_softmmu_targets_ppc64 qemu_softmmu_targets_sh4 qemu_softmmu_targets_sh4eb qemu_softmmu_targets_sparc qemu_softmmu_targets_sparc64 qemu_softmmu_targets_mips64 qemu_softmmu_targets_mips64el qemu_softmmu_targets_ppcemb qemu_user_targets_i386 qemu_user_targets_x86_64 qemu_user_targets_arm qemu_user_targets_cris qemu_user_targets_m68k qemu_user_targets_microblaze qemu_user_targets_mips qemu_user_targets_mipsel qemu_user_targets_ppc qemu_user_targets_ppc64 qemu_user_targets_sh4 qemu_user_targets_sh4eb qemu_user_targets_sparc qemu_user_targets_sparc64 qemu_user_targets_alpha qemu_user_targets_armeb qemu_user_targets_ppc64abi32 qemu_user_targets_sparc32plus "
  87. declare -- IUSE_SOFTMMU_TARGETS="i386 x86_64 arm cris m68k microblaze mips mipsel ppc ppc64 sh4 sh4eb sparc sparc64 mips64 mips64el ppcemb"
  88. declare -- IUSE_USER_TARGETS="i386 x86_64 arm cris m68k microblaze mips mipsel ppc ppc64 sh4 sh4eb sparc sparc64 alpha armeb ppc64abi32 sparc32plus"
  89. declare -x KERNEL="linux"
  90. declare -x KERNEL_ABI="amd64"
  91. declare -- KERNEL_DIR="/usr/src/linux"
  92. declare -- KERNEL_MAKEFILE="/usr/src/linux/Makefile"
  93. declare -x KEYWORDS="amd64 ~ppc ~ppc64 x86"
  94. declare -x KV="3.0.6-gentoo"
  95. declare -- KV_DIR="/usr/src/linux"
  96. declare -- KV_EXTRA="-gentoo"
  97. declare -- KV_FULL="3.0.6-gentoo"
  98. declare -- KV_LOCAL=""
  99. declare -- KV_MAJOR="3"
  100. declare -- KV_MINOR="0"
  101. declare -- KV_OUT_DIR="/lib/modules/3.0.6-gentoo/build"
  102. declare -- KV_PATCH="6"
  103. declare -x LANG="en_AU"
  104. declare -x LCD_DEVICES=""
  105. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  106. declare -x LDFLAGS_amd64="-m elf_x86_64"
  107. declare -x LDFLAGS_default
  108. declare -x LDFLAGS_x32="-m elf32_x86_64"
  109. declare -x LDFLAGS_x86="-m elf_i386"
  110. declare -x LIBDIR_amd64="lib64"
  111. declare -x LIBDIR_amd64_fbsd="lib64"
  112. declare -x LIBDIR_default="lib"
  113. declare -x LIBDIR_n32="lib32"
  114. declare -x LIBDIR_n64="lib64"
  115. declare -x LIBDIR_o32="lib"
  116. declare -x LIBDIR_ppc="lib32"
  117. declare -x LIBDIR_ppc64="lib64"
  118. declare -x LIBDIR_s390="lib32"
  119. declare -x LIBDIR_s390x="lib64"
  120. declare -x LIBDIR_sparc32="lib32"
  121. declare -x LIBDIR_sparc64="lib64"
  122. declare -x LIBDIR_x32="libx32"
  123. declare -x LIBDIR_x86="lib32"
  124. declare -x LIBDIR_x86_fbsd="lib32"
  125. declare -x LIBOPTIONS="-m0644"
  126. declare -x LICENSE="GPL-2"
  127. declare -x MAIL="/var/mail/robert"
  128. declare -x MAKEOPTS="-j3"
  129. declare -x MULTILIB_ABIS="amd64 x86"
  130. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  131. 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"
  132. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  133. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  134. declare -- OUTPUT_DIR="/lib/modules/3.0.6-gentoo/build"
  135. declare -x PATH="/usr/lib64/ccache/bin:/usr/lib64/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3"
  136. declare PDEPEND=" "
  137. declare -x PHP_TARGETS=""
  138. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  139. declare -x PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
  140. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  141. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/qemu-kvm-0.14.1-r2/html")'
  142. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
  143. declare -x PROPERTIES=""
  144. declare -x PROVIDE=""
  145. declare -x PYTHONDONTWRITEBYTECODE="1"
  146. declare -x QEMU_SOFTMMU_TARGETS="i386 x86_64"
  147. declare -x QEMU_USER_TARGETS="i386 x86_64"
  148. declare -x RDEPEND="
  149. !app-emulation/kqemu
  150. !app-emulation/qemu
  151. !app-emulation/qemu-softmmu
  152. !app-emulation/qemu-user
  153. !app-emulation/qemu-kvm-spice
  154. sys-apps/pciutils
  155. >=sys-apps/util-linux-2.16.0
  156. sys-libs/zlib
  157. aio? ( dev-libs/libaio )
  158. alsa? ( >=media-libs/alsa-lib-1.0.13 )
  159. bluetooth? ( net-wireless/bluez )
  160. brltty? ( app-accessibility/brltty )
  161. curl? ( net-misc/curl )
  162. esd? ( media-sound/esound )
  163. fdt? ( >=sys-apps/dtc-1.2.0 )
  164. jpeg? ( virtual/jpeg )
  165. ncurses? ( sys-libs/ncurses )
  166. png? ( media-libs/libpng )
  167. pulseaudio? ( media-sound/pulseaudio )
  168. qemu-ifup? ( sys-apps/iproute2 net-misc/bridge-utils )
  169. rbd? ( sys-cluster/ceph )
  170. sasl? ( dev-libs/cyrus-sasl )
  171. sdl? ( >=media-libs/libsdl-1.2.11[X] )
  172. spice? ( app-emulation/spice )
  173. ssl? ( net-libs/gnutls )
  174. vde? ( net-misc/vde )
  175. xen? ( app-emulation/xen )
  176. "
  177. declare REQUIRED_USE=" "
  178. declare -x RESTRICT="test"
  179. 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}\""
  180. declare -x RUBY_TARGETS=""
  181. declare -x S="/var/tmp/portage/app-emulation/qemu-kvm-0.14.1-r2/work/qemu-kvm-0.14.1"
  182. declare -x SANDBOX_DEBUG="0"
  183. declare -x SANDBOX_DENY=""
  184. declare -x SANDBOX_PID="30701"
  185. declare -x SANDBOX_PREDICT="/var/tmp/portage/app-emulation/qemu-kvm-0.14.1-r2/homedir:/dev/crypto:/var/cache/fontconfig"
  186. declare -x SANDBOX_READ="/:/dev/stdin:/var/cache/ccache:/var/tmp"
  187. declare -x SANDBOX_VERBOSE="1"
  188. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/stderr:/dev/stdout:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/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/cache/ccache:/var/tmp:/var/tmp/:/var/tmp/portage/app-emulation/qemu-kvm-0.14.1-r2/homedir/.bash_history"
  189. declare -x SLOT="0"
  190. declare SRC_URI="mirror://sourceforge/kvm/qemu-kvm/qemu-kvm-0.14.1.tar.gz
  191. http://dev.gentoo.org/~cardoe/distfiles/qemu-kvm-0.14.1-backports-2.tar.bz2"
  192. declare -x SSH_CLIENT="192.168.2.20 49513 22"
  193. declare -x SSH_CONNECTION="192.168.2.20 49513 192.168.2.40 22"
  194. declare -x SSH_TTY="/dev/pts/0"
  195. declare -x SYMLINK_LIB="yes"
  196. declare -x USE="aio amd64 elibc_glibc jpeg kernel_linux multilib ncurses png qemu_softmmu_targets_i386 qemu_softmmu_targets_x86_64 qemu_user_targets_i386 qemu_user_targets_x86_64 ssl userland_GNU vhost-net"
  197. declare -x USERLAND="GNU"
  198. declare -x VIDEO_CARDS=""
  199. 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"
  200. declare -- _="PKG_INSTALL_MASK"
  201. declare -x _E_DOCDESTTREE_=""
  202. declare -x _E_EXEDESTTREE_=""
  203. declare -x _LINUX_CONFIG_EXISTS_DONE="1"
  204. declare -- ___ECLASS_RECUR_MULTILIB="yes"
  205. declare -- ___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes"
  206. declare -- get_version_warning_done=""
  207. declare -- softmmu_targets=" i386-softmmu x86_64-softmmu"
  208. declare -- target="sparc32plus"
  209. __versionator__test_version_compare ()
  210. {
  211. eshopts_push -s extglob;
  212. local lt=1 eq=2 gt=3 p q;
  213. function __versionator__test_version_compare_t ()
  214. {
  215. version_compare "${1}" "${3}";
  216. local r=$?;
  217. [[ ${r} -eq ${2} ]] || echo "FAIL: ${@} (got ${r} exp ${2})"
  218. };
  219. echo "
  220. 0 $lt 1
  221. 1 $lt 2
  222. 2 $gt 1
  223. 2 $eq 2
  224. 0 $eq 0
  225. 10 $lt 20
  226. 68 $eq 068
  227. 068 $gt 67
  228. 068 $lt 69
  229.  
  230. 1.0 $lt 2.0
  231. 2.0 $eq 2.0
  232. 2.0 $gt 1.0
  233.  
  234. 1.0 $gt 0.0
  235. 0.0 $eq 0.0
  236. 0.0 $lt 1.0
  237.  
  238. 0.1 $lt 0.2
  239. 0.2 $eq 0.2
  240. 0.3 $gt 0.2
  241.  
  242. 1.2 $lt 2.1
  243. 2.1 $gt 1.2
  244.  
  245. 1.2.3 $lt 1.2.4
  246. 1.2.4 $gt 1.2.3
  247.  
  248. 1.2.0 $gt 1.2
  249. 1.2.1 $gt 1.2
  250. 1.2 $lt 1.2.1
  251.  
  252. 1.2b $eq 1.2b
  253. 1.2b $lt 1.2c
  254. 1.2b $gt 1.2a
  255. 1.2b $gt 1.2
  256. 1.2 $lt 1.2a
  257.  
  258. 1.3 $gt 1.2a
  259. 1.3 $lt 1.3a
  260.  
  261. 1.0_alpha7 $lt 1.0_beta7
  262. 1.0_beta $lt 1.0_pre
  263. 1.0_pre5 $lt 1.0_rc2
  264. 1.0_rc2 $lt 1.0
  265.  
  266. 1.0_p1 $gt 1.0
  267. 1.0_p1-r1 $gt 1.0_p1
  268.  
  269. 1.0_alpha6-r1 $gt 1.0_alpha6
  270. 1.0_beta6-r1 $gt 1.0_alpha6-r2
  271.  
  272. 1.0_pre1 $lt 1.0_p1
  273.  
  274. 1.0p $gt 1.0_p1
  275. 1.0r $gt 1.0-r1
  276. 1.6.15 $gt 1.6.10-r2
  277. 1.6.10-r2 $lt 1.6.15
  278.  
  279. " | while read a b c; do
  280. [[ -z "${a}${b}${c}" ]] && continue;
  281. __versionator__test_version_compare_t "${a}" "${b}" "${c}";
  282. done;
  283. for q in "alpha beta pre rc=${lt};${gt}" "p=${gt};${lt}";
  284. do
  285. for p in ${q%%=*};
  286. do
  287. local c=${q##*=};
  288. local alt=${c%%;*} agt=${c##*;};
  289. __versionator__test_version_compare_t "1.0" $agt "1.0_${p}";
  290. __versionator__test_version_compare_t "1.0" $agt "1.0_${p}1";
  291. __versionator__test_version_compare_t "1.0" $agt "1.0_${p}068";
  292. __versionator__test_version_compare_t "2.0_${p}" $alt "2.0";
  293. __versionator__test_version_compare_t "2.0_${p}1" $alt "2.0";
  294. __versionator__test_version_compare_t "2.0_${p}068" $alt "2.0";
  295. __versionator__test_version_compare_t "1.0_${p}" $eq "1.0_${p}";
  296. __versionator__test_version_compare_t "0.0_${p}" $lt "0.0_${p}1";
  297. __versionator__test_version_compare_t "666_${p}3" $gt "666_${p}";
  298. __versionator__test_version_compare_t "1_${p}7" $lt "1_${p}8";
  299. __versionator__test_version_compare_t "1_${p}7" $eq "1_${p}7";
  300. __versionator__test_version_compare_t "1_${p}7" $gt "1_${p}6";
  301. __versionator__test_version_compare_t "1_${p}09" $eq "1_${p}9";
  302. __versionator__test_version_compare_t "1_${p}7-r0" $eq "1_${p}7";
  303. __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r1";
  304. __versionator__test_version_compare_t "1_${p}7-r0" $lt "1_${p}7-r01";
  305. __versionator__test_version_compare_t "1_${p}7-r01" $eq "1_${p}7-r1";
  306. __versionator__test_version_compare_t "1_${p}8-r1" $gt "1_${p}7-r100";
  307. __versionator__test_version_compare_t "1_${p}_alpha" $lt "1_${p}_beta";
  308. done;
  309. done;
  310. for p in "-r" "_p";
  311. do
  312. __versionator__test_version_compare_t "7.2${p}1" $lt "7.2${p}2";
  313. __versionator__test_version_compare_t "7.2${p}2" $gt "7.2${p}1";
  314. __versionator__test_version_compare_t "7.2${p}3" $gt "7.2${p}2";
  315. __versionator__test_version_compare_t "7.2${p}2" $lt "7.2${p}3";
  316. done;
  317. __versionator__test_version_compare_t "6.0" $gt "5.0";
  318. __versionator__test_version_compare_t "5.0" $gt "5";
  319. __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0";
  320. __versionator__test_version_compare_t "1.0-r1" $gt "1.0";
  321. __versionator__test_version_compare_t "999999999999999999999999999999" $gt "999999999999999999999999999998";
  322. __versionator__test_version_compare_t "1.0.0" $gt "1.0";
  323. __versionator__test_version_compare_t "1.0.0" $gt "1.0b";
  324. __versionator__test_version_compare_t "1b" $gt "1";
  325. __versionator__test_version_compare_t "1b_p1" $gt "1_p1";
  326. __versionator__test_version_compare_t "1.1b" $gt "1.1";
  327. __versionator__test_version_compare_t "12.2.5" $gt "12.2b";
  328. __versionator__test_version_compare_t "4.0" $lt "5.0";
  329. __versionator__test_version_compare_t "5" $lt "5.0";
  330. __versionator__test_version_compare_t "1.0_pre2" $lt "1.0_p2";
  331. __versionator__test_version_compare_t "1.0_alpha2" $lt "1.0_p2";
  332. __versionator__test_version_compare_t "1.0_alpha1" $lt "1.0_beta1";
  333. __versionator__test_version_compare_t "1.0_beta3" $lt "1.0_rc3";
  334. __versionator__test_version_compare_t "1.001000000000000000001" $lt "1.001000000000000000002";
  335. __versionator__test_version_compare_t "1.00100000000" $lt "1.0010000000000000001";
  336. __versionator__test_version_compare_t "999999999999999999999999999998" $lt "999999999999999999999999999999";
  337. __versionator__test_version_compare_t "1.01" $lt "1.1";
  338. __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1";
  339. __versionator__test_version_compare_t "1.0" $lt "1.0-r1";
  340. __versionator__test_version_compare_t "1.0" $lt "1.0.0";
  341. __versionator__test_version_compare_t "1.0b" $lt "1.0.0";
  342. __versionator__test_version_compare_t "1_p1" $lt "1b_p1";
  343. __versionator__test_version_compare_t "1" $lt "1b";
  344. __versionator__test_version_compare_t "1.1" $lt "1.1b";
  345. __versionator__test_version_compare_t "12.2b" $lt "12.2.5";
  346. __versionator__test_version_compare_t "4.0" $eq "4.0";
  347. __versionator__test_version_compare_t "1.0" $eq "1.0";
  348. __versionator__test_version_compare_t "1.0-r0" $eq "1.0";
  349. __versionator__test_version_compare_t "1.0" $eq "1.0-r0";
  350. __versionator__test_version_compare_t "1.0-r0" $eq "1.0-r0";
  351. __versionator__test_version_compare_t "1.0-r1" $eq "1.0-r1";
  352. __versionator__test_version_compare_t "1" $lt "2";
  353. __versionator__test_version_compare_t "1.0_alpha" $lt "1.0_pre";
  354. __versionator__test_version_compare_t "1.0_beta" $gt "1.0_alpha";
  355. __versionator__test_version_compare_t "0" $lt "0.0";
  356. __versionator__test_version_compare_t "1.0-r0" $lt "1.0-r1";
  357. __versionator__test_version_compare_t "1.0-r1" $gt "1.0-r0";
  358. __versionator__test_version_compare_t "1.0" $lt "1.0-r1";
  359. __versionator__test_version_compare_t "1.0-r1" $gt "1.0";
  360. __versionator__test_version_compare_t "1_p1" $lt "1b_p1";
  361. __versionator__test_version_compare_t "1b" $gt "1";
  362. __versionator__test_version_compare_t "1.1b" $gt "1.1";
  363. __versionator__test_version_compare_t "12.2b" $gt "12.2";
  364. __versionator__test_version_compare_t "1.0" $gt "1";
  365. __versionator__test_version_compare_t "1" $lt "1.0";
  366. __versionator__test_version_compare_t "1.0_alpha" $gt "1_alpha";
  367. __versionator__test_version_compare_t "1.0_alpha" $gt "1";
  368. __versionator__test_version_compare_t "1.0_alpha" $lt "1.0";
  369. __versionator__test_version_compare_t "1.2.0.0_alpha7-r4" $gt "1.2_alpha7-r4";
  370. __versionator__test_version_compare_t "0001" $eq "1";
  371. __versionator__test_version_compare_t "01" $eq "001";
  372. __versionator__test_version_compare_t "0001.1" $eq "1.1";
  373. __versionator__test_version_compare_t "01.01" $eq "1.01";
  374. __versionator__test_version_compare_t "1.010" $eq "1.01";
  375. __versionator__test_version_compare_t "1.00" $eq "1.0";
  376. __versionator__test_version_compare_t "1.0100" $eq "1.010";
  377. __versionator__test_version_compare_t "1" $eq "1-r0";
  378. __versionator__test_version_compare_t "1-r00" $eq "1-r0";
  379. eshopts_pop
  380. }
  381. _assert_pkg_ebuild_phase ()
  382. {
  383. case ${EBUILD_PHASE} in
  384. setup | preinst | postinst)
  385.  
  386. ;;
  387. *)
  388. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  389. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  390. eerror "Package fails at QA and at life. Please file a bug.";
  391. die "Bad package! $1 is only for use in some pkg_* functions!"
  392. ;;
  393. esac
  394. }
  395. _cdrom_locate_file_on_cd ()
  396. {
  397. local mline="";
  398. local showedmsg=0 showjolietmsg=0;
  399. while [[ -z ${CDROM_ROOT} ]]; do
  400. local i=0;
  401. local -a cdset=(${*//:/ });
  402. if [[ -n ${CDROM_SET} ]]; then
  403. cdset=(${cdset[${CDROM_SET}]});
  404. fi;
  405. while [[ -n ${cdset[${i}]} ]]; do
  406. local dir=$(dirname ${cdset[${i}]});
  407. local file=$(basename ${cdset[${i}]});
  408. local point= node= fs= foo=;
  409. while read point node fs foo; do
  410. [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] && continue;
  411. point=${point//\040/ };
  412. [[ ! -d ${point}/${dir} ]] && continue;
  413. [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue;
  414. export CDROM_ROOT=${point};
  415. export CDROM_SET=${i};
  416. export CDROM_MATCH=${cdset[${i}]};
  417. return;
  418. done <<< "$(get_mounts)";
  419. ((++i));
  420. done;
  421. echo;
  422. if [[ ${showedmsg} -eq 0 ]]; then
  423. if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
  424. if [[ -z ${CDROM_NAME} ]]; then
  425. einfo "Please insert+mount the cdrom for ${PN} now !";
  426. else
  427. einfo "Please insert+mount the ${CDROM_NAME} cdrom now !";
  428. fi;
  429. else
  430. if [[ -z ${CDROM_NAME_1} ]]; then
  431. einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !";
  432. else
  433. local var="CDROM_NAME_${CDROM_CURRENT_CD}";
  434. einfo "Please insert+mount the ${!var} cdrom now !";
  435. fi;
  436. fi;
  437. showedmsg=1;
  438. fi;
  439. einfo "Press return to scan for the cd again";
  440. einfo "or hit CTRL+C to abort the emerge.";
  441. echo;
  442. if [[ ${showjolietmsg} -eq 0 ]]; then
  443. showjolietmsg=1;
  444. else
  445. ewarn "If you are having trouble with the detection";
  446. ewarn "of your CD, it is possible that you do not have";
  447. ewarn "Joliet support enabled in your kernel. Please";
  448. ewarn "check that CONFIG_JOLIET is enabled in your kernel.";
  449. ebeep 5;
  450. fi;
  451. read || die "something is screwed with your system";
  452. done
  453. }
  454. _dead_portability_user_funcs ()
  455. {
  456. die "if you really need this, please file a bug for base-system@gentoo.org"
  457. }
  458. _epatch_draw_line ()
  459. {
  460. [[ -z $1 ]] && set "$(printf "%65s" '')";
  461. echo "${1//?/=}"
  462. }
  463. _filter-hardened ()
  464. {
  465. local f;
  466. for f in "$@";
  467. do
  468. case "${f}" in
  469. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  470. gcc-specs-pie || continue;
  471. is-flagq -nopie || append-flags -nopie
  472. ;;
  473. -fstack-protector)
  474. gcc-specs-ssp || continue;
  475. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  476. ;;
  477. -fstack-protector-all)
  478. gcc-specs-ssp-to-all || continue;
  479. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  480. ;;
  481. -fno-strict-overflow)
  482. gcc-specs-nostrict || continue;
  483. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  484. ;;
  485. esac;
  486. done
  487. }
  488. _filter-var ()
  489. {
  490. local f x VAR VAL;
  491. declare -a new;
  492. VAR=$1;
  493. shift;
  494. eval VAL=\${${VAR}};
  495. for f in ${VAL};
  496. do
  497. for x in "$@";
  498. do
  499. [[ ${f} == ${x} ]] && continue 2;
  500. done;
  501. eval new\[\${\#new\[@]}]=\${f};
  502. done;
  503. eval export ${VAR}=\${new\[*]}
  504. }
  505. _gcc-install-dir ()
  506. {
  507. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  508. }
  509. _gcc-specs-directive_raw ()
  510. {
  511. local cc=$(tc-getCC);
  512. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  513. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  514. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  515. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  516. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  517. { spec=spec $0 }
  518. END { print spec }';
  519. return 0
  520. }
  521. _gcc-specs-exists ()
  522. {
  523. [[ -f $(_gcc-install-dir)/$1 ]]
  524. }
  525. _gcc_fullversion ()
  526. {
  527. local ver="$1";
  528. shift;
  529. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  530. eval echo "$ver"
  531. }
  532. _is_flagq ()
  533. {
  534. local x;
  535. for x in ${!1};
  536. do
  537. [[ ${x} == $2 ]] && return 0;
  538. done;
  539. return 1
  540. }
  541. _tc-getPROG ()
  542. {
  543. local tuple=$1;
  544. local v var vars=$2;
  545. local prog=$3;
  546. var=${vars%% *};
  547. for v in ${vars};
  548. do
  549. if [[ -n ${!v} ]]; then
  550. export ${var}="${!v}";
  551. echo "${!v}";
  552. return 0;
  553. fi;
  554. done;
  555. local search=;
  556. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  557. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  558. [[ -n ${search} ]] && prog=${search##*/};
  559. export ${var}=${prog};
  560. echo "${!var}"
  561. }
  562. _unpack_tar ()
  563. {
  564. if [ "${y}" == "tar" ]; then
  565. $1 -c -- "$srcdir$x" | tar xof -;
  566. assert_sigpipe_ok "$myfail";
  567. else
  568. local cwd_dest=${x##*/};
  569. cwd_dest=${cwd_dest%.*};
  570. $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail";
  571. fi
  572. }
  573. append-cflags ()
  574. {
  575. [[ $# -eq 0 ]] && return 0;
  576. export CFLAGS=$(test-flags-CC ${CFLAGS} "$@");
  577. return 0
  578. }
  579. append-cppflags ()
  580. {
  581. [[ $# -eq 0 ]] && return 0;
  582. export CPPFLAGS="${CPPFLAGS} $*";
  583. return 0
  584. }
  585. append-cxxflags ()
  586. {
  587. [[ $# -eq 0 ]] && return 0;
  588. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS} "$@");
  589. return 0
  590. }
  591. append-fflags ()
  592. {
  593. [[ $# -eq 0 ]] && return 0;
  594. export FFLAGS=$(test-flags-F77 ${FFLAGS} "$@");
  595. export FCFLAGS=$(test-flags-FC ${FCFLAGS} "$@");
  596. return 0
  597. }
  598. append-flags ()
  599. {
  600. [[ $# -eq 0 ]] && return 0;
  601. append-cflags "$@";
  602. append-cxxflags "$@";
  603. append-fflags "$@";
  604. return 0
  605. }
  606. append-ldflags ()
  607. {
  608. [[ $# -eq 0 ]] && return 0;
  609. local flag;
  610. for flag in "$@";
  611. do
  612. [[ ${flag} == -l* ]] && ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  613. done;
  614. export LDFLAGS="${LDFLAGS} $*";
  615. return 0
  616. }
  617. append-lfs-flags ()
  618. {
  619. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  620. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  621. }
  622. append-libs ()
  623. {
  624. [[ $# -eq 0 ]] && return 0;
  625. local flag;
  626. for flag in "$@";
  627. do
  628. [[ ${flag} == -l* ]] && flag=${flag#-l};
  629. export LIBS="${LIBS} -l${flag}";
  630. done;
  631. return 0
  632. }
  633. built_with_use ()
  634. {
  635. local hidden="no";
  636. if [[ $1 == "--hidden" ]]; then
  637. hidden="yes";
  638. shift;
  639. fi;
  640. local missing_action="die";
  641. if [[ $1 == "--missing" ]]; then
  642. missing_action=$2;
  643. shift;
  644. shift;
  645. case ${missing_action} in
  646. true | false | die)
  647.  
  648. ;;
  649. *)
  650. die "unknown action '${missing_action}'"
  651. ;;
  652. esac;
  653. fi;
  654. local opt=$1;
  655. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  656. local PKG=$(best_version $1);
  657. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  658. shift;
  659. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  660. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  661. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  662. case ${missing_action} in
  663. true)
  664. return 0
  665. ;;
  666. false)
  667. return 1
  668. ;;
  669. die)
  670. die "Unable to determine what USE flags $PKG was built with"
  671. ;;
  672. esac;
  673. fi;
  674. if [[ ${hidden} == "no" ]]; then
  675. local IUSE_BUILT=($(<"${IUSEFILE}"));
  676. local expand;
  677. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  678. do
  679. if [[ $1 == ${expand}_* ]]; then
  680. expand="";
  681. break;
  682. fi;
  683. done;
  684. if [[ -n ${expand} ]]; then
  685. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  686. case ${missing_action} in
  687. true)
  688. return 0
  689. ;;
  690. false)
  691. return 1
  692. ;;
  693. die)
  694. die "$PKG does not actually support the $1 USE flag!"
  695. ;;
  696. esac;
  697. fi;
  698. fi;
  699. fi;
  700. local USE_BUILT=$(<${USEFILE});
  701. while [[ $# -gt 0 ]]; do
  702. if [[ ${opt} = "-o" ]]; then
  703. has $1 ${USE_BUILT} && return 0;
  704. else
  705. has $1 ${USE_BUILT} || return 1;
  706. fi;
  707. shift;
  708. done;
  709. [[ ${opt} = "-a" ]]
  710. }
  711. cdrom_get_cds ()
  712. {
  713. local cdcnt=0;
  714. local f=;
  715. for f in "$@";
  716. do
  717. ((++cdcnt));
  718. export CDROM_CHECK_${cdcnt}="$f";
  719. done;
  720. export CDROM_TOTAL_CDS=${cdcnt};
  721. export CDROM_CURRENT_CD=1;
  722. if [[ -n ${CD_ROOT}${CD_ROOT_1} ]]; then
  723. local var=;
  724. cdcnt=0;
  725. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  726. ((++cdcnt));
  727. var="CD_ROOT_${cdcnt}";
  728. [[ -z ${!var} ]] && var="CD_ROOT";
  729. if [[ -z ${!var} ]]; then
  730. eerror "You must either use just the CD_ROOT";
  731. eerror "or specify ALL the CD_ROOT_X variables.";
  732. eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables.";
  733. die "could not locate CD_ROOT_${cdcnt}";
  734. fi;
  735. done;
  736. export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}};
  737. einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}";
  738. export CDROM_SET=-1;
  739. for f in ${CDROM_CHECK_1//:/ };
  740. do
  741. ((++CDROM_SET));
  742. [[ -e ${CDROM_ROOT}/${f} ]] && break;
  743. done;
  744. export CDROM_MATCH=${f};
  745. return;
  746. fi;
  747. if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
  748. einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}";
  749. echo;
  750. einfo "If you do not have the CD, but have the data files";
  751. einfo "mounted somewhere on your filesystem, just export";
  752. einfo "the variable CD_ROOT so that it points to the";
  753. einfo "directory containing the files.";
  754. echo;
  755. einfo "For example:";
  756. einfo "export CD_ROOT=/mnt/cdrom";
  757. echo;
  758. else
  759. if [[ -n ${CDROM_NAME_SET} ]]; then
  760. cdcnt=0;
  761. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  762. ((++cdcnt));
  763. export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}";
  764. done;
  765. fi;
  766. einfo "This package will need access to ${CDROM_TOTAL_CDS} cds.";
  767. cdcnt=0;
  768. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  769. ((++cdcnt));
  770. var="CDROM_NAME_${cdcnt}";
  771. [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}";
  772. done;
  773. echo;
  774. einfo "If you do not have the CDs, but have the data files";
  775. einfo "mounted somewhere on your filesystem, just export";
  776. einfo "the following variables so they point to the right place:";
  777. einfon "";
  778. cdcnt=0;
  779. while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
  780. ((++cdcnt));
  781. echo -n " CD_ROOT_${cdcnt}";
  782. done;
  783. echo;
  784. einfo "Or, if you have all the files in the same place, or";
  785. einfo "you only have one cdrom, you can export CD_ROOT";
  786. einfo "and that place will be used as the same data source";
  787. einfo "for all the CDs.";
  788. echo;
  789. einfo "For example:";
  790. einfo "export CD_ROOT_1=/mnt/cdrom";
  791. echo;
  792. fi;
  793. export CDROM_SET="";
  794. export CDROM_CURRENT_CD=0;
  795. cdrom_load_next_cd
  796. }
  797. cdrom_load_next_cd ()
  798. {
  799. local var;
  800. ((++CDROM_CURRENT_CD));
  801. unset CDROM_ROOT;
  802. var=CD_ROOT_${CDROM_CURRENT_CD};
  803. [[ -z ${!var} ]] && var="CD_ROOT";
  804. if [[ -z ${!var} ]]; then
  805. var="CDROM_CHECK_${CDROM_CURRENT_CD}";
  806. _cdrom_locate_file_on_cd ${!var};
  807. else
  808. export CDROM_ROOT=${!var};
  809. fi;
  810. einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
  811. }
  812. check_extra_config ()
  813. {
  814. local config negate die error reworkmodulenames;
  815. local soft_errors_count=0 hard_errors_count=0 config_required=0;
  816. local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  817. linux-info_get_any_version;
  818. for config in ${CONFIG_CHECK};
  819. do
  820. if [[ "${config:0:1}" != "~" ]]; then
  821. config_required=1;
  822. break;
  823. fi;
  824. done;
  825. if [[ ${config_required} == 0 ]]; then
  826. if ! linux_config_exists; then
  827. ewarn "Unable to check for the following kernel config options due";
  828. ewarn "to absence of any configured kernel sources or compiled";
  829. ewarn "config:";
  830. for config in ${CONFIG_CHECK};
  831. do
  832. local_error="ERROR_${config#\~}";
  833. msg="${!local_error}";
  834. if [[ "x${msg}" == "x" ]]; then
  835. local_error="WARNING_${config#\~}";
  836. msg="${!local_error}";
  837. fi;
  838. ewarn " - ${config#\~}${msg:+ - }${msg}";
  839. done;
  840. ewarn "You're on your own to make sure they are set if needed.";
  841. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  842. return 0;
  843. fi;
  844. else
  845. require_configured_kernel;
  846. fi;
  847. einfo "Checking for suitable kernel configuration options...";
  848. for config in ${CONFIG_CHECK};
  849. do
  850. die=1;
  851. error=0;
  852. negate=0;
  853. reworkmodulenames=0;
  854. if [[ ${config:0:1} == "~" ]]; then
  855. die=0;
  856. config=${config:1};
  857. else
  858. if [[ ${config:0:1} == "@" ]]; then
  859. die=0;
  860. reworkmodulenames=1;
  861. config=${config:1};
  862. fi;
  863. fi;
  864. if [[ ${config:0:1} == "!" ]]; then
  865. negate=1;
  866. config=${config:1};
  867. fi;
  868. if [[ ${negate} == 1 ]]; then
  869. linux_chkconfig_present ${config} && error=2;
  870. else
  871. if [[ ${reworkmodulenames} == 1 ]]; then
  872. local temp_config="${config//*:}" i n;
  873. config="${config//:*}";
  874. if linux_chkconfig_present ${config}; then
  875. for i in ${MODULE_NAMES};
  876. do
  877. n="${i//${temp_config}}";
  878. [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  879. done;
  880. error=2;
  881. fi;
  882. else
  883. linux_chkconfig_present ${config} || error=1;
  884. fi;
  885. fi;
  886. if [[ ${error} > 0 ]]; then
  887. local report_func="eerror" local_error;
  888. local_error="ERROR_${config}";
  889. local_error="${!local_error}";
  890. if [[ -z "${local_error}" ]]; then
  891. local_error="${config}_ERROR";
  892. local_error="${!local_error}";
  893. fi;
  894. if [[ ${die} == 0 && -z "${local_error}" ]]; then
  895. local_error="WARNING_${config}";
  896. local_error="${!local_error}";
  897. if [[ -n "${local_error}" ]]; then
  898. report_func="ewarn";
  899. fi;
  900. fi;
  901. if [[ -z "${local_error}" ]]; then
  902. [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  903. local_error="CONFIG_${config}:\t ${local_error}";
  904. fi;
  905. if [[ ${die} == 0 ]]; then
  906. ${report_func} " ${local_error}";
  907. soft_errors_count=$[soft_errors_count + 1];
  908. else
  909. ${report_func} " ${local_error}";
  910. hard_errors_count=$[hard_errors_count + 1];
  911. fi;
  912. fi;
  913. done;
  914. if [[ ${hard_errors_count} > 0 ]]; then
  915. eerror "Please check to make sure these options are set correctly.";
  916. eerror "Failure to do so may cause unexpected problems.";
  917. eerror "Once you have satisfied these options, please try merging";
  918. eerror "this package again.";
  919. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  920. die "Incorrect kernel configuration options";
  921. else
  922. if [[ ${soft_errors_count} > 0 ]]; then
  923. ewarn "Please check to make sure these options are set correctly.";
  924. ewarn "Failure to do so may cause unexpected problems.";
  925. else
  926. eend 0;
  927. fi;
  928. fi;
  929. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  930. }
  931. check_kernel_built ()
  932. {
  933. require_configured_kernel;
  934. get_version;
  935. if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]; then
  936. eerror "These sources have not yet been prepared.";
  937. eerror "We cannot build against an unprepared tree.";
  938. eerror "To resolve this, please type the following:";
  939. eerror;
  940. eerror "# cd ${KV_DIR}";
  941. eerror "# make oldconfig";
  942. eerror "# make modules_prepare";
  943. eerror;
  944. eerror "Then please try merging this module again.";
  945. die "Kernel sources need compiling first";
  946. fi
  947. }
  948. check_license ()
  949. {
  950. local lic=$1;
  951. if [ -z "${lic}" ]; then
  952. lic="${PORTDIR}/licenses/${LICENSE}";
  953. else
  954. if [ -e "${PORTDIR}/licenses/${lic}" ]; then
  955. lic="${PORTDIR}/licenses/${lic}";
  956. else
  957. if [ -e "${PWD}/${lic}" ]; then
  958. lic="${PWD}/${lic}";
  959. else
  960. if [ -e "${lic}" ]; then
  961. lic="${lic}";
  962. fi;
  963. fi;
  964. fi;
  965. fi;
  966. local l="`basename ${lic}`";
  967. local alic;
  968. eshopts_push -o noglob;
  969. for alic in ${ACCEPT_LICENSE};
  970. do
  971. if [[ ${alic} == ${l} ]]; then
  972. eshopts_pop;
  973. return 0;
  974. fi;
  975. done;
  976. eshopts_pop;
  977. [ ! -f "${lic}" ] && die "Could not find requested license ${lic}";
  978. local licmsg=$(emktemp);
  979. cat > ${licmsg} <<-EOF
  980. **********************************************************
  981. The following license outlines the terms of use of this
  982. package. You MUST accept this license for installation to
  983. continue. When you are done viewing, hit 'q'. If you
  984. CTRL+C out of this, the install will not run!
  985. **********************************************************
  986.  
  987. EOF
  988.  
  989. cat ${lic} >> ${licmsg};
  990. ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}";
  991. einfon "Do you accept the terms of this license (${l})? [yes/no] ";
  992. read alic;
  993. case ${alic} in
  994. yes | Yes | y | Y)
  995. return 0
  996. ;;
  997. *)
  998. echo;
  999. echo;
  1000. echo;
  1001. eerror "You MUST accept the license to continue! Exiting!";
  1002. die "Failed to accept license"
  1003. ;;
  1004. esac
  1005. }
  1006. check_modules_supported ()
  1007. {
  1008. require_configured_kernel;
  1009. get_version;
  1010. if ! linux_chkconfig_builtin "MODULES"; then
  1011. eerror "These sources do not support loading external modules.";
  1012. eerror "to be able to use this module please enable \"Loadable modules support\"";
  1013. eerror "in your kernel, recompile and then try merging this module again.";
  1014. die "No support for external modules in ${KV_FULL} config";
  1015. fi
  1016. }
  1017. check_zlibinflate ()
  1018. {
  1019. require_configured_kernel;
  1020. get_version;
  1021. local INFLATE;
  1022. local DEFLATE;
  1023. einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  1024. ebegin "checking ZLIB_INFLATE";
  1025. linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  1026. eend $?;
  1027. [ "$?" != 0 ] && die;
  1028. ebegin "checking ZLIB_DEFLATE";
  1029. linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  1030. eend $?;
  1031. [ "$?" != 0 ] && die;
  1032. local LINENO_START;
  1033. local LINENO_END;
  1034. local SYMBOLS;
  1035. local x;
  1036. LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  1037. LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  1038. (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ));
  1039. (( LINENO_END = $LINENO_END - 1 ));
  1040. SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  1041. for x in $SYMBOLS;
  1042. do
  1043. if [ "${!x}" = "y" ]; then
  1044. einfo "${x} ensures zlib is linked into your kernel - excellent";
  1045. return 0;
  1046. fi;
  1047. done;
  1048. eerror;
  1049. eerror "This kernel module requires ZLIB library support.";
  1050. eerror "You have enabled zlib support in your kernel, but haven't enabled";
  1051. eerror "enabled any option that will ensure that zlib is linked into your";
  1052. eerror "kernel.";
  1053. eerror;
  1054. eerror "Please ensure that you enable at least one of these options:";
  1055. eerror;
  1056. for x in $SYMBOLS;
  1057. do
  1058. eerror " * $x";
  1059. done;
  1060. eerror;
  1061. eerror "Please remember to recompile and install your kernel, and reboot";
  1062. eerror "into your new kernel before attempting to load this kernel module.";
  1063. die "Kernel doesn't include zlib support"
  1064. }
  1065. delete_all_version_separators ()
  1066. {
  1067. replace_all_version_separators "" "${1}"
  1068. }
  1069. delete_version_separator ()
  1070. {
  1071. replace_version_separator "${1}" "" "${2}"
  1072. }
  1073. dlopen_lib ()
  1074. {
  1075. case "${CHOST}" in
  1076. *-linux-gnu* | *-linux-uclibc | *-interix*)
  1077. echo "-ldl"
  1078. ;;
  1079. esac
  1080. }
  1081. doicon ()
  1082. {
  1083. ( local i j ret;
  1084. insinto /usr/share/pixmaps;
  1085. for i in "$@";
  1086. do
  1087. if [[ -f ${i} ]]; then
  1088. doins "${i}";
  1089. ((ret+=$?));
  1090. else
  1091. if [[ -d ${i} ]]; then
  1092. for j in "${i}"/*.png;
  1093. do
  1094. doins "${j}";
  1095. ((ret+=$?));
  1096. done;
  1097. else
  1098. ((++ret));
  1099. fi;
  1100. fi;
  1101. done;
  1102. exit ${ret} )
  1103. }
  1104. domenu ()
  1105. {
  1106. ( local i j ret=0;
  1107. insinto /usr/share/applications;
  1108. for i in "$@";
  1109. do
  1110. if [[ -f ${i} ]]; then
  1111. doins "${i}";
  1112. ((ret+=$?));
  1113. else
  1114. if [[ -d ${i} ]]; then
  1115. for j in "${i}"/*.desktop;
  1116. do
  1117. doins "${j}";
  1118. ((ret+=$?));
  1119. done;
  1120. else
  1121. ((++ret));
  1122. fi;
  1123. fi;
  1124. done;
  1125. exit ${ret} )
  1126. }
  1127. dyn_pretend ()
  1128. {
  1129. if [[ -e $PORTAGE_BUILDDIR/.pretended ]]; then
  1130. vecho ">>> It appears that '$PF' is already pretended; skipping.";
  1131. vecho ">>> Remove '$PORTAGE_BUILDDIR/.pretended' to force pretend.";
  1132. return 0;
  1133. fi;
  1134. ebuild_phase pre_pkg_pretend;
  1135. ebuild_phase pkg_pretend;
  1136. >> "$PORTAGE_BUILDDIR/.pretended" || die "Failed to create $PORTAGE_BUILDDIR/.pretended";
  1137. ebuild_phase post_pkg_pretend
  1138. }
  1139. ebeep ()
  1140. {
  1141. local n;
  1142. if [[ -z ${EBEEP_IGNORE} ]]; then
  1143. for ((n=1 ; n <= ${1:-5} ; n++))
  1144. do
  1145. echo -ne "\a";
  1146. sleep 0.1 &>/dev/null;
  1147. sleep 0,1 &>/dev/null;
  1148. echo -ne "\a";
  1149. sleep 1;
  1150. done;
  1151. fi
  1152. }
  1153. econf_build ()
  1154. {
  1155. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  1156. }
  1157. ecvs_clean ()
  1158. {
  1159. [[ -z $* ]] && set -- .;
  1160. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  1161. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  1162. }
  1163. edos2unix ()
  1164. {
  1165. [[ $# -eq 0 ]] && return 0;
  1166. sed -i 's/\r$//' -- "$@" || die
  1167. }
  1168. egetent ()
  1169. {
  1170. local db=$1 key=$2;
  1171. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  1172. case ${db} in
  1173. passwd | group)
  1174.  
  1175. ;;
  1176. *)
  1177. die "sorry, database '${db}' not yet supported; file a bug"
  1178. ;;
  1179. esac;
  1180. case ${CHOST} in
  1181. *-darwin[678])
  1182. case ${key} in
  1183. *[!0-9]*)
  1184. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  1185. ;;
  1186. *)
  1187. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  1188. ;;
  1189. esac
  1190. ;;
  1191. *-darwin*)
  1192. local mykey;
  1193. case ${db} in
  1194. passwd)
  1195. db="Users" mykey="UniqueID"
  1196. ;;
  1197. group)
  1198. db="Groups" mykey="PrimaryGroupID"
  1199. ;;
  1200. esac;
  1201. case ${key} in
  1202. *[!0-9]*)
  1203. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  1204. ;;
  1205. *)
  1206. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  1207. ;;
  1208. esac
  1209. ;;
  1210. *-freebsd* | *-dragonfly*)
  1211. case ${db} in
  1212. passwd)
  1213. db="user"
  1214. ;;
  1215. *)
  1216.  
  1217. ;;
  1218. esac;
  1219. local opts;
  1220. if [[ ${key} == [[:digit:]]* ]]; then
  1221. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  1222. fi;
  1223. pw show ${db} ${opts} "${key}" -q
  1224. ;;
  1225. *-netbsd* | *-openbsd*)
  1226. grep "${key}:\*:" /etc/${db}
  1227. ;;
  1228. *)
  1229. nscd -i "${db}" 2> /dev/null;
  1230. getent "${db}" "${key}"
  1231. ;;
  1232. esac
  1233. }
  1234. egethome ()
  1235. {
  1236. local pos;
  1237. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  1238. case ${CHOST} in
  1239. *-darwin* | *-freebsd* | *-dragonfly*)
  1240. pos=9
  1241. ;;
  1242. *)
  1243. pos=6
  1244. ;;
  1245. esac;
  1246. egetent passwd "$1" | cut -d: -f${pos}
  1247. }
  1248. egetshell ()
  1249. {
  1250. local pos;
  1251. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  1252. case ${CHOST} in
  1253. *-darwin* | *-freebsd* | *-dragonfly*)
  1254. pos=10
  1255. ;;
  1256. *)
  1257. pos=7
  1258. ;;
  1259. esac;
  1260. egetent passwd "$1" | cut -d: -f${pos}
  1261. }
  1262. emktemp ()
  1263. {
  1264. local exe="touch";
  1265. [[ $1 == -d ]] && exe="mkdir" && shift;
  1266. local topdir=$1;
  1267. if [[ -z ${topdir} ]]; then
  1268. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1269. fi;
  1270. if ! type -P mktemp > /dev/null; then
  1271. local tmp=/;
  1272. while [[ -e ${tmp} ]]; do
  1273. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1274. done;
  1275. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1276. echo "${tmp}";
  1277. else
  1278. if [[ ${exe} == "touch" ]]; then
  1279. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1280. else
  1281. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1282. fi;
  1283. fi
  1284. }
  1285. enewgroup ()
  1286. {
  1287. _assert_pkg_ebuild_phase ${FUNCNAME};
  1288. local egroup=$1;
  1289. shift;
  1290. if [[ -z ${egroup} ]]; then
  1291. eerror "No group specified !";
  1292. die "Cannot call enewgroup without a group";
  1293. fi;
  1294. if [[ -n $(egetent group "${egroup}") ]]; then
  1295. return 0;
  1296. fi;
  1297. einfo "Adding group '${egroup}' to your system ...";
  1298. local egid=$1;
  1299. shift;
  1300. if [[ ! -z ${egid} ]]; then
  1301. if [[ ${egid} -gt 0 ]]; then
  1302. if [[ -n $(egetent group ${egid}) ]]; then
  1303. egid="next available; requested gid taken";
  1304. fi;
  1305. else
  1306. eerror "Groupid given but is not greater than 0 !";
  1307. die "${egid} is not a valid GID";
  1308. fi;
  1309. else
  1310. egid="next available";
  1311. fi;
  1312. einfo " - Groupid: ${egid}";
  1313. if [[ $# -gt 0 ]]; then
  1314. die "extra arguments no longer supported; please file a bug";
  1315. fi;
  1316. function _enewgroup_next_gid ()
  1317. {
  1318. if [[ ${egid} == *[!0-9]* ]]; then
  1319. for ((egid = 101; egid <= 999; egid++))
  1320. do
  1321. [[ -z $(egetent group ${egid}) ]] && break;
  1322. done;
  1323. fi
  1324. };
  1325. case ${CHOST} in
  1326. *-darwin*)
  1327. _enewgroup_next_gid;
  1328. dscl . create "/groups/${egroup}" gid ${egid};
  1329. dscl . create "/groups/${egroup}" passwd '*'
  1330. ;;
  1331. *-freebsd* | *-dragonfly*)
  1332. _enewgroup_next_gid;
  1333. pw groupadd "${egroup}" -g ${egid} || die
  1334. ;;
  1335. *-netbsd*)
  1336. _enewgroup_next_gid;
  1337. groupadd -g ${egid} "${egroup}" || die
  1338. ;;
  1339. *)
  1340. local opts;
  1341. if [[ ${egid} == *[!0-9]* ]]; then
  1342. opts="";
  1343. else
  1344. opts="-g ${egid}";
  1345. fi;
  1346. groupadd -r ${opts} "${egroup}" || die
  1347. ;;
  1348. esac
  1349. }
  1350. enewuser ()
  1351. {
  1352. _assert_pkg_ebuild_phase ${FUNCNAME};
  1353. local euser=$1;
  1354. shift;
  1355. if [[ -z ${euser} ]]; then
  1356. eerror "No username specified !";
  1357. die "Cannot call enewuser without a username";
  1358. fi;
  1359. if [[ -n $(egetent passwd "${euser}") ]]; then
  1360. return 0;
  1361. fi;
  1362. einfo "Adding user '${euser}' to your system ...";
  1363. local opts=();
  1364. local euid=$1;
  1365. shift;
  1366. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1367. if [[ ${euid} -gt 0 ]]; then
  1368. if [[ -n $(egetent passwd ${euid}) ]]; then
  1369. euid="next";
  1370. fi;
  1371. else
  1372. eerror "Userid given but is not greater than 0 !";
  1373. die "${euid} is not a valid UID";
  1374. fi;
  1375. else
  1376. euid="next";
  1377. fi;
  1378. if [[ ${euid} == "next" ]]; then
  1379. for ((euid = 101; euid <= 999; euid++))
  1380. do
  1381. [[ -z $(egetent passwd ${euid}) ]] && break;
  1382. done;
  1383. fi;
  1384. opts+=(-u ${euid});
  1385. einfo " - Userid: ${euid}";
  1386. local eshell=$1;
  1387. shift;
  1388. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1389. if [[ ! -e ${ROOT}${eshell} ]]; then
  1390. eerror "A shell was specified but it does not exist !";
  1391. die "${eshell} does not exist in ${ROOT}";
  1392. fi;
  1393. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1394. eerror "Do not specify ${eshell} yourself, use -1";
  1395. die "Pass '-1' as the shell parameter";
  1396. fi;
  1397. else
  1398. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1399. do
  1400. [[ -x ${ROOT}${eshell} ]] && break;
  1401. done;
  1402. if [[ ${eshell} == "/dev/null" ]]; then
  1403. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1404. case ${USERLAND} in
  1405. GNU)
  1406. eshell="/bin/false"
  1407. ;;
  1408. BSD)
  1409. eshell="/sbin/nologin"
  1410. ;;
  1411. Darwin)
  1412. eshell="/usr/sbin/nologin"
  1413. ;;
  1414. *)
  1415. die "Unable to identify the default shell for userland ${USERLAND}"
  1416. ;;
  1417. esac;
  1418. fi;
  1419. fi;
  1420. einfo " - Shell: ${eshell}";
  1421. opts+=(-s "${eshell}");
  1422. local ehome=$1;
  1423. shift;
  1424. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1425. ehome="/dev/null";
  1426. fi;
  1427. einfo " - Home: ${ehome}";
  1428. opts+=(-d "${ehome}");
  1429. local egroups=$1;
  1430. shift;
  1431. local g egroups_arr;
  1432. IFS="," read -r -a egroups_arr <<< "${egroups}";
  1433. shift;
  1434. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  1435. local defgroup exgroups;
  1436. for g in "${egroups_arr[@]}";
  1437. do
  1438. if [[ -z $(egetent group "${g}") ]]; then
  1439. eerror "You must add group ${g} to the system first";
  1440. die "${g} is not a valid GID";
  1441. fi;
  1442. if [[ -z ${defgroup} ]]; then
  1443. defgroup=${g};
  1444. else
  1445. exgroups+=",${g}";
  1446. fi;
  1447. done;
  1448. opts+=(-g "${defgroup}");
  1449. if [[ ! -z ${exgroups} ]]; then
  1450. opts+=(-G "${exgroups:1}");
  1451. fi;
  1452. fi;
  1453. einfo " - Groups: ${egroups:-(none)}";
  1454. if [[ $# -gt 0 ]]; then
  1455. die "extra arguments no longer supported; please file a bug";
  1456. else
  1457. local comment="added by portage for ${PN}";
  1458. opts+=(-c "${comment}");
  1459. einfo " - GECOS: ${comment}";
  1460. fi;
  1461. case ${CHOST} in
  1462. *-darwin*)
  1463. dscl . create "/users/${euser}" uid ${euid};
  1464. dscl . create "/users/${euser}" shell "${eshell}";
  1465. dscl . create "/users/${euser}" home "${ehome}";
  1466. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  1467. for g in "${egroups_arr[@]}";
  1468. do
  1469. dscl . merge "/groups/${g}" users "${euser}";
  1470. done
  1471. ;;
  1472. *-freebsd* | *-dragonfly*)
  1473. pw useradd "${euser}" "${opts[@]}" || die
  1474. ;;
  1475. *-netbsd*)
  1476. useradd "${opts[@]}" "${euser}" || die
  1477. ;;
  1478. *-openbsd*)
  1479. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  1480. ;;
  1481. *)
  1482. useradd -r "${opts[@]}" "${euser}" || die
  1483. ;;
  1484. esac;
  1485. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1486. einfo " - Creating ${ehome} in ${ROOT}";
  1487. mkdir -p "${ROOT}/${ehome}";
  1488. chown "${euser}" "${ROOT}/${ehome}";
  1489. chmod 755 "${ROOT}/${ehome}";
  1490. fi
  1491. }
  1492. epatch ()
  1493. {
  1494. function _epatch_draw_line ()
  1495. {
  1496. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1497. echo "${1//?/=}"
  1498. };
  1499. unset P4CONFIG P4PORT P4USER;
  1500. if [[ $# -gt 1 ]]; then
  1501. local m;
  1502. for m in "$@";
  1503. do
  1504. epatch "${m}";
  1505. done;
  1506. return 0;
  1507. fi;
  1508. local SINGLE_PATCH="no";
  1509. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1510. if [[ -f $1 ]]; then
  1511. SINGLE_PATCH="yes";
  1512. set -- "$1";
  1513. local EPATCH_SUFFIX=$1;
  1514. else
  1515. if [[ -d $1 ]]; then
  1516. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1517. else
  1518. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1519. epatch "${EPATCH_SOURCE}/$1";
  1520. return $?;
  1521. else
  1522. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1523. echo;
  1524. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1525. eerror;
  1526. eerror " ${EPATCH_SOURCE}";
  1527. eerror " ( ${EPATCH_SOURCE##*/} )";
  1528. echo;
  1529. die "Cannot find \$EPATCH_SOURCE!";
  1530. fi;
  1531. fi;
  1532. fi;
  1533. local PIPE_CMD;
  1534. case ${EPATCH_SUFFIX##*\.} in
  1535. xz)
  1536. PIPE_CMD="xz -dc"
  1537. ;;
  1538. lzma)
  1539. PIPE_CMD="lzma -dc"
  1540. ;;
  1541. bz2)
  1542. PIPE_CMD="bzip2 -dc"
  1543. ;;
  1544. gz | Z | z)
  1545. PIPE_CMD="gzip -dc"
  1546. ;;
  1547. ZIP | zip)
  1548. PIPE_CMD="unzip -p"
  1549. ;;
  1550. *)
  1551.  
  1552. ;;
  1553. esac;
  1554. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1555. local x;
  1556. for x in "$@";
  1557. do
  1558. [[ ! -f ${x} ]] && continue;
  1559. local patchname=${x##*/};
  1560. local a=${patchname#*_};
  1561. a=${a%%_*};
  1562. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1563. continue;
  1564. fi;
  1565. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  1566. eshopts_push -o noglob;
  1567. local ex;
  1568. for ex in ${EPATCH_EXCLUDE};
  1569. do
  1570. if [[ ${patchname} == ${ex} ]]; then
  1571. eshopts_pop;
  1572. continue 2;
  1573. fi;
  1574. done;
  1575. eshopts_pop;
  1576. fi;
  1577. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1578. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1579. einfo "${EPATCH_SINGLE_MSG}";
  1580. else
  1581. einfo "Applying ${patchname} ...";
  1582. fi;
  1583. else
  1584. einfo " ${patchname} ...";
  1585. fi;
  1586. local STDERR_TARGET="${T}/${patchname}.out";
  1587. if [[ -e ${STDERR_TARGET} ]]; then
  1588. STDERR_TARGET="${T}/${patchname}-$$.out";
  1589. fi;
  1590. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  1591. local count=0;
  1592. local PATCH_TARGET;
  1593. if [[ -n ${PIPE_CMD} ]]; then
  1594. PATCH_TARGET="${T}/$$.patch";
  1595. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1596. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1597. echo;
  1598. eerror "Could not extract patch!";
  1599. count=5;
  1600. break;
  1601. fi;
  1602. else
  1603. PATCH_TARGET=${x};
  1604. fi;
  1605. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1606. if [[ -n ${abs_paths} ]]; then
  1607. count=1;
  1608. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1609. fi;
  1610. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1611. if [[ -n ${rel_paths} ]]; then
  1612. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  1613. eqawarn " In the future this will cause a failure.";
  1614. eqawarn "${rel_paths}";
  1615. fi;
  1616. while [[ ${count} -lt 5 ]]; do
  1617. ( _epatch_draw_line "***** ${patchname} *****";
  1618. echo;
  1619. echo "PATCH COMMAND: patch -p${count} ${EPATCH_OPTS} < '${PATCH_TARGET}'";
  1620. echo;
  1621. _epatch_draw_line "***** ${patchname} *****";
  1622. patch -p${count} ${EPATCH_OPTS} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1623. ret=$?;
  1624. echo;
  1625. echo "patch program exited with status ${ret}";
  1626. exit ${ret} ) >> "${STDERR_TARGET}";
  1627. if [ $? -eq 0 ]; then
  1628. ( _epatch_draw_line "***** ${patchname} *****";
  1629. echo;
  1630. echo "ACTUALLY APPLYING ${patchname} ...";
  1631. echo;
  1632. _epatch_draw_line "***** ${patchname} *****";
  1633. patch -p${count} ${EPATCH_OPTS} < "${PATCH_TARGET}" 2>&1;
  1634. ret=$?;
  1635. echo;
  1636. echo "patch program exited with status ${ret}";
  1637. exit ${ret} ) >> "${STDERR_TARGET}";
  1638. if [ $? -ne 0 ]; then
  1639. echo;
  1640. eerror "A dry-run of patch command succeeded, but actually";
  1641. eerror "applying the patch failed!";
  1642. count=5;
  1643. fi;
  1644. break;
  1645. fi;
  1646. : $(( count++ ));
  1647. done;
  1648. if [[ -n ${PIPE_CMD} ]]; then
  1649. rm -f "${PATCH_TARGET}";
  1650. fi;
  1651. if [[ ${count} -ge 5 ]]; then
  1652. echo;
  1653. eerror "Failed Patch: ${patchname} !";
  1654. eerror " ( ${PATCH_TARGET} )";
  1655. eerror;
  1656. eerror "Include in your bugreport the contents of:";
  1657. eerror;
  1658. eerror " ${STDERR_TARGET}";
  1659. echo;
  1660. die "Failed Patch: ${patchname}!";
  1661. fi;
  1662. rm -f "${STDERR_TARGET}";
  1663. eend 0;
  1664. done;
  1665. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1666. :
  1667. }
  1668. epatch_user ()
  1669. {
  1670. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1671. local applied="${T}/epatch_user.applied";
  1672. [[ -e ${applied} ]] && return 2;
  1673. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1674. for check in {${CATEGORY}/${PF},${CATEGORY}/${P},${CATEGORY}/${PN}};
  1675. do
  1676. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1677. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1678. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1679. if [[ -d ${EPATCH_SOURCE} ]]; then
  1680. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1681. echo "${EPATCH_SOURCE}" > "${applied}";
  1682. return 0;
  1683. fi;
  1684. done;
  1685. echo "none" > "${applied}";
  1686. return 1
  1687. }
  1688. epause ()
  1689. {
  1690. [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
  1691. }
  1692. epunt_cxx ()
  1693. {
  1694. local dir=$1;
  1695. [[ -z ${dir} ]] && dir=${S};
  1696. ebegin "Removing useless C++ checks";
  1697. local f;
  1698. find "${dir}" -name configure | while read f; do
  1699. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  1700. done;
  1701. eend 0
  1702. }
  1703. eshopts_pop ()
  1704. {
  1705. [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments";
  1706. local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ));
  1707. [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair";
  1708. local s=${__ESHOPTS_SAVE__[$i]};
  1709. unset __ESHOPTS_SAVE__[$i];
  1710. if [[ ${s} == "shopt -"* ]]; then
  1711. eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}";
  1712. else
  1713. set +$- || die "eshopts_pop: sanity: invalid shell settings: $-";
  1714. set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}";
  1715. fi
  1716. }
  1717. eshopts_push ()
  1718. {
  1719. local i=${#__ESHOPTS_SAVE__[@]};
  1720. if [[ $1 == -[su] ]]; then
  1721. __ESHOPTS_SAVE__[$i]=$(shopt -p);
  1722. [[ $# -eq 0 ]] && return 0;
  1723. shopt "$@" || die "eshopts_push: bad options to shopt: $*";
  1724. else
  1725. __ESHOPTS_SAVE__[$i]=$-;
  1726. [[ $# -eq 0 ]] && return 0;
  1727. set "$@" || die "eshopts_push: bad options to set: $*";
  1728. fi
  1729. }
  1730. esvn_clean ()
  1731. {
  1732. [[ -z $* ]] && set -- .;
  1733. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1734. }
  1735. filter-flags ()
  1736. {
  1737. _filter-hardened "$@";
  1738. _filter-var CFLAGS "$@";
  1739. _filter-var CPPFLAGS "$@";
  1740. _filter-var CXXFLAGS "$@";
  1741. _filter-var FFLAGS "$@";
  1742. _filter-var FCFLAGS "$@";
  1743. return 0
  1744. }
  1745. filter-ldflags ()
  1746. {
  1747. _filter-var LDFLAGS "$@";
  1748. return 0
  1749. }
  1750. filter-lfs-flags ()
  1751. {
  1752. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1753. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1754. }
  1755. filter-mfpmath ()
  1756. {
  1757. local orig_mfpmath new_math prune_math;
  1758. orig_mfpmath=$(get-flag -mfpmath);
  1759. new_math=$(get-flag mfpmath);
  1760. new_math=" ${new_math//,/ } ";
  1761. prune_math="";
  1762. for prune_math in "$@";
  1763. do
  1764. new_math=${new_math/ ${prune_math} / };
  1765. done;
  1766. new_math=$(echo ${new_math});
  1767. new_math=${new_math// /,};
  1768. if [[ -z ${new_math} ]]; then
  1769. filter-flags ${orig_mfpmath};
  1770. else
  1771. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1772. fi;
  1773. return 0
  1774. }
  1775. find_unpackable_file ()
  1776. {
  1777. local src=$1;
  1778. if [[ -z ${src} ]]; then
  1779. src=${DISTDIR}/${A};
  1780. else
  1781. if [[ -e ${DISTDIR}/${src} ]]; then
  1782. src=${DISTDIR}/${src};
  1783. else
  1784. if [[ -e ${PWD}/${src} ]]; then
  1785. src=${PWD}/${src};
  1786. else
  1787. if [[ -e ${src} ]]; then
  1788. src=${src};
  1789. fi;
  1790. fi;
  1791. fi;
  1792. fi;
  1793. [[ ! -e ${src} ]] && return 1;
  1794. echo "${src}"
  1795. }
  1796. gcc-fullversion ()
  1797. {
  1798. _gcc_fullversion '$1.$2.$3' "$@"
  1799. }
  1800. gcc-major-version ()
  1801. {
  1802. _gcc_fullversion '$1' "$@"
  1803. }
  1804. gcc-micro-version ()
  1805. {
  1806. _gcc_fullversion '$3' "$@"
  1807. }
  1808. gcc-minor-version ()
  1809. {
  1810. _gcc_fullversion '$2' "$@"
  1811. }
  1812. gcc-specs-directive ()
  1813. {
  1814. local directive subdname subdirective;
  1815. directive="$(_gcc-specs-directive_raw $1)";
  1816. while [[ ${directive} == *%\(*\)* ]]; do
  1817. subdname=${directive/*%\(};
  1818. subdname=${subdname/\)*};
  1819. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1820. directive="${directive//\%(${subdname})/${subdirective}}";
  1821. done;
  1822. echo "${directive}";
  1823. return 0
  1824. }
  1825. gcc-specs-nostrict ()
  1826. {
  1827. local directive;
  1828. directive=$(gcc-specs-directive cc1);
  1829. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1830. }
  1831. gcc-specs-now ()
  1832. {
  1833. local directive;
  1834. directive=$(gcc-specs-directive link_command);
  1835. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1836. }
  1837. gcc-specs-pie ()
  1838. {
  1839. local directive;
  1840. directive=$(gcc-specs-directive cc1);
  1841. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1842. }
  1843. gcc-specs-relro ()
  1844. {
  1845. local directive;
  1846. directive=$(gcc-specs-directive link_command);
  1847. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1848. }
  1849. gcc-specs-ssp ()
  1850. {
  1851. local directive;
  1852. directive=$(gcc-specs-directive cc1);
  1853. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1854. }
  1855. gcc-specs-ssp-to-all ()
  1856. {
  1857. local directive;
  1858. directive=$(gcc-specs-directive cc1);
  1859. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1860. }
  1861. gcc-version ()
  1862. {
  1863. _gcc_fullversion '$1.$2' "$@"
  1864. }
  1865. gen_usr_ldscript ()
  1866. {
  1867. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1868. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1869. tc-is-static-only && return;
  1870. dodir /usr/${libdir};
  1871. if [[ $1 == "-a" ]]; then
  1872. auto=true;
  1873. shift;
  1874. dodir /${libdir};
  1875. fi;
  1876. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1877. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1878. for lib in "$@";
  1879. do
  1880. local tlib;
  1881. if ${auto}; then
  1882. lib="lib${lib}${suffix}";
  1883. else
  1884. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1885. fi;
  1886. case ${CTARGET:-${CHOST}} in
  1887. *-darwin*)
  1888. if ${auto}; then
  1889. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1890. else
  1891. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1892. fi;
  1893. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1894. tlib=${tlib##*/};
  1895. if ${auto}; then
  1896. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1897. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1898. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1899. fi;
  1900. rm -f "${ED}"/${libdir}/${lib};
  1901. fi;
  1902. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1903. chmod u+w "${ED}${libdir}/${tlib}";
  1904. local nowrite=yes;
  1905. fi;
  1906. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1907. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1908. pushd "${ED}/usr/${libdir}" > /dev/null;
  1909. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1910. popd > /dev/null
  1911. ;;
  1912. *-aix* | *-irix* | *64*-hpux* | *-interix* | *-winnt*)
  1913. if ${auto}; then
  1914. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1915. tlib=$(readlink "${ED}"/${libdir}/${lib});
  1916. tlib=${tlib##*/};
  1917. if [[ -z ${tlib} ]]; then
  1918. tlib=${lib};
  1919. else
  1920. rm -f "${ED}"/${libdir}/${lib};
  1921. fi;
  1922. else
  1923. tlib=${lib};
  1924. fi;
  1925. pushd "${ED}/usr/${libdir}" > /dev/null;
  1926. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1927. popd > /dev/null
  1928. ;;
  1929. hppa*-hpux*)
  1930. if ${auto}; then
  1931. tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  1932. [[ -z ${tlib} ]] && tlib=${lib};
  1933. tlib=${tlib##*/};
  1934. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1935. if [[ ${tlib} != ${lib}* ]]; then
  1936. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1937. fi;
  1938. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  1939. else
  1940. tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  1941. [[ -z ${tlib} ]] && tlib=${lib};
  1942. tlib=${tlib##*/};
  1943. fi;
  1944. pushd "${ED}"/usr/${libdir} > /dev/null;
  1945. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1946. [[ ${tlib} != ${lib} ]] && ln -snf "../../${libdir}/${tlib}" "${tlib}";
  1947. popd > /dev/null
  1948. ;;
  1949. *)
  1950. if ${auto}; then
  1951. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1952. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1953. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1954. if [[ ${tlib} != ${lib}* ]]; then
  1955. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1956. fi;
  1957. rm -f "${ED}"/${libdir}/${lib};
  1958. else
  1959. tlib=${lib};
  1960. fi;
  1961. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1962. /* GNU ld script
  1963. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1964. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1965. run into linking problems. This "fake" dynamic lib is a linker script that
  1966. redirects the linker to the real lib. And yes, this works in the cross-
  1967. compiling scenario as the sysroot-ed linker will prepend the real path.
  1968.  
  1969. See bug http://bugs.gentoo.org/4411 for more info.
  1970. */
  1971. ${output_format}
  1972. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1973. END_LDSCRIPT
  1974.  
  1975. ;;
  1976. esac
  1977. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1978. done
  1979. }
  1980. get-flag ()
  1981. {
  1982. local f findflag="$1";
  1983. for f in ${CFLAGS} ${CXXFLAGS} ${FFLAGS} ${FCFLAGS};
  1984. do
  1985. if [ "${f/${findflag}}" != "${f}" ]; then
  1986. printf "%s\n" "${f/-${findflag}=}";
  1987. return 0;
  1988. fi;
  1989. done;
  1990. return 1
  1991. }
  1992. get_abi_CFLAGS ()
  1993. {
  1994. get_abi_var CFLAGS "$@"
  1995. }
  1996. get_abi_CHOST ()
  1997. {
  1998. get_abi_var CHOST "$@"
  1999. }
  2000. get_abi_CTARGET ()
  2001. {
  2002. get_abi_var CTARGET "$@"
  2003. }
  2004. get_abi_FAKE_TARGETS ()
  2005. {
  2006. get_abi_var FAKE_TARGETS "$@"
  2007. }
  2008. get_abi_LDFLAGS ()
  2009. {
  2010. get_abi_var LDFLAGS "$@"
  2011. }
  2012. get_abi_LIBDIR ()
  2013. {
  2014. get_abi_var LIBDIR "$@"
  2015. }
  2016. get_abi_var ()
  2017. {
  2018. local flag=$1;
  2019. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2020. local var="${flag}_${abi}";
  2021. echo ${!var}
  2022. }
  2023. get_after_major_version ()
  2024. {
  2025. echo $(get_version_component_range 2- "${1:-${PV}}")
  2026. }
  2027. get_all_abis ()
  2028. {
  2029. local order="";
  2030. if [[ -z ${MULTILIB_ABIS} ]]; then
  2031. echo "default";
  2032. return 0;
  2033. fi;
  2034. for x in ${MULTILIB_ABIS};
  2035. do
  2036. if [[ ${x} != ${DEFAULT_ABI} ]]; then
  2037. order="${order:+${order} }${x}";
  2038. fi;
  2039. done;
  2040. order="${order:+${order} }${DEFAULT_ABI}";
  2041. echo ${order};
  2042. return 0
  2043. }
  2044. get_all_libdirs ()
  2045. {
  2046. local libdirs;
  2047. local abi;
  2048. local dir;
  2049. for abi in ${MULTILIB_ABIS};
  2050. do
  2051. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2052. done;
  2053. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2054. echo "${libdirs}"
  2055. }
  2056. get_all_version_components ()
  2057. {
  2058. eshopts_push -s extglob;
  2059. local ver_str=${1:-${PV}} result;
  2060. result=();
  2061. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  2062. echo ${VERSIONATOR_CACHE_RESULT};
  2063. eshopts_pop;
  2064. return;
  2065. fi;
  2066. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  2067. while [[ -n $ver_str ]]; do
  2068. case "${ver_str::1}" in
  2069. [[:digit:]])
  2070. result+=("${ver_str%%[^[:digit:]]*}");
  2071. ver_str=${ver_str##+([[:digit:]])}
  2072. ;;
  2073. [-_.])
  2074. result+=("${ver_str::1}");
  2075. ver_str=${ver_str:1}
  2076. ;;
  2077. [[:alpha:]])
  2078. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  2079. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2080. ver_str=${not_match}
  2081. ;;
  2082. *)
  2083. result+=("${ver_str::1}");
  2084. ver_str=${ver_str:1}
  2085. ;;
  2086. esac;
  2087. done;
  2088. export VERSIONATOR_CACHE_RESULT=${result[*]};
  2089. echo ${result[@]};
  2090. eshopts_pop
  2091. }
  2092. get_bmake ()
  2093. {
  2094. if [[ ${USERLAND} == *BSD ]]; then
  2095. echo make;
  2096. else
  2097. if [[ ${USERLAND} == "Darwin" ]]; then
  2098. echo bsdmake;
  2099. else
  2100. echo pmake;
  2101. fi;
  2102. fi
  2103. }
  2104. get_install_abis ()
  2105. {
  2106. local order="";
  2107. if [[ -z ${MULTILIB_ABIS} ]]; then
  2108. echo "default";
  2109. return 0;
  2110. fi;
  2111. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2112. for x in ${MULTILIB_ABIS};
  2113. do
  2114. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2115. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2116. fi;
  2117. done;
  2118. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2119. if [[ -n ${ABI_ALLOW} ]]; then
  2120. local ordera="";
  2121. for x in ${order};
  2122. do
  2123. if has ${x} ${ABI_ALLOW}; then
  2124. ordera="${ordera} ${x}";
  2125. fi;
  2126. done;
  2127. order=${ordera};
  2128. fi;
  2129. else
  2130. order=${DEFAULT_ABI};
  2131. fi;
  2132. if [[ -z ${order} ]]; then
  2133. 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.";
  2134. fi;
  2135. echo ${order};
  2136. return 0
  2137. }
  2138. get_last_version_component_index ()
  2139. {
  2140. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2141. }
  2142. get_libdir ()
  2143. {
  2144. local CONF_LIBDIR;
  2145. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2146. echo ${CONF_LIBDIR_OVERRIDE};
  2147. else
  2148. get_abi_LIBDIR;
  2149. fi
  2150. }
  2151. get_libname ()
  2152. {
  2153. local libname;
  2154. local ver=$1;
  2155. case ${CHOST} in
  2156. *-cygwin | mingw* | *-mingw*)
  2157. libname="dll"
  2158. ;;
  2159. *-darwin*)
  2160. libname="dylib"
  2161. ;;
  2162. *-mint*)
  2163. libname="irrelevant"
  2164. ;;
  2165. hppa*-hpux*)
  2166. libname="sl"
  2167. ;;
  2168. *)
  2169. libname="so"
  2170. ;;
  2171. esac;
  2172. if [[ -z $* ]]; then
  2173. echo ".${libname}";
  2174. else
  2175. for ver in "$@";
  2176. do
  2177. case ${CHOST} in
  2178. *-darwin*)
  2179. echo ".${ver}.${libname}"
  2180. ;;
  2181. *-mint*)
  2182. echo ".${libname}"
  2183. ;;
  2184. *)
  2185. echo ".${libname}.${ver}"
  2186. ;;
  2187. esac;
  2188. done;
  2189. fi
  2190. }
  2191. get_localversion ()
  2192. {
  2193. local lv_list i x;
  2194. for i in $(ls ${1}/localversion* 2>/dev/null);
  2195. do
  2196. [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}";
  2197. done;
  2198. for i in ${lv_list};
  2199. do
  2200. x="${x}$(<${i})";
  2201. done;
  2202. x=${x/ /};
  2203. echo ${x}
  2204. }
  2205. get_major_version ()
  2206. {
  2207. local c=($(get_all_version_components "${1:-${PV}}"));
  2208. echo ${c[0]}
  2209. }
  2210. get_makefile_extract_function ()
  2211. {
  2212. local a='' b='' mkfunc='getfilevar';
  2213. a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  2214. b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  2215. [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  2216. echo "${mkfunc}"
  2217. }
  2218. get_modname ()
  2219. {
  2220. local modname;
  2221. local ver=$1;
  2222. case ${CHOST} in
  2223. *-darwin*)
  2224. modname="bundle"
  2225. ;;
  2226. *)
  2227. modname="so"
  2228. ;;
  2229. esac;
  2230. echo ".${modname}"
  2231. }
  2232. get_mounts ()
  2233. {
  2234. local point= node= fs= opts= foo=;
  2235. if [[ $(uname -s) == "Linux" ]]; then
  2236. while read node point fs opts foo; do
  2237. echo "${point} ${node} ${fs} ${opts}";
  2238. done < /proc/mounts;
  2239. return;
  2240. fi;
  2241. local IFS=' ';
  2242. LC_ALL=C mount -p | while read node point fs foo; do
  2243. opts=${fs#* };
  2244. fs=${fs%% *};
  2245. echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}";
  2246. done
  2247. }
  2248. get_running_version ()
  2249. {
  2250. KV_FULL=$(uname -r);
  2251. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2252. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  2253. KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  2254. unset KV_FULL;
  2255. get_version;
  2256. return $?;
  2257. else
  2258. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
  2259. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  2260. unset KV_FULL;
  2261. get_version;
  2262. return $?;
  2263. else
  2264. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  2265. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  2266. unset KV_FULL;
  2267. get_version;
  2268. return $?;
  2269. else
  2270. KV_MAJOR=$(get_version_component_range 1 ${KV_FULL});
  2271. KV_MINOR=$(get_version_component_range 2 ${KV_FULL});
  2272. KV_PATCH=$(get_version_component_range 3 ${KV_FULL});
  2273. KV_PATCH=${KV_PATCH//-*};
  2274. KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}}";
  2275. fi;
  2276. fi;
  2277. fi;
  2278. return 0
  2279. }
  2280. get_version ()
  2281. {
  2282. local kbuild_output mkfunc tmplocal;
  2283. [ -n "${KV_FULL}" ] && return 0;
  2284. unset KV_DIR;
  2285. [ -z "${get_version_warning_done}" ] && qeinfo "Determining the location of the kernel source code";
  2286. [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})";
  2287. [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}";
  2288. if [ -z "${KV_DIR}" ]; then
  2289. if [ -z "${get_version_warning_done}" ]; then
  2290. get_version_warning_done=1;
  2291. qeerror "Unable to find kernel sources at ${KERNEL_DIR}";
  2292. if [ "${KERNEL_DIR}" == "/usr/src/linux" ]; then
  2293. qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  2294. qeinfo "(or the kernel you wish to build against).";
  2295. qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  2296. else
  2297. qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  2298. fi;
  2299. fi;
  2300. return 1;
  2301. fi;
  2302. if [ -z "${get_version_warning_done}" ]; then
  2303. qeinfo "Found kernel source directory:";
  2304. qeinfo " ${KV_DIR}";
  2305. fi;
  2306. if [ ! -s "${KV_DIR}/Makefile" ]; then
  2307. if [ -z "${get_version_warning_done}" ]; then
  2308. get_version_warning_done=1;
  2309. qeerror "Could not find a Makefile in the kernel source directory.";
  2310. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  2311. fi;
  2312. return 1;
  2313. fi;
  2314. OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}";
  2315. KERNEL_MAKEFILE="${KV_DIR}/Makefile";
  2316. mkfunc="$(get_makefile_extract_function "${KERNEL_MAKEFILE}")";
  2317. kbuild_output="$(${mkfunc} KBUILD_OUTPUT ${KERNEL_MAKEFILE})";
  2318. OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}";
  2319. KV_MAJOR="$(${mkfunc} VERSION ${KERNEL_MAKEFILE})";
  2320. KV_MINOR="$(${mkfunc} PATCHLEVEL ${KERNEL_MAKEFILE})";
  2321. KV_PATCH="$(${mkfunc} SUBLEVEL ${KERNEL_MAKEFILE})";
  2322. KV_EXTRA="$(${mkfunc} EXTRAVERSION ${KERNEL_MAKEFILE})";
  2323. if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then
  2324. if [ -z "${get_version_warning_done}" ]; then
  2325. get_version_warning_done=1;
  2326. qeerror "Could not detect kernel version.";
  2327. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  2328. fi;
  2329. return 1;
  2330. fi;
  2331. OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build}";
  2332. [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})";
  2333. [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}";
  2334. if [ -n "${KV_OUT_DIR}" ]; then
  2335. qeinfo "Found kernel object directory:";
  2336. qeinfo " ${KV_OUT_DIR}";
  2337. fi;
  2338. KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  2339. if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
  2340. KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  2341. else
  2342. if [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
  2343. KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  2344. else
  2345. KV_LOCAL=;
  2346. fi;
  2347. fi;
  2348. tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  2349. if [ "$KV_LOCAL" = "$tmplocal" ]; then
  2350. KV_LOCAL=;
  2351. else
  2352. KV_LOCAL=$tmplocal;
  2353. fi;
  2354. KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  2355. qeinfo "Found sources for kernel version:";
  2356. qeinfo " ${KV_FULL}";
  2357. return 0
  2358. }
  2359. get_version_component_count ()
  2360. {
  2361. local a=($(get_version_components "${1:-${PV}}"));
  2362. echo ${#a[@]}
  2363. }
  2364. get_version_component_range ()
  2365. {
  2366. eshopts_push -s extglob;
  2367. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2368. local -i i=-1 j=0;
  2369. c=($(get_all_version_components "${v}"));
  2370. range_start=${range%-*};
  2371. range_start=${range_start:-1};
  2372. range_end=${range#*-};
  2373. range_end=${range_end:-${#c[@]}};
  2374. while ((j < range_start)); do
  2375. i+=1;
  2376. ((i > ${#c[@]})) && eshopts_pop && return;
  2377. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2378. done;
  2379. while ((j <= range_end)); do
  2380. echo -n ${c[i]};
  2381. ((i > ${#c[@]})) && eshopts_pop && return;
  2382. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2383. i+=1;
  2384. done;
  2385. eshopts_pop
  2386. }
  2387. get_version_components ()
  2388. {
  2389. local c=$(get_all_version_components "${1:-${PV}}");
  2390. echo ${c//[-._]/ }
  2391. }
  2392. getfilevar ()
  2393. {
  2394. local ERROR basefname basedname myARCH="${ARCH}";
  2395. ERROR=0;
  2396. [ -z "${1}" ] && ERROR=1;
  2397. [ ! -f "${2}" ] && ERROR=1;
  2398. if [ "${ERROR}" = 1 ]; then
  2399. echo -e "\n";
  2400. eerror "getfilevar requires 2 variables, with the second a valid file.";
  2401. eerror " getfilevar <VARIABLE> <CONFIGFILE>";
  2402. else
  2403. basefname="$(basename ${2})";
  2404. basedname="$(dirname ${2})";
  2405. unset ARCH;
  2406. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | make -C "${basedname}" M="${S}" ${BUILD_FIXES} -s -f - 2> /dev/null;
  2407. ARCH=${myARCH};
  2408. fi
  2409. }
  2410. getfilevar_noexec ()
  2411. {
  2412. local ERROR basefname basedname mycat myARCH="${ARCH}";
  2413. ERROR=0;
  2414. mycat='cat';
  2415. [ -z "${1}" ] && ERROR=1;
  2416. [ ! -f "${2}" ] && ERROR=1;
  2417. [ "${2%.gz}" != "${2}" ] && mycat='zcat';
  2418. if [ "${ERROR}" = 1 ]; then
  2419. echo -e "\n";
  2420. eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  2421. eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  2422. else
  2423. ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  2424. s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  2425. s,[[:space:]]*\$,,g ;
  2426. p
  2427. }";
  2428. fi
  2429. }
  2430. has_hardened ()
  2431. {
  2432. die "$0: deprecated, please use gcc-specs-{relro,now}()!"
  2433. }
  2434. has_m32 ()
  2435. {
  2436. [ "$(tc-arch)" = "amd64" ] && has_multilib_profile && return 0;
  2437. local temp=$(emktemp);
  2438. echo "int main() { return(0); }" > "${temp}".c;
  2439. MY_CC=$(tc-getCC);
  2440. ${MY_CC/ .*/} -m32 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  2441. local ret=$?;
  2442. rm -f "${temp}".c;
  2443. [[ ${ret} != 1 ]] && return 0;
  2444. return 1
  2445. }
  2446. has_m64 ()
  2447. {
  2448. local temp="$(emktemp)";
  2449. echo "int main() { return(0); }" > "${temp}".c;
  2450. MY_CC=$(tc-getCC);
  2451. ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  2452. local ret=$?;
  2453. rm -f "${temp}".c;
  2454. [[ ${ret} != 1 ]] && return 0;
  2455. return 1
  2456. }
  2457. has_multilib_profile ()
  2458. {
  2459. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2460. }
  2461. has_pic ()
  2462. {
  2463. die "$0: deprecated, please use gcc-specs-pie()!"
  2464. }
  2465. has_pie ()
  2466. {
  2467. die "$0: deprecated, please use gcc-specs-pie()!"
  2468. }
  2469. has_ssp ()
  2470. {
  2471. die "$0: deprecated, please use gcc-specs-ssp()!"
  2472. }
  2473. has_ssp_all ()
  2474. {
  2475. die "$0: deprecated, please use gcc-specs-ssp()!"
  2476. }
  2477. helpers_die ()
  2478. {
  2479. case "${EAPI:-0}" in
  2480. 0 | 1 | 2 | 3)
  2481. echo -e "$@" 1>&2
  2482. ;;
  2483. *)
  2484. die "$@"
  2485. ;;
  2486. esac
  2487. }
  2488. in_iuse ()
  2489. {
  2490. debug-print-function ${FUNCNAME} "${@}";
  2491. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2492. local flag=${1};
  2493. local liuse=(${IUSE});
  2494. has "${flag}" "${liuse[@]#[+-]}"
  2495. }
  2496. is-flag ()
  2497. {
  2498. is-flagq "$@" && echo true
  2499. }
  2500. is-flagq ()
  2501. {
  2502. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2503. _is_flagq CFLAGS $1 || _is_flagq CXXFLAGS $1 || _is_flagq FFLAGS $1 || _is_flagq FCFLAGS $1
  2504. }
  2505. is-ldflag ()
  2506. {
  2507. is-ldflagq "$@" && echo true
  2508. }
  2509. is-ldflagq ()
  2510. {
  2511. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  2512. _is_flagq LDFLAGS $1
  2513. }
  2514. is-login-disabled ()
  2515. {
  2516. _dead_portability_user_funcs
  2517. }
  2518. is_final_abi ()
  2519. {
  2520. has_multilib_profile || return 0;
  2521. set -- $(get_install_abis);
  2522. local LAST_ABI=$#;
  2523. [[ ${!LAST_ABI} == ${ABI} ]]
  2524. }
  2525. kernel_is ()
  2526. {
  2527. linux-info_get_any_version;
  2528. local operator testagainst value x=0 y=0 z=0;
  2529. case ${1} in
  2530. -lt | lt)
  2531. operator="-lt";
  2532. shift
  2533. ;;
  2534. -gt | gt)
  2535. operator="-gt";
  2536. shift
  2537. ;;
  2538. -le | le)
  2539. operator="-le";
  2540. shift
  2541. ;;
  2542. -ge | ge)
  2543. operator="-ge";
  2544. shift
  2545. ;;
  2546. -eq | eq)
  2547. operator="-eq";
  2548. shift
  2549. ;;
  2550. *)
  2551. operator="-eq"
  2552. ;;
  2553. esac;
  2554. for x in ${@};
  2555. do
  2556. for ((y=0; y<$((3 - ${#x})); y++))
  2557. do
  2558. value="${value}0";
  2559. done;
  2560. value="${value}${x}";
  2561. z=$((${z} + 1));
  2562. case ${z} in
  2563. 1)
  2564. for ((y=0; y<$((3 - ${#KV_MAJOR})); y++))
  2565. do
  2566. testagainst="${testagainst}0";
  2567. done;
  2568. testagainst="${testagainst}${KV_MAJOR}"
  2569. ;;
  2570. 2)
  2571. for ((y=0; y<$((3 - ${#KV_MINOR})); y++))
  2572. do
  2573. testagainst="${testagainst}0";
  2574. done;
  2575. testagainst="${testagainst}${KV_MINOR}"
  2576. ;;
  2577. 3)
  2578. for ((y=0; y<$((3 - ${#KV_PATCH})); y++))
  2579. do
  2580. testagainst="${testagainst}0";
  2581. done;
  2582. testagainst="${testagainst}${KV_PATCH}"
  2583. ;;
  2584. *)
  2585. die "Error in kernel-2_kernel_is(): Too many parameters."
  2586. ;;
  2587. esac;
  2588. done;
  2589. [ "${testagainst}" ${operator} "${value}" ] && return 0 || return 1
  2590. }
  2591. kvm_kern_warn ()
  2592. {
  2593. eerror "Please enable KVM support in your kernel, found at:";
  2594. eerror;
  2595. eerror " Virtualization";
  2596. eerror " Kernel-based Virtual Machine (KVM) support";
  2597. eerror
  2598. }
  2599. linux-info_get_any_version ()
  2600. {
  2601. get_version;
  2602. if [[ $? -ne 0 ]]; then
  2603. ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  2604. get_running_version;
  2605. fi
  2606. }
  2607. linux-info_pkg_setup ()
  2608. {
  2609. linux-info_get_any_version;
  2610. if kernel_is 2 4; then
  2611. if [ "$( gcc-major-version )" -eq "4" ]; then
  2612. echo;
  2613. ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with";
  2614. ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!";
  2615. echo;
  2616. ewarn "Either switch to another gcc-version (via gcc-config) or use a";
  2617. ewarn "newer kernel that supports gcc-4.";
  2618. echo;
  2619. ewarn "Also be aware that bugreports about gcc-4 not working";
  2620. ewarn "with linux-2.4 based ebuilds will be closed as INVALID!";
  2621. echo;
  2622. epause 10;
  2623. fi;
  2624. fi;
  2625. [ -n "${CONFIG_CHECK}" ] && check_extra_config
  2626. }
  2627. linux_chkconfig_builtin ()
  2628. {
  2629. linux_config_qa_check linux_chkconfig_builtin;
  2630. local RESULT;
  2631. local config;
  2632. config="${KV_OUT_DIR}/.config";
  2633. [ ! -f "${config}" ] && config="/proc/config.gz";
  2634. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  2635. [ "${RESULT}" = "y" ] && return 0 || return 1
  2636. }
  2637. linux_chkconfig_module ()
  2638. {
  2639. linux_config_qa_check linux_chkconfig_module;
  2640. local RESULT;
  2641. local config;
  2642. config="${KV_OUT_DIR}/.config";
  2643. [ ! -f "${config}" ] && config="/proc/config.gz";
  2644. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  2645. [ "${RESULT}" = "m" ] && return 0 || return 1
  2646. }
  2647. linux_chkconfig_present ()
  2648. {
  2649. linux_config_qa_check linux_chkconfig_present;
  2650. local RESULT;
  2651. local config;
  2652. config="${KV_OUT_DIR}/.config";
  2653. [ ! -f "${config}" ] && config="/proc/config.gz";
  2654. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  2655. [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
  2656. }
  2657. linux_chkconfig_string ()
  2658. {
  2659. linux_config_qa_check linux_chkconfig_string;
  2660. local config;
  2661. config="${KV_OUT_DIR}/.config";
  2662. [ ! -f "${config}" ] && config="/proc/config.gz";
  2663. getfilevar_noexec "CONFIG_${1}" "${config}"
  2664. }
  2665. linux_config_bin_exists ()
  2666. {
  2667. export _LINUX_CONFIG_EXISTS_DONE=1;
  2668. [ -s "/proc/config.gz" ]
  2669. }
  2670. linux_config_exists ()
  2671. {
  2672. linux_config_src_exists || linux_config_bin_exists
  2673. }
  2674. linux_config_qa_check ()
  2675. {
  2676. local f="$1";
  2677. if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
  2678. ewarn "QA: You called $f before any linux_config_exists!";
  2679. ewarn "QA: The return value of $f will NOT guaranteed later!";
  2680. fi
  2681. }
  2682. linux_config_src_exists ()
  2683. {
  2684. export _LINUX_CONFIG_EXISTS_DONE=1;
  2685. [ -s "${KV_OUT_DIR}/.config" ]
  2686. }
  2687. make_desktop_entry ()
  2688. {
  2689. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2690. local exec=${1};
  2691. local name=${2:-${PN}};
  2692. local icon=${3:-${PN}};
  2693. local type=${4};
  2694. local fields=${5};
  2695. if [[ -z ${type} ]]; then
  2696. local catmaj=${CATEGORY%%-*};
  2697. local catmin=${CATEGORY##*-};
  2698. case ${catmaj} in
  2699. app)
  2700. case ${catmin} in
  2701. accessibility)
  2702. type=Accessibility
  2703. ;;
  2704. admin)
  2705. type=System
  2706. ;;
  2707. antivirus)
  2708. type=System
  2709. ;;
  2710. arch)
  2711. type=Archiving
  2712. ;;
  2713. backup)
  2714. type=Archiving
  2715. ;;
  2716. cdr)
  2717. type=DiscBurning
  2718. ;;
  2719. dicts)
  2720. type=Dictionary
  2721. ;;
  2722. doc)
  2723. type=Documentation
  2724. ;;
  2725. editors)
  2726. type=TextEditor
  2727. ;;
  2728. emacs)
  2729. type=TextEditor
  2730. ;;
  2731. emulation)
  2732. type=Emulator
  2733. ;;
  2734. laptop)
  2735. type=HardwareSettings
  2736. ;;
  2737. office)
  2738. type=Office
  2739. ;;
  2740. pda)
  2741. type=PDA
  2742. ;;
  2743. vim)
  2744. type=TextEditor
  2745. ;;
  2746. xemacs)
  2747. type=TextEditor
  2748. ;;
  2749. esac
  2750. ;;
  2751. dev)
  2752. type="Development"
  2753. ;;
  2754. games)
  2755. case ${catmin} in
  2756. action | fps)
  2757. type=ActionGame
  2758. ;;
  2759. arcade)
  2760. type=ArcadeGame
  2761. ;;
  2762. board)
  2763. type=BoardGame
  2764. ;;
  2765. emulation)
  2766. type=Emulator
  2767. ;;
  2768. kids)
  2769. type=KidsGame
  2770. ;;
  2771. puzzle)
  2772. type=LogicGame
  2773. ;;
  2774. roguelike)
  2775. type=RolePlaying
  2776. ;;
  2777. rpg)
  2778. type=RolePlaying
  2779. ;;
  2780. simulation)
  2781. type=Simulation
  2782. ;;
  2783. sports)
  2784. type=SportsGame
  2785. ;;
  2786. strategy)
  2787. type=StrategyGame
  2788. ;;
  2789. esac;
  2790. type="Game;${type}"
  2791. ;;
  2792. gnome)
  2793. type="Gnome;GTK"
  2794. ;;
  2795. kde)
  2796. type="KDE;Qt"
  2797. ;;
  2798. mail)
  2799. type="Network;Email"
  2800. ;;
  2801. media)
  2802. case ${catmin} in
  2803. gfx)
  2804. type=Graphics
  2805. ;;
  2806. *)
  2807. case ${catmin} in
  2808. radio)
  2809. type=Tuner
  2810. ;;
  2811. sound)
  2812. type=Audio
  2813. ;;
  2814. tv)
  2815. type=TV
  2816. ;;
  2817. video)
  2818. type=Video
  2819. ;;
  2820. esac;
  2821. type="AudioVideo;${type}"
  2822. ;;
  2823. esac
  2824. ;;
  2825. net)
  2826. case ${catmin} in
  2827. dialup)
  2828. type=Dialup
  2829. ;;
  2830. ftp)
  2831. type=FileTransfer
  2832. ;;
  2833. im)
  2834. type=InstantMessaging
  2835. ;;
  2836. irc)
  2837. type=IRCClient
  2838. ;;
  2839. mail)
  2840. type=Email
  2841. ;;
  2842. news)
  2843. type=News
  2844. ;;
  2845. nntp)
  2846. type=News
  2847. ;;
  2848. p2p)
  2849. type=FileTransfer
  2850. ;;
  2851. voip)
  2852. type=Telephony
  2853. ;;
  2854. esac;
  2855. type="Network;${type}"
  2856. ;;
  2857. sci)
  2858. case ${catmin} in
  2859. astro*)
  2860. type=Astronomy
  2861. ;;
  2862. bio*)
  2863. type=Biology
  2864. ;;
  2865. calc*)
  2866. type=Calculator
  2867. ;;
  2868. chem*)
  2869. type=Chemistry
  2870. ;;
  2871. elec*)
  2872. type=Electronics
  2873. ;;
  2874. geo*)
  2875. type=Geology
  2876. ;;
  2877. math*)
  2878. type=Math
  2879. ;;
  2880. physics)
  2881. type=Physics
  2882. ;;
  2883. visual*)
  2884. type=DataVisualization
  2885. ;;
  2886. esac;
  2887. type="Education;Science;${type}"
  2888. ;;
  2889. sys)
  2890. type="System"
  2891. ;;
  2892. www)
  2893. case ${catmin} in
  2894. client)
  2895. type=WebBrowser
  2896. ;;
  2897. esac;
  2898. type="Network;${type}"
  2899. ;;
  2900. *)
  2901. type=
  2902. ;;
  2903. esac;
  2904. fi;
  2905. if [ "${SLOT}" == "0" ]; then
  2906. local desktop_name="${PN}";
  2907. else
  2908. local desktop_name="${PN}-${SLOT}";
  2909. fi;
  2910. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2911. type=${type%;}${type:+;};
  2912. eshopts_push -s extglob;
  2913. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2914. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2915. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2916. icon=${icon%.@(xpm|png|svg)};
  2917. fi;
  2918. eshopts_pop;
  2919. cat > "${desktop}" <<-EOF
  2920. [Desktop Entry]
  2921. Name=${name}
  2922. Type=Application
  2923. Comment=${DESCRIPTION}
  2924. Exec=${exec}
  2925. TryExec=${exec%% *}
  2926. Icon=${icon}
  2927. Categories=${type}
  2928. EOF
  2929.  
  2930. if [[ ${fields:-=} != *=* ]]; then
  2931. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2932. fields="Path=${fields}";
  2933. fi;
  2934. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  2935. ( insinto /usr/share/applications;
  2936. doins "${desktop}" ) || die "installing desktop file failed"
  2937. }
  2938. make_session_desktop ()
  2939. {
  2940. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2941. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2942. local title=$1;
  2943. local command=$2;
  2944. local desktop=${T}/${wm:-${PN}}.desktop;
  2945. shift 2;
  2946. cat > "${desktop}" <<-EOF
  2947. [Desktop Entry]
  2948. Name=${title}
  2949. Comment=This session logs you into ${title}
  2950. Exec=${command} $*
  2951. TryExec=${command}
  2952. Type=XSession
  2953. EOF
  2954.  
  2955. ( insinto /usr/share/xsessions;
  2956. doins "${desktop}" )
  2957. }
  2958. make_wrapper ()
  2959. {
  2960. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2961. local tmpwrapper=$(emktemp);
  2962. cat > "${tmpwrapper}" <<EOF
  2963. #!/bin/sh
  2964. cd "${chdir:-.}"
  2965. if [ -n "${libdir}" ] ; then
  2966. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  2967. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  2968. else
  2969. export LD_LIBRARY_PATH="${libdir}"
  2970. fi
  2971. fi
  2972. exec ${bin} "\$@"
  2973. EOF
  2974.  
  2975. chmod go+rx "${tmpwrapper}";
  2976. if [[ -n ${path} ]]; then
  2977. ( exeinto "${path}";
  2978. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2979. else
  2980. newbin "${tmpwrapper}" "${wrapper}" || die;
  2981. fi
  2982. }
  2983. multilib_env ()
  2984. {
  2985. local CTARGET=${1:-${CTARGET}};
  2986. case ${CTARGET} in
  2987. x86_64*)
  2988. export CFLAGS_x86=${CFLAGS_x86--m32};
  2989. export CHOST_x86=${CTARGET/x86_64/i686};
  2990. export CTARGET_x86=${CHOST_x86};
  2991. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2992. export LIBDIR_x86="lib32";
  2993. else
  2994. export LIBDIR_x86="lib";
  2995. fi;
  2996. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2997. export CHOST_amd64=${CTARGET};
  2998. export CTARGET_amd64=${CHOST_amd64};
  2999. export LIBDIR_amd64="lib64";
  3000. export CFLAGS_x32=${CFLAGS_x32--mx32};
  3001. export CHOST_x32=${CTARGET};
  3002. export CTARGET_x32=${CHOST_x32};
  3003. export LIBDIR_x32="libx32";
  3004. : ${MULTILIB_ABIS=amd64 x86};
  3005. : ${DEFAULT_ABI=amd64}
  3006. ;;
  3007. mips64*)
  3008. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3009. export CHOST_o32=${CTARGET/mips64/mips};
  3010. export CTARGET_o32=${CHOST_o32};
  3011. export LIBDIR_o32="lib";
  3012. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3013. export CHOST_n32=${CTARGET};
  3014. export CTARGET_n32=${CHOST_n32};
  3015. export LIBDIR_n32="lib32";
  3016. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3017. export CHOST_n64=${CTARGET};
  3018. export CTARGET_n64=${CHOST_n64};
  3019. export LIBDIR_n64="lib64";
  3020. : ${MULTILIB_ABIS=n64 n32 o32};
  3021. : ${DEFAULT_ABI=n32}
  3022. ;;
  3023. powerpc64*)
  3024. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3025. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3026. export CTARGET_ppc=${CHOST_ppc};
  3027. export LIBDIR_ppc="lib";
  3028. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3029. export CHOST_ppc64=${CTARGET};
  3030. export CTARGET_ppc64=${CHOST_ppc64};
  3031. export LIBDIR_ppc64="lib64";
  3032. : ${MULTILIB_ABIS=ppc64 ppc};
  3033. : ${DEFAULT_ABI=ppc64}
  3034. ;;
  3035. s390x*)
  3036. export CFLAGS_s390=${CFLAGS_s390--m31};
  3037. export CHOST_s390=${CTARGET/s390x/s390};
  3038. export CTARGET_s390=${CHOST_s390};
  3039. export LIBDIR_s390="lib";
  3040. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3041. export CHOST_s390x=${CTARGET};
  3042. export CTARGET_s390x=${CHOST_s390x};
  3043. export LIBDIR_s390x="lib64";
  3044. : ${MULTILIB_ABIS=s390x s390};
  3045. : ${DEFAULT_ABI=s390x}
  3046. ;;
  3047. sparc*)
  3048. export CFLAGS_sparc32=${CFLAGS_sparc32};
  3049. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3050. export CTARGET_sparc32=${CHOST_sparc32};
  3051. export LIBDIR_sparc32="lib";
  3052. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3053. export CHOST_sparc64=${CTARGET};
  3054. export CTARGET_sparc64=${CHOST_sparc64};
  3055. export LIBDIR_sparc64="lib64";
  3056. : ${MULTILIB_ABIS=sparc64 sparc32};
  3057. : ${DEFAULT_ABI=sparc64}
  3058. ;;
  3059. *)
  3060. : ${MULTILIB_ABIS=default};
  3061. : ${DEFAULT_ABI=default}
  3062. ;;
  3063. esac;
  3064. export MULTILIB_ABIS DEFAULT_ABI
  3065. }
  3066. multilib_toolchain_setup ()
  3067. {
  3068. local v vv;
  3069. export ABI=$1;
  3070. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  3071. for v in CHOST CBUILD AS CC CXX LD;
  3072. do
  3073. vv="__abi_saved_${v}";
  3074. export ${v}="${!vv}";
  3075. unset ${vv};
  3076. done;
  3077. unset __DEFAULT_ABI_SAVED;
  3078. fi;
  3079. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3080. for v in CHOST CBUILD AS CC CXX LD;
  3081. do
  3082. export __abi_saved_${v}="${!v}";
  3083. done;
  3084. export __DEFAULT_ABI_SAVED="true";
  3085. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3086. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3087. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3088. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3089. export CHOST=$(get_abi_CHOST $1);
  3090. export CBUILD=$(get_abi_CHOST $1);
  3091. fi
  3092. }
  3093. newicon ()
  3094. {
  3095. ( insinto /usr/share/pixmaps;
  3096. newins "$@" )
  3097. }
  3098. newmenu ()
  3099. {
  3100. ( insinto /usr/share/applications;
  3101. newins "$@" )
  3102. }
  3103. no-as-needed ()
  3104. {
  3105. case $($(tc-getLD) -v 2>&1 </dev/null) in
  3106. *GNU*)
  3107. echo "-Wl,--no-as-needed"
  3108. ;;
  3109. esac
  3110. }
  3111. nonfatal ()
  3112. {
  3113. if has "${EAPI:-0}" 0 1 2 3 3_pre2; then
  3114. die "$FUNCNAME() not supported in this EAPI";
  3115. fi;
  3116. if [[ $# -lt 1 ]]; then
  3117. die "$FUNCNAME(): Missing argument";
  3118. fi;
  3119. PORTAGE_NONFATAL=1 "$@"
  3120. }
  3121. number_abis ()
  3122. {
  3123. set -- `get_install_abis`;
  3124. echo $#
  3125. }
  3126. path_exists ()
  3127. {
  3128. local opt=$1;
  3129. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  3130. [[ $# -eq 0 ]] && return 1;
  3131. local p r=0;
  3132. for p in "$@";
  3133. do
  3134. [[ -e ${p} ]];
  3135. : $(( r += $? ));
  3136. done;
  3137. case ${opt} in
  3138. -a)
  3139. return $(( r != 0 ))
  3140. ;;
  3141. -o)
  3142. return $(( r == $# ))
  3143. ;;
  3144. esac
  3145. }
  3146. pkg_nofetch ()
  3147. {
  3148. _eapi0_pkg_nofetch "$@"
  3149. }
  3150. pkg_postinst ()
  3151. {
  3152. if [ ! -z "${softmmu_targets}" ]; then
  3153. elog "If you don't have kvm compiled into the kernel, make sure you have";
  3154. elog "the kernel module loaded before running kvm. The easiest way to";
  3155. elog "ensure that the kernel module is loaded is to load it on boot.";
  3156. elog "For AMD CPUs the module is called 'kvm-amd'";
  3157. elog "For Intel CPUs the module is called 'kvm-intel'";
  3158. elog "Please review /etc/conf.d/modules for how to load these";
  3159. elog;
  3160. elog "Make sure your user is in the 'kvm' group";
  3161. elog "Just run 'gpasswd -a <USER> kvm', then have <USER> re-login.";
  3162. elog;
  3163. elog "You will need the Universal TUN/TAP driver compiled into your";
  3164. elog "kernel or loaded as a module to use the virtual network device";
  3165. elog "if using -net tap. You will also need support for 802.1d";
  3166. elog "Ethernet Bridging and a configured bridge if using the provided";
  3167. elog "kvm-ifup script from /etc/kvm.";
  3168. elog;
  3169. elog "The gnutls use flag was renamed to ssl, so adjust your use flags.";
  3170. fi
  3171. }
  3172. pkg_setup ()
  3173. {
  3174. if ! use qemu_softmmu_targets_x86_64 && use x86_64; then
  3175. eerror "You disabled default target QEMU_SOFTMMU_TARGETS=x86_64";
  3176. fi;
  3177. if ! use qemu_softmmu_targets_x86_64 && use x86; then
  3178. eerror "You disabled default target QEMU_SOFTMMU_TARGETS=x86_64";
  3179. fi;
  3180. if kernel_is lt 2 6 25; then
  3181. eerror "This version of KVM requres a host kernel of 2.6.25 or higher.";
  3182. eerror "Either upgrade your kernel";
  3183. else
  3184. if ! linux_config_exists; then
  3185. eerror "Unable to check your kernel for KVM support";
  3186. kvm_kern_warn;
  3187. else
  3188. if ! linux_chkconfig_present KVM; then
  3189. kvm_kern_warn;
  3190. fi;
  3191. fi;
  3192. if use vhost-net && ! linux_chkconfig_present VHOST_NET; then
  3193. ewarn "You have to enable CONFIG_VHOST_NET in the kernel";
  3194. ewarn "to have vhost-net support.";
  3195. fi;
  3196. fi;
  3197. enewgroup kvm
  3198. }
  3199. preserve_old_lib ()
  3200. {
  3201. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  3202. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  3203. die "Invalid preserve_old_lib() usage";
  3204. fi;
  3205. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  3206. has preserve-libs ${FEATURES} && return 0;
  3207. local lib dir;
  3208. for lib in "$@";
  3209. do
  3210. [[ -e ${ROOT}/${lib} ]] || continue;
  3211. dir=${lib%/*};
  3212. dodir ${dir} || die "dodir ${dir} failed";
  3213. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  3214. touch "${D}"/${lib};
  3215. done
  3216. }
  3217. preserve_old_lib_notify ()
  3218. {
  3219. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  3220. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  3221. die "Invalid preserve_old_lib_notify() usage";
  3222. fi;
  3223. has preserve-libs ${FEATURES} && return 0;
  3224. local lib notice=0;
  3225. for lib in "$@";
  3226. do
  3227. [[ -e ${ROOT}/${lib} ]] || continue;
  3228. if [[ ${notice} -eq 0 ]]; then
  3229. notice=1;
  3230. ewarn "Old versions of installed libraries were detected on your system.";
  3231. ewarn "In order to avoid breaking packages that depend on these old libs,";
  3232. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  3233. ewarn "in order to remove these old dependencies. If you do not have this";
  3234. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  3235. ewarn;
  3236. fi;
  3237. [[ ${PN} == "mpfr" ]] && lib=${lib##*/};
  3238. ewarn " # revdep-rebuild --library '${lib}'";
  3239. done;
  3240. if [[ ${notice} -eq 1 ]]; then
  3241. ewarn;
  3242. ewarn "Once you've finished running revdep-rebuild, it should be safe to";
  3243. ewarn "delete the old libraries. Here is a copy & paste for the lazy:";
  3244. for lib in "$@";
  3245. do
  3246. ewarn " # rm '${lib}'";
  3247. done;
  3248. fi
  3249. }
  3250. qeerror ()
  3251. {
  3252. qout eerror "${@}"
  3253. }
  3254. qeinfo ()
  3255. {
  3256. qout einfo "${@}"
  3257. }
  3258. qewarn ()
  3259. {
  3260. qout ewarn "${@}"
  3261. }
  3262. qout ()
  3263. {
  3264. local outputmsg type;
  3265. type=${1};
  3266. shift;
  3267. outputmsg="${@}";
  3268. case "${EBUILD_PHASE}" in
  3269. depend)
  3270. unset outputmsg
  3271. ;;
  3272. clean)
  3273. unset outputmsg
  3274. ;;
  3275. preinst)
  3276. unset outputmsg
  3277. ;;
  3278. esac;
  3279. [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
  3280. }
  3281. raw-ldflags ()
  3282. {
  3283. local x input="$@";
  3284. [[ -z ${input} ]] && input=${LDFLAGS};
  3285. set --;
  3286. for x in ${input};
  3287. do
  3288. x=${x#-Wl,};
  3289. set -- "$@" ${x//,/ };
  3290. done;
  3291. echo "$@"
  3292. }
  3293. register_success_hook ()
  3294. {
  3295. local x;
  3296. for x in $*;
  3297. do
  3298. has $x $EBUILD_SUCCESS_HOOKS || export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x";
  3299. done
  3300. }
  3301. replace-cpu-flags ()
  3302. {
  3303. local newcpu="$#";
  3304. newcpu="${!newcpu}";
  3305. while [ $# -gt 1 ]; do
  3306. replace-flags "-march=${1}" "-march=${newcpu}";
  3307. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3308. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3309. shift;
  3310. done;
  3311. return 0
  3312. }
  3313. replace-flags ()
  3314. {
  3315. [[ $# != 2 ]] && echo && eerror "Usage: replace-flags <old flag> <new flag>" && die "replace-flags takes 2 arguments, not $#";
  3316. local f fset;
  3317. declare -a new_CFLAGS new_CXXFLAGS new_FFLAGS new_FCFLAGS;
  3318. for fset in CFLAGS CXXFLAGS FFLAGS FCFLAGS;
  3319. do
  3320. for f in ${!fset};
  3321. do
  3322. [[ ${f} == ${1} ]] && f=${2};
  3323. eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f};
  3324. done;
  3325. eval export ${fset}=\${new_${fset}\[*]};
  3326. done;
  3327. return 0
  3328. }
  3329. replace-sparc64-flags ()
  3330. {
  3331. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3332. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3333. for x in ${SPARC64_CPUS};
  3334. do
  3335. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3336. done;
  3337. else
  3338. for x in ${SPARC64_CPUS};
  3339. do
  3340. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3341. done;
  3342. fi;
  3343. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3344. for x in ${SPARC64_CPUS};
  3345. do
  3346. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3347. done;
  3348. else
  3349. for x in ${SPARC64_CPUS};
  3350. do
  3351. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3352. done;
  3353. fi;
  3354. export CFLAGS CXXFLAGS
  3355. }
  3356. replace_all_version_separators ()
  3357. {
  3358. local c=($(get_all_version_components "${2:-${PV}}"));
  3359. c=${c[@]//[-._]/$1};
  3360. echo ${c// }
  3361. }
  3362. replace_version_separator ()
  3363. {
  3364. eshopts_push -s extglob;
  3365. local w c v="${3:-${PV}}";
  3366. declare -i i found=0;
  3367. w=${1:-1};
  3368. c=($(get_all_version_components ${v}));
  3369. if [[ ${w} != *[[:digit:]]* ]]; then
  3370. for ((i = 0; i < ${#c[@]}; i++))
  3371. do
  3372. if [[ ${c[i]} == ${w} ]]; then
  3373. c[i]=${2};
  3374. break;
  3375. fi;
  3376. done;
  3377. else
  3378. for ((i = 0; i < ${#c[@]}; i++))
  3379. do
  3380. if [[ -n "${c[i]//[^-._]}" ]]; then
  3381. found+=1;
  3382. if ((found == w)); then
  3383. c[i]=${2};
  3384. break;
  3385. fi;
  3386. fi;
  3387. done;
  3388. fi;
  3389. c=${c[*]};
  3390. echo ${c// };
  3391. eshopts_pop
  3392. }
  3393. require_configured_kernel ()
  3394. {
  3395. if ! linux_config_src_exists; then
  3396. qeerror "Could not find a usable .config in the kernel source directory.";
  3397. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  3398. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  3399. qeerror "it points to the necessary object directory so that it might find .config.";
  3400. die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  3401. fi
  3402. }
  3403. seq ()
  3404. {
  3405. local p=$(type -P seq);
  3406. if [[ -n ${p} ]]; then
  3407. "${p}" "$@";
  3408. return $?;
  3409. fi;
  3410. case $# in
  3411. 1)
  3412. min=1 max=$1 step=1
  3413. ;;
  3414. 2)
  3415. min=$1 max=$2 step=1
  3416. ;;
  3417. 3)
  3418. min=$1 max=$3 step=$2
  3419. ;;
  3420. *)
  3421. die "seq called with wrong number of arguments"
  3422. ;;
  3423. esac;
  3424. p=$(type -P jot);
  3425. if [[ -n ${p} ]]; then
  3426. local reps;
  3427. if [[ ${step} != 0 ]]; then
  3428. reps=$(( (max - min) / step + 1 ));
  3429. else
  3430. reps=0;
  3431. fi;
  3432. jot $reps $min $max $step;
  3433. return $?;
  3434. fi;
  3435. while :; do
  3436. [[ $max < $min && $step > 0 ]] && break;
  3437. [[ $min < $max && $step < 0 ]] && break;
  3438. echo $min;
  3439. : $(( min += step ));
  3440. done;
  3441. return 0
  3442. }
  3443. set_arch_to_kernel ()
  3444. {
  3445. export ARCH=$(tc-arch-kernel)
  3446. }
  3447. set_arch_to_portage ()
  3448. {
  3449. export ARCH=$(tc-arch)
  3450. }
  3451. setup-allowed-flags ()
  3452. {
  3453. if [[ -z ${ALLOWED_FLAGS} ]]; then
  3454. export ALLOWED_FLAGS="-pipe";
  3455. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -O -O0 -O1 -O2 -mcpu -march -mtune";
  3456. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fstack-protector -fstack-protector-all";
  3457. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fbounds-checking -fno-strict-overflow";
  3458. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-PIE -fno-pie -fno-unit-at-a-time";
  3459. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+";
  3460. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-ident -fpermissive";
  3461. export ALLOWED_FLAGS="${ALLOWED_FLAGS} -W* -w";
  3462. fi;
  3463. ALLOWED_FLAGS="${ALLOWED_FLAGS} -fno-stack-protector -fno-stack-protector-all -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer";
  3464. ALLOWED_FLAGS="${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 -D* -U*";
  3465. ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
  3466. ALLOWED_FLAGS="${ALLOWED_FLAGS} -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
  3467. export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks";
  3468. return 0
  3469. }
  3470. src_compile ()
  3471. {
  3472. _eapi2_src_compile "$@"
  3473. }
  3474. src_configure ()
  3475. {
  3476. local conf_opts audio_opts user_targets;
  3477. for target in ${IUSE_SOFTMMU_TARGETS};
  3478. do
  3479. use "qemu_softmmu_targets_${target}" && softmmu_targets="${softmmu_targets} ${target}-softmmu";
  3480. done;
  3481. for target in ${IUSE_USER_TARGETS};
  3482. do
  3483. use "qemu_user_targets_${target}" && user_targets="${user_targets} ${target}-linux-user";
  3484. done;
  3485. if [ -z "${softmmu_targets}" ]; then
  3486. eerror "All SoftMMU targets are disabled. This is invalid for qemu-kvm";
  3487. die "At least 1 SoftMMU target must be enabled";
  3488. else
  3489. einfo "Building the following softmmu targets: ${softmmu_targets}";
  3490. fi;
  3491. if [ ! -z "${user_targets}" ]; then
  3492. einfo "Building the following user targets: ${user_targets}";
  3493. conf_opts="${conf_opts} --enable-linux-user";
  3494. else
  3495. conf_opts="${conf_opts} --disable-linux-user";
  3496. fi;
  3497. conf_opts="${conf_opts} --extra-ldflags=-Wl,-z,execheap";
  3498. use debug && conf_opts="${conf_opts} --enable-debug --disable-strip";
  3499. conf_opts="${conf_opts} --sysconfdir=/etc";
  3500. conf_opts="${conf_opts} $(use_enable aio linux-aio)";
  3501. conf_opts="${conf_opts} $(use_enable bluetooth bluez)";
  3502. conf_opts="${conf_opts} $(use_enable brltty brlapi)";
  3503. conf_opts="${conf_opts} $(use_enable curl)";
  3504. conf_opts="${conf_opts} $(use_enable fdt)";
  3505. conf_opts="${conf_opts} $(use_enable hardened user-pie)";
  3506. conf_opts="${conf_opts} $(use_enable jpeg vnc-jpeg)";
  3507. conf_opts="${conf_opts} $(use_enable ncurses curses)";
  3508. conf_opts="${conf_opts} $(use_enable png vnc-png)";
  3509. conf_opts="${conf_opts} $(use_enable rbd)";
  3510. conf_opts="${conf_opts} $(use_enable sasl vnc-sasl)";
  3511. conf_opts="${conf_opts} $(use_enable sdl)";
  3512. conf_opts="${conf_opts} $(use_enable spice)";
  3513. conf_opts="${conf_opts} $(use_enable ssl vnc-tls)";
  3514. conf_opts="${conf_opts} $(use_enable threads vnc-thread)";
  3515. conf_opts="${conf_opts} $(use_enable vde)";
  3516. conf_opts="${conf_opts} $(use_enable vhost-net)";
  3517. conf_opts="${conf_opts} $(use_enable xen)";
  3518. conf_opts="${conf_opts} --disable-darwin-user --disable-bsd-user";
  3519. audio_opts="oss";
  3520. use alsa && audio_opts="alsa ${audio_opts}";
  3521. use esd && audio_opts="esd ${audio_opts}";
  3522. use pulseaudio && audio_opts="pa ${audio_opts}";
  3523. use sdl && audio_opts="sdl ${audio_opts}";
  3524. ./configure --prefix=/usr --disable-strip --disable-werror --enable-kvm --enable-nptl --enable-uuid ${conf_opts} --audio-drv-list="${audio_opts}" --target-list="${softmmu_targets} ${user_targets}" --cc="$(tc-getCC)" --host-cc="$(tc-getBUILD_CC)" || die "configure failed"
  3525. }
  3526. src_install ()
  3527. {
  3528. emake DESTDIR="${D}" install || die "make install failed";
  3529. if [ ! -z "${softmmu_targets}" ]; then
  3530. insinto /$(get_libdir)/udev/rules.d/;
  3531. doins kvm/scripts/65-kvm.rules || die;
  3532. if use qemu-ifup; then
  3533. insinto /etc/qemu/;
  3534. insopts -m0755;
  3535. doins kvm/scripts/qemu-ifup || die;
  3536. fi;
  3537. if use qemu_softmmu_targets_x86_64; then
  3538. dobin "${FILESDIR}"/qemu-kvm;
  3539. dosym /usr/bin/qemu-kvm /usr/bin/kvm;
  3540. else
  3541. elog "You disabled QEMU_SOFTMMU_TARGETS=x86_64, this disables install";
  3542. elog "of /usr/bin/qemu-kvm and /usr/bin/kvm";
  3543. fi;
  3544. fi;
  3545. dodoc Changelog MAINTAINERS TODO pci-ids.txt || die;
  3546. newdoc pc-bios/README README.pc-bios || die;
  3547. dohtml qemu-doc.html qemu-tech.html || die
  3548. }
  3549. src_prepare ()
  3550. {
  3551. sed -i '/$(DESTDIR)$(docdir)/d' Makefile || die;
  3552. sed -i 's/^\(C\|OP_C\|HELPER_C\)FLAGS=/\1FLAGS+=/' Makefile Makefile.target || die;
  3553. sed -i 's/$(LDFLAGS)/$(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS)/' rules.mak || die;
  3554. sed -e 's~NAME="%k", ~~' -i kvm/scripts/65-kvm.rules || die;
  3555. epatch "${FILESDIR}/qemu-0.11.0-mips64-user-fix.patch";
  3556. [[ -n ${BACKPORTS} ]] && EPATCH_FORCE=yes EPATCH_SUFFIX="patch" EPATCH_SOURCE="${S}/patches" epatch
  3557. }
  3558. src_test ()
  3559. {
  3560. _eapi0_src_test "$@"
  3561. }
  3562. src_unpack ()
  3563. {
  3564. _eapi0_src_unpack "$@"
  3565. }
  3566. strip-flags ()
  3567. {
  3568. local x y flag NEW_CFLAGS NEW_CXXFLAGS NEW_FFLAGS NEW_FCFLAGS;
  3569. setup-allowed-flags;
  3570. local NEW_CFLAGS="";
  3571. local NEW_CXXFLAGS="";
  3572. local NEW_FFLAGS="";
  3573. local NEW_FCFLAGS="";
  3574. if has "~$(tc-arch)" ${ACCEPT_KEYWORDS}; then
  3575. ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}";
  3576. fi;
  3577. set -f;
  3578. for x in ${CFLAGS};
  3579. do
  3580. for y in ${ALLOWED_FLAGS};
  3581. do
  3582. flag=${x%%=*};
  3583. if [ "${flag%%${y}}" = "" ]; then
  3584. NEW_CFLAGS="${NEW_CFLAGS} ${x}";
  3585. break;
  3586. fi;
  3587. done;
  3588. done;
  3589. for x in ${CXXFLAGS};
  3590. do
  3591. for y in ${ALLOWED_FLAGS};
  3592. do
  3593. flag=${x%%=*};
  3594. if [ "${flag%%${y}}" = "" ]; then
  3595. NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}";
  3596. break;
  3597. fi;
  3598. done;
  3599. done;
  3600. for x in ${FFLAGS};
  3601. do
  3602. for y in ${ALLOWED_FLAGS};
  3603. do
  3604. flag=${x%%=*};
  3605. if [ "${flag%%${y}}" = "" ]; then
  3606. NEW_FFLAGS="${NEW_FFLAGS} ${x}";
  3607. break;
  3608. fi;
  3609. done;
  3610. done;
  3611. for x in ${FCFLAGS};
  3612. do
  3613. for y in ${ALLOWED_FLAGS};
  3614. do
  3615. flag=${x%%=*};
  3616. if [ "${flag%%${y}}" = "" ]; then
  3617. NEW_FCFLAGS="${NEW_FCFLAGS} ${x}";
  3618. break;
  3619. fi;
  3620. done;
  3621. done;
  3622. if [ "${CFLAGS/-O}" != "${CFLAGS}" -a "${NEW_CFLAGS/-O}" = "${NEW_CFLAGS}" ]; then
  3623. NEW_CFLAGS="${NEW_CFLAGS} -O2";
  3624. fi;
  3625. if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then
  3626. NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2";
  3627. fi;
  3628. if [ "${FFLAGS/-O}" != "${FFLAGS}" -a "${NEW_FFLAGS/-O}" = "${NEW_FFLAGS}" ]; then
  3629. NEW_FFLAGS="${NEW_FFLAGS} -O2";
  3630. fi;
  3631. if [ "${FCFLAGS/-O}" != "${FCFLAGS}" -a "${NEW_FCFLAGS/-O}" = "${NEW_FCFLAGS}" ]; then
  3632. NEW_FCFLAGS="${NEW_FCFLAGS} -O2";
  3633. fi;
  3634. set +f;
  3635. export CFLAGS="${NEW_CFLAGS}";
  3636. export CXXFLAGS="${NEW_CXXFLAGS}";
  3637. export FFLAGS="${NEW_FFLAGS}";
  3638. export FCFLAGS="${NEW_FCFLAGS}";
  3639. return 0
  3640. }
  3641. strip-linguas ()
  3642. {
  3643. local ls newls nols;
  3644. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  3645. local op=$1;
  3646. shift;
  3647. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  3648. shift;
  3649. local d f;
  3650. for d in "$@";
  3651. do
  3652. if [[ ${op} == "-u" ]]; then
  3653. newls=${ls};
  3654. else
  3655. newls="";
  3656. fi;
  3657. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  3658. do
  3659. if [[ ${op} == "-i" ]]; then
  3660. has ${f} ${ls} && newls="${newls} ${f}";
  3661. else
  3662. has ${f} ${ls} || newls="${newls} ${f}";
  3663. fi;
  3664. done;
  3665. ls=${newls};
  3666. done;
  3667. else
  3668. ls="$@";
  3669. fi;
  3670. nols="";
  3671. newls="";
  3672. for f in ${LINGUAS};
  3673. do
  3674. if has ${f} ${ls}; then
  3675. newls="${newls} ${f}";
  3676. else
  3677. nols="${nols} ${f}";
  3678. fi;
  3679. done;
  3680. [[ -n ${nols} ]] && ewarn "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  3681. export LINGUAS=${newls:1}
  3682. }
  3683. strip-unsupported-flags ()
  3684. {
  3685. export CFLAGS=$(test-flags-CC ${CFLAGS});
  3686. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  3687. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  3688. export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  3689. }
  3690. tc-arch ()
  3691. {
  3692. tc-ninja_magic_to_arch portage "$@"
  3693. }
  3694. tc-arch-kernel ()
  3695. {
  3696. tc-ninja_magic_to_arch kern "$@"
  3697. }
  3698. tc-endian ()
  3699. {
  3700. local host=$1;
  3701. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3702. host=${host%%-*};
  3703. case ${host} in
  3704. alpha*)
  3705. echo big
  3706. ;;
  3707. arm*b*)
  3708. echo big
  3709. ;;
  3710. arm*)
  3711. echo little
  3712. ;;
  3713. cris*)
  3714. echo little
  3715. ;;
  3716. hppa*)
  3717. echo big
  3718. ;;
  3719. i?86*)
  3720. echo little
  3721. ;;
  3722. ia64*)
  3723. echo little
  3724. ;;
  3725. m68*)
  3726. echo big
  3727. ;;
  3728. mips*l*)
  3729. echo little
  3730. ;;
  3731. mips*)
  3732. echo big
  3733. ;;
  3734. powerpc*)
  3735. echo big
  3736. ;;
  3737. s390*)
  3738. echo big
  3739. ;;
  3740. sh*b*)
  3741. echo big
  3742. ;;
  3743. sh*)
  3744. echo little
  3745. ;;
  3746. sparc*)
  3747. echo big
  3748. ;;
  3749. x86_64*)
  3750. echo little
  3751. ;;
  3752. *)
  3753. echo wtf
  3754. ;;
  3755. esac
  3756. }
  3757. tc-env_build ()
  3758. {
  3759. CFLAGS=${BUILD_CFLAGS:--O1 -pipe} CXXFLAGS=${BUILD_CXXFLAGS:--O1 -pipe} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
  3760. }
  3761. tc-export ()
  3762. {
  3763. local var;
  3764. for var in "$@";
  3765. do
  3766. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3767. eval tc-get${var} > /dev/null;
  3768. done
  3769. }
  3770. tc-getAR ()
  3771. {
  3772. tc-getPROG AR ar "$@"
  3773. }
  3774. tc-getAS ()
  3775. {
  3776. tc-getPROG AS as "$@"
  3777. }
  3778. tc-getBUILD_AR ()
  3779. {
  3780. tc-getBUILD_PROG AR ar "$@"
  3781. }
  3782. tc-getBUILD_AS ()
  3783. {
  3784. tc-getBUILD_PROG AS as "$@"
  3785. }
  3786. tc-getBUILD_CC ()
  3787. {
  3788. tc-getBUILD_PROG CC gcc "$@"
  3789. }
  3790. tc-getBUILD_CPP ()
  3791. {
  3792. tc-getBUILD_PROG CPP cpp "$@"
  3793. }
  3794. tc-getBUILD_CXX ()
  3795. {
  3796. tc-getBUILD_PROG CXX g++ "$@"
  3797. }
  3798. tc-getBUILD_LD ()
  3799. {
  3800. tc-getBUILD_PROG LD ld "$@"
  3801. }
  3802. tc-getBUILD_NM ()
  3803. {
  3804. tc-getBUILD_PROG NM nm "$@"
  3805. }
  3806. tc-getBUILD_OBJCOPY ()
  3807. {
  3808. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3809. }
  3810. tc-getBUILD_PKG_CONFIG ()
  3811. {
  3812. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3813. }
  3814. tc-getBUILD_PROG ()
  3815. {
  3816. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  3817. }
  3818. tc-getBUILD_RANLIB ()
  3819. {
  3820. tc-getBUILD_PROG RANLIB ranlib "$@"
  3821. }
  3822. tc-getBUILD_STRIP ()
  3823. {
  3824. tc-getBUILD_PROG STRIP strip "$@"
  3825. }
  3826. tc-getCC ()
  3827. {
  3828. tc-getPROG CC gcc "$@"
  3829. }
  3830. tc-getCPP ()
  3831. {
  3832. tc-getPROG CPP cpp "$@"
  3833. }
  3834. tc-getCXX ()
  3835. {
  3836. tc-getPROG CXX g++ "$@"
  3837. }
  3838. tc-getDLLWRAP ()
  3839. {
  3840. tc-getPROG DLLWRAP dllwrap "$@"
  3841. }
  3842. tc-getF77 ()
  3843. {
  3844. tc-getPROG F77 gfortran "$@"
  3845. }
  3846. tc-getFC ()
  3847. {
  3848. tc-getPROG FC gfortran "$@"
  3849. }
  3850. tc-getGCJ ()
  3851. {
  3852. tc-getPROG GCJ gcj "$@"
  3853. }
  3854. tc-getLD ()
  3855. {
  3856. tc-getPROG LD ld "$@"
  3857. }
  3858. tc-getNM ()
  3859. {
  3860. tc-getPROG NM nm "$@"
  3861. }
  3862. tc-getOBJCOPY ()
  3863. {
  3864. tc-getPROG OBJCOPY objcopy "$@"
  3865. }
  3866. tc-getPKG_CONFIG ()
  3867. {
  3868. tc-getPROG PKG_CONFIG pkg-config "$@"
  3869. }
  3870. tc-getPROG ()
  3871. {
  3872. _tc-getPROG CHOST "$@"
  3873. }
  3874. tc-getRANLIB ()
  3875. {
  3876. tc-getPROG RANLIB ranlib "$@"
  3877. }
  3878. tc-getRC ()
  3879. {
  3880. tc-getPROG RC windres "$@"
  3881. }
  3882. tc-getSTRIP ()
  3883. {
  3884. tc-getPROG STRIP strip "$@"
  3885. }
  3886. tc-has-openmp ()
  3887. {
  3888. local base="${T}/test-tc-openmp";
  3889. cat > "${base}.c" <<-EOF
  3890. #include <omp.h>
  3891. int main() {
  3892. int nthreads, tid, ret = 0;
  3893. #pragma omp parallel private(nthreads, tid)
  3894. {
  3895. tid = omp_get_thread_num();
  3896. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3897. }
  3898. return ret;
  3899. }
  3900. EOF
  3901.  
  3902. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  3903. local ret=$?;
  3904. rm -f "${base}"*;
  3905. return ${ret}
  3906. }
  3907. tc-has-tls ()
  3908. {
  3909. local base="${T}/test-tc-tls";
  3910. cat > "${base}.c" <<-EOF
  3911. int foo(int *i) {
  3912. static __thread int j = 0;
  3913. return *i ? j : *i;
  3914. }
  3915. EOF
  3916.  
  3917. local flags;
  3918. case $1 in
  3919. -s)
  3920. flags="-S"
  3921. ;;
  3922. -c)
  3923. flags="-c"
  3924. ;;
  3925. -l)
  3926.  
  3927. ;;
  3928. -*)
  3929. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3930. ;;
  3931. esac;
  3932. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3933. [[ $1 == -* ]] && shift;
  3934. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  3935. local ret=$?;
  3936. rm -f "${base}"*;
  3937. return ${ret}
  3938. }
  3939. tc-is-cross-compiler ()
  3940. {
  3941. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  3942. }
  3943. tc-is-hardfloat ()
  3944. {
  3945. [[ ${CTARGET//_/-} == *-hardfloat-* ]] && echo "yes" || echo "no"
  3946. }
  3947. tc-is-softfloat ()
  3948. {
  3949. case ${CTARGET} in
  3950. bfin* | h8300*)
  3951. echo "only"
  3952. ;;
  3953. *)
  3954. [[ ${CTARGET//_/-} == *-softfloat-* ]] && echo "yes" || echo "no"
  3955. ;;
  3956. esac
  3957. }
  3958. tc-is-static-only ()
  3959. {
  3960. local host=${CTARGET:-${CHOST}};
  3961. return $([[ ${host} == *-mint* ]])
  3962. }
  3963. tc-ninja_magic_to_arch ()
  3964. {
  3965. function ninj ()
  3966. {
  3967. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3968. };
  3969. local type=$1;
  3970. local host=$2;
  3971. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3972. case ${host} in
  3973. alpha*)
  3974. echo alpha
  3975. ;;
  3976. arm*)
  3977. echo arm
  3978. ;;
  3979. avr*)
  3980. ninj avr32 avr
  3981. ;;
  3982. bfin*)
  3983. ninj blackfin bfin
  3984. ;;
  3985. cris*)
  3986. echo cris
  3987. ;;
  3988. hppa*)
  3989. ninj parisc hppa
  3990. ;;
  3991. i?86*)
  3992. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  3993. echo i386;
  3994. else
  3995. echo x86;
  3996. fi
  3997. ;;
  3998. ia64*)
  3999. echo ia64
  4000. ;;
  4001. m68*)
  4002. echo m68k
  4003. ;;
  4004. mips*)
  4005. echo mips
  4006. ;;
  4007. nios2*)
  4008. echo nios2
  4009. ;;
  4010. nios*)
  4011. echo nios
  4012. ;;
  4013. powerpc*)
  4014. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  4015. echo powerpc;
  4016. else
  4017. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  4018. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  4019. echo powerpc;
  4020. else
  4021. echo ppc;
  4022. fi;
  4023. else
  4024. if [[ ${host} == powerpc64* ]]; then
  4025. echo ppc64;
  4026. else
  4027. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  4028. ninj ppc64 ppc;
  4029. else
  4030. echo ppc;
  4031. fi;
  4032. fi;
  4033. fi;
  4034. fi
  4035. ;;
  4036. s390*)
  4037. echo s390
  4038. ;;
  4039. sh64*)
  4040. ninj sh64 sh
  4041. ;;
  4042. sh*)
  4043. echo sh
  4044. ;;
  4045. sparc64*)
  4046. ninj sparc64 sparc
  4047. ;;
  4048. sparc*)
  4049. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  4050. ;;
  4051. vax*)
  4052. echo vax
  4053. ;;
  4054. x86_64*freebsd*)
  4055. echo amd64
  4056. ;;
  4057. x86_64*)
  4058. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  4059. echo x86;
  4060. else
  4061. ninj x86_64 amd64;
  4062. fi
  4063. ;;
  4064. *)
  4065. echo unknown
  4066. ;;
  4067. esac
  4068. }
  4069. test-flag-CC ()
  4070. {
  4071. test-flag-PROG "CC" "$1"
  4072. }
  4073. test-flag-CXX ()
  4074. {
  4075. test-flag-PROG "CXX" "$1"
  4076. }
  4077. test-flag-F77 ()
  4078. {
  4079. test-flag-PROG "F77" "$1"
  4080. }
  4081. test-flag-FC ()
  4082. {
  4083. test-flag-PROG "FC" "$1"
  4084. }
  4085. test-flag-PROG ()
  4086. {
  4087. local comp=$1;
  4088. local flags="$2";
  4089. [[ -z ${comp} || -z ${flags} ]] && return 1;
  4090. local PROG=$(tc-get${comp});
  4091. ${PROG} ${flags} -c -o /dev/null -xc /dev/null > /dev/null 2>&1
  4092. }
  4093. test-flags ()
  4094. {
  4095. test-flags-CC "$@"
  4096. }
  4097. test-flags-CC ()
  4098. {
  4099. test-flags-PROG "CC" "$@"
  4100. }
  4101. test-flags-CXX ()
  4102. {
  4103. test-flags-PROG "CXX" "$@"
  4104. }
  4105. test-flags-F77 ()
  4106. {
  4107. test-flags-PROG "F77" "$@"
  4108. }
  4109. test-flags-FC ()
  4110. {
  4111. test-flags-PROG "FC" "$@"
  4112. }
  4113. test-flags-PROG ()
  4114. {
  4115. local comp=$1;
  4116. local flags;
  4117. local x;
  4118. shift;
  4119. [[ -z ${comp} ]] && return 1;
  4120. for x in "$@";
  4121. do
  4122. test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}";
  4123. done;
  4124. echo "${flags}";
  4125. [[ -n ${flags} ]]
  4126. }
  4127. test_flag ()
  4128. {
  4129. die "$0: deprecated, please use test-flags()!"
  4130. }
  4131. test_version_info ()
  4132. {
  4133. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  4134. return 0;
  4135. else
  4136. return 1;
  4137. fi
  4138. }
  4139. treecopy ()
  4140. {
  4141. dest=${!#};
  4142. files_count=$#;
  4143. while (( $# > 1 )); do
  4144. dirstruct=$(dirname "$1");
  4145. mkdir -p "${dest}/${dirstruct}";
  4146. cp -pPR "$1" "${dest}/${dirstruct}";
  4147. shift;
  4148. done
  4149. }
  4150. unpack_makeself ()
  4151. {
  4152. local src_input=${1:-${A}};
  4153. local src=$(find_unpackable_file "${src_input}");
  4154. local skip=$2;
  4155. local exe=$3;
  4156. [[ -z ${src} ]] && die "Could not locate source for '${src_input}'";
  4157. local shrtsrc=$(basename "${src}");
  4158. echo ">>> Unpacking ${shrtsrc} to ${PWD}";
  4159. if [[ -z ${skip} ]]; then
  4160. local ver=$(grep -m1 -a '#.*Makeself' "${src}" | awk '{print $NF}');
  4161. local skip=0;
  4162. exe=tail;
  4163. case ${ver} in
  4164. 1.5.* | 1.6.0-nv)
  4165. skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
  4166. ;;
  4167. 2.0 | 2.0.1)
  4168. skip=$(grep -a ^' 'tail "${src}" | awk '{print $2}' | cut -b2-)
  4169. ;;
  4170. 2.1.1)
  4171. skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-);
  4172. (( skip++ ))
  4173. ;;
  4174. 2.1.2)
  4175. skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1);
  4176. (( skip++ ))
  4177. ;;
  4178. 2.1.3)
  4179. skip=`grep -a ^offset= "${src}" | awk '{print $3}'`;
  4180. (( skip++ ))
  4181. ;;
  4182. 2.1.4 | 2.1.5)
  4183. skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1);
  4184. skip=$(head -n ${skip} "${src}" | wc -c);
  4185. exe="dd"
  4186. ;;
  4187. *)
  4188. eerror "I'm sorry, but I was unable to support the Makeself file.";
  4189. eerror "The version I detected was '${ver}'.";
  4190. eerror "Please file a bug about the file ${shrtsrc} at";
  4191. eerror "http://bugs.gentoo.org/ so that support can be added.";
  4192. die "makeself version '${ver}' not supported"
  4193. ;;
  4194. esac;
  4195. debug-print "Detected Makeself version ${ver} ... using ${skip} as offset";
  4196. fi;
  4197. case ${exe} in
  4198. tail)
  4199. exe="tail -n +${skip} '${src}'"
  4200. ;;
  4201. dd)
  4202. exe="dd ibs=${skip} skip=1 if='${src}'"
  4203. ;;
  4204. *)
  4205. die "makeself cant handle exe '${exe}'"
  4206. ;;
  4207. esac;
  4208. local filetype tmpfile=$(emktemp);
  4209. eval ${exe} 2> /dev/null | head -c 512 > "${tmpfile}";
  4210. filetype=$(file -b "${tmpfile}") || die;
  4211. case ${filetype} in
  4212. *tar\ archive*)
  4213. eval ${exe} | tar --no-same-owner -xf -
  4214. ;;
  4215. bzip2*)
  4216. eval ${exe} | bzip2 -dc | tar --no-same-owner -xf -
  4217. ;;
  4218. gzip*)
  4219. eval ${exe} | tar --no-same-owner -xzf -
  4220. ;;
  4221. compress*)
  4222. eval ${exe} | gunzip | tar --no-same-owner -xf -
  4223. ;;
  4224. *)
  4225. eerror "Unknown filetype \"${filetype}\" ?";
  4226. false
  4227. ;;
  4228. esac;
  4229. assert "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
  4230. }
  4231. unpack_pdv ()
  4232. {
  4233. local src=$(find_unpackable_file "$1");
  4234. local sizeoff_t=$2;
  4235. [[ -z ${src} ]] && die "Could not locate source for '$1'";
  4236. [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(";
  4237. local shrtsrc=$(basename "${src}");
  4238. echo ">>> Unpacking ${shrtsrc} to ${PWD}";
  4239. local metaskip=$(tail -c ${sizeoff_t} "${src}" | hexdump -e \"%i\");
  4240. local tailskip=$(tail -c $((${sizeoff_t}*2)) "${src}" | head -c ${sizeoff_t} | hexdump -e \"%i\");
  4241. local metafile=$(emktemp);
  4242. tail -c +$((${metaskip}+1)) "${src}" > "${metafile}";
  4243. local datafile=$(tail -c +$((${metaskip}+1)) "${src}" | strings | head -n 1);
  4244. datafile=$(basename "${datafile}");
  4245. local tmpfile=$(emktemp);
  4246. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c 512 > ${tmpfile};
  4247. local iscompressed=$(file -b "${tmpfile}");
  4248. if [[ ${iscompressed:0:8} == "compress" ]]; then
  4249. iscompressed=1;
  4250. mv ${tmpfile}{,.Z};
  4251. gunzip ${tmpfile};
  4252. else
  4253. iscompressed=0;
  4254. fi;
  4255. local istar=$(file -b "${tmpfile}");
  4256. if [[ ${istar:0:9} == "POSIX tar" ]]; then
  4257. istar=1;
  4258. else
  4259. istar=0;
  4260. fi;
  4261. if [ ${iscompressed} -eq 1 ]; then
  4262. if [ ${istar} -eq 1 ]; then
  4263. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar -xzf -;
  4264. else
  4265. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | gzip -dc > ${datafile};
  4266. fi;
  4267. else
  4268. if [ ${istar} -eq 1 ]; then
  4269. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar --no-same-owner -xf -;
  4270. else
  4271. tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) > ${datafile};
  4272. fi;
  4273. fi;
  4274. true
  4275. }
  4276. use_if_iuse ()
  4277. {
  4278. in_iuse $1 || return 1;
  4279. use $1
  4280. }
  4281. usex ()
  4282. {
  4283. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  4284. }
  4285. validate_desktop_entries ()
  4286. {
  4287. if [[ -x /usr/bin/desktop-file-validate ]]; then
  4288. einfo "Checking desktop entry validity";
  4289. local directories="";
  4290. for d in /usr/share/applications $@;
  4291. do
  4292. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  4293. done;
  4294. if [[ -n ${directories} ]]; then
  4295. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  4296. do
  4297. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  4298. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  4299. done;
  4300. fi;
  4301. echo "";
  4302. else
  4303. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  4304. fi
  4305. }
  4306. version_compare ()
  4307. {
  4308. eshopts_push -s extglob;
  4309. local ver_a=${1} ver_b=${2} parts_a parts_b;
  4310. local cur_tok_a cur_tok_b num_part_a num_part_b;
  4311. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  4312. parts_a=($(get_all_version_components "${ver_a}" ));
  4313. parts_b=($(get_all_version_components "${ver_b}" ));
  4314. local -i inf_loop=0;
  4315. while true; do
  4316. inf_loop+=1;
  4317. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  4318. prev_idx_a=cur_idx_a;
  4319. prev_idx_b=cur_idx_b;
  4320. cur_tok_a=${parts_a[cur_idx_a]};
  4321. cur_tok_b=${parts_b[cur_idx_b]};
  4322. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  4323. cur_idx_a+=1;
  4324. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  4325. else
  4326. cur_tok_a=;
  4327. fi;
  4328. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  4329. cur_idx_b+=1;
  4330. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  4331. else
  4332. cur_tok_b=;
  4333. fi;
  4334. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  4335. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  4336. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  4337. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  4338. cur_tok_a=${cur_tok_a%%+(0)};
  4339. cur_tok_b=${cur_tok_b%%+(0)};
  4340. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  4341. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  4342. else
  4343. cur_tok_a=${cur_tok_a##+(0)};
  4344. cur_tok_b=${cur_tok_b##+(0)};
  4345. : ${cur_tok_a:=0};
  4346. : ${cur_tok_b:=0};
  4347. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  4348. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  4349. fi;
  4350. done;
  4351. local letter_a=;
  4352. letter_a=${parts_a[cur_idx_a]};
  4353. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  4354. cur_idx_a+=1;
  4355. else
  4356. letter_a=@;
  4357. fi;
  4358. local letter_b=;
  4359. letter_b=${parts_b[cur_idx_b]};
  4360. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  4361. cur_idx_b+=1;
  4362. else
  4363. letter_b=@;
  4364. fi;
  4365. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  4366. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  4367. inf_loop=0;
  4368. while true; do
  4369. inf_loop+=1;
  4370. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  4371. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  4372. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  4373. cur_tok_a=${parts_a[cur_idx_a]};
  4374. cur_tok_b=${parts_b[cur_idx_b]};
  4375. num_part_a=0;
  4376. num_part_b=0;
  4377. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  4378. cur_idx_a+=1;
  4379. num_part_a=${cur_tok_a##+([a-z])};
  4380. num_part_a=${num_part_a##+(0)};
  4381. : ${num_part_a:=0};
  4382. cur_tok_a=${cur_tok_a%%+([0-9])};
  4383. else
  4384. cur_tok_a=;
  4385. fi;
  4386. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  4387. cur_idx_b+=1;
  4388. num_part_b=${cur_tok_b##+([a-z])};
  4389. num_part_b=${num_part_b##+(0)};
  4390. : ${num_part_b:=0};
  4391. cur_tok_b=${cur_tok_b%%+([0-9])};
  4392. else
  4393. cur_tok_b=;
  4394. fi;
  4395. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  4396. local suffix;
  4397. for suffix in alpha beta pre rc "" p;
  4398. do
  4399. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  4400. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  4401. done;
  4402. else
  4403. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  4404. break;
  4405. else
  4406. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  4407. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  4408. fi;
  4409. fi;
  4410. done;
  4411. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  4412. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  4413. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  4414. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  4415. fi;
  4416. num_part_a=${parts_a[cur_idx_a]#r};
  4417. num_part_a=${num_part_a##+(0)};
  4418. : ${num_part_a:=0};
  4419. num_part_b=${parts_b[cur_idx_b]#r};
  4420. num_part_b=${num_part_b##+(0)};
  4421. : ${num_part_b:=0};
  4422. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  4423. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  4424. eshopts_pop;
  4425. return 2
  4426. }
  4427. version_format_string ()
  4428. {
  4429. local fstr=$1;
  4430. shift;
  4431. set -- $(get_version_components "$@");
  4432. eval echo "${fstr}"
  4433. }
  4434. version_is_at_least ()
  4435. {
  4436. local want_s="$1" have_s="${2:-${PVR}}" r;
  4437. version_compare "${want_s}" "${have_s}";
  4438. r=$?;
  4439. case $r in
  4440. 1 | 2)
  4441. return 0
  4442. ;;
  4443. 3)
  4444. return 1
  4445. ;;
  4446. *)
  4447. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  4448. ;;
  4449. esac
  4450. }
  4451. version_sort ()
  4452. {
  4453. eshopts_push -s extglob;
  4454. local items=;
  4455. local -i left=0;
  4456. items=("$@");
  4457. while ((left < ${#items[@]})); do
  4458. local -i lowest_idx=left;
  4459. local -i idx=lowest_idx+1;
  4460. while ((idx < ${#items[@]})); do
  4461. version_compare "${items[lowest_idx]}" "${items[idx]}";
  4462. [[ $? -eq 3 ]] && lowest_idx=idx;
  4463. idx+=1;
  4464. done;
  4465. local tmp=${items[lowest_idx]};
  4466. items[lowest_idx]=${items[left]};
  4467. items[left]=${tmp};
  4468. left+=1;
  4469. done;
  4470. echo ${items[@]};
  4471. eshopts_pop
  4472. }
  4473.  
  4474.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement