def __init__(self, no_match_group_specs=(), error_group_specs=(), no_match_pkg_specs=(), error_pkg_specs=(), module_depsolv_errors=()): """Initialize the marking error instance.""" msg = _("Problems in request:") if (no_match_pkg_specs): msg += "\n" + _("missing packages: ") + ", ".join(no_match_pkg_specs) if (error_pkg_specs): msg += "\n" + _("broken packages: ") + ", ".join(error_pkg_specs) if (no_match_group_specs): msg += "\n" + _("missing groups or modules: ") + ", ".join(no_match_group_specs) if (error_group_specs): msg += "\n" + _("broken groups or modules: ") + ", ".join(error_group_specs) if (module_depsolv_errors): msg_mod = dnf.util._format_resolve_problems(module_depsolv_errors[0]) if module_depsolv_errors[1] == \ libdnf.module.ModulePackageContainer.ModuleErrorType_ERROR_IN_DEFAULTS: msg += "\n" + "\n".join([P_('Modular dependency problem with Defaults:', 'Modular dependency problems with Defaults:', len(module_depsolv_errors)), msg_mod]) else: msg += "\n" + "\n".join([P_('Modular dependency problem:', 'Modular dependency problems:', len(module_depsolv_errors)), msg_mod]) super(MarkingErrors, self).__init__(msg) self.no_match_group_specs = no_match_group_specs self.error_group_specs = error_group_specs self.no_match_pkg_specs = no_match_pkg_specs self.error_pkg_specs = error_pkg_specs self.module_depsolv_errors = module_depsolv_errors
def errorSummary(self, errstring): """Parse the error string for 'interesting' errors which can be grouped, such as disk space issues. :param errstring: the error string :return: a string containing a summary of the errors """ summary = '' # do disk space report first p = re.compile('needs (\d+)MB on the (\S+) filesystem') disk = {} for m in p.finditer(errstring): if m.group(2) not in disk: disk[m.group(2)] = int(m.group(1)) if disk[m.group(2)] < int(m.group(1)): disk[m.group(2)] = int(m.group(1)) if disk: summary += _('Disk Requirements:\n') for k in disk: summary += P_( ' At least %dMB more space needed on the %s filesystem.\n', ' At least %dMB more space needed on the %s filesystem.\n', disk[k]) % (disk[k], k) # TODO: simplify the dependency errors? # Fixup the summary summary = _('Error Summary\n-------------\n') + summary return summary
def run(self): cachedir = self.base.conf.cachedir md_lock = dnf.lock.build_metadata_lock(cachedir, True) download_lock = dnf.lock.build_download_lock(cachedir, True) rpmdb_lock = dnf.lock.build_rpmdb_lock(self.base.conf.persistdir, True) while True: try: with md_lock and download_lock and rpmdb_lock: types = set(t for c in self.opts.type for t in _CACHE_TYPES[c]) files = list(_tree(cachedir)) logger.debug(_('Cleaning data: ' + ' '.join(types))) if 'expire-cache' in types: expired = _cached_repos(files) self.base._repo_persistor.expired_to_add.update( expired) types.remove('expire-cache') logger.info(_('Cache was expired')) patterns = [dnf.repo.CACHE_FILES[t] for t in types] count = _clean(cachedir, _filter(files, patterns)) logger.info( P_('%d file removed', '%d files removed', count) % count) return except dnf.exceptions.LockError as e: if not self.base.conf.exit_on_lock: msg = _('Waiting for process with pid %d to finish.' % (e.pid)) logger.info(msg) time.sleep(3) else: raise e
def __init__(self, no_match_group_specs=(), error_group_specs=(), no_match_pkg_specs=(), error_pkg_specs=(), module_debsolv_errors=()): """Initialize the marking error instance.""" msg = _("Problems in request:") if (no_match_pkg_specs): msg += "\n" + _("missing packages: ") + ", ".join( no_match_pkg_specs) if (error_pkg_specs): msg += "\n" + _("broken packages: ") + ", ".join(error_pkg_specs) if (no_match_group_specs): msg += "\n" + _("missing groups or modules: ") + ", ".join( no_match_group_specs) if (error_group_specs): msg += "\n" + _("broken groups or modules: ") + ", ".join( error_group_specs) if (module_debsolv_errors): msg_mod = dnf.util._format_resolve_problems(module_debsolv_errors) msg += "\n" + "\n".join([ P_('Modular dependency problem:', 'Modular dependency problems:', len(module_debsolv_errors)), msg_mod ]) super(MarkingErrors, self).__init__(msg) self.no_match_group_specs = no_match_group_specs self.error_group_specs = error_group_specs self.no_match_pkg_specs = no_match_pkg_specs self.error_pkg_specs = error_pkg_specs self.module_debsolv_errors = module_debsolv_errors
def run(self): cachedir = self.base.conf.cachedir types = set(t for c in self.opts.type for t in _CACHE_TYPES[c]) files = list(_tree(cachedir)) logger.debug(_('Cleaning data: ' + ' '.join(types))) if 'expire-cache' in types: expired = _cached_repos(files) self.base._repo_persistor.expired_to_add.update(expired) types.remove('expire-cache') patterns = [dnf.repo.CACHE_FILES[t] for t in types] count = _clean(cachedir, _filter(files, patterns)) logger.info(P_('%d file removed', '%d files removed', count) % count)
def _clean_filelist(filetype, filelist): removed = 0 for item in filelist: try: misc.unlink_f(item) except OSError: logger.critical(_('Cannot remove %s file %s'), filetype, item) continue else: logger.log(dnf.logging.DDEBUG, _('%s file %s removed'), filetype, item) removed += 1 msg = P_('%d %s file removed', '%d %s files removed', removed) msg %= (removed, filetype) return 0, [msg]
def format_modular_solver_errors(errors): msg = dnf.util._format_resolve_problems(errors) return "\n".join( [P_('Modular dependency problem:', 'Modular dependency problems:', len(errors)), msg])
def main(args): (opts, parser) = parse_arguments(args) try: conf = AutomaticConfig(opts.conf_path, opts.downloadupdates, opts.installupdates) with dnf.Base() as base: cli = dnf.cli.Cli(base) cli._read_conf_file() # Although dnf-automatic does not use demands, the versionlock # plugin uses this demand do decide whether it's rules should # be applied. # https://bugzilla.redhat.com/show_bug.cgi?id=1746562 cli.demands.resolving = True conf.update_baseconf(base.conf) base.init_plugins(cli=cli) logger.debug(_('Started dnf-automatic.')) if opts.timer: sleeper = random.randint(0, conf.commands.random_sleep) logger.debug( P_('Sleep for {} second', 'Sleep for {} seconds', sleeper).format(sleeper)) time.sleep(sleeper) base.pre_configure_plugins() base.read_all_repos() if not wait_for_network(base.repos, conf.commands.network_online_timeout): logger.warning(_('System is off-line.')) base.configure_plugins() base.fill_sack() upgrade(base, conf.commands.upgrade_type) base.resolve() output = dnf.cli.output.Output(base, base.conf) trans = base.transaction if not trans: return 0 lst = output.list_transaction(trans, total_width=80) emitters = build_emitters(conf) emitters.notify_available(lst) if not conf.commands.download_updates: emitters.commit() return 0 base.download_packages(trans.install_set) emitters.notify_downloaded() if not conf.commands.apply_updates: emitters.commit() return 0 gpgsigcheck(base, trans.install_set) base.do_transaction() emitters.notify_applied() emitters.commit() except dnf.exceptions.Error as exc: logger.error(_('Error: %s'), ucd(exc)) return 1 return 0