Ejemplo n.º 1
0
    def load_bugs(self, filename):
        # Bug file format:
        #  $(module)/$(checkname) $(bugnumber)
        # Sample bug file:
        #  evolution/LibGnomeCanvas 571742
        #
        # Alternatively, the $(checkname) can be replaced by a column number,
        # like: evolution/col:2 543234
        #
        # also, if there is only a single check, the /$(checkname) part
        # can be skipped.
        self.bugs = {}
        if not filename:
            return
        if filename.startswith('http://'):
            if filename.startswith('http://live.gnome.org') and not filename.endswith('?action=raw'):
                filename += '?action=raw'
            try:
                filename = httpcache.load(filename, age=0)
            except Exception as e:
                logging.warning('could not download %s: %s' % (filename, e))
                return
        for line in file(filename):
            line = line.strip()
            if not line:
                continue
            if line.startswith('#'):
                continue
            part, bugnumber = line.split()
            if '/' in part:
                module_name, check = part.split('/')
                if check.startswith('col:'):
                    check = self.checks[int(check[4:])-1].__name__
            elif len(self.checks) == 1:
                module_name = part
                check = self.checks[0].__name__
            else:
                continue
            self.bugs[(module_name, check)] = bugnumber

        self.bug_status = {}

        bug_status = httpcache.load(
                'http://bugzilla.gnome.org/show_bug.cgi?%s&'
                'ctype=xml&field=bug_id&field=bug_status&field=emblems&'
                'field=resolution' % '&'.join(['id=' + x for x in self.bugs.values() if x.isdigit()]),
                age=0)
        tree = ET.parse(bug_status)
        for bug in tree.findall('bug'):
            bug_id = bug.find('bug_id').text
            bug_resolved = (bug.find('resolution') is not None)
            bug_has_patch = (bug.find('emblems') is not None and 'P' in bug.find('emblems').text)
            self.bug_status[bug_id] = {
                'resolution': bug_resolved,
                'patch': bug_has_patch,
                }
Ejemplo n.º 2
0
    def _do_patches(self, buildscript):
        # now patch the working tree
        for (patch, patchstrip) in self.patches:
            patchfile = ''
            if urlparse.urlparse(patch)[0]:
                # patch name has scheme, get patch from network
                try:
                    patchfile = httpcache.load(patch, nonetwork=buildscript.config.nonetwork)
                except urllib2.HTTPError as e:
                    raise BuildStateError(_('could not download patch (error: %s)') % e.code)
                except urllib2.URLError as e:
                    raise BuildStateError(_('could not download patch'))
            elif self.repository.moduleset_uri:
                # get it relative to the moduleset uri, either in the same
                # directory or a patches/ subdirectory
                for patch_prefix in ('.', 'patches', '../patches'):
                    uri = urlparse.urljoin(self.repository.moduleset_uri,
                            os.path.join(patch_prefix, patch))
                    try:
                        patchfile = httpcache.load(uri, nonetwork=buildscript.config.nonetwork)
                    except Exception as e:
                        continue
                    if not os.path.isfile(patchfile):
                        continue
                    break
                else:
                    patchfile = ''

            if not patchfile:
                # nothing else, use jhbuild provided patches
                possible_locations = []
                if self.config.modulesets_dir:
                    possible_locations.append(os.path.join(self.config.modulesets_dir, 'patches'))
                    possible_locations.append(os.path.join(self.config.modulesets_dir, '../patches'))
                if PKGDATADIR:
                    possible_locations.append(os.path.join(PKGDATADIR, 'patches'))
                if SRCDIR:
                    possible_locations.append(os.path.join(SRCDIR, 'patches'))
                for dirname in possible_locations:
                    patchfile = os.path.join(dirname, patch)
                    if os.path.exists(patchfile):
                        break
                else:
                    raise CommandError(_('Failed to find patch: %s') % patch)

            buildscript.set_action(_('Applying patch'), self, action_target=patch)
            # patchfile can be a relative file
            buildscript.execute('patch -p%d < "%s"'
                                % (patchstrip, os.path.abspath(patchfile)),
                                cwd=self.raw_srcdir)
