Advertisement
Guest User

environment

a guest
Mar 21st, 2012
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.84 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 AR="x86_64-pc-linux-gnu-ar"
  6. declare -x ARCH="amd64"
  7. declare -x BOOTSTRAP_USE="cxx unicode multilib 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 CC="x86_64-pc-linux-gnu-gcc"
  12. declare -x CFLAGS="-O2 -pipe"
  13. declare -x CFLAGS_amd64="-m64"
  14. declare -x CFLAGS_default
  15. declare -x CFLAGS_x32="-mx32"
  16. declare -x CFLAGS_x86="-m32"
  17. declare -x CHOST="x86_64-pc-linux-gnu"
  18. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  19. declare -x CHOST_default="x86_64-pc-linux-gnu"
  20. declare -x CHOST_x32="x86_64-pc-linux-gnu"
  21. declare -x CHOST_x86="i686-pc-linux-gnu"
  22. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  23. declare -x CONFIGURE_EPREFIX="/home/bmillare/gentoo-prefix"
  24. declare -x CPATH="/usr/site/intel_cpp-11.0.074/mkl/include:/usr/site/intel_cpp-11.0.074/tbb/include:/usr/site/intel_fortan-11.0.074/mkl/include"
  25. declare -x CROSSCOMPILE_OPTS=""
  26. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  27. declare -x CUDA_INSTALL_PATH="/usr/site/cuda/"
  28. declare -x CXXFLAGS="-O2 -pipe"
  29. declare -x DEFAULT_ABI="default"
  30. declare -x DEFINED_PHASES=" configure install postinst prepare setup"
  31. declare DEPEND="!prefix? ( >=sys-apps/openrc-0.9.9.3 )
  32. app-arch/xz-utils "
  33. declare DESCRIPTION="Standard Linux networking tools"
  34. declare -x DESTTREE="/usr"
  35. declare -x DIROPTIONS="-m0755"
  36. declare -x DYLD_LIBRARY_PATH="/usr/site/intel_cpp-11.0.074/tbb/em64t/cc3.4.3_libc2.3.4_kernel2.6.9/lib"
  37. declare -x EAPI="3"
  38. declare -x ELIBC="glibc"
  39. declare -x ENVIRONMENT="BATCH"
  40. declare -- EPATCH_EXCLUDE="0001-revert-621a2f376334f8097604b9fee5783e0f1141e66d-for-.patch"
  41. declare -- EPATCH_FORCE="no"
  42. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  43. declare -- EPATCH_OPTS="-g0 -E --no-backup-if-mismatch"
  44. declare -- EPATCH_SINGLE_MSG=""
  45. declare -- EPATCH_SOURCE="/home/bmillare/gentoo-prefix/var/tmp/portage/sys-apps/net-tools-1.60_p20120127084908/work/patch"
  46. declare -- EPATCH_SUFFIX="patch.bz2"
  47. declare -x EXEOPTIONS="-m0755"
  48. declare -x FCFLAGS=""
  49. 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}\""
  50. declare -x FFLAGS=""
  51. declare -x FPATH="/usr/site/intel_cpp-11.0.074/mkl/include:/usr/site/intel_fortan-11.0.074/mkl/include"
  52. declare -x GCC_SPECS=""
  53. 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"
  54. declare -x GRUB_PLATFORMS=""
  55. declare -x G_BROKEN_FILENAMES="1"
  56. declare -x HISTSIZE="1000"
  57. declare HOMEPAGE="http://net-tools.sourceforge.net/"
  58. declare -x INCLUDE="/usr/site/intel_cpp-11.0.074/mkl/include:/usr/site/intel_fortan-11.0.074/mkl/include"
  59. declare -x INHERITED=" multilib prefix toolchain-funcs user eutils flag-o-matic"
  60. declare -x INPUTRC="/etc/inputrc"
  61. declare -x INPUT_DEVICES="keyboard mouse evdev"
  62. declare -x INSDESTTREE=""
  63. declare -x INSOPTIONS="-m0644"
  64. declare -x INTEL_LICENSE_FILE="/usr/site/intel_cpp-11.0.074/licenses:/opt/intel/licenses:/home/bmillare/intel/licenses:/usr/site/intel_fortan-11.0.074/licenses:/opt/intel/licenses:/home/bmillare/intel/licenses"
  65. declare IUSE="nls old-output static "
  66. declare -x KERNEL="linux"
  67. declare -x KERNEL_ABI="default"
  68. declare -x KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
  69. declare -x KV=""
  70. declare -x LANG="en_US.UTF-8"
  71. declare -x LCD_DEVICES=""
  72. declare -x LDFLAGS="-Wl,-O1"
  73. declare -x LDFLAGS_amd64="-m elf_x86_64"
  74. declare -x LDFLAGS_default
  75. declare -x LDFLAGS_x32="-m elf32_x86_64"
  76. declare -x LDFLAGS_x86="-m elf_i386"
  77. declare -x LD_LIBRARY_PATH="/usr/local/lib/:/usr/local/lib64/:/usr/mpi/intel/openmpi-1.4.3/lib64:/usr/site/intel_cpp-11.0.074/mkl/lib/em64t:/usr/site/intel_cpp-11.0.074/tbb/em64t/cc3.4.3_libc2.3.4_kernel2.6.9/lib:/usr/site/intel_cpp-11.0.074/lib/intel64:/usr/site/intel_fortan-11.0.074/mkl/lib/em64t:/usr/site/intel_fortan-11.0.074/lib/intel64:/usr/site/cuda/lib64:/usr/site/cuda/lib:"
  78. declare -x LIBDIR_amd64="lib"
  79. declare -x LIBDIR_amd64_fbsd="lib64"
  80. declare -x LIBDIR_default="lib"
  81. declare -x LIBDIR_n32="lib32"
  82. declare -x LIBDIR_n64="lib64"
  83. declare -x LIBDIR_o32="lib"
  84. declare -x LIBDIR_ppc="lib32"
  85. declare -x LIBDIR_ppc64="lib64"
  86. declare -x LIBDIR_s390="lib32"
  87. declare -x LIBDIR_s390x="lib64"
  88. declare -x LIBDIR_sparc32="lib32"
  89. declare -x LIBDIR_sparc64="lib64"
  90. declare -x LIBDIR_x32="libx32"
  91. declare -x LIBDIR_x86="lib32"
  92. declare -x LIBDIR_x86_fbsd="lib32"
  93. declare -x LIBOPTIONS="-m0644"
  94. declare -x LIBRARY_PATH="/usr/site/intel_cpp-11.0.074/mkl/lib/em64t:/usr/site/intel_cpp-11.0.074/tbb/em64t/cc3.4.3_libc2.3.4_kernel2.6.9/lib:/usr/site/intel_fortan-11.0.074/mkl/lib/em64t"
  95. declare -x LICENSE="GPL-2"
  96. declare -x MAKEOPTS="-j12"
  97. declare -x MKLROOT="/usr/site/intel_cpp-11.0.074/mkl"
  98. declare -x MULTILIB_ABIS="amd64"
  99. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  100. 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"
  101. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  102. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  103. declare -x NLSPATH="/usr/site/intel_cpp-11.0.074/mkl/lib/em64t/locale/%l_%t/%N:/usr/site/intel_cpp-11.0.074/idb/intel64/locale/%l_%t/%N:/usr/site/intel_cpp-11.0.074/lib/intel64/locale/%l_%t/%N:/usr/site/intel_fortan-11.0.074/mkl/lib/em64t/locale/%l_%t/%N:/usr/site/intel_fortan-11.0.074/idb/intel64/locale/%l_%t/%N:/usr/site/intel_fortan-11.0.074/lib/intel64/locale/%l_%t/%N"
  104. declare -- PATCH_VER="1"
  105. declare -x PATH="/home/bmillare/gentoo-prefix/usr/lib/portage/bin/ebuild-helpers:/home/bmillare/gentoo-prefix/usr/sbin:/home/bmillare/gentoo-prefix/usr/bin:/home/bmillare/gentoo-prefix/sbin:/home/bmillare/gentoo-prefix/bin:/home/bmillare/gentoo-prefix/opt/bin:/home/bmillare/gentoo-prefix/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/bin:/bin"
  106. declare -x PBS_ENVIRONMENT="PBS_BATCH"
  107. declare -x PBS_GPUFILE="/var/spool/torque/aux//10344.schedulergpu"
  108. declare -x PBS_JOBCOOKIE="4402738C10EED3847960A50EE6D603B3"
  109. declare -x PBS_JOBID="10344.scheduler"
  110. declare -x PBS_JOBNAME="compile"
  111. declare -x PBS_MOMPORT="15003"
  112. declare -x PBS_NODEFILE="/var/spool/torque/aux//10344.scheduler"
  113. declare -x PBS_NODENUM="0"
  114. declare -x PBS_NP="12"
  115. declare -x PBS_NUM_NODES="1"
  116. declare -x PBS_NUM_PPN="12"
  117. declare -x PBS_O_HOME="/home/bmillare"
  118. declare -x PBS_O_HOST="login"
  119. declare -x PBS_O_LANG="en_US.UTF-8"
  120. declare -x PBS_O_LOGNAME="bmillare"
  121. declare -x PBS_O_MAIL="/var/spool/mail/bmillare"
  122. declare -x PBS_O_PATH="/home/bmillare/gentoo-prefix/usr/bin:/home/bmillare/gentoo-prefix/bin:/home/bmillare/gentoo-prefix/opt/bin:/home/bmillare/gentoo-prefix/usr/sbin:/home/bmillare/gentoo-prefix/sbin:/home/bmillare/gentoo-prefix/usr/x86_64-pc-linux-gnu/binutils-bin/2.22:/home/bmillare/gentoo-prefix/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/bin:/bin"
  123. declare -x PBS_O_QUEUE="batch"
  124. declare -x PBS_O_SHELL="/bin/bash"
  125. declare -x PBS_O_WORKDIR="/home/bmillare"
  126. declare -x PBS_QUEUE="batch"
  127. declare -x PBS_SERVER="scheduler"
  128. declare -x PBS_TASKNUM="1"
  129. declare -x PBS_VERSION="TORQUE-2.5.7"
  130. declare -x PBS_VNODENUM="0"
  131. declare PDEPEND=""
  132. declare -x PHP_TARGETS=""
  133. declare -x PKG_CONFIG_PATH="/home/bmillare/gentoo-prefix/usr/lib/pkgconfig:/home/bmillare/gentoo-prefix/usr/share/pkgconfig"
  134. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  135. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/net-tools-1.60_p20120127084908/html")'
  136. declare -x PORTAGE_ROOT_USER="bmillare"
  137. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
  138. declare -x PROPERTIES=""
  139. declare -x PROVIDE=""
  140. declare -x PYTHONDONTWRITEBYTECODE="1"
  141. declare -x RDEPEND="!prefix? ( >=sys-apps/openrc-0.9.9.3 ) "
  142. declare REPOSITORY
  143. declare REQUIRED_USE=""
  144. declare -x RESTRICT=""
  145. 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}\""
  146. declare -x RUBY_TARGETS=""
  147. declare -x S="/home/bmillare/gentoo-prefix/var/tmp/portage/sys-apps/net-tools-1.60_p20120127084908/work/net-tools-1.60_p20120127084908"
  148. declare -x SANDBOX_DENY=""
  149. declare -x SANDBOX_PREDICT=""
  150. declare -x SANDBOX_READ="/:/home/bmillare/gentoo-prefix/var/tmp"
  151. declare -x SANDBOX_WRITE="/home/bmillare/gentoo-prefix/var/tmp"
  152. declare -x SLOT="0"
  153. declare SRC_URI="mirror://gentoo/net-tools-1.60_p20120127084908.tar.xz
  154. mirror://gentoo/net-tools-1.60_p20120127084908-patches-1.tar.xz"
  155. declare -x SSH_ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass"
  156. declare -x SYMLINK_LIB=""
  157. declare -x USE="amd64 elibc_glibc kernel_linux nls prefix userland_GNU"
  158. declare -x USERLAND="GNU"
  159. declare -x VIDEO_CARDS=""
  160. 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"
  161. declare -x _E_DOCDESTTREE_=""
  162. declare -x _E_EXEDESTTREE_=""
  163. declare -a __ESTACK_eshopts__='()'
  164. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  165. declare -- ___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
  166. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  167. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  168. declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
  169. declare -- phase_func
  170. _assert_pkg_ebuild_phase ()
  171. {
  172. case ${EBUILD_PHASE} in
  173. setup | preinst | postinst)
  174.  
  175. ;;
  176. *)
  177. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  178. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  179. eerror "Package fails at QA and at life. Please file a bug.";
  180. die "Bad package! $1 is only for use in some pkg_* functions!"
  181. ;;
  182. esac
  183. }
  184. _epatch_draw_line ()
  185. {
  186. [[ -z $1 ]] && set "$(printf "%65s" '')";
  187. echo "${1//?/=}"
  188. }
  189. _filter-hardened ()
  190. {
  191. local f;
  192. for f in "$@";
  193. do
  194. case "${f}" in
  195. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  196. gcc-specs-pie || continue;
  197. is-flagq -nopie || append-flags -nopie
  198. ;;
  199. -fstack-protector)
  200. gcc-specs-ssp || continue;
  201. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  202. ;;
  203. -fstack-protector-all)
  204. gcc-specs-ssp-to-all || continue;
  205. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  206. ;;
  207. -fno-strict-overflow)
  208. gcc-specs-nostrict || continue;
  209. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  210. ;;
  211. esac;
  212. done
  213. }
  214. _filter-var ()
  215. {
  216. local f x var=$1 new=();
  217. shift;
  218. for f in ${!var};
  219. do
  220. for x in "$@";
  221. do
  222. [[ ${f} == ${x} ]] && continue 2;
  223. done;
  224. new+=("${f}");
  225. done;
  226. eval export ${var}=\""${new[*]}"\"
  227. }
  228. _gcc-install-dir ()
  229. {
  230. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  231. }
  232. _gcc-specs-directive_raw ()
  233. {
  234. local cc=$(tc-getCC);
  235. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  236. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  237. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  238. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  239. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  240. { spec=spec $0 }
  241. END { print spec }';
  242. return 0
  243. }
  244. _gcc-specs-exists ()
  245. {
  246. [[ -f $(_gcc-install-dir)/$1 ]]
  247. }
  248. _gcc_fullversion ()
  249. {
  250. local ver="$1";
  251. shift;
  252. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  253. eval echo "$ver"
  254. }
  255. _is_flagq ()
  256. {
  257. local x;
  258. for x in ${!1};
  259. do
  260. [[ ${x} == $2 ]] && return 0;
  261. done;
  262. return 1
  263. }
  264. _tc-getPROG ()
  265. {
  266. local tuple=$1;
  267. local v var vars=$2;
  268. local prog=$3;
  269. var=${vars%% *};
  270. for v in ${vars};
  271. do
  272. if [[ -n ${!v} ]]; then
  273. export ${var}="${!v}";
  274. echo "${!v}";
  275. return 0;
  276. fi;
  277. done;
  278. local search=;
  279. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  280. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  281. [[ -n ${search} ]] && prog=${search##*/};
  282. export ${var}=${prog};
  283. echo "${!var}"
  284. }
  285. all-flag-vars ()
  286. {
  287. echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  288. }
  289. append-cflags ()
  290. {
  291. [[ $# -eq 0 ]] && return 0;
  292. export CFLAGS=$(test-flags-CC ${CFLAGS} "$@");
  293. return 0
  294. }
  295. append-cppflags ()
  296. {
  297. [[ $# -eq 0 ]] && return 0;
  298. export CPPFLAGS="${CPPFLAGS} $*";
  299. return 0
  300. }
  301. append-cxxflags ()
  302. {
  303. [[ $# -eq 0 ]] && return 0;
  304. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS} "$@");
  305. return 0
  306. }
  307. append-fflags ()
  308. {
  309. [[ $# -eq 0 ]] && return 0;
  310. export FFLAGS=$(test-flags-F77 ${FFLAGS} "$@");
  311. export FCFLAGS=$(test-flags-FC ${FCFLAGS} "$@");
  312. return 0
  313. }
  314. append-flags ()
  315. {
  316. [[ $# -eq 0 ]] && return 0;
  317. append-cflags "$@";
  318. append-cxxflags "$@";
  319. append-fflags "$@";
  320. return 0
  321. }
  322. append-ldflags ()
  323. {
  324. [[ $# -eq 0 ]] && return 0;
  325. local flag;
  326. for flag in "$@";
  327. do
  328. [[ ${flag} == -l* ]] && ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  329. done;
  330. export LDFLAGS="${LDFLAGS} $(test-flags "$@")";
  331. return 0
  332. }
  333. append-lfs-flags ()
  334. {
  335. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  336. case ${CHOST} in
  337. *-aix*)
  338. append-cppflags -D_LARGE_FILES -D_LARGE_FILE_API
  339. ;;
  340. *)
  341. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  342. ;;
  343. esac
  344. }
  345. append-libs ()
  346. {
  347. [[ $# -eq 0 ]] && return 0;
  348. local flag;
  349. for flag in "$@";
  350. do
  351. [[ ${flag} == -l* ]] && flag=${flag#-l};
  352. export LIBS="${LIBS} -l${flag}";
  353. done;
  354. return 0
  355. }
  356. built_with_use ()
  357. {
  358. local hidden="no";
  359. if [[ $1 == "--hidden" ]]; then
  360. hidden="yes";
  361. shift;
  362. fi;
  363. local missing_action="die";
  364. if [[ $1 == "--missing" ]]; then
  365. missing_action=$2;
  366. shift;
  367. shift;
  368. case ${missing_action} in
  369. true | false | die)
  370.  
  371. ;;
  372. *)
  373. die "unknown action '${missing_action}'"
  374. ;;
  375. esac;
  376. fi;
  377. local opt=$1;
  378. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  379. local PKG=$(best_version $1);
  380. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  381. shift;
  382. local USEFILE="${EROOT}"/var/db/pkg/${PKG}/USE;
  383. local IUSEFILE="${EROOT}"/var/db/pkg/${PKG}/IUSE;
  384. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  385. case ${missing_action} in
  386. true)
  387. return 0
  388. ;;
  389. false)
  390. return 1
  391. ;;
  392. die)
  393. die "Unable to determine what USE flags $PKG was built with"
  394. ;;
  395. esac;
  396. fi;
  397. if [[ ${hidden} == "no" ]]; then
  398. local IUSE_BUILT=($(<"${IUSEFILE}"));
  399. local expand;
  400. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  401. do
  402. if [[ $1 == ${expand}_* ]]; then
  403. expand="";
  404. break;
  405. fi;
  406. done;
  407. if [[ -n ${expand} ]]; then
  408. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  409. case ${missing_action} in
  410. true)
  411. return 0
  412. ;;
  413. false)
  414. return 1
  415. ;;
  416. die)
  417. die "$PKG does not actually support the $1 USE flag!"
  418. ;;
  419. esac;
  420. fi;
  421. fi;
  422. fi;
  423. local USE_BUILT=$(<${USEFILE});
  424. while [[ $# -gt 0 ]]; do
  425. if [[ ${opt} = "-o" ]]; then
  426. has $1 ${USE_BUILT} && return 0;
  427. else
  428. has $1 ${USE_BUILT} || return 1;
  429. fi;
  430. shift;
  431. done;
  432. [[ ${opt} = "-a" ]]
  433. }
  434. call-ebuildshell ()
  435. {
  436. if ! has ebuildshell ${FEATURES}; then
  437. "$@";
  438. return $?;
  439. fi;
  440. ( umask 002;
  441. ( ( set;
  442. declare -p;
  443. declare -fp;
  444. shopt -p;
  445. if [[ ${BASH_VERSINFO[0]} == 3 ]]; then
  446. export;
  447. fi ) | filter_readonly_variables --filter-for-subshell;
  448. echo 'declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS';
  449. echo "export PS1='EBUILD ${PN} $1 \$ '";
  450. echo 'unset ENV';
  451. echo "type $1";
  452. echo "echo WANTED: $@";
  453. echo "trap '";
  454. echo "umask 002";
  455. echo "(";
  456. echo " set";
  457. echo " declare -p";
  458. echo " declare -fp";
  459. echo " shopt -p";
  460. if [[ ${BASH_VERSINFO[0]} == 3 ]]; then
  461. echo " export";
  462. fi;
  463. echo -n ")";
  464. echo -n " | filter_readonly_variables --filter-metadata";
  465. echo " > ${T}/ebuildshell-environment-outcome' 0" ) > ${T}/ebuildshell-environment;
  466. chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} "${T}/ebuildshell-environment" &>/dev/null;
  467. chmod g+w "${T}/ebuildshell-environment" &>/dev/null );
  468. rm -f "${T}/ebuildshell-environment-outcome" &>/dev/null;
  469. unset BASH_ENV;
  470. env -i ${BASH} --rcfile "${T}/ebuildshell-environment" -i || die;
  471. chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} "${T}/ebuildshell-environment-outcome" &>/dev/null;
  472. chmod g+w "${T}/ebuildshell-environment-outcome" &>/dev/null;
  473. source "${T}/ebuildshell-environment-outcome" &>/dev/null
  474. }
  475. check_license ()
  476. {
  477. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  478. }
  479. doicon ()
  480. {
  481. ( local i j ret;
  482. insinto /usr/share/pixmaps;
  483. for i in "$@";
  484. do
  485. if [[ -f ${i} ]]; then
  486. doins "${i}";
  487. ((ret+=$?));
  488. else
  489. if [[ -d ${i} ]]; then
  490. for j in "${i}"/*.png;
  491. do
  492. doins "${j}";
  493. ((ret+=$?));
  494. done;
  495. else
  496. ((++ret));
  497. fi;
  498. fi;
  499. done;
  500. exit ${ret} )
  501. }
  502. domenu ()
  503. {
  504. ( local i j ret=0;
  505. insinto /usr/share/applications;
  506. for i in "$@";
  507. do
  508. if [[ -f ${i} ]]; then
  509. doins "${i}";
  510. ((ret+=$?));
  511. else
  512. if [[ -d ${i} ]]; then
  513. for j in "${i}"/*.desktop;
  514. do
  515. doins "${j}";
  516. ((ret+=$?));
  517. done;
  518. else
  519. ((++ret));
  520. fi;
  521. fi;
  522. done;
  523. exit ${ret} )
  524. }
  525. ebeep ()
  526. {
  527. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  528. }
  529. econf_build ()
  530. {
  531. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  532. }
  533. ecvs_clean ()
  534. {
  535. [[ -z $* ]] && set -- .;
  536. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  537. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  538. }
  539. edos2unix ()
  540. {
  541. [[ $# -eq 0 ]] && return 0;
  542. sed -i 's/\r$//' -- "$@" || die
  543. }
  544. egetent ()
  545. {
  546. local db=$1 key=$2;
  547. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  548. case ${db} in
  549. passwd | group)
  550.  
  551. ;;
  552. *)
  553. die "sorry, database '${db}' not yet supported; file a bug"
  554. ;;
  555. esac;
  556. case ${CHOST} in
  557. *-darwin[678])
  558. case ${key} in
  559. *[!0-9]*)
  560. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  561. ;;
  562. *)
  563. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  564. ;;
  565. esac
  566. ;;
  567. *-darwin*)
  568. local mykey;
  569. case ${db} in
  570. passwd)
  571. db="Users" mykey="UniqueID"
  572. ;;
  573. group)
  574. db="Groups" mykey="PrimaryGroupID"
  575. ;;
  576. esac;
  577. case ${key} in
  578. *[!0-9]*)
  579. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  580. ;;
  581. *)
  582. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  583. ;;
  584. esac
  585. ;;
  586. *-freebsd* | *-dragonfly*)
  587. case ${db} in
  588. passwd)
  589. db="user"
  590. ;;
  591. *)
  592.  
  593. ;;
  594. esac;
  595. local opts;
  596. if [[ ${key} == [[:digit:]]* ]]; then
  597. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  598. fi;
  599. pw show ${db} ${opts} "${key}" -q
  600. ;;
  601. *-netbsd* | *-openbsd*)
  602. grep "${key}:\*:" /etc/${db}
  603. ;;
  604. *)
  605. nscd -i "${db}" 2> /dev/null;
  606. getent "${db}" "${key}"
  607. ;;
  608. esac
  609. }
  610. egethome ()
  611. {
  612. local pos;
  613. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  614. case ${CHOST} in
  615. *-darwin* | *-freebsd* | *-dragonfly*)
  616. pos=9
  617. ;;
  618. *)
  619. pos=6
  620. ;;
  621. esac;
  622. egetent passwd "$1" | cut -d: -f${pos}
  623. }
  624. egetshell ()
  625. {
  626. local pos;
  627. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  628. case ${CHOST} in
  629. *-darwin* | *-freebsd* | *-dragonfly*)
  630. pos=10
  631. ;;
  632. *)
  633. pos=7
  634. ;;
  635. esac;
  636. egetent passwd "$1" | cut -d: -f${pos}
  637. }
  638. emktemp ()
  639. {
  640. local exe="touch";
  641. [[ $1 == -d ]] && exe="mkdir" && shift;
  642. local topdir=$1;
  643. if [[ -z ${topdir} ]]; then
  644. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  645. fi;
  646. if ! type -P mktemp > /dev/null; then
  647. local tmp=/;
  648. while [[ -e ${tmp} ]]; do
  649. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  650. done;
  651. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  652. echo "${tmp}";
  653. else
  654. if [[ ${exe} == "touch" ]]; then
  655. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  656. else
  657. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  658. fi;
  659. fi
  660. }
  661. enewgroup ()
  662. {
  663. _assert_pkg_ebuild_phase ${FUNCNAME};
  664. local egroup=$1;
  665. shift;
  666. if [[ -z ${egroup} ]]; then
  667. eerror "No group specified !";
  668. die "Cannot call enewgroup without a group";
  669. fi;
  670. rootuid=$(python -c 'from portage.const import rootuid; print rootuid');
  671. if [[ ${rootuid} != 0 ]]; then
  672. ewarn "'enewgroup()' disabled in Prefixed Portage with non root user";
  673. return 0;
  674. fi;
  675. if [[ -n $(egetent group "${egroup}") ]]; then
  676. return 0;
  677. fi;
  678. einfo "Adding group '${egroup}' to your system ...";
  679. local egid=$1;
  680. shift;
  681. if [[ ! -z ${egid} ]]; then
  682. if [[ ${egid} -gt 0 ]]; then
  683. if [[ -n $(egetent group ${egid}) ]]; then
  684. egid="next available; requested gid taken";
  685. fi;
  686. else
  687. eerror "Groupid given but is not greater than 0 !";
  688. die "${egid} is not a valid GID";
  689. fi;
  690. else
  691. egid="next available";
  692. fi;
  693. einfo " - Groupid: ${egid}";
  694. if [[ $# -gt 0 ]]; then
  695. die "extra arguments no longer supported; please file a bug";
  696. fi;
  697. function _enewgroup_next_gid ()
  698. {
  699. if [[ ${egid} == *[!0-9]* ]]; then
  700. for ((egid = 101; egid <= 999; egid++))
  701. do
  702. [[ -z $(egetent group ${egid}) ]] && break;
  703. done;
  704. fi
  705. };
  706. case ${CHOST} in
  707. *-darwin*)
  708. _enewgroup_next_gid;
  709. dscl . create "/groups/${egroup}" gid ${egid};
  710. dscl . create "/groups/${egroup}" passwd '*'
  711. ;;
  712. *-freebsd* | *-dragonfly*)
  713. _enewgroup_next_gid;
  714. pw groupadd "${egroup}" -g ${egid} || die
  715. ;;
  716. *-netbsd*)
  717. _enewgroup_next_gid;
  718. groupadd -g ${egid} "${egroup}" || die
  719. ;;
  720. *)
  721. local opts;
  722. if [[ ${egid} == *[!0-9]* ]]; then
  723. opts="";
  724. else
  725. opts="-g ${egid}";
  726. fi;
  727. groupadd -r ${opts} "${egroup}" || die
  728. ;;
  729. esac
  730. }
  731. enewuser ()
  732. {
  733. _assert_pkg_ebuild_phase ${FUNCNAME};
  734. local euser=$1;
  735. shift;
  736. if [[ -z ${euser} ]]; then
  737. eerror "No username specified !";
  738. die "Cannot call enewuser without a username";
  739. fi;
  740. rootuid=$(python -c 'from portage.const import rootuid; print rootuid');
  741. if [[ ${rootuid} != 0 ]]; then
  742. ewarn "'enewuser()' disabled in Prefixed Portage with non-root user";
  743. return 0;
  744. fi;
  745. if [[ -n $(egetent passwd "${euser}") ]]; then
  746. return 0;
  747. fi;
  748. einfo "Adding user '${euser}' to your system ...";
  749. local opts=();
  750. local euid=$1;
  751. shift;
  752. if [[ -n ${euid} && ${euid} != -1 ]]; then
  753. if [[ ${euid} -gt 0 ]]; then
  754. if [[ -n $(egetent passwd ${euid}) ]]; then
  755. euid="next";
  756. fi;
  757. else
  758. eerror "Userid given but is not greater than 0 !";
  759. die "${euid} is not a valid UID";
  760. fi;
  761. else
  762. euid="next";
  763. fi;
  764. if [[ ${euid} == "next" ]]; then
  765. for ((euid = 101; euid <= 999; euid++))
  766. do
  767. [[ -z $(egetent passwd ${euid}) ]] && break;
  768. done;
  769. fi;
  770. opts+=(-u ${euid});
  771. einfo " - Userid: ${euid}";
  772. local eshell=$1;
  773. shift;
  774. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  775. if [[ ! -e ${EROOT}${eshell} ]]; then
  776. eerror "A shell was specified but it does not exist !";
  777. die "${eshell} does not exist in ${EROOT}";
  778. fi;
  779. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  780. eerror "Do not specify ${eshell} yourself, use -1";
  781. die "Pass '-1' as the shell parameter";
  782. fi;
  783. else
  784. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  785. do
  786. [[ -x ${ROOT}${eshell} ]] && break;
  787. done;
  788. if [[ ${eshell} == "/dev/null" ]]; then
  789. eerror "Unable to identify the shell to use, proceeding with userland default.";
  790. case ${USERLAND} in
  791. GNU)
  792. eshell="/bin/false"
  793. ;;
  794. BSD)
  795. eshell="/sbin/nologin"
  796. ;;
  797. Darwin)
  798. eshell="/usr/sbin/nologin"
  799. ;;
  800. *)
  801. die "Unable to identify the default shell for userland ${USERLAND}"
  802. ;;
  803. esac;
  804. fi;
  805. fi;
  806. einfo " - Shell: ${eshell}";
  807. opts+=(-s "${eshell}");
  808. local ehome=$1;
  809. shift;
  810. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  811. ehome="/dev/null";
  812. fi;
  813. einfo " - Home: ${ehome}";
  814. opts+=(-d "${ehome}");
  815. local egroups=$1;
  816. shift;
  817. local g egroups_arr;
  818. IFS="," read -r -a egroups_arr <<< "${egroups}";
  819. shift;
  820. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  821. local defgroup exgroups;
  822. for g in "${egroups_arr[@]}";
  823. do
  824. if [[ -z $(egetent group "${g}") ]]; then
  825. eerror "You must add group ${g} to the system first";
  826. die "${g} is not a valid GID";
  827. fi;
  828. if [[ -z ${defgroup} ]]; then
  829. defgroup=${g};
  830. else
  831. exgroups+=",${g}";
  832. fi;
  833. done;
  834. opts+=(-g "${defgroup}");
  835. if [[ ! -z ${exgroups} ]]; then
  836. opts+=(-G "${exgroups:1}");
  837. fi;
  838. fi;
  839. einfo " - Groups: ${egroups:-(none)}";
  840. if [[ $# -gt 0 ]]; then
  841. die "extra arguments no longer supported; please file a bug";
  842. else
  843. local comment="added by portage for ${PN}";
  844. opts+=(-c "${comment}");
  845. einfo " - GECOS: ${comment}";
  846. fi;
  847. case ${CHOST} in
  848. *-darwin*)
  849. dscl . create "/users/${euser}" uid ${euid};
  850. dscl . create "/users/${euser}" shell "${eshell}";
  851. dscl . create "/users/${euser}" home "${ehome}";
  852. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  853. for g in "${egroups_arr[@]}";
  854. do
  855. dscl . merge "/groups/${g}" users "${euser}";
  856. done
  857. ;;
  858. *-freebsd* | *-dragonfly*)
  859. pw useradd "${euser}" "${opts[@]}" || die
  860. ;;
  861. *-netbsd*)
  862. useradd "${opts[@]}" "${euser}" || die
  863. ;;
  864. *-openbsd*)
  865. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  866. ;;
  867. *)
  868. useradd -r "${opts[@]}" "${euser}" || die
  869. ;;
  870. esac;
  871. if [[ ! -e ${EROOT}/${ehome} ]]; then
  872. einfo " - Creating ${ehome} in ${EROOT}";
  873. mkdir -p "${EROOT}/${ehome}";
  874. chown "${euser}" "${EROOT}/${ehome}";
  875. chmod 755 "${EROOT}/${ehome}";
  876. fi
  877. }
  878. epatch ()
  879. {
  880. function _epatch_draw_line ()
  881. {
  882. [[ -z $1 ]] && set "$(printf "%65s" '')";
  883. echo "${1//?/=}"
  884. };
  885. unset P4CONFIG P4PORT P4USER;
  886. if [[ $# -gt 1 ]]; then
  887. local m;
  888. for m in "$@";
  889. do
  890. epatch "${m}";
  891. done;
  892. return 0;
  893. fi;
  894. local SINGLE_PATCH="no";
  895. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  896. if [[ -f $1 ]]; then
  897. SINGLE_PATCH="yes";
  898. set -- "$1";
  899. local EPATCH_SUFFIX=$1;
  900. else
  901. if [[ -d $1 ]]; then
  902. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  903. else
  904. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  905. epatch "${EPATCH_SOURCE}/$1";
  906. return $?;
  907. else
  908. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  909. echo;
  910. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  911. eerror;
  912. eerror " ${EPATCH_SOURCE}";
  913. eerror " ( ${EPATCH_SOURCE##*/} )";
  914. echo;
  915. die "Cannot find \$EPATCH_SOURCE!";
  916. fi;
  917. fi;
  918. fi;
  919. local PIPE_CMD;
  920. case ${EPATCH_SUFFIX##*\.} in
  921. xz)
  922. PIPE_CMD="xz -dc"
  923. ;;
  924. lzma)
  925. PIPE_CMD="lzma -dc"
  926. ;;
  927. bz2)
  928. PIPE_CMD="bzip2 -dc"
  929. ;;
  930. gz | Z | z)
  931. PIPE_CMD="gzip -dc"
  932. ;;
  933. ZIP | zip)
  934. PIPE_CMD="unzip -p"
  935. ;;
  936. *)
  937.  
  938. ;;
  939. esac;
  940. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  941. local x;
  942. for x in "$@";
  943. do
  944. [[ ! -f ${x} ]] && continue;
  945. local patchname=${x##*/};
  946. local a=${patchname#*_};
  947. a=${a%%_*};
  948. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  949. continue;
  950. fi;
  951. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  952. eshopts_push -o noglob;
  953. local ex;
  954. for ex in ${EPATCH_EXCLUDE};
  955. do
  956. if [[ ${patchname} == ${ex} ]]; then
  957. eshopts_pop;
  958. continue 2;
  959. fi;
  960. done;
  961. eshopts_pop;
  962. fi;
  963. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  964. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  965. einfo "${EPATCH_SINGLE_MSG}";
  966. else
  967. einfo "Applying ${patchname} ...";
  968. fi;
  969. else
  970. einfo " ${patchname} ...";
  971. fi;
  972. local STDERR_TARGET="${T}/${patchname}.out";
  973. if [[ -e ${STDERR_TARGET} ]]; then
  974. STDERR_TARGET="${T}/${patchname}-$$.out";
  975. fi;
  976. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  977. local count=0;
  978. local PATCH_TARGET;
  979. if [[ -n ${PIPE_CMD} ]]; then
  980. PATCH_TARGET="${T}/$$.patch";
  981. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  982. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  983. echo;
  984. eerror "Could not extract patch!";
  985. count=5;
  986. break;
  987. fi;
  988. else
  989. PATCH_TARGET=${x};
  990. fi;
  991. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  992. if [[ -n ${abs_paths} ]]; then
  993. count=1;
  994. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  995. fi;
  996. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  997. if [[ -n ${rel_paths} ]]; then
  998. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  999. eqawarn " In the future this will cause a failure.";
  1000. eqawarn "${rel_paths}";
  1001. fi;
  1002. local patch_cmd;
  1003. while [[ ${count} -lt 5 ]]; do
  1004. patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}";
  1005. ( _epatch_draw_line "***** ${patchname} *****";
  1006. echo;
  1007. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1008. echo;
  1009. _epatch_draw_line "***** ${patchname} *****";
  1010. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1011. ret=$?;
  1012. echo;
  1013. echo "patch program exited with status ${ret}";
  1014. exit ${ret} ) >> "${STDERR_TARGET}";
  1015. if [ $? -eq 0 ]; then
  1016. ( _epatch_draw_line "***** ${patchname} *****";
  1017. echo;
  1018. echo "ACTUALLY APPLYING ${patchname} ...";
  1019. echo;
  1020. _epatch_draw_line "***** ${patchname} *****";
  1021. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1022. ret=$?;
  1023. echo;
  1024. echo "patch program exited with status ${ret}";
  1025. exit ${ret} ) >> "${STDERR_TARGET}";
  1026. if [ $? -ne 0 ]; then
  1027. echo;
  1028. eerror "A dry-run of patch command succeeded, but actually";
  1029. eerror "applying the patch failed!";
  1030. count=5;
  1031. fi;
  1032. break;
  1033. fi;
  1034. : $(( count++ ));
  1035. done;
  1036. if [[ -n ${PIPE_CMD} ]]; then
  1037. rm -f "${PATCH_TARGET}";
  1038. fi;
  1039. if [[ ${count} -ge 5 ]]; then
  1040. echo;
  1041. eerror "Failed Patch: ${patchname} !";
  1042. eerror " ( ${PATCH_TARGET} )";
  1043. eerror;
  1044. eerror "Include in your bugreport the contents of:";
  1045. eerror;
  1046. eerror " ${STDERR_TARGET}";
  1047. echo;
  1048. die "Failed Patch: ${patchname}!";
  1049. fi;
  1050. rm -f "${STDERR_TARGET}";
  1051. cat >> "${T}/epatch.log" <<-EOF
  1052. PATCH: ${x}
  1053. CMD: ${patch_cmd}
  1054. PWD: ${PWD}
  1055.  
  1056. EOF
  1057.  
  1058. eend 0;
  1059. done;
  1060. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1061. :
  1062. }
  1063. epatch_user ()
  1064. {
  1065. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1066. local applied="${T}/epatch_user.log";
  1067. [[ -e ${applied} ]] && return 2;
  1068. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1069. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}};
  1070. do
  1071. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1072. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1073. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1074. if [[ -d ${EPATCH_SOURCE} ]]; then
  1075. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1076. echo "${EPATCH_SOURCE}" > "${applied}";
  1077. return 0;
  1078. fi;
  1079. done;
  1080. echo "none" > "${applied}";
  1081. return 1
  1082. }
  1083. epause ()
  1084. {
  1085. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  1086. }
  1087. eprefixify ()
  1088. {
  1089. [[ $# -lt 1 ]] && die "at least one argument required";
  1090. einfo "Adjusting to prefix ${EPREFIX:-/}";
  1091. local x;
  1092. for x in "$@";
  1093. do
  1094. if [[ -e ${x} ]]; then
  1095. ebegin " ${x##*/}";
  1096. sed -i -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" "${x}";
  1097. eend $? || die "failed to eprefixify ${x}";
  1098. else
  1099. die "${x} does not exist";
  1100. fi;
  1101. done;
  1102. return 0
  1103. }
  1104. epunt_cxx ()
  1105. {
  1106. local dir=$1;
  1107. [[ -z ${dir} ]] && dir=${S};
  1108. ebegin "Removing useless C++ checks";
  1109. local f;
  1110. find "${dir}" -name configure | while read f; do
  1111. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  1112. done;
  1113. eend 0
  1114. }
  1115. eshopts_pop ()
  1116. {
  1117. local s;
  1118. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1119. if [[ ${s} == "shopt -"* ]]; then
  1120. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1121. else
  1122. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1123. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1124. fi
  1125. }
  1126. eshopts_push ()
  1127. {
  1128. if [[ $1 == -[su] ]]; then
  1129. estack_push eshopts "$(shopt -p)";
  1130. [[ $# -eq 0 ]] && return 0;
  1131. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1132. else
  1133. estack_push eshopts $-;
  1134. [[ $# -eq 0 ]] && return 0;
  1135. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1136. fi
  1137. }
  1138. estack_pop ()
  1139. {
  1140. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1141. local __estack_name="__ESTACK_$1__";
  1142. shift;
  1143. local __estack_retvar=$1;
  1144. shift;
  1145. eval local __estack_i=\${#${__estack_name}\[@\]};
  1146. [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  1147. if [[ -n ${__estack_retvar} ]]; then
  1148. eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  1149. fi;
  1150. eval unset ${__estack_name}\[${__estack_i}\]
  1151. }
  1152. estack_push ()
  1153. {
  1154. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1155. local stack_name="__ESTACK_$1__";
  1156. shift;
  1157. eval ${stack_name}+=\( \"\$@\" \)
  1158. }
  1159. esvn_clean ()
  1160. {
  1161. [[ -z $* ]] && set -- .;
  1162. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1163. }
  1164. eumask_pop ()
  1165. {
  1166. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1167. local s;
  1168. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1169. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1170. }
  1171. eumask_push ()
  1172. {
  1173. estack_push eumask "$(umask)";
  1174. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1175. }
  1176. filter-flags ()
  1177. {
  1178. _filter-hardened "$@";
  1179. local v;
  1180. for v in $(all-flag-vars);
  1181. do
  1182. _filter-var ${v} "$@";
  1183. done;
  1184. return 0
  1185. }
  1186. filter-ldflags ()
  1187. {
  1188. _filter-var LDFLAGS "$@";
  1189. return 0
  1190. }
  1191. filter-lfs-flags ()
  1192. {
  1193. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1194. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_LARGE_FILES -D_LARGE_FILE_API
  1195. }
  1196. filter-mfpmath ()
  1197. {
  1198. local orig_mfpmath new_math prune_math;
  1199. orig_mfpmath=$(get-flag -mfpmath);
  1200. new_math=$(get-flag mfpmath);
  1201. new_math=" ${new_math//,/ } ";
  1202. prune_math="";
  1203. for prune_math in "$@";
  1204. do
  1205. new_math=${new_math/ ${prune_math} / };
  1206. done;
  1207. new_math=$(echo ${new_math});
  1208. new_math=${new_math// /,};
  1209. if [[ -z ${new_math} ]]; then
  1210. filter-flags ${orig_mfpmath};
  1211. else
  1212. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1213. fi;
  1214. return 0
  1215. }
  1216. gcc-fullversion ()
  1217. {
  1218. _gcc_fullversion '$1.$2.$3' "$@"
  1219. }
  1220. gcc-major-version ()
  1221. {
  1222. _gcc_fullversion '$1' "$@"
  1223. }
  1224. gcc-micro-version ()
  1225. {
  1226. _gcc_fullversion '$3' "$@"
  1227. }
  1228. gcc-minor-version ()
  1229. {
  1230. _gcc_fullversion '$2' "$@"
  1231. }
  1232. gcc-specs-directive ()
  1233. {
  1234. local directive subdname subdirective;
  1235. directive="$(_gcc-specs-directive_raw $1)";
  1236. while [[ ${directive} == *%\(*\)* ]]; do
  1237. subdname=${directive/*%\(};
  1238. subdname=${subdname/\)*};
  1239. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1240. directive="${directive//\%(${subdname})/${subdirective}}";
  1241. done;
  1242. echo "${directive}";
  1243. return 0
  1244. }
  1245. gcc-specs-nostrict ()
  1246. {
  1247. local directive;
  1248. directive=$(gcc-specs-directive cc1);
  1249. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1250. }
  1251. gcc-specs-now ()
  1252. {
  1253. local directive;
  1254. directive=$(gcc-specs-directive link_command);
  1255. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1256. }
  1257. gcc-specs-pie ()
  1258. {
  1259. local directive;
  1260. directive=$(gcc-specs-directive cc1);
  1261. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1262. }
  1263. gcc-specs-relro ()
  1264. {
  1265. local directive;
  1266. directive=$(gcc-specs-directive link_command);
  1267. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1268. }
  1269. gcc-specs-ssp ()
  1270. {
  1271. local directive;
  1272. directive=$(gcc-specs-directive cc1);
  1273. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1274. }
  1275. gcc-specs-ssp-to-all ()
  1276. {
  1277. local directive;
  1278. directive=$(gcc-specs-directive cc1);
  1279. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1280. }
  1281. gcc-version ()
  1282. {
  1283. _gcc_fullversion '$1.$2' "$@"
  1284. }
  1285. gen_usr_ldscript ()
  1286. {
  1287. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1288. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1289. tc-is-static-only && return;
  1290. dodir /usr/${libdir};
  1291. if [[ $1 == "-a" ]]; then
  1292. auto=true;
  1293. shift;
  1294. dodir /${libdir};
  1295. fi;
  1296. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1297. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1298. for lib in "$@";
  1299. do
  1300. local tlib;
  1301. if ${auto}; then
  1302. lib="lib${lib}${suffix}";
  1303. else
  1304. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1305. fi;
  1306. case ${CTARGET:-${CHOST}} in
  1307. *-darwin*)
  1308. if ${auto}; then
  1309. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1310. else
  1311. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1312. fi;
  1313. if [[ -z ${tlib} ]]; then
  1314. ewarn "gen_usr_ldscript: unable to read install_name from ${lib}";
  1315. tlib=${lib};
  1316. fi;
  1317. tlib=${tlib##*/};
  1318. if ${auto}; then
  1319. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1320. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1321. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1322. fi;
  1323. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  1324. fi;
  1325. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1326. chmod u+w "${ED}${libdir}/${tlib}";
  1327. local nowrite=yes;
  1328. fi;
  1329. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1330. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1331. pushd "${ED}/usr/${libdir}" > /dev/null;
  1332. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1333. popd > /dev/null
  1334. ;;
  1335. *-aix* | *-irix* | *64*-hpux* | *-interix* | *-winnt*)
  1336. if ${auto}; then
  1337. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1338. tlib=$(readlink "${ED}"/${libdir}/${lib});
  1339. tlib=${tlib##*/};
  1340. if [[ -z ${tlib} ]]; then
  1341. tlib=${lib};
  1342. else
  1343. rm -f "${ED}"/${libdir}/${lib};
  1344. fi;
  1345. else
  1346. tlib=${lib};
  1347. fi;
  1348. pushd "${ED}/usr/${libdir}" > /dev/null;
  1349. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1350. popd > /dev/null
  1351. ;;
  1352. hppa*-hpux*)
  1353. if ${auto}; then
  1354. tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  1355. [[ -z ${tlib} ]] && tlib=${lib};
  1356. tlib=${tlib##*/};
  1357. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1358. if [[ ${tlib} != ${lib}* ]]; then
  1359. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1360. fi;
  1361. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  1362. else
  1363. tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  1364. [[ -z ${tlib} ]] && tlib=${lib};
  1365. tlib=${tlib##*/};
  1366. fi;
  1367. pushd "${ED}"/usr/${libdir} > /dev/null;
  1368. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1369. [[ ${tlib} != ${lib} ]] && ln -snf "../../${libdir}/${tlib}" "${tlib}";
  1370. popd > /dev/null
  1371. ;;
  1372. *)
  1373. if ${auto}; then
  1374. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1375. if [[ -z ${tlib} ]]; then
  1376. ewarn "gen_usr_ldscript: unable to read SONAME from ${lib}";
  1377. tlib=${lib};
  1378. fi;
  1379. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1380. if [[ ${tlib} != ${lib}* ]]; then
  1381. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1382. fi;
  1383. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  1384. else
  1385. tlib=${lib};
  1386. fi;
  1387. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1388. /* GNU ld script
  1389. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1390. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1391. run into linking problems. This "fake" dynamic lib is a linker script that
  1392. redirects the linker to the real lib. And yes, this works in the cross-
  1393. compiling scenario as the sysroot-ed linker will prepend the real path.
  1394.  
  1395. See bug http://bugs.gentoo.org/4411 for more info.
  1396. */
  1397. ${output_format}
  1398. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1399. END_LDSCRIPT
  1400.  
  1401. ;;
  1402. esac
  1403. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1404. done
  1405. }
  1406. get-flag ()
  1407. {
  1408. local f var findflag="$1";
  1409. for var in $(all-flag-vars);
  1410. do
  1411. for f in ${!var};
  1412. do
  1413. if [ "${f/${findflag}}" != "${f}" ]; then
  1414. printf "%s\n" "${f/-${findflag}=}";
  1415. return 0;
  1416. fi;
  1417. done;
  1418. done;
  1419. return 1
  1420. }
  1421. get_abi_CFLAGS ()
  1422. {
  1423. get_abi_var CFLAGS "$@"
  1424. }
  1425. get_abi_CHOST ()
  1426. {
  1427. get_abi_var CHOST "$@"
  1428. }
  1429. get_abi_CTARGET ()
  1430. {
  1431. get_abi_var CTARGET "$@"
  1432. }
  1433. get_abi_FAKE_TARGETS ()
  1434. {
  1435. get_abi_var FAKE_TARGETS "$@"
  1436. }
  1437. get_abi_LDFLAGS ()
  1438. {
  1439. get_abi_var LDFLAGS "$@"
  1440. }
  1441. get_abi_LIBDIR ()
  1442. {
  1443. get_abi_var LIBDIR "$@"
  1444. }
  1445. get_abi_var ()
  1446. {
  1447. local flag=$1;
  1448. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1449. local var="${flag}_${abi}";
  1450. echo ${!var}
  1451. }
  1452. get_all_abis ()
  1453. {
  1454. local order="";
  1455. if [[ -z ${MULTILIB_ABIS} ]]; then
  1456. echo "default";
  1457. return 0;
  1458. fi;
  1459. for x in ${MULTILIB_ABIS};
  1460. do
  1461. if [[ ${x} != ${DEFAULT_ABI} ]]; then
  1462. order="${order:+${order} }${x}";
  1463. fi;
  1464. done;
  1465. order="${order:+${order} }${DEFAULT_ABI}";
  1466. echo ${order};
  1467. return 0
  1468. }
  1469. get_all_libdirs ()
  1470. {
  1471. local libdirs;
  1472. local abi;
  1473. local dir;
  1474. for abi in ${MULTILIB_ABIS};
  1475. do
  1476. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1477. done;
  1478. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1479. echo "${libdirs}"
  1480. }
  1481. get_install_abis ()
  1482. {
  1483. local order="";
  1484. if [[ -z ${MULTILIB_ABIS} ]]; then
  1485. echo "default";
  1486. return 0;
  1487. fi;
  1488. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1489. for x in ${MULTILIB_ABIS};
  1490. do
  1491. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1492. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1493. fi;
  1494. done;
  1495. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1496. if [[ -n ${ABI_ALLOW} ]]; then
  1497. local ordera="";
  1498. for x in ${order};
  1499. do
  1500. if has ${x} ${ABI_ALLOW}; then
  1501. ordera="${ordera} ${x}";
  1502. fi;
  1503. done;
  1504. order=${ordera};
  1505. fi;
  1506. else
  1507. order=${DEFAULT_ABI};
  1508. fi;
  1509. if [[ -z ${order} ]]; then
  1510. 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.";
  1511. fi;
  1512. echo ${order};
  1513. return 0
  1514. }
  1515. get_libdir ()
  1516. {
  1517. local CONF_LIBDIR;
  1518. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1519. echo ${CONF_LIBDIR_OVERRIDE};
  1520. else
  1521. get_abi_LIBDIR;
  1522. fi
  1523. }
  1524. get_libname ()
  1525. {
  1526. local libname;
  1527. local ver=$1;
  1528. case ${CHOST} in
  1529. *-cygwin | mingw* | *-mingw*)
  1530. libname="dll"
  1531. ;;
  1532. *-darwin*)
  1533. libname="dylib"
  1534. ;;
  1535. *-mint*)
  1536. libname="irrelevant"
  1537. ;;
  1538. hppa*-hpux*)
  1539. libname="sl"
  1540. ;;
  1541. *)
  1542. libname="so"
  1543. ;;
  1544. esac;
  1545. if [[ -z $* ]]; then
  1546. echo ".${libname}";
  1547. else
  1548. for ver in "$@";
  1549. do
  1550. case ${CHOST} in
  1551. *-darwin*)
  1552. echo ".${ver}.${libname}"
  1553. ;;
  1554. *-mint*)
  1555. echo ".${libname}"
  1556. ;;
  1557. *)
  1558. echo ".${libname}.${ver}"
  1559. ;;
  1560. esac;
  1561. done;
  1562. fi
  1563. }
  1564. get_modname ()
  1565. {
  1566. local modname;
  1567. local ver=$1;
  1568. case ${CHOST} in
  1569. *-darwin*)
  1570. modname="bundle"
  1571. ;;
  1572. *)
  1573. modname="so"
  1574. ;;
  1575. esac;
  1576. echo ".${modname}"
  1577. }
  1578. has_m32 ()
  1579. {
  1580. die "${FUNCNAME}: don't use this anymore"
  1581. }
  1582. has_m64 ()
  1583. {
  1584. eqawarn "${FUNCNAME}: don't use this anymore";
  1585. local temp="$(emktemp)";
  1586. echo "int main() { return(0); }" > "${temp}".c;
  1587. MY_CC=$(tc-getCC);
  1588. ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  1589. local ret=$?;
  1590. rm -f "${temp}".c;
  1591. [[ ${ret} != 1 ]] && return 0;
  1592. return 1
  1593. }
  1594. has_multilib_profile ()
  1595. {
  1596. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1597. }
  1598. in_iuse ()
  1599. {
  1600. debug-print-function ${FUNCNAME} "${@}";
  1601. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  1602. local flag=${1};
  1603. local liuse=(${IUSE});
  1604. has "${flag}" "${liuse[@]#[+-]}"
  1605. }
  1606. is-flag ()
  1607. {
  1608. is-flagq "$@" && echo true
  1609. }
  1610. is-flagq ()
  1611. {
  1612. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1613. local var;
  1614. for var in $(all-flag-vars);
  1615. do
  1616. _is_flagq ${var} "$1" && return 0;
  1617. done;
  1618. return 1
  1619. }
  1620. is-ldflag ()
  1621. {
  1622. is-ldflagq "$@" && echo true
  1623. }
  1624. is-ldflagq ()
  1625. {
  1626. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1627. _is_flagq LDFLAGS $1
  1628. }
  1629. is_final_abi ()
  1630. {
  1631. has_multilib_profile || return 0;
  1632. set -- $(get_install_abis);
  1633. local LAST_ABI=$#;
  1634. [[ ${!LAST_ABI} == ${ABI} ]]
  1635. }
  1636. maint_pkg_create ()
  1637. {
  1638. cd /usr/local/src/net-tools;
  1639. local stamp=$(date --date="$(git log -n1 --pretty=format:%ci master)" -u +%Y%m%d%H%M%S);
  1640. local pv="${PV/_p*}_p${stamp}";
  1641. pv=${pv/9999/1.60};
  1642. local p="${PN}-${pv}";
  1643. git archive --prefix="nt/" master | tar xf - -C "${T}";
  1644. pushd "${T}" > /dev/null;
  1645. pushd nt > /dev/null;
  1646. sed -i "/^RELEASE/s:=.*:=${pv}:" Makefile || die;
  1647. emake dist > /dev/null;
  1648. popd > /dev/null;
  1649. zcat ${p}.tar.gz | xz > ${p}.tar.xz;
  1650. rm -f ${p}.tar.gz;
  1651. popd > /dev/null;
  1652. local patches="${p}-patches-${PATCH_VER:-1}";
  1653. local d="${T}/${patches}";
  1654. mkdir "${d}";
  1655. git format-patch -o "${d}" master..gentoo > /dev/null;
  1656. echo "From http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git" > "${d}"/README;
  1657. tar cf - -C "${T}" ${d##*/} | xz > "${T}"/${patches}.tar.xz;
  1658. rm -rf "${d}";
  1659. du -b "${T}"/*.tar.xz
  1660. }
  1661. make_desktop_entry ()
  1662. {
  1663. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  1664. local exec=${1};
  1665. local name=${2:-${PN}};
  1666. local icon=${3:-${PN}};
  1667. local type=${4};
  1668. local fields=${5};
  1669. if [[ -z ${type} ]]; then
  1670. local catmaj=${CATEGORY%%-*};
  1671. local catmin=${CATEGORY##*-};
  1672. case ${catmaj} in
  1673. app)
  1674. case ${catmin} in
  1675. accessibility)
  1676. type="Utility;Accessibility"
  1677. ;;
  1678. admin)
  1679. type=System
  1680. ;;
  1681. antivirus)
  1682. type=System
  1683. ;;
  1684. arch)
  1685. type="Utility;Archiving"
  1686. ;;
  1687. backup)
  1688. type="Utility;Archiving"
  1689. ;;
  1690. cdr)
  1691. type="AudioVideo;DiscBurning"
  1692. ;;
  1693. dicts)
  1694. type="Office;Dictionary"
  1695. ;;
  1696. doc)
  1697. type=Documentation
  1698. ;;
  1699. editors)
  1700. type="Utility;TextEditor"
  1701. ;;
  1702. emacs)
  1703. type="Development;TextEditor"
  1704. ;;
  1705. emulation)
  1706. type="System;Emulator"
  1707. ;;
  1708. laptop)
  1709. type="Settings;HardwareSettings"
  1710. ;;
  1711. office)
  1712. type=Office
  1713. ;;
  1714. pda)
  1715. type="Office;PDA"
  1716. ;;
  1717. vim)
  1718. type="Development;TextEditor"
  1719. ;;
  1720. xemacs)
  1721. type="Development;TextEditor"
  1722. ;;
  1723. esac
  1724. ;;
  1725. dev)
  1726. type="Development"
  1727. ;;
  1728. games)
  1729. case ${catmin} in
  1730. action | fps)
  1731. type=ActionGame
  1732. ;;
  1733. arcade)
  1734. type=ArcadeGame
  1735. ;;
  1736. board)
  1737. type=BoardGame
  1738. ;;
  1739. emulation)
  1740. type=Emulator
  1741. ;;
  1742. kids)
  1743. type=KidsGame
  1744. ;;
  1745. puzzle)
  1746. type=LogicGame
  1747. ;;
  1748. roguelike)
  1749. type=RolePlaying
  1750. ;;
  1751. rpg)
  1752. type=RolePlaying
  1753. ;;
  1754. simulation)
  1755. type=Simulation
  1756. ;;
  1757. sports)
  1758. type=SportsGame
  1759. ;;
  1760. strategy)
  1761. type=StrategyGame
  1762. ;;
  1763. esac;
  1764. type="Game;${type}"
  1765. ;;
  1766. gnome)
  1767. type="Gnome;GTK"
  1768. ;;
  1769. kde)
  1770. type="KDE;Qt"
  1771. ;;
  1772. mail)
  1773. type="Network;Email"
  1774. ;;
  1775. media)
  1776. case ${catmin} in
  1777. gfx)
  1778. type=Graphics
  1779. ;;
  1780. *)
  1781. case ${catmin} in
  1782. radio)
  1783. type=Tuner
  1784. ;;
  1785. sound)
  1786. type=Audio
  1787. ;;
  1788. tv)
  1789. type=TV
  1790. ;;
  1791. video)
  1792. type=Video
  1793. ;;
  1794. esac;
  1795. type="AudioVideo;${type}"
  1796. ;;
  1797. esac
  1798. ;;
  1799. net)
  1800. case ${catmin} in
  1801. dialup)
  1802. type=Dialup
  1803. ;;
  1804. ftp)
  1805. type=FileTransfer
  1806. ;;
  1807. im)
  1808. type=InstantMessaging
  1809. ;;
  1810. irc)
  1811. type=IRCClient
  1812. ;;
  1813. mail)
  1814. type=Email
  1815. ;;
  1816. news)
  1817. type=News
  1818. ;;
  1819. nntp)
  1820. type=News
  1821. ;;
  1822. p2p)
  1823. type=FileTransfer
  1824. ;;
  1825. voip)
  1826. type=Telephony
  1827. ;;
  1828. esac;
  1829. type="Network;${type}"
  1830. ;;
  1831. sci)
  1832. case ${catmin} in
  1833. astro*)
  1834. type=Astronomy
  1835. ;;
  1836. bio*)
  1837. type=Biology
  1838. ;;
  1839. calc*)
  1840. type=Calculator
  1841. ;;
  1842. chem*)
  1843. type=Chemistry
  1844. ;;
  1845. elec*)
  1846. type=Electronics
  1847. ;;
  1848. geo*)
  1849. type=Geology
  1850. ;;
  1851. math*)
  1852. type=Math
  1853. ;;
  1854. physics)
  1855. type=Physics
  1856. ;;
  1857. visual*)
  1858. type=DataVisualization
  1859. ;;
  1860. esac;
  1861. type="Education;Science;${type}"
  1862. ;;
  1863. sys)
  1864. type="System"
  1865. ;;
  1866. www)
  1867. case ${catmin} in
  1868. client)
  1869. type=WebBrowser
  1870. ;;
  1871. esac;
  1872. type="Network;${type}"
  1873. ;;
  1874. *)
  1875. type=
  1876. ;;
  1877. esac;
  1878. fi;
  1879. if [ "${SLOT}" == "0" ]; then
  1880. local desktop_name="${PN}";
  1881. else
  1882. local desktop_name="${PN}-${SLOT}";
  1883. fi;
  1884. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  1885. type=${type%;}${type:+;};
  1886. eshopts_push -s extglob;
  1887. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  1888. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  1889. ewarn "allowed in .desktop files if the value is not an absolute path.";
  1890. icon=${icon%.@(xpm|png|svg)};
  1891. fi;
  1892. eshopts_pop;
  1893. cat > "${desktop}" <<-EOF
  1894. [Desktop Entry]
  1895. Name=${name}
  1896. Type=Application
  1897. Comment=${DESCRIPTION}
  1898. Exec=${exec}
  1899. TryExec=${exec%% *}
  1900. Icon=${icon}
  1901. Categories=${type}
  1902. EOF
  1903.  
  1904. if [[ ${fields:-=} != *=* ]]; then
  1905. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  1906. fields="Path=${fields}";
  1907. fi;
  1908. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  1909. ( insinto /usr/share/applications;
  1910. doins "${desktop}" ) || die "installing desktop file failed"
  1911. }
  1912. make_session_desktop ()
  1913. {
  1914. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  1915. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  1916. local title=$1;
  1917. local command=$2;
  1918. local desktop=${T}/${wm:-${PN}}.desktop;
  1919. shift 2;
  1920. cat > "${desktop}" <<-EOF
  1921. [Desktop Entry]
  1922. Name=${title}
  1923. Comment=This session logs you into ${title}
  1924. Exec=${command} $*
  1925. TryExec=${command}
  1926. Type=XSession
  1927. EOF
  1928.  
  1929. ( insinto /usr/share/xsessions;
  1930. doins "${desktop}" )
  1931. }
  1932. make_wrapper ()
  1933. {
  1934. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  1935. local tmpwrapper=$(emktemp);
  1936. cat > "${tmpwrapper}" <<EOF
  1937. #!${EPREFIX}/bin/sh
  1938. cd "${chdir:-.}"
  1939. if [ -n "${libdir}" ] ; then
  1940. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  1941. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${EPREFIX}${libdir}"
  1942. else
  1943. export LD_LIBRARY_PATH="${EPREFIX}${libdir}"
  1944. fi
  1945. # ultra-dirty, just do the same for Darwin
  1946. if [ "\${DYLD_LIBRARY_PATH+set}" = "set" ] ; then
  1947. export DYLD_LIBRARY_PATH="\${DYLD_LIBRARY_PATH}:${EPERFIX}${libdir}"
  1948. else
  1949. export DYLD_LIBRARY_PATH="${EPREFIX}${libdir}"
  1950. fi
  1951. fi
  1952. exec "${EPREFIX}"${bin} "\$@"
  1953. EOF
  1954.  
  1955. chmod go+rx "${tmpwrapper}";
  1956. if [[ -n ${path} ]]; then
  1957. ( exeinto "${path}";
  1958. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  1959. else
  1960. newbin "${tmpwrapper}" "${wrapper}" || die;
  1961. fi
  1962. }
  1963. multilib_env ()
  1964. {
  1965. local CTARGET=${1:-${CTARGET}};
  1966. case ${CTARGET} in
  1967. x86_64*)
  1968. export CFLAGS_x86=${CFLAGS_x86--m32};
  1969. export CHOST_x86=${CTARGET/x86_64/i686};
  1970. export CTARGET_x86=${CHOST_x86};
  1971. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1972. export LIBDIR_x86="lib32";
  1973. else
  1974. export LIBDIR_x86="lib";
  1975. fi;
  1976. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1977. export CHOST_amd64=${CTARGET};
  1978. export CTARGET_amd64=${CHOST_amd64};
  1979. export LIBDIR_amd64="lib64";
  1980. export CFLAGS_x32=${CFLAGS_x32--mx32};
  1981. export CHOST_x32=${CTARGET};
  1982. export CTARGET_x32=${CHOST_x32};
  1983. export LIBDIR_x32="libx32";
  1984. : ${MULTILIB_ABIS=amd64 x86};
  1985. : ${DEFAULT_ABI=amd64}
  1986. ;;
  1987. mips64*)
  1988. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1989. export CHOST_o32=${CTARGET/mips64/mips};
  1990. export CTARGET_o32=${CHOST_o32};
  1991. export LIBDIR_o32="lib";
  1992. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1993. export CHOST_n32=${CTARGET};
  1994. export CTARGET_n32=${CHOST_n32};
  1995. export LIBDIR_n32="lib32";
  1996. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1997. export CHOST_n64=${CTARGET};
  1998. export CTARGET_n64=${CHOST_n64};
  1999. export LIBDIR_n64="lib64";
  2000. : ${MULTILIB_ABIS=n64 n32 o32};
  2001. : ${DEFAULT_ABI=n32}
  2002. ;;
  2003. powerpc64*)
  2004. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2005. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2006. export CTARGET_ppc=${CHOST_ppc};
  2007. export LIBDIR_ppc="lib";
  2008. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2009. export CHOST_ppc64=${CTARGET};
  2010. export CTARGET_ppc64=${CHOST_ppc64};
  2011. export LIBDIR_ppc64="lib64";
  2012. : ${MULTILIB_ABIS=ppc64 ppc};
  2013. : ${DEFAULT_ABI=ppc64}
  2014. ;;
  2015. s390x*)
  2016. export CFLAGS_s390=${CFLAGS_s390--m31};
  2017. export CHOST_s390=${CTARGET/s390x/s390};
  2018. export CTARGET_s390=${CHOST_s390};
  2019. export LIBDIR_s390="lib";
  2020. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2021. export CHOST_s390x=${CTARGET};
  2022. export CTARGET_s390x=${CHOST_s390x};
  2023. export LIBDIR_s390x="lib64";
  2024. : ${MULTILIB_ABIS=s390x s390};
  2025. : ${DEFAULT_ABI=s390x}
  2026. ;;
  2027. sparc*)
  2028. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2029. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2030. export CTARGET_sparc32=${CHOST_sparc32};
  2031. export LIBDIR_sparc32="lib";
  2032. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2033. export CHOST_sparc64=${CTARGET};
  2034. export CTARGET_sparc64=${CHOST_sparc64};
  2035. export LIBDIR_sparc64="lib64";
  2036. : ${MULTILIB_ABIS=sparc64 sparc32};
  2037. : ${DEFAULT_ABI=sparc64}
  2038. ;;
  2039. *)
  2040. : ${MULTILIB_ABIS=default};
  2041. : ${DEFAULT_ABI=default}
  2042. ;;
  2043. esac;
  2044. export MULTILIB_ABIS DEFAULT_ABI
  2045. }
  2046. multilib_toolchain_setup ()
  2047. {
  2048. local v vv;
  2049. export ABI=$1;
  2050. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  2051. for v in CHOST CBUILD AS CC CXX LD;
  2052. do
  2053. vv="__abi_saved_${v}";
  2054. export ${v}="${!vv}";
  2055. unset ${vv};
  2056. done;
  2057. unset __DEFAULT_ABI_SAVED;
  2058. fi;
  2059. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2060. for v in CHOST CBUILD AS CC CXX LD;
  2061. do
  2062. export __abi_saved_${v}="${!v}";
  2063. done;
  2064. export __DEFAULT_ABI_SAVED="true";
  2065. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2066. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2067. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2068. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2069. export CHOST=$(get_abi_CHOST $1);
  2070. export CBUILD=$(get_abi_CHOST $1);
  2071. fi
  2072. }
  2073. newicon ()
  2074. {
  2075. ( insinto /usr/share/pixmaps;
  2076. newins "$@" )
  2077. }
  2078. newmenu ()
  2079. {
  2080. ( insinto /usr/share/applications;
  2081. newins "$@" )
  2082. }
  2083. no-as-needed ()
  2084. {
  2085. case $($(tc-getLD) -v 2>&1 </dev/null) in
  2086. *GNU*)
  2087. echo "-Wl,--no-as-needed"
  2088. ;;
  2089. esac
  2090. }
  2091. number_abis ()
  2092. {
  2093. set -- `get_install_abis`;
  2094. echo $#
  2095. }
  2096. path_exists ()
  2097. {
  2098. local opt=$1;
  2099. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  2100. [[ $# -eq 0 ]] && return 1;
  2101. local p r=0;
  2102. for p in "$@";
  2103. do
  2104. [[ -e ${p} ]];
  2105. : $(( r += $? ));
  2106. done;
  2107. case ${opt} in
  2108. -a)
  2109. return $(( r != 0 ))
  2110. ;;
  2111. -o)
  2112. return $(( r == $# ))
  2113. ;;
  2114. esac
  2115. }
  2116. pkg_nofetch ()
  2117. {
  2118. _eapi0_pkg_nofetch "$@"
  2119. }
  2120. pkg_postinst ()
  2121. {
  2122. einfo "etherwake and such have been split into net-misc/ethercard-diag"
  2123. }
  2124. pkg_setup ()
  2125. {
  2126. [[ -n ${VAPIER_LOVES_YOU} ]] && maint_pkg_create
  2127. }
  2128. post_src_install ()
  2129. {
  2130. prefix-post_src_install
  2131. }
  2132. prefix-post_src_install ()
  2133. {
  2134. local f;
  2135. if [[ ${PN} != "libiconv" && -n $(ls "${ED}"/usr/lib*/charset.alias 2>/dev/null) ]]; then
  2136. einfo "automatically removing charset.alias";
  2137. rm -f "${ED}"/usr/lib*/charset.alias;
  2138. fi
  2139. }
  2140. preserve_old_lib ()
  2141. {
  2142. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2143. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2144. die "Invalid preserve_old_lib() usage";
  2145. fi;
  2146. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2147. has preserve-libs ${FEATURES} && return 0;
  2148. [[ ${CHOST} == *-aix* ]] && {
  2149. einfo "Not preserving libs on AIX (yet), not implemented.";
  2150. return 0
  2151. };
  2152. local lib dir;
  2153. for lib in "$@";
  2154. do
  2155. [[ -e ${EROOT}/${lib} ]] || continue;
  2156. dir=${lib%/*};
  2157. dodir ${dir} || die "dodir ${dir} failed";
  2158. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  2159. touch "${ED}"/${lib};
  2160. done
  2161. }
  2162. preserve_old_lib_notify ()
  2163. {
  2164. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2165. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2166. die "Invalid preserve_old_lib_notify() usage";
  2167. fi;
  2168. has preserve-libs ${FEATURES} && return 0;
  2169. local lib notice=0;
  2170. for lib in "$@";
  2171. do
  2172. [[ -e ${EROOT}/${lib} ]] || continue;
  2173. if [[ ${notice} -eq 0 ]]; then
  2174. notice=1;
  2175. ewarn "Old versions of installed libraries were detected on your system.";
  2176. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2177. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2178. ewarn "in order to remove these old dependencies. If you do not have this";
  2179. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2180. ewarn;
  2181. fi;
  2182. [[ ${PN} == "mpfr" ]] && lib=${lib##*/};
  2183. ewarn " # revdep-rebuild --library '${lib}'";
  2184. done;
  2185. if [[ ${notice} -eq 1 ]]; then
  2186. ewarn;
  2187. ewarn "Once you've finished running revdep-rebuild, it should be safe to";
  2188. ewarn "delete the old libraries. Here is a copy & paste for the lazy:";
  2189. for lib in "$@";
  2190. do
  2191. ewarn " # rm '${lib}'";
  2192. done;
  2193. fi
  2194. }
  2195. profile-post_src_install ()
  2196. {
  2197. prefix-post_src_install
  2198. }
  2199. raw-ldflags ()
  2200. {
  2201. local x input="$@";
  2202. [[ -z ${input} ]] && input=${LDFLAGS};
  2203. set --;
  2204. for x in ${input};
  2205. do
  2206. x=${x#-Wl,};
  2207. set -- "$@" ${x//,/ };
  2208. done;
  2209. echo "$@"
  2210. }
  2211. replace-cpu-flags ()
  2212. {
  2213. local newcpu="$#";
  2214. newcpu="${!newcpu}";
  2215. while [ $# -gt 1 ]; do
  2216. replace-flags "-march=${1}" "-march=${newcpu}";
  2217. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2218. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2219. shift;
  2220. done;
  2221. return 0
  2222. }
  2223. replace-flags ()
  2224. {
  2225. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2226. local f var new;
  2227. for var in $(all-flag-vars);
  2228. do
  2229. new=();
  2230. for f in ${!var};
  2231. do
  2232. [[ ${f} == ${1} ]] && f=${2};
  2233. new+=("${f}");
  2234. done;
  2235. eval export ${var}=\""${new[*]}"\";
  2236. done;
  2237. return 0
  2238. }
  2239. replace-sparc64-flags ()
  2240. {
  2241. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2242. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2243. for x in ${SPARC64_CPUS};
  2244. do
  2245. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2246. done;
  2247. else
  2248. for x in ${SPARC64_CPUS};
  2249. do
  2250. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2251. done;
  2252. fi;
  2253. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2254. for x in ${SPARC64_CPUS};
  2255. do
  2256. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2257. done;
  2258. else
  2259. for x in ${SPARC64_CPUS};
  2260. do
  2261. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2262. done;
  2263. fi;
  2264. export CFLAGS CXXFLAGS
  2265. }
  2266. set_opt ()
  2267. {
  2268. local opt=$1 ans;
  2269. shift;
  2270. ans=$("$@" && echo y || echo n);
  2271. einfo "Setting option ${opt} to ${ans}";
  2272. sed -i -e "/^bool.* ${opt} /s:[yn]$:${ans}:" config.in || die
  2273. }
  2274. setup-allowed-flags ()
  2275. {
  2276. ALLOWED_FLAGS="-pipe";
  2277. ALLOWED_FLAGS+=" -O -O1 -O2 -Os -mcpu -march -mtune";
  2278. ALLOWED_FLAGS+=" -fstack-protector -fstack-protector-all";
  2279. ALLOWED_FLAGS+=" -fbounds-checking -fno-strict-overflow";
  2280. ALLOWED_FLAGS+=" -fno-PIE -fno-pie -fno-unit-at-a-time";
  2281. ALLOWED_FLAGS+=" -g -g[0-9] -ggdb -ggdb[0-9] -gstabs -gstabs+";
  2282. ALLOWED_FLAGS+=" -fno-ident -fpermissive";
  2283. ALLOWED_FLAGS+=" -W* -w";
  2284. ALLOWED_FLAGS+=" -fno-stack-protector -fno-stack-protector-all -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer";
  2285. 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*";
  2286. ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
  2287. ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
  2288. export ALLOWED_FLAGS;
  2289. return 0
  2290. }
  2291. src_compile ()
  2292. {
  2293. _eapi2_src_compile "$@"
  2294. }
  2295. src_configure ()
  2296. {
  2297. set_opt I18N use nls;
  2298. set_opt HAVE_HWIB has_version '>=sys-kernel/linux-headers-2.6';
  2299. if use static; then
  2300. append-flags -static;
  2301. append-ldflags -static;
  2302. fi;
  2303. tc-export AR CC;
  2304. yes "" | ./configure.sh config.in || die
  2305. }
  2306. src_install ()
  2307. {
  2308. emake DESTDIR="${ED}" install || die;
  2309. dodoc README README.ipv6 TODO
  2310. }
  2311. src_prepare ()
  2312. {
  2313. if [[ -n ${PATCH_VER} ]]; then
  2314. use old-output || EPATCH_EXCLUDE="0001-revert-621a2f376334f8097604b9fee5783e0f1141e66d-for-.patch";
  2315. EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch "${WORKDIR}"/${P}-patches-${PATCH_VER};
  2316. fi
  2317. }
  2318. src_test ()
  2319. {
  2320. _eapi0_src_test "$@"
  2321. }
  2322. src_unpack ()
  2323. {
  2324. _eapi0_src_unpack "$@"
  2325. }
  2326. strip-flags ()
  2327. {
  2328. local x y var;
  2329. setup-allowed-flags;
  2330. set -f;
  2331. for var in $(all-flag-vars);
  2332. do
  2333. local new=();
  2334. for x in ${!var};
  2335. do
  2336. local flag=${x%%=*};
  2337. for y in ${ALLOWED_FLAGS};
  2338. do
  2339. if [[ -z ${flag%%${y}} ]]; then
  2340. new+=("${x}");
  2341. break;
  2342. fi;
  2343. done;
  2344. done;
  2345. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2346. new+=(-O2);
  2347. fi;
  2348. eval export ${var}=\""${new[*]}"\";
  2349. done;
  2350. set +f;
  2351. return 0
  2352. }
  2353. strip-linguas ()
  2354. {
  2355. local ls newls nols;
  2356. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2357. local op=$1;
  2358. shift;
  2359. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2360. shift;
  2361. local d f;
  2362. for d in "$@";
  2363. do
  2364. if [[ ${op} == "-u" ]]; then
  2365. newls=${ls};
  2366. else
  2367. newls="";
  2368. fi;
  2369. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2370. do
  2371. if [[ ${op} == "-i" ]]; then
  2372. has ${f} ${ls} && newls="${newls} ${f}";
  2373. else
  2374. has ${f} ${ls} || newls="${newls} ${f}";
  2375. fi;
  2376. done;
  2377. ls=${newls};
  2378. done;
  2379. else
  2380. ls="$@";
  2381. fi;
  2382. nols="";
  2383. newls="";
  2384. for f in ${LINGUAS};
  2385. do
  2386. if has ${f} ${ls}; then
  2387. newls="${newls} ${f}";
  2388. else
  2389. nols="${nols} ${f}";
  2390. fi;
  2391. done;
  2392. [[ -n ${nols} ]] && ewarn "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2393. export LINGUAS=${newls:1}
  2394. }
  2395. strip-unsupported-flags ()
  2396. {
  2397. export CFLAGS=$(test-flags-CC ${CFLAGS});
  2398. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  2399. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  2400. export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  2401. }
  2402. tc-arch ()
  2403. {
  2404. tc-ninja_magic_to_arch portage "$@"
  2405. }
  2406. tc-arch-kernel ()
  2407. {
  2408. tc-ninja_magic_to_arch kern "$@"
  2409. }
  2410. tc-endian ()
  2411. {
  2412. local host=$1;
  2413. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2414. host=${host%%-*};
  2415. case ${host} in
  2416. alpha*)
  2417. echo big
  2418. ;;
  2419. arm*b*)
  2420. echo big
  2421. ;;
  2422. arm*)
  2423. echo little
  2424. ;;
  2425. cris*)
  2426. echo little
  2427. ;;
  2428. hppa*)
  2429. echo big
  2430. ;;
  2431. i?86*)
  2432. echo little
  2433. ;;
  2434. ia64*)
  2435. echo little
  2436. ;;
  2437. m68*)
  2438. echo big
  2439. ;;
  2440. mips*l*)
  2441. echo little
  2442. ;;
  2443. mips*)
  2444. echo big
  2445. ;;
  2446. powerpc*)
  2447. echo big
  2448. ;;
  2449. s390*)
  2450. echo big
  2451. ;;
  2452. sh*b*)
  2453. echo big
  2454. ;;
  2455. sh*)
  2456. echo little
  2457. ;;
  2458. sparc*)
  2459. echo big
  2460. ;;
  2461. x86_64*)
  2462. echo little
  2463. ;;
  2464. *)
  2465. echo wtf
  2466. ;;
  2467. esac
  2468. }
  2469. tc-env_build ()
  2470. {
  2471. 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) "$@"
  2472. }
  2473. tc-export ()
  2474. {
  2475. local var;
  2476. for var in "$@";
  2477. do
  2478. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2479. eval tc-get${var} > /dev/null;
  2480. done
  2481. }
  2482. tc-getAR ()
  2483. {
  2484. tc-getPROG AR ar "$@"
  2485. }
  2486. tc-getAS ()
  2487. {
  2488. tc-getPROG AS as "$@"
  2489. }
  2490. tc-getBUILD_AR ()
  2491. {
  2492. tc-getBUILD_PROG AR ar "$@"
  2493. }
  2494. tc-getBUILD_AS ()
  2495. {
  2496. tc-getBUILD_PROG AS as "$@"
  2497. }
  2498. tc-getBUILD_CC ()
  2499. {
  2500. tc-getBUILD_PROG CC gcc "$@"
  2501. }
  2502. tc-getBUILD_CPP ()
  2503. {
  2504. tc-getBUILD_PROG CPP cpp "$@"
  2505. }
  2506. tc-getBUILD_CXX ()
  2507. {
  2508. tc-getBUILD_PROG CXX g++ "$@"
  2509. }
  2510. tc-getBUILD_LD ()
  2511. {
  2512. tc-getBUILD_PROG LD ld "$@"
  2513. }
  2514. tc-getBUILD_NM ()
  2515. {
  2516. tc-getBUILD_PROG NM nm "$@"
  2517. }
  2518. tc-getBUILD_OBJCOPY ()
  2519. {
  2520. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2521. }
  2522. tc-getBUILD_PKG_CONFIG ()
  2523. {
  2524. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2525. }
  2526. tc-getBUILD_PROG ()
  2527. {
  2528. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  2529. }
  2530. tc-getBUILD_RANLIB ()
  2531. {
  2532. tc-getBUILD_PROG RANLIB ranlib "$@"
  2533. }
  2534. tc-getBUILD_STRIP ()
  2535. {
  2536. tc-getBUILD_PROG STRIP strip "$@"
  2537. }
  2538. tc-getCC ()
  2539. {
  2540. tc-getPROG CC gcc "$@"
  2541. }
  2542. tc-getCPP ()
  2543. {
  2544. tc-getPROG CPP cpp "$@"
  2545. }
  2546. tc-getCXX ()
  2547. {
  2548. tc-getPROG CXX g++ "$@"
  2549. }
  2550. tc-getDLLWRAP ()
  2551. {
  2552. tc-getPROG DLLWRAP dllwrap "$@"
  2553. }
  2554. tc-getF77 ()
  2555. {
  2556. tc-getPROG F77 gfortran "$@"
  2557. }
  2558. tc-getFC ()
  2559. {
  2560. tc-getPROG FC gfortran "$@"
  2561. }
  2562. tc-getGCJ ()
  2563. {
  2564. tc-getPROG GCJ gcj "$@"
  2565. }
  2566. tc-getLD ()
  2567. {
  2568. tc-getPROG LD ld "$@"
  2569. }
  2570. tc-getNM ()
  2571. {
  2572. tc-getPROG NM nm "$@"
  2573. }
  2574. tc-getOBJCOPY ()
  2575. {
  2576. tc-getPROG OBJCOPY objcopy "$@"
  2577. }
  2578. tc-getPKG_CONFIG ()
  2579. {
  2580. tc-getPROG PKG_CONFIG pkg-config "$@"
  2581. }
  2582. tc-getPROG ()
  2583. {
  2584. _tc-getPROG CHOST "$@"
  2585. }
  2586. tc-getRANLIB ()
  2587. {
  2588. tc-getPROG RANLIB ranlib "$@"
  2589. }
  2590. tc-getRC ()
  2591. {
  2592. tc-getPROG RC windres "$@"
  2593. }
  2594. tc-getSTRIP ()
  2595. {
  2596. tc-getPROG STRIP strip "$@"
  2597. }
  2598. tc-has-openmp ()
  2599. {
  2600. local base="${T}/test-tc-openmp";
  2601. cat > "${base}.c" <<-EOF
  2602. #include <omp.h>
  2603. int main() {
  2604. int nthreads, tid, ret = 0;
  2605. #pragma omp parallel private(nthreads, tid)
  2606. {
  2607. tid = omp_get_thread_num();
  2608. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  2609. }
  2610. return ret;
  2611. }
  2612. EOF
  2613.  
  2614. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  2615. local ret=$?;
  2616. rm -f "${base}"*;
  2617. return ${ret}
  2618. }
  2619. tc-has-tls ()
  2620. {
  2621. local base="${T}/test-tc-tls";
  2622. cat > "${base}.c" <<-EOF
  2623. int foo(int *i) {
  2624. static __thread int j = 0;
  2625. return *i ? j : *i;
  2626. }
  2627. EOF
  2628.  
  2629. local flags;
  2630. case $1 in
  2631. -s)
  2632. flags="-S"
  2633. ;;
  2634. -c)
  2635. flags="-c"
  2636. ;;
  2637. -l)
  2638.  
  2639. ;;
  2640. -*)
  2641. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  2642. ;;
  2643. esac;
  2644. : ${flags:=-fPIC -shared -Wl,-z,defs};
  2645. [[ $1 == -* ]] && shift;
  2646. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  2647. local ret=$?;
  2648. rm -f "${base}"*;
  2649. return ${ret}
  2650. }
  2651. tc-is-cross-compiler ()
  2652. {
  2653. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  2654. }
  2655. tc-is-hardfloat ()
  2656. {
  2657. [[ ${CTARGET//_/-} == *-hardfloat-* ]] && echo "yes" || echo "no"
  2658. }
  2659. tc-is-softfloat ()
  2660. {
  2661. case ${CTARGET} in
  2662. bfin* | h8300*)
  2663. echo "only"
  2664. ;;
  2665. *)
  2666. [[ ${CTARGET//_/-} == *-softfloat-* ]] && echo "yes" || echo "no"
  2667. ;;
  2668. esac
  2669. }
  2670. tc-is-static-only ()
  2671. {
  2672. local host=${CTARGET:-${CHOST}};
  2673. return $([[ ${host} == *-mint* ]])
  2674. }
  2675. tc-ninja_magic_to_arch ()
  2676. {
  2677. function ninj ()
  2678. {
  2679. [[ ${type} == "kern" ]] && echo $1 || echo $2
  2680. };
  2681. local type=$1;
  2682. local host=$2;
  2683. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2684. case ${host} in
  2685. powerpc-apple-darwin*)
  2686. echo ppc-macos
  2687. ;;
  2688. powerpc64-apple-darwin*)
  2689. echo ppc64-macos
  2690. ;;
  2691. i?86-apple-darwin*)
  2692. echo x86-macos
  2693. ;;
  2694. x86_64-apple-darwin*)
  2695. echo x64-macos
  2696. ;;
  2697. sparc-sun-solaris*)
  2698. echo sparc-solaris
  2699. ;;
  2700. sparcv9-sun-solaris*)
  2701. echo sparc64-solaris
  2702. ;;
  2703. i?86-pc-solaris*)
  2704. echo x86-solaris
  2705. ;;
  2706. x86_64-pc-solaris*)
  2707. echo x64-solaris
  2708. ;;
  2709. powerpc-ibm-aix*)
  2710. echo ppc-aix
  2711. ;;
  2712. mips-sgi-irix*)
  2713. echo mips-irix
  2714. ;;
  2715. ia64w-hp-hpux*)
  2716. echo ia64w-hpux
  2717. ;;
  2718. ia64-hp-hpux*)
  2719. echo ia64-hpux
  2720. ;;
  2721. hppa*64*-hp-hpux*)
  2722. echo hppa64-hpux
  2723. ;;
  2724. hppa*-hp-hpux*)
  2725. echo hppa-hpux
  2726. ;;
  2727. i?86-pc-freebsd*)
  2728. echo x86-freebsd
  2729. ;;
  2730. x86_64-pc-freebsd*)
  2731. echo x64-freebsd
  2732. ;;
  2733. powerpc-unknown-openbsd*)
  2734. echo ppc-openbsd
  2735. ;;
  2736. i?86-pc-openbsd*)
  2737. echo x86-openbsd
  2738. ;;
  2739. x86_64-pc-openbsd*)
  2740. echo x64-openbsd
  2741. ;;
  2742. i?86-pc-netbsd*)
  2743. echo x86-netbsd
  2744. ;;
  2745. i?86-pc-interix*)
  2746. echo x86-interix
  2747. ;;
  2748. i?86-pc-winnt*)
  2749. echo x86-winnt
  2750. ;;
  2751. alpha*)
  2752. echo alpha
  2753. ;;
  2754. arm*)
  2755. echo arm
  2756. ;;
  2757. avr*)
  2758. ninj avr32 avr
  2759. ;;
  2760. bfin*)
  2761. ninj blackfin bfin
  2762. ;;
  2763. cris*)
  2764. echo cris
  2765. ;;
  2766. hppa*)
  2767. ninj parisc hppa
  2768. ;;
  2769. i?86*)
  2770. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  2771. echo i386;
  2772. else
  2773. echo x86;
  2774. fi
  2775. ;;
  2776. ia64*)
  2777. echo ia64
  2778. ;;
  2779. m68*)
  2780. echo m68k
  2781. ;;
  2782. mips*)
  2783. echo mips
  2784. ;;
  2785. nios2*)
  2786. echo nios2
  2787. ;;
  2788. nios*)
  2789. echo nios
  2790. ;;
  2791. powerpc*)
  2792. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  2793. echo powerpc;
  2794. else
  2795. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  2796. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  2797. echo powerpc;
  2798. else
  2799. echo ppc;
  2800. fi;
  2801. else
  2802. if [[ ${host} == powerpc64* ]]; then
  2803. echo ppc64;
  2804. else
  2805. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  2806. ninj ppc64 ppc;
  2807. else
  2808. echo ppc;
  2809. fi;
  2810. fi;
  2811. fi;
  2812. fi
  2813. ;;
  2814. s390*)
  2815. echo s390
  2816. ;;
  2817. sh64*)
  2818. ninj sh64 sh
  2819. ;;
  2820. sh*)
  2821. echo sh
  2822. ;;
  2823. sparc64*)
  2824. ninj sparc64 sparc
  2825. ;;
  2826. sparc*)
  2827. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  2828. ;;
  2829. vax*)
  2830. echo vax
  2831. ;;
  2832. x86_64*freebsd*)
  2833. echo amd64
  2834. ;;
  2835. x86_64*)
  2836. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  2837. echo x86;
  2838. else
  2839. ninj x86_64 amd64;
  2840. fi
  2841. ;;
  2842. *)
  2843. echo unknown
  2844. ;;
  2845. esac
  2846. }
  2847. test-flag-CC ()
  2848. {
  2849. test-flag-PROG "CC" "$1"
  2850. }
  2851. test-flag-CXX ()
  2852. {
  2853. test-flag-PROG "CXX" "$1"
  2854. }
  2855. test-flag-F77 ()
  2856. {
  2857. test-flag-PROG "F77" "$1"
  2858. }
  2859. test-flag-FC ()
  2860. {
  2861. test-flag-PROG "FC" "$1"
  2862. }
  2863. test-flag-PROG ()
  2864. {
  2865. local comp=$1;
  2866. local flag=$2;
  2867. [[ -z ${comp} || -z ${flag} ]] && return 1;
  2868. local src=${T}/tf-${comp}-${SECONDS}.c;
  2869. echo "main() {}" > "${src}";
  2870. local PROG=$(tc-get${comp});
  2871. ${PROG} "${flag}" -c -o "${src}.o" "${src}" > /dev/null 2>&1;
  2872. local ret=$?;
  2873. rm -f "${src}"{,.o};
  2874. [[ ${ret} == 0 ]] && true || false
  2875. }
  2876. test-flags ()
  2877. {
  2878. test-flags-CC "$@"
  2879. }
  2880. test-flags-CC ()
  2881. {
  2882. test-flags-PROG "CC" "$@"
  2883. }
  2884. test-flags-CXX ()
  2885. {
  2886. test-flags-PROG "CXX" "$@"
  2887. }
  2888. test-flags-F77 ()
  2889. {
  2890. test-flags-PROG "F77" "$@"
  2891. }
  2892. test-flags-FC ()
  2893. {
  2894. test-flags-PROG "FC" "$@"
  2895. }
  2896. test-flags-PROG ()
  2897. {
  2898. local comp=$1;
  2899. local flags;
  2900. local x;
  2901. shift;
  2902. [[ -z ${comp} ]] && return 1;
  2903. for x in "$@";
  2904. do
  2905. test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}" || ewarn "removing ${x} because ${comp} rejected it";
  2906. done;
  2907. echo "${flags}";
  2908. [[ -n ${flags} ]]
  2909. }
  2910. test_version_info ()
  2911. {
  2912. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  2913. return 0;
  2914. else
  2915. return 1;
  2916. fi
  2917. }
  2918. use_if_iuse ()
  2919. {
  2920. in_iuse $1 || return 1;
  2921. use $1
  2922. }
  2923. usex ()
  2924. {
  2925. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  2926. }
  2927. validate_desktop_entries ()
  2928. {
  2929. if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]]; then
  2930. einfo "Checking desktop entry validity";
  2931. local directories="";
  2932. for d in /usr/share/applications $@;
  2933. do
  2934. [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}";
  2935. done;
  2936. if [[ -n ${directories} ]]; then
  2937. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  2938. do
  2939. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  2940. [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:};
  2941. done;
  2942. fi;
  2943. echo "";
  2944. else
  2945. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  2946. fi
  2947. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement