示例#1
0
文件: cli.py 项目: StefDev/dnf
    def read_conf_file(self, path=None, root="/", releasever=None,
                       overrides=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf
        conf.installroot = root
        conf.read(path)
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(root)
            if releasever is None:
                msg = _('releasever not given and can not be detected '
                        'from the installroot.')
                raise dnf.exceptions.ConfigError(msg)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(root)

        if overrides is not None:
            conf.override(overrides)

        conf.logdir = dnf.yum.config.logdir_fit(conf.logdir)
        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)
            conf._var_replace(opt)

        self.base.logging.setup_from_dnf_conf(conf)

        # repos are ver/arch specific so add $basearch/$releasever
        conf._repos_persistdir = os.path.normpath(
            '%s/repos/%s/%s/' % (conf.persistdir,
                                 subst.get('basearch', '$basearch'),
                                 subst.get('releasever', '$releasever')))

        timer()
        return conf
示例#2
0
    def read_conf_file(self,
                       path=None,
                       root="/",
                       releasever=None,
                       overrides=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf
        conf.installroot = root
        conf.read(path)
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(root)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(root)

        if overrides is not None:
            conf.override(overrides)

        conf.logdir = dnf.yum.config.logdir_fit(conf.logdir)
        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)
            conf._var_replace(opt)

        self.base.logging.setup_from_dnf_conf(conf)

        timer()
        return conf
示例#3
0
文件: cli.py 项目: hnk/dnf
    def read_conf_file(self,
                       path=None,
                       root="/",
                       releasever=None,
                       overrides=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf
        conf.installroot = root
        conf.read(path)
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(root)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(root)

        if overrides is not None:
            conf.override(overrides)

        conf.logdir = dnf.yum.config.logdir_fit(conf.logdir)
        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)
            conf._var_replace(opt)

        self.base.logging.setup_from_dnf_conf(conf)

        timer()
        return conf
示例#4
0
文件: cli.py 项目: dhgutteridge/dnf
    def _read_conf_file(self, releasever=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf

        # search config file inside the installroot first
        conf._search_inside_installroot('config_file_path')

        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)

        # search reposdir file inside the installroot first
        conf._search_inside_installroot('reposdir')

        # cachedir, logs, releasever, and gpgkey are taken from or stored in installroot
        subst = conf.substitutions
        subst.update_from_etc(conf.installroot)
        if releasever is None and conf.releasever is None:
            releasever = dnf.rpm.detect_releasever(conf.installroot)
        elif releasever == '/':
            releasever = dnf.rpm.detect_releasever(releasever)
        if releasever is not None:
            conf.releasever = releasever
        if conf.releasever is None:
            logger.warning(
                _("Unable to detect release version (use '--releasever' to specify "
                  "release version)"))

        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)

        self.base._logging._setup_from_dnf_conf(conf)

        timer()
        return conf
示例#5
0
文件: cli.py 项目: nphilipp/dnf
    def _read_conf_file(self, releasever=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf

        # search config file inside the installroot first
        conf._search_inside_installroot('config_file_path')

        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)

        # search reposdir file inside the installroot first
        conf._search_inside_installroot('reposdir')

        # cachedir, logs, releasever, and gpgkey are taken from or stored in installroot
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(conf.installroot)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(conf.installroot)

        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)

        self.base._logging._setup_from_dnf_conf(conf)

        timer()
        return conf
示例#6
0
文件: cli.py 项目: hutarova/dnf
    def read_conf_file(self, path=None, root="/", releasever=None,
                       overrides=None):
        conf_st = time.time()
        conf = self.base.conf
        conf.installroot = root
        conf.read(path)
        conf.releasever = releasever
        conf.yumvar_update_from_etc()

        if overrides is not None:
            conf.override(overrides)

        conf.logdir = dnf.yum.config.logdir_fit(conf.logdir)
        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)
            conf._var_replace(opt)

        self.base.logging.setup_from_dnf_conf(conf)

        # repos are ver/arch specific so add $basearch/$releasever
        yumvar = conf.yumvar
        conf._repos_persistdir = os.path.normpath(
            '%s/repos/%s/%s/' % (conf.persistdir,
                                 yumvar.get('basearch', '$basearch'),
                                 yumvar.get('releasever', '$releasever')))
        self.logger.debug('Config time: %0.3f' % (time.time() - conf_st))
        return conf
