示例#1
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)

        module_set = jhbuild.moduleset.load(config)
        module_list = []
        default_repo = jhbuild.moduleset.get_default_repo()
        for modname in args:
            try:
                module = module_set.get_module(modname, ignore_case=True)
            except KeyError:
                if not default_repo:
                    raise FatalError(
                        _('unknown module %s and no default repository to try an automatic module'
                          ) % modname)

                logging.info(_('module "%(modname)s" does not exist, created automatically using repository "%(reponame)s"') % \
                         {'modname': modname, 'reponame': default_repo.name})
                module = AutogenModule(modname, default_repo.branch(modname))
                module.config = config

            module_list.append(module)

        if not module_list:
            self.parser.error(_('This command requires a module parameter.'))

        # remove modules that are not marked as installed
        packagedb = module_set.packagedb
        for module in module_list[:]:
            if not packagedb.check(module.name):
                logging.warn(
                    _('Module %(mod)r is not installed') %
                    {'mod': module.name})
                module_list.remove(module)
            else:
                packagedb.uninstall(module.name)
示例#2
0
 def _download_tarball(self, buildscript, localfile):
     if not os.access(self.config.tarballdir, os.R_OK | os.W_OK | os.X_OK):
         raise FatalError(
             _('tarball dir (%s) must be writable') %
             self.config.tarballdir)
     """Downloads the tarball off the internet, using wget or curl."""
     extra_env = {
         'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'),
         'PATH': os.environ.get('UNMANGLED_PATH')
     }
     lines = [['wget', '--continue', self.module, '-O', localfile],
              [
                  'curl', '--continue-at', '-', '-L', self.module, '-o',
                  localfile
              ]]
     lines = [line for line in lines if has_command(line[0])]
     if not lines:
         raise FatalError(_("unable to find wget or curl"))
     try:
         return buildscript.execute(lines[0], extra_env=extra_env)
     except CommandError:
         # Cleanup potential leftover file
         if os.path.exists(localfile):
             os.remove(localfile)
         raise
示例#3
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)
        config.buildscript = 'tinderbox'

        if options.outputdir is not None:
            config.tinderbox_outputdir = options.outputdir

        if not config.tinderbox_outputdir:
            raise UsageError(_('output directory for tinderbox build not specified'))

        module_set = jhbuild.moduleset.load(config)
        full_module_list = module_set.get_full_module_list(
            args or config.modules, config.skip)
        module_list = module_set.remove_system_modules(full_module_list)

        # remove modules up to startat
        if options.startat:
            while module_list and module_list[0].name != options.startat:
                del module_list[0]
            if not module_list:
                raise FatalError(_('%s not in module list') % options.startat)

        if config.check_sysdeps:
            module_state = module_set.get_module_state(full_module_list)
            if not self.required_system_dependencies_installed(module_state):
                self.print_system_dependencies(module_state)
                raise FatalError(_('Required system dependencies not installed.'
                                   ' Install using the command %(cmd)s or to '
                                   'ignore system dependencies use command-line'
                                   ' option %(opt)s' \
                                   % {'cmd' : "'jhbuild sysdeps --install'",
                                      'opt' : '--nodeps'}))

        build = jhbuild.frontends.get_buildscript(config, module_list, module_set=module_set)
        return build.build()
示例#4
0
    def run(self, config, options, args, help=None):
        module_name = options.in_builddir or options.in_checkoutdir
        if module_name:
            module_set = jhbuild.moduleset.load(config)
            try:
                module = module_set.get_module(module_name, ignore_case = True)
            except KeyError as e:
                raise FatalError(_("A module called '%s' could not be found.") % e)

            build = jhbuild.frontends.get_buildscript(config, [module], module_set=module_set)
            if options.in_builddir:
                workingdir = module.get_builddir(build)
            else:
                workingdir = module.get_srcdir(build)
            try:
                build.execute(args, cwd=workingdir)
            except CommandError as exc:
                if args:
                    raise FatalError(_("Unable to execute the command '%s'") % args[0])
                else:
                    raise FatalError(str(exc))
        else:
            try:
                os.execlp(args[0], *args)
            except IndexError:
                raise FatalError(_('No command given'))
            except OSError as exc:
                raise FatalError(_("Unable to execute the command '%(command)s': %(err)s") % {
                        'command':args[0], 'err':str(exc)})
示例#5
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)
        module_set = jhbuild.moduleset.load(config)
        if options.startat and options.list_all_modules:
            raise UsageError(_('Conflicting options specified (\'--start-at\' and \'--all-modules\')'))

        if options.list_all_modules:
            module_list = module_set.modules.values()
        else:
            module_list = module_set.get_module_list \
                              (args or config.modules, config.skip,
                               tags=config.tags,
                               include_suggests= not config.ignore_suggests,
                               include_afters=options.list_optional_modules)

        # remove modules up to startat
        if options.startat:
            while module_list and module_list[0].name != options.startat:
                del module_list[0]
            if not module_list:
                raise FatalError(_('%s not in module list') % options.startat)

        for mod in module_list:
            if options.show_rev:
                rev = mod.get_revision()
                if rev:
                    uprint('%s (%s)' % (mod.name, rev))
                else:
                    uprint(mod.name)
            else:
                uprint(mod.name)
示例#6
0
 def __init__(self):
     Command.__init__(self, [
         make_option('-a',
                     '--autogen',
                     action='store_true',
                     dest='autogen',
                     default=False,
                     help=_('always run autogen.sh')),
         make_option('-c',
                     '--clean',
                     action='store_true',
                     dest='clean',
                     default=False,
                     help=_('run make clean before make')),
         make_option('--check',
                     action='store_true',
                     dest='check',
                     default=False,
                     help=_('run make check after building')),
         make_option('-q',
                     '--quiet',
                     action='store_true',
                     dest='quiet',
                     default=False,
                     help=_('quiet (no output)')),
     ])
示例#7
0
    def _download_and_unpack(self, buildscript):
        localfile = self._local_tarball
        if not os.path.exists(self.config.tarballdir):
            try:
                os.makedirs(self.config.tarballdir)
            except OSError:
                raise FatalError(
                    _('tarball dir (%s) can not be created') %
                    self.config.tarballdir)
        try:
            self._check_tarball()
        except BuildStateError:
            # don't have the tarball, try downloading it and check again
            self._download_tarball(buildscript, localfile)
            self._check_tarball()

        # now to unpack it
        try:
            unpack_archive(buildscript, localfile, self.checkoutroot,
                           self.checkoutdir)
        except CommandError:
            raise FatalError(_('failed to unpack %s') % localfile)

        if not os.path.exists(self.srcdir):
            raise BuildStateError(
                _('could not unpack tarball (expected %s dir)') %
                os.path.basename(self.srcdir))

        if self.patches:
            self._do_patches(buildscript)
示例#8
0
 def parse_args(self, args):
     self.parser = OptionParser(
         usage='%%prog %s %s' %
         (self.name, _(self.usage_args) if self.usage_args else ''),
         description=_(self.doc) if self.doc else '')
     self.parser.add_options(self.options)
     return self.parser.parse_args(args)
示例#9
0
def get_branch(node, repositories, default_repo, config):
    """Scan for a <branch> element and create a corresponding Branch object."""
    name = node.getAttribute('id')
    childnode = find_first_child_node(node, 'branch')
    if childnode is None:
        raise FatalError(_('no <branch> element found for %s') % name)

    # look up the repository for this branch ...
    if childnode.hasAttribute('repo'):
        try:
            repo = repositories[childnode.getAttribute('repo')]
        except KeyError:
            repo_names = ', '.join([r.name for r in repositories.values()])
            raise UndefinedRepositoryError(
                _('Repository=%(missing)s not found for module id=%(module)s. Possible repositories are %(possible)s'
                  % {'missing': childnode.getAttribute('repo'), 'module': name,
                     'possible': repo_names}))
    elif default_repo:
        repo = repositories[default_repo]
    else:
        raise UndefinedRepositoryError(
                _('No repository for module id=%(module)s. Either set branch/repo or default repository.'
                  % {'module': name}))

    if repo.mirrors:
        mirror_type = config.mirror_policy
        if name in config.module_mirror_policy:
            mirror_type = config.module_mirror_policy[name]
        if mirror_type in repo.mirrors:
            repo = repo.mirrors[mirror_type]

    return repo.branch_from_xml(name, childnode, repositories, default_repo)
示例#10
0
 def do_configure(self, buildscript):
     buildscript.set_action(_('Configuring'), self)
     srcdir = self.get_srcdir(buildscript)
     builddir = self.get_builddir(buildscript)
     if os.path.exists(builddir):
         try:
             # Clear CMake files so we get a clean configure.
             os.unlink(os.path.join(builddir, 'CMakeCache.txt'))
             shutil.rmtree(os.path.join(builddir, 'CMakeFiles'))
         except EnvironmentError:
             pass
     else:
         os.makedirs(builddir)
     prefix = os.path.expanduser(buildscript.config.prefix)
     if not inpath('cmake', os.environ['PATH'].split(os.pathsep)):
         raise CommandError(_('%s not found') % 'cmake')
     baseargs = '-DCMAKE_INSTALL_PREFIX=%s -DCMAKE_INSTALL_LIBDIR=lib' % prefix
     cmakeargs = self.get_cmakeargs()
     if self.use_ninja:
         baseargs += ' -G Ninja'
     # CMake on Windows generates VS projects or NMake makefiles by default.
     # When using MSYS "MSYS Makefiles" is the best guess. "Unix Makefiles"
     # and "MinGW Makefiles" could also work (each is a bit different).
     if os.name == 'nt' and os.getenv("MSYSCON") and '-G' not in cmakeargs:
         baseargs += ' -G "MSYS Makefiles"'
     cmakedir = os.path.join(srcdir,
                             self.cmakedir) if self.cmakedir else srcdir
     cmd = 'cmake %s %s %s' % (baseargs, cmakeargs, cmakedir)
     buildscript.execute(cmd, cwd=builddir, extra_env=self.extra_env)
示例#11
0
    def check_build_policy(self, buildscript):
        if buildscript.config.build_policy not in ('updated', 'updated-deps'):
            return

        # Always trigger a build for dirty branches if supported by the version
        # control module.
        if hasattr(self.branch, 'is_dirty') and self.branch.is_dirty():
            return

        if not buildscript.moduleset.packagedb.check(self.name, self.get_revision() or ''):
            # package has not been updated
            return

        # module has not been updated
        if buildscript.config.build_policy == 'updated':
            buildscript.message(_('Skipping %s (not updated)') % self.name)
            return self.PHASE_DONE

        if buildscript.config.build_policy == 'updated-deps':
            install_date = buildscript.moduleset.packagedb.installdate(self.name)
            for dep in self.dependencies:
                install_date_dep = buildscript.moduleset.packagedb.installdate(dep)
                if install_date_dep is not None and install_date is not None and install_date_dep > install_date:
                    # a dependency has been updated
                    return None
            else:
                buildscript.message(
                        _('Skipping %s (package and dependencies not updated)') % self.name)
                return self.PHASE_DONE
示例#12
0
    def create_ui(self):
        vbox = Gtk.VBox()
        self.vbox.add(vbox)

        sclwin = Gtk.ScrolledWindow()
        sclwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
        sclwin.set_size_request(-1, 200)
        vbox.pack_start(self.create_frame(_('Module'), sclwin), True, True, 0)

        self.treeview = Gtk.TreeView(self.modules_model)
        self.treeview.set_headers_visible(False)
        sclwin.add(self.treeview)
        selection = self.treeview.get_selection()
        selection.connect('changed', self.on_selection_changed_cb)

        renderer = Gtk.CellRendererText()
        tv_col = Gtk.TreeViewColumn('', renderer, text=0)
        tv_col.set_expand(True)
        tv_col.set_min_width(200)
        self.treeview.append_column(tv_col)

        self.startat_model = Gtk.ListStore(str)
        self.combo_startat = Gtk.ComboBox.new_with_model(self.startat_model)
        cell = Gtk.CellRendererText()
        self.combo_startat.pack_start(cell, True)
        self.combo_startat.add_attribute(cell, 'text', 0)
        vbox.pack_start(self.create_frame(_('Start At'), self.combo_startat),
                        True, True, 0)

        self.vbox.show_all()

        self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
        self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
示例#13
0
 def __init__(self):
     Command.__init__(self, [
         make_option('-s',
                     '--skip',
                     metavar='MODULES',
                     action='append',
                     dest='skip',
                     default=[],
                     help=_('treat the given modules as up to date')),
         make_option('-t',
                     '--start-at',
                     metavar='MODULE',
                     action='store',
                     dest='startat',
                     default=None,
                     help=_('start updating at the given module')),
         make_option('--tags',
                     action='append',
                     dest='tags',
                     default=[],
                     help=_('update only modules with the given tags')),
         make_option('-D',
                     metavar='DATE-SPEC',
                     action='store',
                     dest='sticky_date',
                     default=None,
                     help=_('set a sticky date when checking out modules')),
         make_option('--ignore-suggests',
                     action='store_true',
                     dest='ignore_suggests',
                     default=False,
                     help=_('ignore all soft-dependencies')),
     ])
示例#14
0
    def run(self, config, options, args, help=None):
        if options.honour_config is False:
            config.makeclean = True
        module_set = jhbuild.moduleset.load(config)
        try:
            module_list = [
                module_set.get_module(modname, ignore_case=True)
                for modname in args
            ]
        except KeyError as e:
            raise FatalError(_("A module called '%s' could not be found.") % e)

        if not module_list:
            self.parser.error(_('This command requires a module parameter.'))

        if not config.makeclean:
            logging.info(
                _('clean command called while makeclean is set to False, skipped.'
                  ))
            return 0

        build = jhbuild.frontends.get_buildscript(config,
                                                  module_list,
                                                  module_set=module_set)
        if options.distclean:
            clean_phase = 'distclean'
        else:
            clean_phase = 'clean'
        return build.build(phases=[clean_phase])
示例#15
0
    def switch_branch_if_necessary(self, buildscript):
        """
        The switch depends on the requested tag, the requested branch, and the
        state and type of the current branch.

        An imminent branch switch generates an error if there are uncommited
        changes.
        """
        wanted_branch = self.get_branch_switch_destination()
        switch_command = []
        if self.tag:
            switch_command = ['git', 'checkout', self.tag]
        elif wanted_branch:
            if self.is_local_branch(wanted_branch):
                switch_command = ['git', 'checkout', wanted_branch]
            else:
                if not self.find_remote_branch_online_if_necessary(
                        buildscript, 'origin', wanted_branch):
                    raise CommandError(
                        _('The requested branch "%s" is '
                          'not available. Neither locally, nor remotely '
                          'in the origin remote.' % wanted_branch))
                switch_command = [
                    'git', 'checkout', '--track', '-b', wanted_branch,
                    'origin/' + wanted_branch
                ]

        if switch_command:
            if self.is_dirty():
                raise CommandError(_('Refusing to switch a dirty tree.'))
            buildscript.execute(switch_command,
                                cwd=self.get_checkoutdir(),
                                extra_env=get_git_extra_env())
示例#16
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)

        module_set = jhbuild.moduleset.load(config)
        module_list = []
        for modname in args:
            modname = modname.rstrip(os.sep)
            try:
                module = module_set.get_module(modname, ignore_case=True)
            except KeyError:
                default_repo = jhbuild.moduleset.get_default_repo()
                if not default_repo:
                    continue
                from jhbuild.modtypes.autotools import AutogenModule
                module = AutogenModule(modname, default_repo.branch(modname))
                module.config = config
                logging.info(_('module "%(modname)s" does not exist, created automatically using repository "%(reponame)s"') % \
                             {'modname': modname, 'reponame': default_repo.name})
            module_list.append(module)

        if not module_list:
            self.parser.error(_('This command requires a module parameter.'))

        build = jhbuild.frontends.get_buildscript(config, module_list, module_set=module_set)
        return build.build()
