Split out a _check_build_log() function from spawnebuild().
authorZac Medico <zmedico@gentoo.org>
Sun, 29 Jun 2008 08:50:36 +0000 (08:50 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 29 Jun 2008 08:50:36 +0000 (08:50 -0000)
svn path=/main/trunk/; revision=10847

pym/portage/__init__.py

index e9e6e085b697a8b492092521cd92e14d0803f7dc..e15e78ffdff0dba729071fdf067669564769b868 100644 (file)
@@ -4198,73 +4198,7 @@ def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
 
        if phase_retval == os.EX_OK:
                if mydo == "install" and logfile:
-                       try:
-                               f = open(logfile, 'rb')
-                       except EnvironmentError:
-                               pass
-                       else:
-                               am_maintainer_mode = []
-
-                               bash_command_not_found = []
-                               bash_command_not_found_re = re.compile(
-                                       r'(.*): line (\d*): (.*): command not found$')
-
-                               configure_opts_warn = []
-                               configure_opts_warn_re = re.compile(
-                                       r'^configure: WARNING: Unrecognized options: .*')
-                               am_maintainer_mode_re = re.compile(r'.*/missing --run .*')
-                               am_maintainer_mode_exclude_re = \
-                                       re.compile(r'.*/missing --run (autoheader|makeinfo)')
-                               try:
-                                       for line in f:
-                                               if am_maintainer_mode_re.search(line) is not None and \
-                                                       am_maintainer_mode_exclude_re.search(line) is None:
-                                                       am_maintainer_mode.append(line.rstrip("\n"))
-
-                                               if bash_command_not_found_re.match(line) is not None:
-                                                       bash_command_not_found.append(line.rstrip("\n"))
-
-                                               if configure_opts_warn_re.match(line) is not None:
-                                                       configure_opts_warn.append(line.rstrip("\n"))
-                               finally:
-                                       f.close()
-
-                               from portage.elog.messages import eqawarn
-                               def _eqawarn(lines):
-                                       for line in lines:
-                                               eqawarn(line, phase=mydo, key=mysettings.mycpv)
-                               from textwrap import wrap
-                               wrap_width = 70
-
-                               if am_maintainer_mode:
-                                       msg = ["QA Notice: Automake \"maintainer mode\" detected:"]
-                                       msg.append("")
-                                       msg.extend("\t" + line for line in am_maintainer_mode)
-                                       msg.append("")
-                                       msg.extend(wrap(
-                                               "If you patch Makefile.am, " + \
-                                               "configure.in,  or configure.ac then you " + \
-                                               "should use autotools.eclass and " + \
-                                               "eautomake or eautoreconf. Exceptions " + \
-                                               "are limited to system packages " + \
-                                               "for which it is impossible to run " + \
-                                               "autotools during stage building. " + \
-                                               "See http://www.gentoo.org/p" + \
-                                               "roj/en/qa/autofailure.xml for more information.",
-                                               wrap_width))
-                                       _eqawarn(msg)
-
-                               if bash_command_not_found:
-                                       msg = ["QA Notice: command not found:"]
-                                       msg.append("")
-                                       msg.extend("\t" + line for line in bash_command_not_found)
-                                       _eqawarn(msg)
-
-                               if configure_opts_warn:
-                                       msg = ["QA Notice: Unrecognized configure options:"]
-                                       msg.append("")
-                                       msg.extend("\t" + line for line in configure_opts_warn)
-                                       _eqawarn(msg)
+                       _check_build_log(mysettings)
 
                if mydo == "install":
                        _post_src_install_uid_fix(mysettings)
@@ -4276,6 +4210,83 @@ def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
                                return qa_retval
        return phase_retval
 
+def _check_build_log(mysettings):
+       """
+       Search the content of $PORTAGE_LOG_FILE if it exists
+       and generate the following QA Notices when appropriate:
+
+         * Automake "maintainer mode"
+         * command not found
+         * Unrecognized configure options
+       """
+       logfile = mysettings.get("PORTAGE_LOG_FILE", None)
+       try:
+               f = open(logfile, 'rb')
+       except EnvironmentError:
+               return
+
+       am_maintainer_mode = []
+       bash_command_not_found = []
+       bash_command_not_found_re = re.compile(
+               r'(.*): line (\d*): (.*): command not found$')
+
+       configure_opts_warn = []
+       configure_opts_warn_re = re.compile(
+               r'^configure: WARNING: Unrecognized options: .*')
+       am_maintainer_mode_re = re.compile(r'.*/missing --run .*')
+       am_maintainer_mode_exclude_re = \
+               re.compile(r'.*/missing --run (autoheader|makeinfo)')
+       try:
+               for line in f:
+                       if am_maintainer_mode_re.search(line) is not None and \
+                               am_maintainer_mode_exclude_re.search(line) is None:
+                               am_maintainer_mode.append(line.rstrip("\n"))
+
+                       if bash_command_not_found_re.match(line) is not None:
+                               bash_command_not_found.append(line.rstrip("\n"))
+
+                       if configure_opts_warn_re.match(line) is not None:
+                               configure_opts_warn.append(line.rstrip("\n"))
+       finally:
+               f.close()
+
+       from portage.elog.messages import eqawarn
+       def _eqawarn(lines):
+               for line in lines:
+                       eqawarn(line, phase="install", key=mysettings.mycpv)
+       from textwrap import wrap
+       wrap_width = 70
+
+       if am_maintainer_mode:
+               msg = ["QA Notice: Automake \"maintainer mode\" detected:"]
+               msg.append("")
+               msg.extend("\t" + line for line in am_maintainer_mode)
+               msg.append("")
+               msg.extend(wrap(
+                       "If you patch Makefile.am, " + \
+                       "configure.in,  or configure.ac then you " + \
+                       "should use autotools.eclass and " + \
+                       "eautomake or eautoreconf. Exceptions " + \
+                       "are limited to system packages " + \
+                       "for which it is impossible to run " + \
+                       "autotools during stage building. " + \
+                       "See http://www.gentoo.org/p" + \
+                       "roj/en/qa/autofailure.xml for more information.",
+                       wrap_width))
+               _eqawarn(msg)
+
+       if bash_command_not_found:
+               msg = ["QA Notice: command not found:"]
+               msg.append("")
+               msg.extend("\t" + line for line in bash_command_not_found)
+               _eqawarn(msg)
+
+       if configure_opts_warn:
+               msg = ["QA Notice: Unrecognized configure options:"]
+               msg.append("")
+               msg.extend("\t" + line for line in configure_opts_warn)
+               _eqawarn(msg)
+
 def _post_src_install_uid_fix(mysettings):
        """
        Files in $D with user and group bits that match the "portage"