Ejemplo n.º 3
0
    def load_false_positives(self, filename):
        self.false_positives = {}
        if not filename:
            return
        if filename.startswith('http://'):
            if filename.startswith('http://live.gnome.org') and not filename.endswith('?action=raw'):
                filename += '?action=raw'
            try:
                filename = httpcache.load(filename, age=0)
            except Exception as e:
                logging.warning('could not download %s: %s' % (filename, e))
                return
        for line in file(filename):
            line = line.strip()
            if not line:
                continue
            if line.startswith('#'):
                continue
            if ' ' in line:
                part, extra = line.split(' ', 1)
            else:
                part, extra = line, '-'

            if '/' in part:
                module_name, check = part.split('/')
                if check.startswith('col:'):
                    check = self.checks[int(check[4:])-1].__name__
            elif len(self.checks) == 1:
                module_name = part
                check = self.checks[0].__name__
            else:
                continue

            self.false_positives[(module_name, check)] = extra
Ejemplo n.º 4
0
 def install_mingw_w32(self, config, buildscript):
     buildscript.set_action(_("Downloading MinGW W32"), self)
     path = load(MINGW_W32_i686_LINUX)
     mingw_root = self.mingw_root(os.path.join(config.prefix, '..'), 'w32')
     buildscript.set_action(_("Extracting %s") % os.path.basename(path), self)
     unpack_tar_file(path, mingw_root)
     buildscript.set_action(_("Fixing lib paths"), self)
     self.fix_lib_paths(buildscript, W32_i686_LINUX_SYSROOT,
                        os.path.join(mingw_root, 'i686-w64-mingw32', 'lib'),
                        '%s/i686-w64-mingw32/lib32' % mingw_root) 
Ejemplo n.º 5
0
 def _do_patches(self, buildscript):
     # now patch the working tree
     for (patch, patchstrip) in self.patches:
         patchfile = ''
         if urlparse.urlparse(patch)[0]:
             # patch name has scheme, get patch from network
             try:
                 patchfile = httpcache.load(patch, nonetwork=buildscript.config.nonetwork)
             except urllib2.HTTPError, e:
                 raise BuildStateError(_('could not download patch (error: %s)') % e.code)
             except urllib2.URLError, e:
                 raise BuildStateError(_('could not download patch'))
Ejemplo n.º 6
0
 def load_false_positives(self, filename):
     self.false_positives = {}
     if not filename:
         return
     if filename.startswith('http://'):
         if filename.startswith('http://live.gnome.org') and not filename.endswith('?action=raw'):
             filename += '?action=raw'
         try:
             filename = httpcache.load(filename, age=0)
         except Exception, e:
             logging.warning('could not download %s: %s' % (filename, e))
             return
Ejemplo n.º 7
0
 def load_bugs(self, filename):
     # Bug file format:
     #  $(module)/$(checkname) $(bugnumber)
     # Sample bug file:
     #  evolution/LibGnomeCanvas 571742
     #
     # Alternatively, the $(checkname) can be replaced by a column number,
     # like: evolution/col:2 543234
     #
     # also, if there is only a single check, the /$(checkname) part
     # can be skipped.
     self.bugs = {}
     if not filename:
         return
     if filename.startswith('http://'):
         if filename.startswith('http://live.gnome.org') and not filename.endswith('?action=raw'):
             filename += '?action=raw'
         try:
             filename = httpcache.load(filename, age=0)
         except Exception, e:
             logging.warning('could not download %s: %s' % (filename, e))
             return
Ejemplo n.º 8
0
def _parse_module_set(config, uri):
    try:
        filename = httpcache.load(uri, nonetwork=config.nonetwork, age=0)
    except Exception, e:
        raise FatalError(_('could not download %s: %s') % (uri, e))
