コード例 #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
ファイル: 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
コード例 #8
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
コード例 #9
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
コード例 #10
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
コード例 #11
0
ファイル: test_config.py プロジェクト: dcantrell/dnf
 def test_prepend_installroot(self):
     conf = Conf()
     conf.installroot = '/mnt/root'
     conf.prepend_installroot('persistdir')
     self.assertEqual(conf.persistdir, '/mnt/root/var/lib/dnf')
コード例 #12
0
 def test_prepend_installroot(self):
     conf = Conf()
     conf.installroot = '/mnt/root'
     conf.prepend_installroot('persistdir')
     self.assertEqual(conf.persistdir, '/mnt/root/var/lib/dnf')