Esempio n. 1
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)

        if not config.partial_build:
            raise FatalError(_("Partial build is not enabled; add partial_build = True to ~/.jhbuildrc"))

        module_set = jhbuild.moduleset.load(config)
        modules = args or config.modules
        module_list = module_set.get_module_list(modules, process_sysdeps=False)
        module_state = module_set.get_system_modules(module_list)

        have_new_enough = False
        have_too_old = False

        print _('System installed packages which are new enough:')
        for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
            if (installed_version is not None) and new_enough:
                have_new_enough = True
                print (_("  %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
                                                                                   'req': req_version,
                                                                                   'installed': installed_version}))
        if not have_new_enough:
            print _('  (none)')

        print _('System installed packages which are too old:') 
        for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
            if (installed_version is not None) and (not new_enough):
                have_too_old = True
                print (_("  %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
                                                                                    'req': req_version,
                                                                                    'installed': installed_version}))
        if not have_too_old:
            print _('  (none)')
                
        print _('No matching system package installed:')
        uninstalled = []
        for pkg_config,(module, req_version, installed_version, new_enough) in module_state.iteritems():
            if installed_version is None:
                print (_("  %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
                                                            'req': req_version})
                uninstalled.append(pkg_config)
        if len(uninstalled) == 0:
            print _('  (none)')

        if options.install:
            installer = SystemInstall.find_best()
            if installer is None:
                raise FatalError(_("Don't know how to install packages on this system"))

            if len(uninstalled) == 0:
                logging.info(_("No uninstalled system dependencies to install for modules: %r" % (modules, )))
            else:
                logging.info(_("Installing dependencies on system: %s" % (' '.join(uninstalled), )))
                installer.install(uninstalled)
