profile.bashrc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
  3. type -P gmake > /dev/null && alias make=gmake
  4. type -P gpatch > /dev/null && alias patch=gpatch
  5. type -P gsed > /dev/null && alias sed=gsed
  6. type -P gawk > /dev/null && alias awk=gawk
  7. type -P gfind > /dev/null && alias find=gfind
  8. type -P gxargs > /dev/null && alias xargs=gxargs
  9. # Attempt to point the default SHELL used by configure scripts to bash.
  10. # while most should work with BSD's bourne just fine, the extra scripts
  11. # used by some applications (specially test scripts) use way too many bashisms.
  12. # Alexis Ballier <29 May 2012>: Disable this, we should rather fix bugs and it
  13. # seems to confuse libtool a couple of packages (dev-libs/libtar, net-dns/hesiod)
  14. # export CONFIG_SHELL="/bin/bash"
  15. # Hack to avoid every package that uses libiconv/gettext
  16. # install a charset.alias that will collide with libiconv's one
  17. # See bugs 169678, 195148 and 256129.
  18. # Also the discussion on
  19. # https://archives.gentoo.org/gentoo-dev/msg_8cb1805411f37b4eb168a3e680e531f3.xml
  20. bsd-post_src_install()
  21. {
  22. if [ "${PN}" != "libiconv" -a -e "${D}"/usr/lib*/charset.alias ] ; then
  23. rm -f "${D}"/usr/lib*/charset.alias
  24. fi
  25. }
  26. # These are because of
  27. # https://archives.gentoo.org/gentoo-dev/msg_529a0806ed2cf841a467940a57e2d588.xml
  28. # The profile-* ones are meant to be used in etc/portage/profile.bashrc by user
  29. # until there is the registration mechanism.
  30. profile-post_src_install() { bsd-post_src_install ; }
  31. post_src_install() { bsd-post_src_install ; }
  32. # Another hack to fix old versions of install-sh (automake) where a non-gnu
  33. # mkdir is not considered thread-safe (make install errors with -j > 1)
  34. bsd-patch_install-sh() {
  35. # Do nothing if we don't have patch installed:
  36. if [[ -z $(type -P gpatch) ]]; then
  37. return 0
  38. fi
  39. # Do nothing if $S does not exist
  40. [ -d "${S}" ] || return 0
  41. local EPDIR="${ECLASSDIR}/ELT-patches/install-sh"
  42. local EPATCHES="${EPDIR}/1.5.6 ${EPDIR}/1.5.4 ${EPDIR}/1.5"
  43. local ret=0
  44. cd "${S}"
  45. for file in $(find . -name "install-sh" -print); do
  46. if [[ -n $(egrep "scriptversion=2005|scriptversion=2004" ${file}) ]]; then
  47. einfo "Automatically patching parallel-make unfriendly install-sh."
  48. # Stolen from libtool.eclass
  49. for mypatch in ${EPATCHES}; do
  50. if gpatch -p0 --dry-run "${file}" "${mypatch}" &> "${T}/patch_install-sh.log"; then
  51. gpatch -p0 -g0 --no-backup-if-mismatch "${file}" "${mypatch}" \
  52. &> "${T}/patch_install-sh.log"
  53. ret=$?
  54. break
  55. else
  56. ret=1
  57. fi
  58. done
  59. if [[ ret -eq 0 ]]; then
  60. einfo "Patch applied successfully on \"${file}\"."
  61. else
  62. ewarn "Unable to apply install-sh patch. "
  63. ewarn "If you experience errors during install phase, try with MAKEOPTS=\"-j1\""
  64. fi
  65. fi
  66. done
  67. }
  68. # It should be run after everything has been unpacked/patched, some developers
  69. # do patch this little bastard from time to time.
  70. # So do it after unpack() for EAPI=0|1 and after prepare() for everything else.
  71. if [[ -n $EAPI ]] ; then
  72. case "$EAPI" in
  73. 0|1)
  74. profile-post_src_unpack() { bsd-patch_install-sh ; }
  75. post_src_unpack() { bsd-patch_install-sh ; }
  76. ;;
  77. *)
  78. profile_post_src_prepare() { bsd-patch_install-sh ; }
  79. post_src_prepare() { bsd-patch_install-sh ; }
  80. ;;
  81. esac
  82. fi