summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Górny <gentoo@mgorny.alt.pl>2010-04-22 17:43:59 +0000
committerZac Medico <zmedico@gentoo.org>2010-04-29 16:51:48 -0700
commitef2024a33be93a256beef28c1423ba1fb706383d (patch)
treea1581fa88b7113338bbfd0ae4b545ec26a375f63
parent2cfb3e852ce4ce9e83690e8033f50d32f696f5bd (diff)
downloadportage-ef2024a33be93a256beef28c1423ba1fb706383d.tar.gz
portage-ef2024a33be93a256beef28c1423ba1fb706383d.tar.bz2
portage-ef2024a33be93a256beef28c1423ba1fb706383d.zip
Support per-package bashrc files.
Support loading per-package bashrc files from the /etc/portage/env directory. The invidual files should reside in a directory matching ${CATEGORY}, with names matching ${PN}, ${PN}:${SLOT}, ${P} and/or ${PF} (which are applied in that order).
-rwxr-xr-xbin/ebuild.sh23
-rw-r--r--bin/isolated-functions.sh2
-rw-r--r--doc/config/bashrc.docbook12
-rw-r--r--man/portage.521
-rw-r--r--pym/portage/const.py1
-rw-r--r--pym/portage/package/ebuild/config.py2
-rw-r--r--pym/portage/package/ebuild/doebuild.py6
7 files changed, 51 insertions, 16 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 57ceb2848..968bf6bc5 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -1557,17 +1557,20 @@ source_all_bashrcs() {
# 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}"
}
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index fa23b6675..6bead30b2 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -553,7 +553,7 @@ save_ebuild_env() {
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 \
diff --git a/doc/config/bashrc.docbook b/doc/config/bashrc.docbook
index 2f0626215..f36fec5e6 100644
--- a/doc/config/bashrc.docbook
+++ b/doc/config/bashrc.docbook
@@ -3,9 +3,17 @@
<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>
diff --git a/man/portage.5 b/man/portage.5
index fb354c220..6c78cbd54 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -59,6 +59,9 @@ package.use
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
@@ -407,6 +410,8 @@ it were a single file.
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,
@@ -616,6 +621,22 @@ masters = gentoo kde
.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
diff --git a/pym/portage/const.py b/pym/portage/const.py
index 2c5e233f1..445677bd9 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -34,6 +34,7 @@ MODULES_FILE_PATH = USER_CONFIG_PATH + "/modules"
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"
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index dc7e1a857..db30c2c61 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -172,7 +172,7 @@ class config(object):
"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",
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 9cf16cfea..531cb2386 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -32,8 +32,8 @@ from portage import auxdbkeys, bsd_chflags, dep_check, \
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
@@ -211,6 +211,8 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings,
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")