Esempio n. 2
0
    def run(self, config, options, args, help=None):
        def fmt_details(pkg_config, req_version, installed_version):
            fmt_list = []
            if pkg_config:
                fmt_list.append(pkg_config)
            if req_version:
                fmt_list.append(_('required=%s') % req_version)
            if installed_version and installed_version != 'unknown':
                fmt_list.append(_('installed=%s') % installed_version)
            # Translators: This is used to separate items of package metadata
            fmt_str = _(', ').join(fmt_list)
            if fmt_str:
                return _('(%s)') % fmt_str
            else:
                return ''

        config.set_from_cmdline_options(options)

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

        if options.dump_all:
            for module in module_list:
                if (isinstance(module, SystemModule)
                        or isinstance(module.branch, TarballBranch)
                        and module.pkg_config is not None):
                    if module.pkg_config is not None:
                        print('pkgconfig:{0}'.format(
                            module.pkg_config[:-3]))  # remove .pc

                    if module.systemdependencies is not None:
                        for dep_type, value, altdeps in module.systemdependencies:
                            sys.stdout.write('{0}:{1}'.format(dep_type, value))
                            for dep_type, value, empty in altdeps:
                                sys.stdout.write(',{0}:{1}'.format(
                                    dep_type, value))
                            sys.stdout.write('\n')

            return

        module_state = module_set.get_module_state(module_list)

        have_new_enough = False
        have_too_old = False

        if options.dump:
            for module, (req_version, installed_version, new_enough,
                         systemmodule) in iteritems(module_state):
                if new_enough:
                    continue

                if installed_version is not None and systemmodule:
                    # it's already installed but it's too old and we
                    # don't know how to build a new one for ourselves
                    have_too_old = True

                # request installation in two cases:
                #   1) we don't know how to build it
                #   2) we don't want to build it ourselves
                #
                # partial_build is on by default so this check will only
                # fail if someone explicitly turned it off
                if systemmodule or config.partial_build:
                    assert (module.pkg_config or module.systemdependencies)

                    if module.pkg_config is not None:
                        print('pkgconfig:{0}'.format(
                            module.pkg_config[:-3]))  # remove .pc

                    if module.systemdependencies is not None:
                        for dep_type, value, altdeps in module.systemdependencies:
                            sys.stdout.write('{0}:{1}'.format(dep_type, value))
                            for dep_type, value, empty in altdeps:
                                sys.stdout.write(',{0}:{1}'.format(
                                    dep_type, value))
                            sys.stdout.write('\n')

            if have_too_old:
                return 1

            return

        print(_('System installed packages which are new enough:'))
        for module, (req_version, installed_version, new_enough,
                     systemmodule) in iteritems(module_state):
            if (installed_version
                    is not None) and new_enough and (config.partial_build
                                                     or systemmodule):
                have_new_enough = True
                print('    %s %s' %
                      (module.name,
                       fmt_details(module.pkg_config, req_version,
                                   installed_version)))
        if not have_new_enough:
            print(_('  (none)'))

        print(_('Required packages:'))
        print(_('  System installed packages which are too old:'))
        for module, (req_version, installed_version, new_enough,
                     systemmodule) in iteritems(module_state):
            if (installed_version
                    is not None) and (not new_enough) and systemmodule:
                have_too_old = True
                print('    %s %s' %
                      (module.name,
                       fmt_details(module.pkg_config, req_version,
                                   installed_version)))
        if not have_too_old:
            print(_('    (none)'))

        print(_('  No matching system package installed:'))
        uninstalled = []
        for module, (req_version, installed_version, new_enough,
                     systemmodule) in iteritems(module_state):
            if installed_version is None and (not new_enough) and systemmodule:
                print('    %s %s' %
                      (module.name,
                       fmt_details(module.pkg_config, req_version,
                                   installed_version)))
                if module.pkg_config is not None:
                    uninstalled.append((module.name, 'pkgconfig',
                                        module.pkg_config[:-3]))  # remove .pc
                elif module.systemdependencies is not None:
                    for dep_type, value, altdeps in module.systemdependencies:
                        uninstalled.append((module.name, dep_type, value))
        if len(uninstalled) == 0:
            print(_('    (none)'))

        have_too_old = False

        if config.partial_build:
            print(
                _('Optional packages: (JHBuild will build the missing packages)'
                  ))
            print(_('  System installed packages which are too old:'))
            for module, (req_version, installed_version, new_enough,
                         systemmodule) in iteritems(module_state):
                if (installed_version is not None) and (not new_enough) and (
                        not systemmodule):
                    have_too_old = True
                    print('    %s %s' %
                          (module.name,
                           fmt_details(module.pkg_config, req_version,
                                       installed_version)))
            if not have_too_old:
                print(_('    (none)'))

            print(_('  No matching system package installed:'))
            for module, (req_version, installed_version, new_enough,
                         systemmodule) in iteritems(module_state):
                if installed_version is None and (not new_enough) and (
                        not systemmodule):
                    print('    %s %s' %
                          (module.name,
                           fmt_details(module.pkg_config, req_version,
                                       installed_version)))
                    if module.pkg_config is not None:
                        uninstalled.append(
                            (module.name, 'pkgconfig',
                             module.pkg_config[:-3]))  # remove .pc

            if len(uninstalled) == 0:
                print(_('    (none)'))

        if options.install:
            installer = SystemInstall.find_best()
            if installer is None:
                # FIXME: This should be implemented per Colin's design:
                # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3
                if cmds.has_command('apt-get'):
                    raise FatalError(
                        _("%(cmd)s is required to install "
                          "packages on this system. Please "
                          "install %(cmd)s.") % {'cmd': 'apt-file'})

                raise FatalError(
                    _("Don't know how to install packages on this system"))

            if len(uninstalled) == 0:
                logging.info(
                    _("No uninstalled system dependencies to install for modules: %r"
                      ) % (modules, ))
            else:
                logging.info(_("Installing dependencies on system: %s") % \
                             ' '.join(pkg[0] for pkg in uninstalled))
                installer.install(uninstalled, assume_yes=options.assume_yes)