示例#17
0
    def _update(self, buildscript, copydir=None, update_mirror=True):
        cwd = self.get_checkoutdir()
        git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}

        if not os.path.exists(os.path.join(cwd, '.git')):
            if os.path.exists(os.path.join(cwd, '.svn')):
                raise CommandError(
                    _('Failed to update module as it switched to git (you should check for changes then remove the directory).'
                      ))
            raise CommandError(
                _('Failed to update module (missing .git) (you should check for changes then remove the directory).'
                  ))

        if update_mirror:
            self.update_dvcs_mirror(buildscript)

        buildscript.execute(
            ['git', 'remote', 'set-url', 'origin', self.module],
            **git_extra_args)

        buildscript.execute(['git', 'remote', 'update', 'origin'],
                            **git_extra_args)

        if self.config.sticky_date:
            self.move_to_sticky_date(buildscript)

        self.switch_branch_if_necessary(buildscript)

        self.rebase_current_branch(buildscript)

        self._update_submodules(buildscript)
示例#18
0
    def start_build(self):
        self.server = ServerProxy(self.xmlrpc_report_url, allow_none = True)
        if self.verbose:
            self.server.verbose_timeout = True

        # close stdin
        sys.stdin.close()

        info = {}
        import socket
        un = os.uname()

        info['build_host'] = socket.gethostname()
        info['architecture'] = (un[0], un[2], un[4])

        distro = get_distro()
        if distro:
            info['distribution'] = distro

        info['module_set'] = self.config.moduleset

        try:
            self.build_id = self.server.start_build(info)
        except xmlrpclib.ProtocolError as e:
            if e.errcode == 403:
                print(_('ERROR: Wrong credentials, please check username/password'), file=sys.stderr)
                sys.exit(1)
            raise

        
        if self.verbose:
            s = _('Starting Build #%s') % self.build_id
            print(s)
            print('=' * len(s))
            print('')
示例#19
0
        def dep_resolve(node, resolved, seen, after):
            ''' Recursive depth-first search of the dependency tree. Creates
            the build order into the list 'resolved'. <after/> modules are
            added to the dependency tree but flagged. When search finished
            <after/> modules not a real dependency are removed.
            '''
            circular = False
            seen.append(node)
            if include_suggests:
                edges = node.dependencies + node.suggests + node.after
            else:
                edges = node.dependencies + node.after
            # do not include <after> modules because a previous visited <after>
            # module may later be a hard dependency
            resolved_deps = [module for module, after_module in resolved \
                             if not after_module]
            for edge_name in edges:
                edge = self.modules.get(edge_name)
                if edge is None:
                    if node not in [i[0] for i in resolved]:
                        self._warn(_('%(module)s has a dependency on unknown'
                                     ' "%(invalid)s" module') % \
                                   {'module'  : node.name,
                                    'invalid' : edge_name})
                elif edge_name not in skip and edge not in resolved_deps:
                    if edge in seen:
                        # circular dependency detected
                        circular = True
                        if self.raise_exception_on_warning:
                            # Translation of string not required - used in
                            # unit tests only
                            raise UsageError('Circular dependencies detected')
                        if warn_about_circular_dependencies:
                            self._warn(_('Circular dependencies detected: %s') \
                                       % ' -> '.join([i.name for i in seen] \
                                                     + [edge.name]))
                        break
                    else:
                        if edge_name in node.after:
                            dep_resolve(edge, resolved, seen, True)
                        elif edge_name in node.suggests:
                            dep_resolve(edge, resolved, seen, after)
                        elif edge_name in node.dependencies:
                            dep_resolve(edge, resolved, seen, after)
                            # hard dependency may be missed if a cyclic
                            # dependency. Add it:
                            if edge not in [i[0] for i in resolved]:
                                resolved.append((edge, after))

            seen.remove(node)

            if not circular:
                if node not in [i[0] for i in resolved]:
                    resolved.append((node, after))
                elif not after:
                    # a dependency exists for an after, flag to keep
                    for index, item in enumerate(resolved):
                        if item[1] is True and item[0] == node:
                            resolved[index] = (node, False)
