Advertisement
Guest User

Untitled

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