Esempio n. 3
0
    def run(self, config, options, args, help=None):

        def fmt_details(pkg_config, req_version, installed_version):
            fmt_list = []
            if pkg_config:
                fmt_list.append(pkg_config)
            if req_version:
                fmt_list.append(_('required=%s') % req_version)
            if installed_version and installed_version != 'unknown':
                fmt_list.append(_('installed=%s') % installed_version)
            # Translators: This is used to separate items of package metadata
            fmt_str = _(', ').join(fmt_list)
            if fmt_str:
                return _('(%s)') % fmt_str
            else:
                return ''

        config.set_from_cmdline_options(options)

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

        if options.dump_all:
            for module in module_list:
                if (isinstance(module, SystemModule) or isinstance(module.branch, TarballBranch) and
                                                        module.pkg_config is not None):
                    if module.pkg_config is not None:
                        print 'pkgconfig:{0}'.format(module.pkg_config[:-3]) # remove .pc

                    if module.systemdependencies is not None:
                        for dep_type, value, altdeps in module.systemdependencies:
                            sys.stdout.write('{0}:{1}'.format(dep_type, value))
                            for dep_type, value, empty in altdeps:
                                sys.stdout.write(',{0}:{1}'.format(dep_type, value))
                            sys.stdout.write('\n')
            return

        if options.dump_runtime:
            # dump runtime packages with version
            systemdependencies = []
            for module in module_list:
                package_entry = module_set.packagedb.get(module.name)
                if package_entry:
                    systemdependencies += package_entry.systemdependencies

            for module in module_list:
                if isinstance(module, SystemModule) and module.runtime:
                    systemdependencies += module.systemdependencies or []

            found, notfound = self._find_system_packages(systemdependencies)
            # TODO: print out notfound

            versionedpackages = {}
            allpackages = self._get_all_system_packages()
            for pattern, packages in found.iteritems():
                for package in packages:
                    if package in allpackages:
                        versionedpackages[package] = allpackages[package]
                        break

            # output the versioned packages
            for package, version in sorted(versionedpackages.items()):
                sys.stdout.write('%s=%s\n' % (package, version))

            return

        module_state = module_set.get_module_state(module_list)

        have_new_enough = False
        have_too_old = False

        if options.dump:
            for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                if new_enough:
                    continue

                if installed_version is not None and systemmodule:
                    # it's already installed but it's too old and we
                    # don't know how to build a new one for ourselves
                    have_too_old = True

                # request installation in two cases:
                #   1) we don't know how to build it
                #   2) we don't want to build it ourselves
                #
                # partial_build is on by default so this check will only
                # fail if someone explicitly turned it off
                if systemmodule or config.partial_build:
                    assert (module.pkg_config or module.systemdependencies)

                    if module.pkg_config is not None:
                        print 'pkgconfig:{0}'.format(module.pkg_config[:-3]) # remove .pc

                    if module.systemdependencies is not None:
                        for dep_type, value, altdeps in module.systemdependencies:
                            sys.stdout.write('{0}:{1}'.format(dep_type, value))
                            for dep_type, value, empty in altdeps:
                                sys.stdout.write(',{0}:{1}'.format(dep_type, value))
                            sys.stdout.write('\n')

            if have_too_old:
                return 1

            return

        print _('System installed packages which are new enough:')
        for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if (installed_version is not None) and new_enough and (config.partial_build or systemmodule):
                have_new_enough = True
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
        if not have_new_enough:
            print _('  (none)')

        uninstalled = []

        print _('Required packages:')
        print _('  System installed packages which are too old:')
        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if (installed_version is not None) and (not new_enough) and systemmodule:
                have_too_old = True
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
                if module.pkg_config is not None:
                    uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc
                elif module.systemdependencies is not None:
                    for dep_type, value in module.systemdependencies:
                        uninstalled.append((module.name, dep_type, value))
        if not have_too_old:
            print _('    (none)')

        print _('  No matching system package installed:')
        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if installed_version is None and (not new_enough) and systemmodule:
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
                if module.pkg_config is not None:
                    uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc
                elif module.systemdependencies is not None:
                    for dep_type, value, altdeps in module.systemdependencies:
                        uninstalled.append((module.name, dep_type, value))
                        for dep_type, value, empty in altdeps:
                            uninstalled.append((module.name, dep_type, value))

        if len(uninstalled) == 0:
            print _('    (none)')

        have_too_old = False

        if config.partial_build:
            print _('Optional packages: (JHBuild will build the missing packages)')
            print _('  System installed packages which are too old:')
            for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                if (installed_version is not None) and (not new_enough) and (not systemmodule):
                    have_too_old = True
                    print ('    %s %s' % (module.name,
                                          fmt_details(module.pkg_config,
                                                      req_version,
                                                      installed_version)))
                    if module.pkg_config is not None:
                        uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc
            if not have_too_old:
                print _('    (none)')

            print _('  No matching system package installed:')
            for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                if installed_version is None and (not new_enough) and (not systemmodule):
                    print ('    %s %s' % (module.name,
                                          fmt_details(module.pkg_config,
                                                      req_version,
                                                      installed_version)))
                    if module.pkg_config is not None:
                        uninstalled.append((module.name, 'pkgconfig', module.pkg_config[:-3])) # remove .pc

            if len(uninstalled) == 0:
                print _('    (none)')

        if options.install:
            installer = SystemInstall.find_best()
            if installer is None:
                # FIXME: This should be implemented per Colin's design:
                # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3
                if cmds.has_command('apt-get'):
                    raise FatalError(_("%(cmd)s is required to install "
                                       "packages on this system. Please "
                                       "install %(cmd)s.")
                                     % {'cmd' : 'apt-file'})

                raise FatalError(_("Don't know how to install packages on this system"))

            if len(uninstalled) == 0:
                logging.info(_("No uninstalled system dependencies to install for modules: %r") % (modules, ))
                return

            logging.info(_("Installing dependencies on system: %s") % \
                           ' '.join(pkg[0] for pkg in uninstalled))
            installer.install(uninstalled)