示例#20
0
    def run(self, config, options, args, help=None):
        # Grab the cwd before anything changes it
        cwd = self.get_cwd()

        # Explicitly don't touch the network for this
        options.nonetwork = True
        options.force_policy = True
        config.set_from_cmdline_options(options)

        makeargs = config.makeargs
        for arg in args:
            # if uninstalling, skip install.
            if arg == 'uninstall' or arg.startswith('uninstall-'):
                config.noinstall = True
            # pipes.quote (and really, trying to safely quote shell arguments) is
            # broken, but executing commands as strings is pervasive throughout
            # jhbuild...this is a hack that will probably live until someone just
            # replaces jhbuild entirely.
            makeargs = '%s %s' % (makeargs, pipes.quote(arg))
        config.makeargs = makeargs

        module_set = jhbuild.moduleset.load(config)

        if not cwd.startswith(config.checkoutroot):
            logging.error(
                _('The current directory is not in the checkout root %r') %
                (config.checkoutroot, ))
            return False

        cwd = cwd[len(config.checkoutroot):]
        cwd = cwd.lstrip(os.sep)
        modname, _slash, _rest = cwd.partition(os.sep)

        try:
            module = module_set.get_module(modname, ignore_case=True)
        except KeyError:
            default_repo = jhbuild.moduleset.get_default_repo()
            if not default_repo:
                logging.error(
                    _('No module matching current directory %r in the moduleset'
                      ) % (modname, ))
                return False

            # Try meson first, then autotools
            if os.path.exists(os.path.join(self.get_cwd(), 'meson.build')):
                from jhbuild.modtypes.meson import MesonModule
                module = MesonModule(modname, default_repo.branch(modname))
            else:
                from jhbuild.modtypes.autotools import AutogenModule
                module = AutogenModule(modname, default_repo.branch(modname))

            module.config = config
            logging.info(_('module "%(modname)s" does not exist, created automatically using repository "%(reponame)s"') % \
                         {'modname': modname, 'reponame': default_repo.name})

        build = jhbuild.frontends.get_buildscript(config, [module],
                                                  module_set=module_set)
        return build.build()
示例#21
0
 def end_build(self, failures):
     self.is_end_of_build = True
     if len(failures) == 0:
         self.message(_('success'))
     else:
         self.message(_('the following modules were not built'))
         for module in failures:
             print(module, end=' ')
         print('')
示例#22
0
 def __init__(self):
     Command.__init__(self, [
         make_option('--honour-config',
                     action='store_true', dest='honour_config', default=False,
                     help=_('honour the makeclean setting in config file')),
         make_option('--distclean',
                     action='store_true', dest='distclean', default=False,
                     help=_('completely clean source tree')),
         ])
示例#23
0
 def __init__(self):
     Command.__init__(self, [
         make_option('--in-builddir', metavar='MODULE',
                     action='store', dest='in_builddir', default = None,
                     help=_('run command in build dir of the given module')),
         make_option('--in-checkoutdir', metavar='MODULE',
                     action='store', dest='in_checkoutdir', default = None,
                     help=_('run command in checkout dir of the given module')),
         ])
示例#24
0
 def __init__(self):
     Command.__init__(self, [
         make_option('--soft-deps',
                     action='store_true', dest='soft_deps', default=False,
                     help=_('add dotted lines to soft dependencies')),
         make_option('--clusters',
                     action='store_true', dest='clusters', default=False,
                     help=_('group modules from metamodule together')),
         ])
