示例#1
0
    def start_build(self):
        assert self.outputdir

        # close stdin
        sys.stdin.close()

        info = []
        import socket
        un = os.uname()

        info.append(('Build Host', socket.gethostname()))
        info.append(('Architecture', '%s %s (%s)' % (un[0], un[2], un[4])))
        info.append(('System', sysid.get_pretty_name()))
        info.append(('Module Set', self.config.moduleset))
        info.append(('Start Time', self.timestamp()))

        buildplatform = '<table>\n'
        for (key, val) in info:
            buildplatform += '<tr><th align="left">%s</th><td>%s</td></tr>\n' \
                             % (key, val)
        buildplatform += '</table>\n'

        self.indexfp = open_text(os.path.join(self.outputdir, 'index.html'),
                                 'w',
                                 encoding='utf-8',
                                 errors='xmlcharrefreplace')

        self.indexfp.write(index_header % {
            'buildplatform': buildplatform,
            'charset': 'UTF-8'
        })
        self.indexfp.flush()
示例#2
0
 def manifest(self):
     if self._manifest:
         return self._manifest
     if not os.path.exists(
             os.path.join(self.dirname, 'manifests', self.package)):
         return None
     self._manifest = []
     for line in open_text(
             os.path.join(self.dirname, 'manifests', self.package)):
         self._manifest.append(line.strip())
     return self._manifest
示例#3
0
    def start_module(self, module):
        self.modulefilename = '%s.html' % module.replace('/', '_')
        self.indexfp.write('<tr>'
                           '<td>%s</td>'
                           '<td><a href="%s">%s</a></td>'
                           '<td>\n' %
                           (self.timestamp(), self.modulefilename, module))
        self.modulefp = open_text(os.path.join(self.outputdir,
                                               self.modulefilename),
                                  'w',
                                  encoding='utf-8',
                                  errors='xmlcharrefreplace')

        for handle in logging.getLogger().handlers:
            if isinstance(handle, logging.StreamHandler):
                handle.stream = self.modulefp

        self.modulefp.write(buildlog_header % {
            'module': module,
            'charset': 'UTF-8'
        })
示例#4
0
    def run(self, config, options, args, help=None):
        if options.output:
            output = TextIO()
        else:
            output = sys.stdout

        config.partial_build = False
        self.module_set = jhbuild.moduleset.load(config)
        if options.list_all_modules:
            module_list = list(self.module_set.modules.values())
        else:
            module_list = self.module_set.get_module_list(
                args or config.modules, config.skip)

        if type(config.moduleset) is str:
            moduleset = [config.moduleset]
        else:
            moduleset = config.moduleset
        title = _('External deps for GNOME')
        for ms in moduleset:
            try:
                gnome_ver = re.findall('\\d+\\.\\d+', ms)[0]
            except IndexError:
                continue
            title = _('External deps for GNOME %s') % gnome_ver
            break

        print(HTML_AT_TOP % {'title': title}, file=output)
        print('<table>', file=output)
        print('<tbody>', file=output)

        module_list.sort(key=lambda x: x.name.lower())
        for mod in module_list:
            # if not mod.moduleset_name.startswith('gnome-suites-core-deps-base'):
            #    continue

            if not hasattr(mod.branch, 'version'):
                continue

            rdeps = self.compute_rdeps(mod)
            classes = []
            if len(rdeps) == 0:
                classes.append('zero')
            else:
                for rdep in rdeps:
                    rdep_mod = self.module_set.modules.get(rdep)
                    if not hasattr(rdep_mod.branch, 'version'):
                        break
                else:
                    # module who only has tarballs as dependency
                    classes.append('far')
                if len(rdeps) > 5:
                    classes.append('many')

            print('<tr class="%s">' % ' '.join(classes), file=output)
            print('<th>%s</th>' % mod.name, file=output)
            version = mod.branch.version
            if mod.branch.patches:
                version = version + ' (%s)' % _('patched')
            print('<td class="version">%s</td>' % version, file=output)
            print('<td class="url"><a href="%s">tarball</a></td>' %
                  mod.branch.module,
                  file=output)
            if len(rdeps) > 5:
                rdeps = rdeps[:4] + [_('and %d others.') % (len(rdeps) - 4)]
            print('<td class="rdeps">%s</td>' % ', '.join(rdeps), file=output)
            print('</tr>', file=output)

        print('</tbody>', file=output)
        print('</table>', file=output)

        print('<div id="footer">', file=output)
        print('Generated:', time.strftime('%Y-%m-%d %H:%M:%S %z'), file=output)
        print('on ', socket.getfqdn(), file=output)
        print('</div>', file=output)

        print('</body>', file=output)
        print('</html>', file=output)

        if output != sys.stdout:
            open_text(options.output, 'w').write(output.getvalue())