Esempio n. 4
0
    def run(self, config, options, args, help=None):

        def fmt_details(pkg_config, req_version, installed_version):
            fmt_list = []
            if pkg_config:
                fmt_list.append(pkg_config)
            if req_version:
                fmt_list.append(_('required=%s') % req_version)
            if installed_version and installed_version != 'unknown':
                fmt_list.append(_('installed=%s') % installed_version)
            # Translators: This is used to separate items of package metadata
            fmt_str = _(', ').join(fmt_list)
            if fmt_str:
                return _('(%s)') % fmt_str
            else:
                return ''

        config.set_from_cmdline_options(options)

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

        have_new_enough = False
        have_too_old = False

        print _('System installed packages which are new enough:')
        for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if (installed_version is not None) and new_enough and (config.partial_build or systemmodule):
                have_new_enough = True
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
        if not have_new_enough:
            print _('  (none)')

        print _('Required packages:')
        print _('  System installed packages which are too old:')
        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if (installed_version is not None) and (not new_enough) and systemmodule:
                have_too_old = True
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
        if not have_too_old:
            print _('    (none)')

        print _('  No matching system package installed:')
        uninstalled_pkgconfigs = []
        uninstalled_filenames = []
        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
            if installed_version is None and (not new_enough) and systemmodule:
                print ('    %s %s' % (module.name,
                                      fmt_details(module.pkg_config,
                                                  req_version,
                                                  installed_version)))
                if module.pkg_config is not None:
                    uninstalled_pkgconfigs.append((module.name,
                                                   # remove .pc
                                                   module.pkg_config[:-3]))
                elif module.systemdependencies is not None:
                    for dep_type, value in module.systemdependencies:
                        if dep_type.lower() == 'path':
                            uninstalled_filenames.append(
                                (module.name,
                                 os.path.join(config.system_prefix, 'bin',
                                              value),))
                        elif dep_type.lower() == 'c_include':
                            uninstalled_filenames.append(
                                (module.name,
                                 os.path.join(config.system_prefix, 'include',
                                              value),))
        if len(uninstalled_pkgconfigs) + len(uninstalled_filenames) == 0:
            print _('    (none)')

        have_too_old = False

        if config.partial_build:
            print _('Optional packages: (JHBuild will build the missing packages)')
            print _('  System installed packages which are too old:')
            for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                if (installed_version is not None) and (not new_enough) and (not systemmodule):
                    have_too_old = True
                    print ('    %s %s' % (module.name,
                                          fmt_details(module.pkg_config,
                                                      req_version,
                                                      installed_version)))
            if not have_too_old:
                print _('    (none)')

            print _('  No matching system package installed:')
            for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                if installed_version is None and (not new_enough) and (not systemmodule):
                    print ('    %s %s' % (module.name,
                                          fmt_details(module.pkg_config,
                                                      req_version,
                                                      installed_version)))
                    if module.pkg_config is not None:
                        uninstalled_pkgconfigs.append((module.name,
                                                       # remove .pc
                                                       module.pkg_config[:-3]))

            if len(uninstalled_pkgconfigs) == 0:
                print _('  (none)')

        if options.install:
            installer = SystemInstall.find_best()
            if installer is None:
                # FIXME: This should be implemented per Colin's design:
                # https://bugzilla.gnome.org/show_bug.cgi?id=682104#c3
                if cmds.has_command('apt-get'):
                    raise FatalError(_("%(cmd)s is required to install "
                                       "packages on this system. Please "
                                       "install %(cmd)s.")
                                     % {'cmd' : 'apt-file'})

                raise FatalError(_("Don't know how to install packages on this system"))

            if (len(uninstalled_pkgconfigs) +
                len(uninstalled_filenames)) == 0:
                logging.info(_("No uninstalled system dependencies to install for modules: %r" % (modules, )))
            else:
                logging.info(_("Installing dependencies on system: %s" % \
                               ' '.join([pkg[0] for pkg in
                                         uninstalled_pkgconfigs +
                                         uninstalled_filenames])))
                installer.install(uninstalled_pkgconfigs,
                                  uninstalled_filenames)