示例#25
0
 def __init__(self):
     Command.__init__(self, [
         make_option('-s', '--skip', metavar='MODULES',
                     action='append', dest='skip', default=[],
                     help=_('don\'t package the given modules')),
         make_option('-t', '--start-at', metavar='MODULE',
                     action='store', dest='startat', default=None,
                     help=_('start building at the given module')),
         ])
示例#26
0
    def _get_patch_files(self, buildscript):
        patch_files = []

        # now patch the working tree
        for (patch, patchstrip) in self.patches:
            patchfile = ''
            if urlutils.urlparse(patch)[0]:
                # patch name has scheme, get patch from network
                try:
                    patchfile = httpcache.load(
                        patch, nonetwork=buildscript.config.nonetwork)
                except urlutils.HTTPError as e:
                    raise BuildStateError(
                        _('could not download patch (error: %s)') % e.code)
                except urlutils.URLError:
                    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 = urlutils.urljoin(self.repository.moduleset_uri,
                                           os.path.join(patch_prefix, patch))
                    try:
                        patchfile = httpcache.load(
                            uri, nonetwork=buildscript.config.nonetwork)
                    except Exception:
                        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)

            patch_files.append((patchfile, patch, patchstrip))

        return patch_files
示例#27
0
    def checkout(self, buildscript):
        srcdir = self.get_srcdir(buildscript)
        buildscript.set_action(_('Checking out'), self)
        self.branch.checkout(buildscript)
        # did the checkout succeed?
        if not os.path.exists(srcdir):
            raise BuildStateError(_('source directory %s was not created') % srcdir)

        if self.check_build_policy(buildscript) == self.PHASE_DONE:
            raise SkipToEnd()
示例#28
0
def get_uri(filename):
    try:
        info = get_info(filename)
    except CommandError:
        raise BuildStateError(_('could not get Subversion URI for %s')
                              % filename)
    if 'url' not in info:
        raise BuildStateError(_('could not parse "svn info" output for %s')
                              % filename)
    return info['url']
示例#29
0
def get_kconfigs(node, repositories, default_repo):
    id = node.getAttribute('id')

    kconfigs = []
    kconfig = None

    for childnode in node.childNodes:
        if childnode.nodeType != childnode.ELEMENT_NODE or childnode.nodeName != 'kconfig':
            continue

        if childnode.hasAttribute('repo'):
            repo_name = childnode.getAttribute('repo')
            try:
                repo = repositories[repo_name]
            except KeyError:
                raise FatalError(
                    _(
                        'Repository=%(missing)s not found for kconfig in linux id=%(linux_id)s. Possible repositories are %(possible)s'
                        % {
                            'missing': repo_name,
                            'linux_id': id,
                            'possible': repositories
                        }))
        else:
            try:
                repo = repositories[default_repo]
            except KeyError:
                raise FatalError(
                    _(
                        'Default repository=%(missing)s not found for kconfig in linux id=%(linux_id)s. Possible repositories are %(possible)s'
                        % {
                            'missing': default_repo,
                            'linux_id': id,
                            'possible': repositories
                        }))

        branch = repo.branch_from_xml(id, childnode, repositories,
                                      default_repo)

        version = childnode.getAttribute('version')

        if childnode.hasAttribute('config'):
            path = os.path.join(kconfig.srcdir,
                                childnode.getAttribute('config'))
        else:
            path = kconfig.srcdir

        kconfig = LinuxConfig(version, path, branch)
        kconfigs.append(kconfig)

    if not kconfigs:
        kconfig = LinuxConfig('default', None, None)
        kconfigs.append(kconfig)

    return kconfigs
示例#30
0
    def do_install(self, buildscript):
        if self.uninstall_before_install:
            packagedb = buildscript.moduleset.packagedb
            if packagedb.check(self.name):
                buildscript.set_action(_('Uninstalling old installed version'), self)
                packagedb.uninstall(self.name)

        buildscript.set_action(_('Installing'), self)
        destdir = self.prepare_installroot(buildscript)
        self.make(buildscript, self.makeinstallargs or 'install', makeargs='DESTDIR={}'.format(destdir))
        self.process_install(buildscript, self.get_revision())