Advertisement
Guest User

Build Environment

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