From: Fabian Groffen Date: Tue, 9 Jan 2007 19:25:22 +0000 (-0000) Subject: Merged from trunk 5479:5485 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4d65b08c3927971431748321ef7b0e96296b96e7;p=portage.git Merged from trunk 5479:5485 Don't automatically fix digests in --pretend mode. (prefix also has isSvn mode) s/prefix/suffix/ Thanks to hydrogen for reporting on irc. s/suffix/version prefix/ since it really is a prefix for the version string. For bug #160893, ignore a KeyError during cache cleansing since that key isn't wanted anyway. Implement QA checks that attempt to detect changed shopts and IFS in ebuild/eclass/profile code. Spit a warning if that is the case. I expect this check will eventually reset the shopts and IFS, but in this case it may break things that depend on the current behavior. (WarnerBro) Antarus' bash improvements, thanks for Genone for reporting this major bug. (WarnerBro) svn path=/main/branches/prefix/; revision=5500 --- diff --git a/NEWS b/NEWS index 6d369961e..f556895bd 100644 --- a/NEWS +++ b/NEWS @@ -41,7 +41,7 @@ portage-2.1 (ongoing via pre releases) and general notices. Collects eerror/ewarn/elog/einfo messages. * New elog function (should replace einfo in many cases) * version syntax enhancements allowing multiple suffixes and a new 'cvs' - prefix for denoting "live sources" ebuilds. + version prefix for denoting "live sources" ebuilds. * config files as directories enabling more flexible settings management. * Addition of an register_die_hook method that allows ebuild/eclasses to register functions to be called for better debugging on errors. diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 097aac35a..bc925f9a4 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -18,9 +18,34 @@ fi 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. Note: For now these shoudl always return success. + +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" + return 0 +} + +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" + return 0 +} + if [ "$*" != "depend" ] && [ "$*" != "clean" ] && [ "$*" != "nofetch" ]; then if [ -f "${T}/environment" ]; then - source "${T}/environment" &>/dev/null + qa_source "${T}/environment" &>/dev/null fi fi @@ -101,11 +126,14 @@ for dir in ${PROFILE_PATHS}; do # 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. @@ -833,13 +861,13 @@ gen_wrapper() { } 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 @@ -873,7 +901,7 @@ dyn_unpack() { 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 @@ -883,12 +911,12 @@ dyn_unpack() { 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() { @@ -1041,7 +1069,7 @@ abort_install() { 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 @@ -1089,7 +1117,7 @@ dyn_compile() { 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 @@ -1103,7 +1131,7 @@ dyn_compile() { #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}" @@ -1131,16 +1159,16 @@ dyn_compile() { 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 @@ -1154,13 +1182,13 @@ dyn_test() { 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 } @@ -1174,7 +1202,7 @@ dyn_install() { 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 @@ -1188,12 +1216,12 @@ dyn_install() { #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 ${ED}" 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 } @@ -1203,12 +1231,12 @@ dyn_preinst() { 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() { @@ -1386,8 +1414,8 @@ inherit() { #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 @@ -1719,21 +1747,21 @@ 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 diff --git a/bin/repoman b/bin/repoman index a8cf1d78b..c2d6437bd 100755 --- a/bin/repoman +++ b/bin/repoman @@ -467,7 +467,9 @@ if os.path.isdir(".svn"): except: err("Error grabbing repository information; exiting.") -if not "--pretend" in myoptions and not isCvs and not isSvn: +if mymode == "commit" and \ + not isCvs and not isSvn and \ + "--pretend" not in myoptions: print print darkgreen("Not in a CVS or SVN repository; enabling pretend mode.") myoptions.append("--pretend"); @@ -929,7 +931,8 @@ for x in scanlist: fails["svn.IO_error"].append(checkdir+"/files svn info") continue - if mymode in ("fix", "commit"): + if mymode in ("fix", "commit") and \ + "--pretend" not in myoptions: repoman_settings["O"] = checkdir if not portage.digestgen([], repoman_settings, myportdb=portdb): print "Unable to generate manifest." diff --git a/pym/cache/util.py b/pym/cache/util.py index df97bcfa5..dcfea5717 100644 --- a/pym/cache/util.py +++ b/pym/cache/util.py @@ -90,7 +90,10 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None, # ok. by this time, the trg_cache is up to date, and we have a dict # with a crapload of cpv's. we now walk the target db, removing stuff if it's in the list. for key in dead_nodes: - try: del trg_cache[key] + try: + del trg_cache[key] + except KeyError: + pass except cache_errors.CacheError, ce: noise.exception(ce) del ce