- Remove ebuild.autotools repoman check since it produces lots
authorZac Medico <zmedico@gentoo.org>
Thu, 31 Jan 2008 08:20:22 +0000 (08:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 31 Jan 2008 08:20:22 +0000 (08:20 -0000)
  of false positives (bug #207104) and its hard to parse bash

- Use QA_INTERCEPTORS in ebuild.sh to implement a runtime
  'QA Notice' when autotools is called directly

trunk r9235

svn path=/main/branches/2.1.2/; revision=9247

bin/ebuild.sh
bin/isolated-functions.sh
bin/repoman

index 28ba561c4fae6f8b594aacde046a874b6ef39780..8bcb3dd2b5abd76d1ae49a38dcd45cd0b341c4d1 100755 (executable)
@@ -1579,9 +1579,17 @@ unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
 # Turn of extended glob matching so that g++ doesn't get incorrectly matched.
 shopt -u extglob
 
-QA_INTERCEPTORS="javac java-config python python-config perl grep egrep fgrep sed gcc g++ cc bash awk nawk gawk pkg-config"
+if [[ ${EBUILD_PHASE} == depend ]] ; then
+       QA_INTERCEPTORS="awk bash cc egrep fgrep g++
+               gawk gcc grep javac java-config nawk perl
+               pkg-config python python-config sed"
+elif [[ ${EBUILD_PHASE} == clean* ]] ; then
+       unset QA_INTERCEPTORS
+else
+       QA_INTERCEPTORS="autoconf automake aclocal libtoolize"
+fi
 # level the QA interceptors if we're in depend
-if hasq "depend" "${EBUILD_SH_ARGS}"; then
+if [[ -n ${QA_INTERCEPTORS} ]] ; then
        for BIN in ${QA_INTERCEPTORS}; do
                BIN_PATH=$(type -Pf ${BIN})
                if [ "$?" != "0" ]; then
@@ -1589,14 +1597,27 @@ if hasq "depend" "${EBUILD_SH_ARGS}"; then
                else
                        BODY="${BIN_PATH} \"\$@\"; return \$?"
                fi
-               FUNC_SRC="${BIN}() {
-               if [ \$ECLASS_DEPTH -gt 0 ]; then
-                       eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
+               if [[ ${EBUILD_PHASE} == depend ]] ; then
+                       FUNC_SRC="${BIN}() {
+                               if [ \$ECLASS_DEPTH -gt 0 ]; then
+                                       eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
+                               else
+                                       eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
+                               fi
+                       ${BODY}
+                       }"
+               elif hasq ${BIN} autoconf automake aclocal libtoolize ; then
+                       FUNC_SRC="${BIN}() {
+                               eqawarn \"QA Notice: '${BIN}' called by \${FUNCNAME[1]}: \${CATEGORY}/\${PF}\"
+                               eqawarn \"Use autotools.eclass instead of calling '${BIN}' directly.\"
+                       ${BODY}
+                       }"
                else
-                       eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
+                       FUNC_SRC="${BIN}() {
+                               eqawarn \"QA Notice: '${BIN}' called by \${FUNCNAME[1]}: \${CATEGORY}/\${PF}\"
+                       ${BODY}
+                       }"
                fi
-               ${BODY}
-               }";
                eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
        done
        unset BIN_PATH BIN BODY FUNC_SRC
@@ -1720,12 +1741,6 @@ fi
 #a reasonable default for $S
 [[ -z ${S} ]] && export S=${WORKDIR}/${P}
 
-#wipe the interceptors.  we don't want saved.
-if hasq "depend" "${EBUILD_SH_ARGS}"; then
-       unset -f $QA_INTERCEPTORS
-       unset QA_INTERCEPTORS
-fi
-
 #some users have $TMP/$TMPDIR to a custom dir in their home ...
 #this will cause sandbox errors with some ./configure
 #scripts, so set it to $T.
index 7e7e710e05d958c23d7f6644815cd04f9151a155..5750ce8ddd691b7b227db40d6b5b49e5db1c02b7 100644 (file)
@@ -454,7 +454,8 @@ save_ebuild_env() {
                        debug-print-section inherit EXPORT_FUNCTIONS newdepend newrdepend \
                        newpdepend do_newdepend remove_path_entry killparent \
                        save_ebuild_env filter_readonly_variables preprocess_ebuild_env \
-                       source_all_bashrcs ebuild_phase ebuild_phase_with_hooks
+                       source_all_bashrcs ebuild_phase ebuild_phase_with_hooks \
+                       ${QA_INTERCEPTORS}
 
                # portage config variables and variables set directly by portage
                unset BAD BRACKET BUILD_PREFIX COLS \
index 674aa61fd11d52ce546aa5c63e7ba033186940fc..022897683b542152f43455f9e1f654b4498ab5f8 100755 (executable)
@@ -207,7 +207,6 @@ qahelp={
        "ebuild.majorsyn":"This ebuild has a major syntax error that may cause the ebuild to fail partially or fully",
        "ebuild.minorsyn":"This ebuild has a minor syntax error that contravenes gentoo coding style",
        "ebuild.badheader":"This ebuild has a malformed header",
-       "ebuild.autotools":"Ebuild calls autotools directly instead of using autotools.eclass",
        "metadata.missing":"Missing metadata.xml files",
        "metadata.bad":"Bad metadata.xml files",
        "virtual.versioned":"PROVIDE contains virtuals with versions",
@@ -225,7 +224,6 @@ qawarnings=[
 "ebuild.notadded",
 "ebuild.nostable",
 "ebuild.allmasked",
-"ebuild.autotools",
 "ebuild.nesteddie",
 "desktop.invalid",
 "digest.assumed",
@@ -1017,18 +1015,6 @@ class EbuildUselessCdS(LineCheck):
                elif self.method_re.match(line):
                        self.check_next_line = True
 
-class Autotools(LineCheck):
-       """Check for direct calls to autotools"""
-       repoman_check_name = 'ebuild.autotools'
-       re = re.compile(r'^[^#]*([^e]|^)(autoconf|automake|aclocal|libtoolize)')
-
-       def check(self, num, line):
-               """Run the check on line and return error if there is one"""
-               m = self.re.match(line)
-               if m is not None:
-                       return ("Direct calls to '%s'" % m.group(2)) + \
-                               " instead of using autotools.eclass on line: %d"
-
 class EbuildQuotedA(LineCheck):
        """Ensure ebuilds have no quoting around ${A}"""
 
@@ -1040,7 +1026,7 @@ class EbuildQuotedA(LineCheck):
                if match:
                        return "Quoted \"${A}\" on line: %d"
 
-_constant_checks = tuple((c() for c in (Autotools,
+_constant_checks = tuple((c() for c in (
        EbuildQuote, EbuildUselessDodoc, EbuildUselessCdS,
        EbuildNestedDie, EbuildQuotedA)))