baselayout-prefix-2.2-r5.ebuild 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit eutils multilib libtool
  5. MY_P=${P/-prefix/} # just use "upstream" sources
  6. DESCRIPTION="Minimal baselayout for Gentoo Prefix installs"
  7. HOMEPAGE="https://www.gentoo.org/"
  8. SRC_URI="mirror://gentoo/${MY_P}.tar.bz2
  9. https://dev.gentoo.org/~vapier/dist/${MY_P}.tar.bz2"
  10. LICENSE="GPL-2"
  11. SLOT="0"
  12. IUSE="prefix-chaining"
  13. KEYWORDS="~arm ~ppc-aix ~x64-cygwin ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
  14. RDEPEND="sys-apps/gentoo-functions"
  15. DEPEND="${RDEPEND}"
  16. S=${WORKDIR}/${MY_P}
  17. pkg_preinst() {
  18. # This is written in src_install (so it's in CONTENTS), but punt all
  19. # pending updates to avoid user having to do etc-update (and make the
  20. # pkg_postinst logic simpler).
  21. rm -f "${EROOT}"/etc/._cfg????_gentoo-release
  22. }
  23. src_prepare() {
  24. if use prefix-chaining; then
  25. epatch "${FILESDIR}"/baselayout-${PV}-prefix-chaining.patch
  26. # need to set the PKG_CONFIG_PATH globally for this prefix, when
  27. # chaining is enabled, since pkg-config may not be installed locally,
  28. # but still .pc files should be found for all RDEPENDable prefixes in
  29. # the chain.
  30. echo "PKG_CONFIG_PATH=\"/usr/lib/pkgconfig:/usr/share/pkgconfig\"" >> etc/env.d/00basic
  31. echo "PORTAGE_OVERRIDE_EPREFIX=\"${EPREFIX}\"" >> etc/env.d/00basic
  32. echo "PORTAGE_CONFIGROOT=\"${EPREFIX}\"" >> etc/env.d/00basic
  33. echo "EPREFIX=\"${EPREFIX}\"" >> etc/env.d/00basic
  34. fi
  35. default
  36. }
  37. src_install() {
  38. # make functions.sh available in /etc/init.d (from gentoo-functions)
  39. # Note: we cannot replace the symlink with a file here, or Portage will
  40. # config-protect it, and etc-update can't handle symlink to file updates
  41. dodir etc/init.d
  42. dosym ../../lib/gentoo/functions.sh /etc/init.d/functions.sh
  43. dodir etc
  44. sed \
  45. -e "/PATH=/!s:/\(etc\|usr/bin\|bin\):\"${EPREFIX}\"/\1:g" \
  46. -e "/PATH=/s|\([:\"]\)/|\1${EPREFIX}/|g" \
  47. etc/profile > "${ED}"/etc/profile || die
  48. if ! use prefix-chaining; then
  49. sed \
  50. -e "/PATH=.*\/sbin/s|\"$|:/usr/sbin:/sbin\"|" \
  51. -e "/PATH=.*\/bin/s|\"$|:/usr/bin:/bin\"|" \
  52. -i "${ED}"/etc/profile || die
  53. fi
  54. dodir etc/env.d
  55. sed \
  56. -e "s:/\(etc/env.d\|opt\|usr\):${EPREFIX}/\1:g" \
  57. -e "/^PATH=/s|\"$|:${EPREFIX}/usr/sbin:${EPREFIX}/sbin\"|" \
  58. etc/env.d/00basic > "${ED}"/etc/env.d/00basic || die
  59. dodoc ChangeLog.svn
  60. # add the host OS MANPATH
  61. if [[ -d "${ROOT}"/usr/share/man ]] ; then
  62. echo 'MANPATH="/usr/share/man"' > "${ED}"/etc/env.d/99basic || die
  63. fi
  64. # rc-scripts version for testing of features that *should* be present
  65. echo "Gentoo Prefix Base System release ${PV}" > "${ED}"/etc/gentoo-release
  66. # FHS compatibility symlinks stuff
  67. dosym /var/tmp /usr/tmp
  68. # add a dummy to avoid Portage shebang errors
  69. dodir sbin
  70. cat > "${ED}"/sbin/runscript <<- EOF
  71. #!/usr/bin/env sh
  72. source "${EPREFIX}/lib/gentoo/functions.sh"
  73. eerror "runscript/openrc-run not supported by Gentoo Prefix Base System release ${PV}" 1>&2
  74. exit 1
  75. EOF
  76. chmod 755 "${ED}"/sbin/runscript || die
  77. cp "${ED}"/sbin/{runscript,openrc-run} || die
  78. }
  79. pkg_postinst() {
  80. # Take care of the etc-update for the user
  81. if [ -e "${EROOT}"/etc/._cfg0000_gentoo-release ] ; then
  82. mv "${EROOT}"/etc/._cfg0000_gentoo-release "${EROOT}"/etc/gentoo-release
  83. fi
  84. # baselayout leaves behind a lot of .keep files, so let's clean them up
  85. find "${EROOT}"/lib/rcscripts/ -name .keep -exec rm -f {} + 2>/dev/null
  86. find "${EROOT}"/lib/rcscripts/ -depth -type d -exec rmdir {} + 2>/dev/null
  87. }