declare -rx EBUILD_PHASE
+# These two functions wrap sourcing and calling respectively. At present they
+# perform a qa check to make sure eclasses and ebuilds and profiles don't mess
+# with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
+# when they are done.
+
+qa_source() {
+ local shopts=$(shopt) OLDIFS="$IFS"
+ source "$@"
+ [[ $shopts != $(shopt) ]] &&
+ vecho "QA Notice: Global shell options were changed and not restored while sourcing $1"
+ [[ "$IFS" != "$OLDIFS" ]] &&
+ vecho "QA Notice: IFS was changed and not reset while sourcing $1"
+}
+
+qa_call() {
+ local shopts=$(shopt) OLDIFS="$IFS"
+ "$@"
+ [[ $shopts != $(shopt) ]] &&
+ vecho "QA Notice: Global shell options were changed while calling $1"
+ [[ "$IFS" != "$OLDIFS" ]] &&
+ vecho "QA Notice: IFS was changed and not reset while calling $1"
+}
+
if [ "$*" != "depend" ] && [ "$*" != "clean" ] && [ "$*" != "nofetch" ]; then
if [ -f "${T}/environment" ]; then
- source "${T}/environment" &>/dev/null
+ qa_source "${T}/environment" &>/dev/null
fi
fi
# Must unset it so that it doesn't mess up assumptions in the RCs.
unset IFS
if [ -f "${dir}/profile.bashrc" ]; then
- source "${dir}/profile.bashrc"
+ qa_source "${dir}/profile.bashrc"
fi
done
restore_IFS
+# 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.
}
dyn_setup() {
- [ "$(type -t pre_pkg_setup)" == "function" ] && pre_pkg_setup
- pkg_setup
- [ "$(type -t post_pkg_setup)" == "function" ] && post_pkg_setup
+ [ "$(type -t pre_pkg_setup)" == "function" ] && qa_call pre_pkg_setup
+ qa_call pkg_setup
+ [ "$(type -t post_pkg_setup)" == "function" ] && qa_call post_pkg_setup
}
dyn_unpack() {
- [ "$(type -t pre_src_unpack)" == "function" ] && pre_src_unpack
+ [ "$(type -t pre_src_unpack)" == "function" ] && qa_call pre_src_unpack
local newstuff="no"
if [ -e "${WORKDIR}" ]; then
local x
if [ -e "${WORKDIR}" ]; then
if [ "$newstuff" == "no" ]; then
vecho ">>> WORKDIR is up-to-date, keeping..."
- [ "$(type -t post_src_unpack)" == "function" ] && post_src_unpack
+ [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
return 0
fi
fi
fi
cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
vecho ">>> Unpacking source..."
- src_unpack
+ qa_call src_unpack
touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in ${PORTAGE_BUILDDIR}"
vecho ">>> Source unpacked."
cd "${PORTAGE_BUILDDIR}"
- [ "$(type -t post_src_unpack)" == "function" ] && post_src_unpack
+ [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
}
dyn_clean() {
dyn_compile() {
trap "abort_compile" SIGINT SIGQUIT
- [ "$(type -t pre_src_compile)" == "function" ] && pre_src_compile
+ [ "$(type -t pre_src_compile)" == "function" ] && qa_call pre_src_compile
[ "${CFLAGS-unset}" != "unset" ] && export CFLAGS
[ "${CXXFLAGS-unset}" != "unset" ] && export CXXFLAGS
vecho ">>> It appears that '${PF}' is already compiled; skipping."
vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force install."
trap SIGINT SIGQUIT
- [ "$(type -t post_src_compile)" == "function" ] && post_src_compile
+ [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
return
fi
if [ -d "${S}" ]; then
#our libtool to create problematic .la files
export PWORKDIR="$WORKDIR"
vecho ">>> Compiling source in ${srcdir} ..."
- src_compile
+ qa_call src_compile
vecho ">>> Source compiled."
#|| abort_compile "fail"
cd "${PORTAGE_BUILDDIR}"
touch DEBUGBUILD
fi
- [ "$(type -t post_src_compile)" == "function" ] && post_src_compile
+ [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
trap SIGINT SIGQUIT
}
dyn_test() {
- [ "$(type -t pre_src_test)" == "function" ] && pre_src_test
+ [ "$(type -t pre_src_test)" == "function" ] && qa_call pre_src_test
if [ "${PORTAGE_BUILDDIR}/.tested" -nt "${WORKDIR}" ]; then
vecho ">>> It appears that ${PN} has already been tested; skipping."
- [ "$(type -t post_src_test)" == "function" ] && post_src_test
+ [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
return
fi
trap "abort_test" SIGINT SIGQUIT
vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
else
addpredict /
- src_test
+ qa_call src_test
SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
fi
cd "${PORTAGE_BUILDDIR}"
touch .tested || die "Failed to 'touch .tested' in ${PORTAGE_BUILDDIR}"
- [ "$(type -t post_src_test)" == "function" ] && post_src_test
+ [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
trap SIGINT SIGQUIT
}
return 0
fi
trap "abort_install" SIGINT SIGQUIT
- [ "$(type -t pre_src_install)" == "function" ] && pre_src_install
+ [ "$(type -t pre_src_install)" == "function" ] && qa_call pre_src_install
rm -rf "${PORTAGE_BUILDDIR}/image"
mkdir "${PORTAGE_BUILDDIR}/image"
if [ -d "${S}" ]; then
#some packages uses an alternative to $S to build in, cause
#our libtool to create problematic .la files
export PWORKDIR="$WORKDIR"
- src_install
+ qa_call src_install
touch "${PORTAGE_BUILDDIR}/.installed"
vecho ">>> Completed installing ${PF} into ${D}"
vecho
cd ${PORTAGE_BUILDDIR}
- [ "$(type -t post_src_install)" == "function" ] && post_src_install
+ [ "$(type -t post_src_install)" == "function" ] && qa_call post_src_install
trap SIGINT SIGQUIT
}
return 1
fi
- [ "$(type -t pre_pkg_preinst)" == "function" ] && pre_pkg_preinst
+ [ "$(type -t pre_pkg_preinst)" == "function" ] && qa_call pre_pkg_preinst
declare -r D=${IMAGE}
pkg_preinst
- [ "$(type -t post_pkg_preinst)" == "function" ] && post_pkg_preinst
+ [ "$(type -t post_pkg_preinst)" == "function" ] && qa_call post_pkg_preinst
}
dyn_help() {
#turn on glob expansion
set +f
- source "$location" || die "died sourcing $location in inherit()"
-
+ qa_source "$location" || die "died sourcing $location in inherit()"
+
#turn off glob expansion
set -f
for myarg in ${EBUILD_SH_ARGS} ; do
case $myarg in
nofetch)
- pkg_nofetch
+ qa_call pkg_nofetch
exit 1
;;
prerm|postrm|postinst|config)
export SANDBOX_ON="0"
if [ "$PORTAGE_DEBUG" != "1" ]; then
- [ "$(type -t pre_pkg_${myarg})" == "function" ] && pre_pkg_${myarg}
- pkg_${myarg}
- [ "$(type -t post_pkg_${myarg})" == "function" ] && post_pkg_${myarg}
+ [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
+ qa_call pkg_${myarg}
+ [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
#Allow non-zero return codes since they can be caused by &&
else
set -x
- [ "$(type -t pre_pkg_${myarg})" == "function" ] && pre_pkg_${myarg}
- pkg_${myarg}
- [ "$(type -t post_pkg_${myarg})" == "function" ] && post_pkg_${myarg}
+ [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
+ qa_call pkg_${myarg}
+ [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
#Allow non-zero return codes since they can be caused by &&
set +x
fi