# We assume if people are changing shopts in their bashrc they do so at their
# own peril. This is the ONLY non-portage bit of code that can change shopts
# without a QA violation.
- if [ -f "${PORTAGE_BASHRC}" ]; then
- # If $- contains x, then tracing has already enabled elsewhere for some
- # reason. We preserve it's state so as not to interfere.
- if [ "$PORTAGE_DEBUG" != "1" ] || [ "${-/x/}" != "$-" ]; then
- source "${PORTAGE_BASHRC}"
- else
- set -x
- source "${PORTAGE_BASHRC}"
- set +x
+ for x in "${PORTAGE_BASHRC}" "${PM_EBUILD_HOOK_DIR}"/${CATEGORY}/{${PN},${PN}:${SLOT},${P},${PF}}; do
+ if [ -r "${x}" ]; then
+ # If $- contains x, then tracing has already enabled elsewhere for some
+ # reason. We preserve it's state so as not to interfere.
+ if [ "$PORTAGE_DEBUG" != "1" ] || [ "${-/x/}" != "$-" ]; then
+ source "${x}"
+ else
+ set -x
+ source "${x}"
+ set +x
+ fi
fi
- fi
+ done
+
[ ! -z "${OCC}" ] && export CC="${OCC}"
[ ! -z "${OCXX}" ] && export CXX="${OCXX}"
}
LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
NOCOLOR NORMAL PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \
PORTAGE_ACTUAL_DISTDIR PORTAGE_ARCHLIST \
- PORTAGE_BASHRC PORTAGE_BASHRCS_SOURCED \
+ PORTAGE_BASHRC PM_EBUILD_HOOK_DIR PORTAGE_BASHRCS_SOURCED \
PORTAGE_BINPKG_TAR_OPTS PORTAGE_BINPKG_TMPFILE PORTAGE_BUILDDIR \
PORTAGE_COLORMAP PORTAGE_CONFIGROOT PORTAGE_DEBUG \
PORTAGE_DEPCACHEDIR PORTAGE_GID \
<sect1 id='config-bashrc-locations'>
<title>bashrc locations</title>
<para>
- If a bashrc file is located at <filename>/etc/portage/bashrc</filename>
- then it will be sourced before an ebuild is executed.
+ If one or more bashrc files exist in the following locations, they will
+ be sourced before the ebuild is executed in the following order:
</para>
+
+ <orderedlist>
+ <listitem><para><filename>/etc/portage/bashrc</filename></para></listitem>
+ <listitem><para><filename>/etc/portage/env/${CATEGORY}/${PN}</filename></para></listitem>
+ <listitem><para><filename>/etc/portage/env/${CATEGORY}/${PN}:${SLOT}</filename></para></listitem>
+ <listitem><para><filename>/etc/portage/env/${CATEGORY}/${P}</filename></para></listitem>
+ <listitem><para><filename>/etc/portage/env/${CATEGORY}/${PF}</filename></para></listitem>
+ </orderedlist>
</sect1>
<sect1 id='config-bashrc-ebuild-phase-hooks'>
<title>Ebuild Phase Hooks</title>
repos.conf
.fi
.TP
+.BR /etc/portage/env/
+package-specific bashrc files
+.TP
.BR /etc/portage/profile/
site-specific overrides of \fB/etc/make.profile/\fR
.TP
If needed, this file can be used to set up a special environment for ebuilds,
different from the standard root environment. The syntax is the same as for
any other bash script.
+
+Additional package-specific bashrc files can be created in /etc/portage/env.
.TP
.BR categories
A simple list of valid categories that may be used in /usr/portage,
.fi
.RE
.TP
+.BR /etc/portage/env/
+.RS
+In this directory additional package-specific bashrc files can be created.
+Portage will source all of them after \fB/etc/portage/bashrc\fR in the following
+order:
+.nr step 1 1
+.IP \n[step]. 3
+/etc/portage/env/${CATEGORY}/${PN}
+.IP \n+[step].
+/etc/portage/env/${CATEGORY}/${PN}:${SLOT}
+.IP \n+[step].
+/etc/portage/env/${CATEGORY}/${P}
+.IP \n+[step].
+/etc/portage/env/${CATEGORY}/${PF}
+.RE
+.TP
.BR /usr/portage/metadata/
.RS
.TP
CUSTOM_PROFILE_PATH = USER_CONFIG_PATH + "/profile"
USER_VIRTUALS_FILE = USER_CONFIG_PATH + "/virtuals"
EBUILD_SH_ENV_FILE = USER_CONFIG_PATH + "/bashrc"
+EBUILD_SH_ENV_DIR = USER_CONFIG_PATH + "/env"
CUSTOM_MIRRORS_FILE = USER_CONFIG_PATH + "/mirrors"
COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map"
PROFILE_PATH = "etc/make.profile"
"PKGDIR",
"PKGUSE", "PKG_LOGDIR", "PKG_TMPDIR",
"PORTAGE_ACTUAL_DISTDIR", "PORTAGE_ARCHLIST",
- "PORTAGE_BASHRC",
+ "PORTAGE_BASHRC", "PM_EBUILD_HOOK_DIR",
"PORTAGE_BINPKG_FILE", "PORTAGE_BINPKG_TAR_OPTS",
"PORTAGE_BINPKG_TMPFILE",
"PORTAGE_BIN_PATH",
eapi_is_supported, merge, os, selinux, StringIO, \
unmerge, _encodings, _parse_eapi_ebuild_head, _os_merge, \
_shell_quote, _split_ebuild_name_glep55, _unicode_decode, _unicode_encode
-from portage.const import EBUILD_SH_ENV_FILE, EBUILD_SH_BINARY, \
- INVALID_ENV_FILE, MISC_SH_BINARY
+from portage.const import EBUILD_SH_ENV_FILE, EBUILD_SH_ENV_DIR, \
+ EBUILD_SH_BINARY, INVALID_ENV_FILE, MISC_SH_BINARY
from portage.data import portage_gid, portage_uid, secpass, \
uid, userpriv_groups
from portage.dbapi.virtual import fakedbapi
mysettings["PORTAGE_BASHRC"] = os.path.join(
mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_FILE)
+ mysettings["PM_EBUILD_HOOK_DIR"] = os.path.join(
+ mysettings["PORTAGE_CONFIGROOT"], EBUILD_SH_ENV_DIR)
mysettings["EBUILD_EXIT_STATUS_FILE"] = os.path.join(
mysettings["PORTAGE_BUILDDIR"], ".exit_status")