Example #1
0
def load_config(user_conf_file=USER_CONF_FILE,
                system_conf_file=SYSTEM_CONF_FILE,
                debug=False, prepend_sources=(), append_sources=(), skip_config_files=False):
    """
    the main entry point for any code looking to use pkgcore.

    :param user_conf_file: file to attempt to load, else defaults to trying to
        load portage 2 style configs (/etc/make.conf, /etc/make.profile)

    :return: :obj:`pkgcore.config.central.ConfigManager` instance
        representing the system config.
    """

    from pkgcore.config import central, cparser
    from pkgcore.plugin import get_plugins
    import os

    configs = list(prepend_sources)
    configs.extend(get_plugins('global_config'))
    if not skip_config_files:
        have_system_conf = os.path.isfile(system_conf_file)
        have_user_conf = os.path.isfile(user_conf_file)
        if have_system_conf or have_user_conf:
            if have_system_conf:
                configs.append(
                    cparser.config_from_file(open(system_conf_file)))
            if have_user_conf:
                configs.append(cparser.config_from_file(open(user_conf_file)))
        else:
            # make.conf...
            from pkgcore.ebuild.portage_conf import config_from_make_conf
            configs.append(config_from_make_conf())
    configs.extend(append_sources)
    return central.CompatConfigManager(central.ConfigManager(configs, debug=debug))
Example #2
0
def load_config(user_conf_file=USER_CONF_FILE,
                system_conf_file=SYSTEM_CONF_FILE,
                debug=False,
                prepend_sources=(),
                append_sources=(),
                skip_config_files=False,
                profile_override=None,
                location='/etc/'):
    """
    the main entry point for any code looking to use pkgcore.

    :param user_conf_file: file to attempt to load, else defaults to trying to
        load portage 2 style configs (/etc/portage/make.conf and
        /etc/portage/make.profile or the deprecated /etc/make.conf and
        /etc/make.profile locations)
    :param location: location the portage configuration is based in,
        defaults to /etc
    :param profile_override: profile to use instead of the current system
        profile, i.e. the target path of the /etc/portage/make.profile
        (or deprecated /etc/make.profile) symlink

    :return: :obj:`pkgcore.config.central.ConfigManager` instance
        representing the system config.
    """

    from pkgcore.config import central, cparser
    from pkgcore.plugin import get_plugins
    import os

    configs = list(prepend_sources)
    configs.extend(get_plugins('global_config'))
    if not skip_config_files:
        have_system_conf = os.path.isfile(system_conf_file)
        have_user_conf = os.path.isfile(user_conf_file)
        if have_system_conf or have_user_conf:
            if have_system_conf:
                with open(system_conf_file) as f:
                    configs.append(cparser.config_from_file(f))
            if have_user_conf:
                with open(user_conf_file) as f:
                    configs.append(cparser.config_from_file(f))
        else:
            # make.conf...
            from pkgcore.ebuild.portage_conf import config_from_make_conf
            configs.append(
                config_from_make_conf(location=location,
                                      profile_override=profile_override))
    configs.extend(append_sources)
    return central.CompatConfigManager(
        central.ConfigManager(configs, debug=debug))
Example #3
0
def load_config(user_conf_file=USER_CONF_FILE,
                system_conf_file=SYSTEM_CONF_FILE,
                debug=False, prepend_sources=(), append_sources=(),
                skip_config_files=False, profile_override=None,
                location='/etc/'):
    """
    the main entry point for any code looking to use pkgcore.

    :param user_conf_file: file to attempt to load, else defaults to trying to
        load portage 2 style configs (/etc/portage/make.conf and
        /etc/portage/make.profile or the deprecated /etc/make.conf and
        /etc/make.profile locations)
    :param location: location the portage configuration is based in,
        defaults to /etc
    :param profile_override: profile to use instead of the current system
        profile, i.e. the target path of the /etc/portage/make.profile
        (or deprecated /etc/make.profile) symlink

    :return: :obj:`pkgcore.config.central.ConfigManager` instance
        representing the system config.
    """

    from pkgcore.config import central, cparser
    from pkgcore.plugin import get_plugins
    import os

    configs = list(prepend_sources)
    configs.extend(get_plugins('global_config'))
    if not skip_config_files:
        have_system_conf = os.path.isfile(system_conf_file)
        have_user_conf = os.path.isfile(user_conf_file)
        if have_system_conf or have_user_conf:
            if have_system_conf:
                with open(system_conf_file) as f:
                    configs.append(cparser.config_from_file(f))
            if have_user_conf:
                with open(user_conf_file) as f:
                    configs.append(cparser.config_from_file(f))
        else:
            # make.conf...
            from pkgcore.ebuild.portage_conf import config_from_make_conf
            configs.append(config_from_make_conf(
                location=location, profile_override=profile_override))
    configs.extend(append_sources)
    return central.CompatConfigManager(central.ConfigManager(configs, debug=debug))