Ejemplo n.º 9
0
def _parse_module_set(config, uri):
    try:
        filename = httpcache.load(uri, nonetwork=config.nonetwork, age=0)
    except Exception as e:
        raise FatalError(_('could not download %s: %s') % (uri, e))
    filename = os.path.normpath(filename)
    try:
        document = xml.dom.minidom.parse(filename)
    except IOError as e:
        raise FatalError(_('failed to parse %s: %s') % (filename, e))
    except xml.parsers.expat.ExpatError as e:
        raise FatalError(_('failed to parse %s: %s') % (uri, e))

    assert document.documentElement.nodeName == 'moduleset'

    for node in _child_elements_matching(document.documentElement, ['redirect']):
        new_url = node.getAttribute('href')
        logging.info('moduleset is now located at %s', new_url)
        return _parse_module_set(config, new_url)

    _handle_conditions(config, document.documentElement)

    moduleset = ModuleSet(config = config)
    moduleset_name = document.documentElement.getAttribute('name')
    if not moduleset_name:
        moduleset_name = os.path.basename(uri)
        if moduleset_name.endswith('.modules'):
            moduleset_name = moduleset_name[:-len('.modules')]

    # load up list of repositories
    repositories = {}
    default_repo = None
    for node in _child_elements_matching(
            document.documentElement, ['repository', 'cvsroot', 'svnroot',
                                       'arch-archive']):
        name = node.getAttribute('name')
        if node.getAttribute('default') == 'yes':
            default_repo = name
        if node.nodeName == 'repository':
            repo_type = node.getAttribute('type')
            repo_class = get_repo_type(repo_type)
            kws = {}
            for attr in repo_class.init_xml_attrs:
                if node.hasAttribute(attr):
                    kws[attr.replace('-', '_')] = node.getAttribute(attr)
            if name in repositories:
                logging.warning(_('Duplicate repository:') + ' '+ name)
            repositories[name] = repo_class(config, name, **kws)
            repositories[name].moduleset_uri = uri
            mirrors = {}
            for mirror in _child_elements_matching(node, ['mirror']):
                mirror_type = mirror.getAttribute('type')
                mirror_class = get_repo_type(mirror_type)
                kws = {}
                for attr in mirror_class.init_xml_attrs:
                    if mirror.hasAttribute(attr):
                        kws[attr.replace('-','_')] = mirror.getAttribute(attr)
                mirrors[mirror_type] = mirror_class(config, name, **kws)
                #mirrors[mirror_type].moduleset_uri = uri
            setattr(repositories[name], "mirrors", mirrors)
        if node.nodeName == 'cvsroot':
            cvsroot = node.getAttribute('root')
            if node.hasAttribute('password'):
                password = node.getAttribute('password')
            else:
                password = None
            repo_type = get_repo_type('cvs')
            repositories[name] = repo_type(config, name,
                                           cvsroot=cvsroot, password=password)
        elif node.nodeName == 'svnroot':
            svnroot = node.getAttribute('href')
            repo_type = get_repo_type('svn')
            repositories[name] = repo_type(config, name, href=svnroot)
        elif node.nodeName == 'arch-archive':
            archive_uri = node.getAttribute('href')
            repo_type = get_repo_type('arch')
            repositories[name] = repo_type(config, name,
                                           archive=name, href=archive_uri)

    # and now module definitions
    for node in _child_elements(document.documentElement):
        if node.nodeName == 'include':
            href = node.getAttribute('href')
            inc_uri = urlparse.urljoin(uri, href)
            try:
                inc_moduleset = _parse_module_set(config, inc_uri)
            except UndefinedRepositoryError:
                raise
            except FatalError as e:
                if inc_uri[0] == '/':
                    raise e
                # look up in local modulesets
                inc_uri = os.path.join(os.path.dirname(__file__), '..', 'modulesets',
                                   href)
                inc_moduleset = _parse_module_set(config, inc_uri)

            moduleset.modules.update(inc_moduleset.modules)
        elif node.nodeName in ['repository', 'cvsroot', 'svnroot',
                               'arch-archive']:
            pass
        else:
            module = modtypes.parse_xml_node(node, config, uri,
                    repositories, default_repo)
            if moduleset_name:
                module.tags.append(moduleset_name)
            module.moduleset_name = moduleset_name
            moduleset.add(module)

    # keep default repository around, used when creating automatic modules
    global _default_repo
    if default_repo:
        _default_repo = repositories[default_repo]

    return moduleset