示例#5
0
    def run(self, config, options, args, help=None):
        if options.output:
            output = TextIO()
            global curses
            if curses and config.progress_bar:
                try:
                    curses.setupterm()
                except Exception:
                    curses = None
        else:
            output = sys.stdout

        if not self.checks:
            self.load_checks_from_options(options.checks)

        self.load_bugs(options.bugfile)
        self.load_false_positives(options.falsepositivesfile)

        config.devhelp_dirname = options.devhelp_dirname
        config.partial_build = False

        module_set = jhbuild.moduleset.load(config)
        if options.list_all_modules:
            self.module_list = module_set.modules.values()
        else:
            self.module_list = module_set.get_module_list(args or config.modules, config.skip)

        results = {}
        try:
            cachedir = os.path.join(os.environ['XDG_CACHE_HOME'], 'jhbuild')
        except KeyError:
            cachedir = os.path.join(os.environ['HOME'], '.cache','jhbuild')
        if options.cache:
            try:
                results = pickle.load(open(os.path.join(cachedir, options.cache), "rb"))
            except Exception:
                pass

        self.repeat_row_header = 0
        if len(self.checks) > 4:
            self.repeat_row_header = 1

        for module_num, mod in enumerate(self.module_list):
            if mod.type in ('meta', 'tarball'):
                continue
            if not mod.branch or mod.branch.repository.__class__.__name__ not in (
                    'SubversionRepository', 'GitRepository'):
                if not mod.moduleset_name.startswith('gnome-external-deps'):
                    continue

            if not os.path.exists(mod.branch.srcdir):
                continue

            tree_id = mod.branch.tree_id()
            valid_cache = (tree_id and results.get(mod.name, {}).get('tree-id') == tree_id)

            if mod.name not in results:
                results[mod.name] = {
                    'results': {}
                }
            results[mod.name]['tree-id'] = tree_id
            r = results[mod.name]['results']
            for check in self.checks:
                if valid_cache and check.__name__ in r:
                    continue
                try:
                    c = check(config, mod)
                except ExcludedModuleException:
                    continue

                if output != sys.stdout and config.progress_bar:
                    progress_percent = 1.0 * (module_num-1) / len(self.module_list)
                    msg = '%s: %s' % (mod.name, check.__name__)
                    self.display_status_line(progress_percent, module_num, msg)

                try:
                    c.run()
                except CouldNotPerformCheckException:
                    continue
                except ExcludedModuleException:
                    continue

                try:
                    c.fix_false_positive(self.false_positives.get((mod.name, check.__name__)))
                except ExcludedModuleException:
                    continue

                r[check.__name__] = [c.status, c.complexity, c.result_comment]

        if not os.path.exists(cachedir):
            os.makedirs(cachedir)
        if options.cache:
            pickle.dump(results, open(os.path.join(cachedir, options.cache), 'wb'))

        print(HTML_AT_TOP % {'title': self.title}, file=output)
        if self.page_intro:
            print(self.page_intro, file=output)
        print('<table>', file=output)
        print('<thead>', file=output)
        print('<tr><td></td>', file=output)
        for check in self.checks:
            print('<th>%s</th>' % check.__name__, file=output)
        print('<td></td></tr>', file=output)
        if [x for x in self.checks if x.header_note]:
            print('<tr><td></td>', file=output)
            for check in self.checks:
                print('<td>%s</td>' % (check.header_note or ''), file=output)
            print('</tr>', file=output)
        print('</thead>', file=output)
        print('<tbody>', file=output)

        processed_modules = {'gnome-common': True}
        suites = []
        for module_key, module in module_set.modules.items():
            if not isinstance(module_set.get_module(module_key), MetaModule):
                continue
            if module_key.endswith('upcoming-deprecations'):
                # mark deprecated modules as processed, so they don't show in "Others"
                try:
                    metamodule = module_set.get_module(module_key)
                except KeyError:
                    continue
                for module_name in metamodule.dependencies:
                    processed_modules[module_name] = True
            else:
                suites.append([module_key, module_key.replace('meta-', '')])

        not_other_module_names = []
        for suite_key, suite_label in suites:
            metamodule = module_set.get_module(suite_key)
            module_names = [x for x in metamodule.dependencies if x in results]
            if not module_names:
                continue
            print('<tr><td class="heading" colspan="%d">%s</td></tr>' % (
                    1+len(self.checks)+self.repeat_row_header, suite_label), file=output)
            for module_name in module_names:
                if module_name in not_other_module_names:
                    continue
                r = results[module_name].get('results')
                print(self.get_mod_line(module_name, r), file=output)
                processed_modules[module_name] = True
            not_other_module_names.extend(module_names)

        external_deps = [x for x in results.keys() if \
                         x in [y.name for y in self.module_list] and \
                         x not in processed_modules and \
                         module_set.get_module(x).moduleset_name.startswith('gnome-external-deps')]
        if external_deps:
            print('<tr><td class="heading" colspan="%d">%s</td></tr>' % (
                    1+len(self.checks)+self.repeat_row_header, 'External Dependencies'), file=output)
            for module_name in sorted(external_deps):
                if module_name not in results:
                    continue
                r = results[module_name].get('results')
                try:
                    version = module_set.get_module(module_name).branch.version
                except Exception:
                    version = None
                print(self.get_mod_line(module_name, r, version_number=version), file=output)

        other_module_names = [x for x in results.keys() if \
                              x not in processed_modules and x not in external_deps]
        if other_module_names:
            print('<tr><td class="heading" colspan="%d">%s</td></tr>' % (
                    1+len(self.checks)+self.repeat_row_header, 'Others'), file=output)
            for module_name in sorted(other_module_names):
                if module_name not in results:
                    continue
                r = results[module_name].get('results')
                print(self.get_mod_line(module_name, r), file=output)
        print('</tbody>', file=output)
        print('<tfoot>', file=output)

        print('<tr><td></td>', file=output)
        for check in self.checks:
            print('<th>%s</th>' % check.__name__, file=output)
        print('<td></td></tr>', file=output)

        print(self.get_stat_line(results, not_other_module_names), file=output)
        print('</tfoot>', file=output)
        print('</table>', file=output)

        if (options.bugfile and options.bugfile.startswith('http://')) or \
                (options.falsepositivesfile and options.falsepositivesfile.startswith('http://')):
            print('<div id="data">', file=output)
            print('<p>The following data sources are used:</p>', file=output)
            print('<ul>', file=output)
            if options.bugfile.startswith('http://'):
                print('  <li><a href="%s">Bugs</a></li>' % options.bugfile, file=output)
            if options.falsepositivesfile.startswith('http://'):
                print('  <li><a href="%s">False positives</a></li>' % options.falsepositivesfile, file=output)
            print('</ul>', file=output)
            print('</div>', file=output)

        print('<div id="footer">', file=output)
        print('Generated:', time.strftime('%Y-%m-%d %H:%M:%S %z'), file=output)
        print('on ', socket.getfqdn(), file=output)
        print('</div>', file=output)

        print('</body>', file=output)
        print('</html>', file=output)

        if output != sys.stdout:
            open_text(options.output, 'w').write(output.getvalue())

        if output != sys.stdout and config.progress_bar:
            sys.stdout.write('\n')
            sys.stdout.flush()