示例#7
0
    def read_conf_file(self, path=None, root="/", releasever=None,
                       overrides=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf
        conf.installroot = root
        conf.read(path)
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(root)
            if releasever is None:
                msg = _('releasever not given and can not be detected '
                        'from the installroot.')
                raise dnf.exceptions.ConfigError(msg)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(root)

        if overrides is not None:
            conf.override(overrides)

        conf.logdir = dnf.yum.config.logdir_fit(conf.logdir)
        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)
            conf._var_replace(opt)

        self.base.logging.setup_from_dnf_conf(conf)

        # repos are ver/arch specific so add $basearch/$releasever
        conf._repos_persistdir = os.path.normpath(
            '%s/repos/%s/%s/' % (conf.persistdir,
                                 subst.get('basearch', '$basearch'),
                                 subst.get('releasever', '$releasever')))

        timer()
        return conf
示例#8
0
文件: cli.py 项目: ParisMeuleman/dnf
    def _read_conf_file(self, releasever=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf

        # search config file inside the installroot first
        conf._search_inside_installroot('config_file_path')

        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)

        # search reposdir file inside the installroot first
        conf._search_inside_installroot('reposdir')

        # cachedir, logs, releasever, and gpgkey are taken from or stored in installroot
        if releasever is None:
            releasever = dnf.rpm.detect_releasever(conf.installroot)
        conf.releasever = releasever
        subst = conf.substitutions
        subst.update_from_etc(conf.installroot)

        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)

        self.base._logging._setup_from_dnf_conf(conf)

        timer()
        return conf
示例#9
0
文件: cli.py 项目: mscherer/dnf
    def _read_conf_file(self, releasever=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf

        # search config file inside the installroot first
        conf._search_inside_installroot('config_file_path')

        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)

        # search reposdir file inside the installroot first
        conf._search_inside_installroot('reposdir')

        # cachedir, logs, releasever, and gpgkey are taken from or stored in installroot
        subst = conf.substitutions
        subst.update_from_etc(conf.installroot)
        if releasever is None and conf.releasever is None:
            releasever = dnf.rpm.detect_releasever(conf.installroot)
        elif releasever == '/':
            releasever = dnf.rpm.detect_releasever(releasever)
        if releasever is not None:
            conf.releasever = releasever
        if conf.releasever is None:
            logger.warning(_("Unable to detect release version (use '--releasever' to specify "
                             "release version)"))

        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)

        self.base._logging._setup_from_dnf_conf(conf)

        timer()
        return conf
示例#10
0
文件: test_parser.py 项目: zedr/dnf
 def test_empty_option(self):
     # Parser is able to read config file with option without value
     FN = tests.support.resource_path('etc/empty_option.conf')
     conf = dnf.conf.Conf()
     conf.config_file_path = FN
     conf.read()
     self.assertEqual(conf.installroot, '')
示例#11
0
 def test_empty_option(self):
     # Parser is able to read config file with option without value
     FN = tests.support.resource_path('etc/empty_option.conf')
     conf = dnf.conf.Conf()
     conf.config_file_path = FN
     conf.read()
     self.assertEqual(conf.reposdir, '')
示例#12
0
 def test_conf_from_file(self):
     conf = Conf()
     # defaults
     self.assertFalse(conf.gpgcheck)
     self.assertEqual(conf.installonly_limit, 3)
     self.assertTrue(conf.clean_requirements_on_remove)
     conf.config_file_path = '%s/etc/dnf/dnf.conf' % tests.support.dnf_toplevel()
     conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
     self.assertTrue(conf.gpgcheck)
     self.assertEqual(conf.installonly_limit, 3)
     self.assertTrue(conf.clean_requirements_on_remove)
