def __init__(self, section='main', parser=None): # pylint: disable=R0915 config = cfg.ConfigMain() super(MainConf, self).__init__(config, section, parser) self._get_option('pluginpath')._set([dnf.const.PLUGINPATH], PRIO_DEFAULT) self._get_option('pluginconfpath')._set([dnf.const.PLUGINCONFPATH], PRIO_DEFAULT) self.substitutions = dnf.conf.substitutions.Substitutions() self.arch = hawkey.detect_arch() self._config.system_cachedir().set(PRIO_DEFAULT, dnf.const.SYSTEM_CACHEDIR) # setup different cache and log for non-priviledged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: msg = _('Could not set cachedir: {}').format(ucd(e)) raise dnf.exceptions.Error(msg) self._config.cachedir().set(PRIO_DEFAULT, cachedir) self._config.logdir().set(PRIO_DEFAULT, logdir) # TODO move to libdnf self.modulesdir = PathOption('/etc/dnf/modules.d', absPath=True) # TODO move to libdnf self.moduledefaultsdir = PathOption('/etc/dnf/modules.defaults.d', absPath=True)
def __init__(self, section='main', parser=None): # pylint: disable=R0915 config = libdnf.conf.ConfigMain() super(MainConf, self).__init__(config, section, parser) self._set_value('pluginpath', [dnf.const.PLUGINPATH], PRIO_DEFAULT) self._set_value('pluginconfpath', [dnf.const.PLUGINCONFPATH], PRIO_DEFAULT) self.substitutions = dnf.conf.substitutions.Substitutions() self.arch = hawkey.detect_arch() self._config.system_cachedir().set(PRIO_DEFAULT, dnf.const.SYSTEM_CACHEDIR) # setup different cache and log for non-privileged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: msg = _('Could not set cachedir: {}').format(ucd(e)) raise dnf.exceptions.Error(msg) self._config.cachedir().set(PRIO_DEFAULT, cachedir) self._config.logdir().set(PRIO_DEFAULT, logdir) # track list of temporary files created self.tempfiles = []
def _fit_lock_dir(dir_): if not dnf.util.am_i_root(): # for regular users the best we currently do is not to clash with # another DNF process of the same user. Since dir_ is quite definitely # not writable for us, yet significant, use its hash: hexdir = hashlib.sha1(dir_.encode('utf-8')).hexdigest() dir_ = os.path.join(misc.getCacheDir(), 'locks', hexdir) return dir_
def _fit_lock_dir(dir_): if not dnf.util.am_i_root(): # for regular users the best we currently do is not to clash with # another DNF process of the same user. Since dir_ is quite definitely # not writable for us, yet significant, use its hash: hexdir = hashlib.md5(dir_.encode('utf-8')).hexdigest() dir_ = os.path.join(misc.getCacheDir(), 'locks', hexdir) return dir_
def _make_ready(self): if self._ready: return self._ready = True self._system_cachedir = self.prefix if util.am_i_root(): self._cachedir = self._system_cachedir else: try: user_prefix = misc.getCacheDir() self._cachedir = user_prefix except (IOError, OSError) as e: logger.critical(_('Could not set cachedir: %s'), ucd(e))
def load_installed(self, releasever): # Load from dnf rpmdb all installed packages with dnf.Base() as self.yb: cachedir = getCacheDir() self.yb.conf.cachedir = cachedir self.yb.conf.releasever = dnf.rpm.detect_releasever( self.yb.conf.installroot) self.yb.read_all_repos() self.yb.fill_sack() self.q = self.yb.sack.query() self.q = self.q.installed() self.installed_packages = self.q # Send it to all bodhi_workers for i in range(self.bodhi_workers_count): self.bodhi_workers_queue.put([ 'set_installed_packages', ['bodhi_worker' + str(i), self.installed_packages] ]) # Wait for Bodhi workers to finish self.bodhi_workers_queue.join() # Send installed packages to GUI main_thread_call(self.main_thread.set_installed_packages, self.installed_packages) # Grab it from Koji session = koji.ClientSession('http://koji.fedoraproject.org/kojihub') tagged_packages = session.listTagged('f' + str(releasever) + '-updates-testing') # Prepare packages into dictionary to find it faster pkgs_dict = {} for pkg in self.installed_packages: pkgs_dict[pkg.name] = pkg # See packages for choosen release pkgsForBodhi = [] for tagged_pkg in tagged_packages: if tagged_pkg['package_name'] in pkgs_dict.keys(): pkgsForBodhi.append(pkgs_dict[tagged_pkg['package_name']]) # Send these packages to BodhiWorker queue main_thread_call(self.main_thread.set_num_of_pkgs_to_process, len(pkgsForBodhi)) for pkg in pkgsForBodhi: self.bodhi_workers_queue.put(['package_update', pkg])
def load_installed(self, releasever): # Load from dnf rpmdb all installed packages with dnf.Base() as self.yb: cachedir = getCacheDir() self.yb.conf.cachedir = cachedir self.yb.conf.releasever = dnf.rpm.detect_releasever(self.yb.conf.installroot) self.yb.read_all_repos() self.yb.fill_sack() self.q = self.yb.sack.query() self.q = self.q.installed() self.installed_packages = self.q # Send it to all bodhi_workers for i in range(self.bodhi_workers_count): self.bodhi_workers_queue.put(['set_installed_packages', ['bodhi_worker' + str(i), self.installed_packages]]) # Wait for Bodhi workers to finish self.bodhi_workers_queue.join() # Send installed packages to GUI main_thread_call(self.main_thread.set_installed_packages, self.installed_packages) # Grab it from Koji session = koji.ClientSession('http://koji.fedoraproject.org/kojihub') tagged_packages = session.listTagged('f' + str(releasever) + '-updates-testing') # Prepare packages into dictionary to find it faster pkgs_dict = {} for pkg in self.installed_packages: pkgs_dict[pkg.name] = pkg # See packages for choosen release pkgsForBodhi = [] for tagged_pkg in tagged_packages: if tagged_pkg['package_name'] in pkgs_dict.keys(): pkgsForBodhi.append(pkgs_dict[tagged_pkg['package_name']]) # Send these packages to BodhiWorker queue main_thread_call(self.main_thread.set_num_of_pkgs_to_process, len(pkgsForBodhi)) for pkg in pkgsForBodhi: self.bodhi_workers_queue.put(['package_update', pkg])
def __init__(self, section='main', parser=None): # pylint: disable=R0915 config = libdnf.conf.ConfigMain() super(MainConf, self).__init__(config, section, parser) self._set_value('pluginpath', [dnf.const.PLUGINPATH], PRIO_DEFAULT) self._set_value('pluginconfpath', [dnf.const.PLUGINCONFPATH], PRIO_DEFAULT) self.substitutions = dnf.conf.substitutions.Substitutions() self.arch = hawkey.detect_arch() self._config.system_cachedir().set(PRIO_DEFAULT, dnf.const.SYSTEM_CACHEDIR) # setup different cache and log for non-priviledged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: msg = _('Could not set cachedir: {}').format(ucd(e)) raise dnf.exceptions.Error(msg) self._config.cachedir().set(PRIO_DEFAULT, cachedir) self._config.logdir().set(PRIO_DEFAULT, logdir)
def __init__(self, section='main', parser=None): # pylint: disable=R0915 super(MainConf, self).__init__(section, parser) self.substitutions = dnf.conf.substitutions.Substitutions() self.arch = hawkey.detect_arch() # setup different cache and log for non-priviledged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: logger.critical(_('Could not set cachedir: %s'), ucd(e)) self._add_option('debuglevel', IntOption(2, range_min=0, range_max=10)) # :api self._add_option('errorlevel', IntOption(2, range_min=0, range_max=10)) self._add_option('installroot', PathOption('/', abspath=True)) # :api self._add_option('config_file_path', PathOption(dnf.const.CONF_FILENAME)) # :api self._add_option('plugins', BoolOption(True)) self._add_option('pluginpath', ListOption([dnf.const.PLUGINPATH])) # :api self._add_option('pluginconfpath', ListOption([dnf.const.PLUGINCONFPATH])) # :api self._add_option('persistdir', PathOption(dnf.const.PERSISTDIR)) # :api self._add_option('transformdb', BoolOption(True)) # :api self._add_option('recent', IntOption(7, range_min=0)) self._add_option('retries', PositiveIntOption(10, names_of_0=["0"])) self._add_option('reset_nice', BoolOption(True)) self._add_option('cachedir', PathOption(cachedir)) # :api self._add_option('system_cachedir', PathOption(dnf.const.SYSTEM_CACHEDIR)) # :api self._add_option('cacheonly', BoolOption(False)) self._add_option('keepcache', BoolOption(False)) self._add_option('logdir', Option(logdir)) # :api self._add_option('reposdir', ListOption(['/etc/yum.repos.d', '/etc/yum/repos.d', '/etc/distro.repos.d'])) # :api self._add_option('debug_solver', BoolOption(False)) self._add_option('excludepkgs', ListAppendOption()) self._add_option('includepkgs', ListAppendOption()) self._add_option('exclude', self._get_option('excludepkgs')) # ^ compatibility with yum self._add_option('fastestmirror', BoolOption(False)) self._add_option('proxy', UrlOption(schemes=('http', 'ftp', 'https', 'socks5', 'socks5h', 'socks4', 'socks4a'), allow_none=True)) # :api self._add_option('proxy_username', Option()) # :api self._add_option('proxy_password', Option()) # :api self._add_option('protected_packages', ListOption("dnf glob:/etc/yum/protected.d/*.conf " \ "glob:/etc/dnf/protected.d/*.conf")) #:api self._add_option('username', Option()) # :api self._add_option('password', Option()) # :api self._add_option('installonlypkgs', ListAppendOption(dnf.const.INSTALLONLYPKGS)) self._add_option('group_package_types', ListOption(dnf.const.GROUP_PACKAGE_TYPES)) # NOTE: If you set this to 2, then because it keeps the current # kernel it means if you ever install an "old" kernel it'll get rid # of the newest one so you probably want to use 3 as a minimum # ... if you turn it on. self._add_option('installonly_limit', PositiveIntOption(3, range_min=2, names_of_0=["0", "<off>"])) # :api self._add_option('tsflags', ListAppendOption()) # :api self._add_option('assumeyes', BoolOption(False)) # :api self._add_option('assumeno', BoolOption(False)) self._add_option('check_config_file_age', BoolOption(True)) self._add_option('defaultyes', BoolOption(False)) self._add_option('diskspacecheck', BoolOption(True)) self._add_option('gpgcheck', BoolOption(False)) self._add_option('repo_gpgcheck', BoolOption(False)) self._add_option('localpkg_gpgcheck', BoolOption(False)) self._add_option('obsoletes', BoolOption(True)) self._add_option('showdupesfromrepos', BoolOption(False)) self._add_option('enabled', BoolOption(True)) self._add_option('enablegroups', BoolOption(True)) self._add_option('exit_on_lock', BoolOption(False)) self._add_option('bandwidth', BytesOption(0)) self._add_option('minrate', BytesOption(1000)) self._add_option('ip_resolve', CaselessSelectionOption(choices=('ipv4', 'ipv6', 'whatever'), mapper={'4': 'ipv4', '6': 'ipv6'})) self._add_option('throttle', ThrottleOption(0)) self._add_option('timeout', SecondsOption(30)) self._add_option('max_parallel_downloads', IntOption(None, range_min=1)) self._add_option('metadata_expire', SecondsOption(60 * 60 * 48)) # 48 hours self._add_option('metadata_timer_sync', SecondsOption(60 * 60 * 3)) # 3 hours self._add_option('disable_excludes', ListOption()) self._add_option('multilib_policy', SelectionOption('best', choices=('best', 'all'))) # :api self._add_option('best', BoolOption(False)) # :api self._add_option('install_weak_deps', BoolOption(True)) self._add_option('bugtracker_url', Option(dnf.const.BUGTRACKER)) self._add_option('color', SelectionOption('auto', choices=('auto', 'never', 'always'), mapper={'on': 'always', 'yes' : 'always', '1' : 'always', 'true': 'always', 'off': 'never', 'no': 'never', '0': 'never', 'false': 'never', 'tty': 'auto', 'if-tty': 'auto'}) ) self._add_option('color_list_installed_older', Option('bold')) self._add_option('color_list_installed_newer', Option('bold,yellow')) self._add_option('color_list_installed_reinstall', Option('normal')) self._add_option('color_list_installed_extra', Option('bold,red')) self._add_option('color_list_available_upgrade', Option('bold,blue')) self._add_option('color_list_available_downgrade', Option('dim,cyan')) self._add_option('color_list_available_reinstall', Option('bold,underline,green')) self._add_option('color_list_available_install', Option('normal')) self._add_option('color_update_installed', Option('normal')) self._add_option('color_update_local', Option('bold')) self._add_option('color_update_remote', Option('normal')) self._add_option('color_search_match', Option('bold')) self._add_option('sslcacert', PathOption()) # :api self._add_option('sslverify', BoolOption(True)) # :api self._add_option('sslclientcert', Option()) # :api self._add_option('sslclientkey', Option()) # :api self._add_option('deltarpm', BoolOption(True)) self._add_option('deltarpm_percentage', PositiveIntOption(75, names_of_0=["0", "<off>"])) self._add_option('history_record', BoolOption(True)) self._add_option('history_record_packages', ListOption(['dnf', 'rpm'])) self._add_option('rpmverbosity', Option('info')) self._add_option('strict', BoolOption(True)) # :api self._add_option('skip_broken', BoolOption(False)) # :yum-compatibility self._add_option('autocheck_running_kernel', BoolOption(True)) # :yum-compatibility self._add_option('clean_requirements_on_remove', BoolOption(True)) self._add_option('history_list_view', SelectionOption('commands', choices=('single-user-commands', 'users', 'commands'), mapper={'cmds': 'commands', 'default': 'commands'})) self._add_option('upgrade_group_objects_upgrade', BoolOption(True)) # :api self._add_option('destdir', PathOption(None)) self._add_option('comment', Option()) # runtime only options self._add_option('downloadonly', BoolOption(False, runtimeonly=True)) self._add_option('ignorearch', BoolOption(False)) self._add_option('cacheonly', BoolOption(False))
def __init__(self, section='main', parser=None): # pylint: disable=R0915 super(MainConf, self).__init__(section, parser) self.substitutions = dnf.conf.substitutions.Substitutions() # setup different cache and log for non-priviledged users if dnf.util.am_i_root(): cachedir = dnf.const.SYSTEM_CACHEDIR logdir = '/var/log' else: try: cachedir = logdir = misc.getCacheDir() except (IOError, OSError) as e: logger.critical(_('Could not set cachedir: %s'), ucd(e)) self._add_option('debuglevel', IntOption(2, range_min=0, range_max=10)) # :api self._add_option('errorlevel', IntOption(2, range_min=0, range_max=10)) self._add_option('installroot', PathOption('/', abspath=True)) # :api self._add_option('config_file_path', PathOption(dnf.const.CONF_FILENAME)) # :api self._add_option('plugins', BoolOption(True)) self._add_option('pluginpath', ListOption([dnf.const.PLUGINPATH])) # :api self._add_option('pluginconfpath', ListOption([dnf.const.PLUGINCONFPATH])) # :api self._add_option('persistdir', PathOption(dnf.const.PERSISTDIR)) # :api self._add_option('recent', IntOption(7, range_min=0)) self._add_option('retries', PositiveIntOption(10, names_of_0=["0"])) self._add_option('reset_nice', BoolOption(True)) self._add_option('cachedir', PathOption(cachedir)) # :api self._add_option('system_cachedir', PathOption(dnf.const.SYSTEM_CACHEDIR)) # :api self._add_option('keepcache', BoolOption(False)) self._add_option('logdir', Option(logdir)) # :api self._add_option('reposdir', ListOption([ '/etc/yum.repos.d', '/etc/yum/repos.d', '/etc/distro.repos.d' ])) # :api self._add_option('debug_solver', BoolOption(False)) self._add_option('excludepkgs', ListAppendOption()) self._add_option('includepkgs', ListAppendOption()) self._add_option('exclude', self._get_option('excludepkgs')) # ^ compatibility with yum self._add_option('fastestmirror', BoolOption(False)) self._add_option('proxy', UrlOption(schemes=('http', 'ftp', 'https', 'socks5', 'socks5h', 'socks4', 'socks4a'), allow_none=True)) # :api self._add_option('proxy_username', Option()) # :api self._add_option('proxy_password', Option()) # :api self._add_option('protected_packages', ListOption("dnf glob:/etc/yum/protected.d/*.conf " \ "glob:/etc/dnf/protected.d/*.conf")) #:api self._add_option('username', Option()) # :api self._add_option('password', Option()) # :api self._add_option('installonlypkgs', ListAppendOption(dnf.const.INSTALLONLYPKGS)) self._add_option('group_package_types', ListOption(dnf.const.GROUP_PACKAGE_TYPES)) # NOTE: If you set this to 2, then because it keeps the current # kernel it means if you ever install an "old" kernel it'll get rid # of the newest one so you probably want to use 3 as a minimum # ... if you turn it on. self._add_option('installonly_limit', PositiveIntOption(0, range_min=2, names_of_0=["0", "<off>"])) # :api self._add_option('tsflags', ListAppendOption()) # :api self._add_option('assumeyes', BoolOption(False)) # :api self._add_option('assumeno', BoolOption(False)) self._add_option('check_config_file_age', BoolOption(True)) self._add_option('defaultyes', BoolOption(False)) self._add_option('diskspacecheck', BoolOption(True)) self._add_option('gpgcheck', BoolOption(False)) self._add_option('repo_gpgcheck', BoolOption(False)) self._add_option('localpkg_gpgcheck', BoolOption(False)) self._add_option('obsoletes', BoolOption(True)) self._add_option('showdupesfromrepos', BoolOption(False)) self._add_option('enabled', BoolOption(True)) self._add_option('enablegroups', BoolOption(True)) self._add_option('exit_on_lock', BoolOption(False)) self._add_option('bandwidth', BytesOption(0)) self._add_option('minrate', BytesOption(1000)) self._add_option( 'ip_resolve', CaselessSelectionOption(choices=('ipv4', 'ipv6', 'whatever'), mapper={ '4': 'ipv4', '6': 'ipv6' })) self._add_option('throttle', ThrottleOption(0)) self._add_option('timeout', SecondsOption(30)) self._add_option('max_parallel_downloads', IntOption(None, range_min=1)) self._add_option('metadata_expire', SecondsOption(60 * 60 * 48)) # 48 hours self._add_option('metadata_timer_sync', SecondsOption(60 * 60 * 3)) # 3 hours self._add_option('disable_excludes', ListOption()) self._add_option('multilib_policy', SelectionOption('best', choices=('best', 'all'))) # :api self._add_option('best', BoolOption(False)) # :api self._add_option('install_weak_deps', BoolOption(True)) self._add_option('bugtracker_url', Option(dnf.const.BUGTRACKER)) self._add_option( 'color', SelectionOption('auto', choices=('auto', 'never', 'always'), mapper={ 'on': 'always', 'yes': 'always', '1': 'always', 'true': 'always', 'off': 'never', 'no': 'never', '0': 'never', 'false': 'never', 'tty': 'auto', 'if-tty': 'auto' })) self._add_option('color_list_installed_older', Option('bold')) self._add_option('color_list_installed_newer', Option('bold,yellow')) self._add_option('color_list_installed_reinstall', Option('normal')) self._add_option('color_list_installed_extra', Option('bold,red')) self._add_option('color_list_available_upgrade', Option('bold,blue')) self._add_option('color_list_available_downgrade', Option('dim,cyan')) self._add_option('color_list_available_reinstall', Option('bold,underline,green')) self._add_option('color_list_available_install', Option('normal')) self._add_option('color_update_installed', Option('normal')) self._add_option('color_update_local', Option('bold')) self._add_option('color_update_remote', Option('normal')) self._add_option('color_search_match', Option('bold')) self._add_option('sslcacert', PathOption()) # :api self._add_option('sslverify', BoolOption(True)) # :api self._add_option('sslclientcert', Option()) # :api self._add_option('sslclientkey', Option()) # :api self._add_option('deltarpm', BoolOption(True)) self._add_option('deltarpm_percentage', PositiveIntOption(75, names_of_0=["0", "<off>"])) self._add_option('history_record', BoolOption(True)) self._add_option('history_record_packages', ListOption(['dnf', 'rpm'])) self._add_option('rpmverbosity', Option('info')) self._add_option('strict', BoolOption(True)) # :api self._add_option('skip_broken', BoolOption(False)) # :yum-compatibility self._add_option('autocheck_running_kernel', BoolOption(True)) # :yum-compatibility self._add_option('clean_requirements_on_remove', BoolOption(True)) self._add_option( 'history_list_view', SelectionOption('commands', choices=('single-user-commands', 'users', 'commands'), mapper={ 'cmds': 'commands', 'default': 'commands' })) self._add_option('upgrade_group_objects_upgrade', BoolOption(True)) # :api # runtime only options self._add_option('downloadonly', BoolOption(False, runtimeonly=True))