Advertisement
odb9088

build_env

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