Esempio n. 5
0
    def run(self, config, options, args, help=None):
        config.set_from_cmdline_options(options)

        module_set = jhbuild.moduleset.load(config)
        modules = args or config.modules
        module_list = module_set.get_full_module_list(modules)
        module_state = module_set.get_system_modules(module_list)

        have_new_enough = False
        have_too_old = False

        print _('System installed packages which are new enough:')
        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
            if (installed_version is not None) and new_enough and (config.partial_build or required_sysdep):
                have_new_enough = True
                print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
                                                                                      'req': req_version,
                                                                                      'installed': installed_version}))
        if not have_new_enough:
            print _('  (none)')

        print _('Required packages:')
        print _('  System installed packages which are too old:')
        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
            if (installed_version is not None) and (not new_enough) and required_sysdep:
                have_too_old = True
                print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
                                                                                      'req': req_version,
                                                                                      'installed': installed_version}))
        if not have_too_old:
            print _('    (none)')

        print _('  No matching system package installed:')
        uninstalled = []
        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
            if installed_version is None and required_sysdep:
                print (_("    %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
                                                              'req': req_version})
                uninstalled.append(pkg_config)
        if len(uninstalled) == 0:
            print _('    (none)')

        have_too_old = False

        if config.partial_build:
            print _('Optional packages: (JHBuild will build the missing packages)')
            print _('  System installed packages which are too old:')
            for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
                if (installed_version is not None) and (not new_enough) and (not required_sysdep):
                    have_too_old = True
                    print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
                                                                                          'req': req_version,
                                                                                          'installed': installed_version}))
            if not have_too_old:
                print _('    (none)')

            print _('  No matching system package installed:')
            for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
                if installed_version is None and (not required_sysdep):
                    print (_("    %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
                                                                  'req': req_version})
                    uninstalled.append(pkg_config)
            if len(uninstalled) == 0:
                print _('  (none)')

            if options.install:
                installer = SystemInstall.find_best()
                if installer is None:
                    raise FatalError(_("Don't know how to install packages on this system"))

                if len(uninstalled) == 0:
                    logging.info(_("No uninstalled system dependencies to install for modules: %r" % (modules, )))
                else:
                    logging.info(_("Installing dependencies on system: %s" % (' '.join(uninstalled), )))
                    installer.install(uninstalled)