示例#13
0
 def test_conf_from_file(self):
     conf = Conf()
     # defaults
     self.assertFalse(conf.gpgcheck)
     self.assertEqual(conf.installonly_limit, 3)
     self.assertTrue(conf.clean_requirements_on_remove)
     conf.config_file_path = '%s/etc/dnf/dnf.conf' % tests.support.dnf_toplevel()
     conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
     self.assertTrue(conf.gpgcheck)
     self.assertEqual(conf.installonly_limit, 3)
     self.assertTrue(conf.clean_requirements_on_remove)
示例#14
0
    def _read_conf_file(self, releasever=None):
        timer = dnf.logging.Timer('config')
        conf = self.base.conf

        # replace remote config path with downloaded file
        conf._check_remote_file('config_file_path')

        # search config file inside the installroot first
        conf._search_inside_installroot('config_file_path')

        # check whether a config file is requested from command line and the file exists
        filename = conf._get_value('config_file_path')
        if (conf._get_priority('config_file_path') == dnf.conf.PRIO_COMMANDLINE) and \
                not os.path.isfile(filename):
            raise dnf.exceptions.ConfigError(
                _('Config file "{}" does not exist').format(filename))

        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)

        # search reposdir file inside the installroot first
        from_root = conf._search_inside_installroot('reposdir')
        # Update vars from same root like repos were taken
        if conf._get_priority('varsdir') == dnf.conf.PRIO_COMMANDLINE:
            from_root = "/"
        subst = conf.substitutions
        subst.update_from_etc(from_root, varsdir=conf._get_value('varsdir'))
        # cachedir, logs, releasever, and gpgkey are taken from or stored in installroot
        if releasever is None and conf.releasever is None:
            releasever = dnf.rpm.detect_releasever(conf.installroot)
        elif releasever == '/':
            releasever = dnf.rpm.detect_releasever(releasever)
        if releasever is not None:
            conf.releasever = releasever
        if conf.releasever is None:
            logger.warning(
                _("Unable to detect release version (use '--releasever' to specify "
                  "release version)"))

        for opt in ('cachedir', 'logdir', 'persistdir'):
            conf.prepend_installroot(opt)

        self.base._logging._setup_from_dnf_conf(conf)

        timer()
        return conf
示例#15
0
文件: test_config.py 项目: edynox/dnf
    def test_order_insensitive(self):
        conf = Conf()
        conf.config_file_path = '%s/etc/dnf/dnf.conf' % support.dnf_toplevel()
        opts = argparse.Namespace(gpgcheck=False,
                        main_setopts=argparse.Namespace(installonly_limit=5))
        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
        # update from commandline
        conf._configure_from_options(opts)
        self.assertFalse(conf.gpgcheck)
        self.assertEqual(conf.installonly_limit, 5)

        # and the other way round should have the same result
        # update from commandline
        conf._configure_from_options(opts)
        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
        self.assertFalse(conf.gpgcheck)
        self.assertEqual(conf.installonly_limit, 5)
示例#16
0
    def test_order_insensitive(self):
        conf = Conf()
        conf.config_file_path = '%s/etc/dnf/dnf.conf' % tests.support.dnf_toplevel(
        )
        opts = argparse.Namespace(gpgcheck=False,
                                  main_setopts={'installonly_limit': ['5']})
        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
        # update from commandline
        conf._configure_from_options(opts)
        self.assertFalse(conf.gpgcheck)
        self.assertEqual(conf.installonly_limit, 5)

        # and the other way round should have the same result
        # update from commandline
        conf._configure_from_options(opts)
        # read config
        conf.read(priority=dnf.conf.PRIO_MAINCONFIG)
        self.assertFalse(conf.gpgcheck)
        self.assertEqual(conf.installonly_limit, 5)