Blame SOURCES/0008-Module-switch-command.patch

5dd470
From 6ed0458744090ab307da9d9118690372b2e66ca8 Mon Sep 17 00:00:00 2001
5dd470
From: Jaroslav Mracek <jmracek@redhat.com>
5dd470
Date: Wed, 11 Nov 2020 12:47:21 +0100
5dd470
Subject: [PATCH 1/5] Make module_base better industrialized for method reuse
5dd470
5dd470
It will allow to use internal for module switch command.
5dd470
---
5dd470
 dnf/module/module_base.py | 29 ++++++++++++++++++++---------
5dd470
 1 file changed, 20 insertions(+), 9 deletions(-)
5dd470
5dd470
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
5dd470
index 49c871c4..0da4fab1 100644
5dd470
--- a/dnf/module/module_base.py
5dd470
+++ b/dnf/module/module_base.py
5dd470
@@ -323,7 +323,7 @@ class ModuleBase(object):
5dd470
             assert len(streamDict) == 1
5dd470
         return moduleDict
5dd470
 
5dd470
-    def _resolve_specs_enable_update_sack(self, module_specs):
5dd470
+    def _resolve_specs_enable(self, module_specs):
5dd470
         no_match_specs = []
5dd470
         error_spec = []
5dd470
         module_dicts = {}
5dd470
@@ -339,6 +339,9 @@ class ModuleBase(object):
5dd470
                 error_spec.append(spec)
5dd470
                 logger.error(ucd(e))
5dd470
                 logger.error(_("Unable to resolve argument {}").format(spec))
5dd470
+        return no_match_specs, error_spec, module_dicts
5dd470
+
5dd470
+    def _update_sack(self):
5dd470
         hot_fix_repos = [i.id for i in self.base.repos.iter_enabled() if i.module_hotfixes]
5dd470
         try:
5dd470
             solver_errors = self.base.sack.filter_modules(
5dd470
@@ -347,6 +350,10 @@ class ModuleBase(object):
5dd470
                 debugsolver=self.base.conf.debug_solver)
5dd470
         except hawkey.Exception as e:
5dd470
             raise dnf.exceptions.Error(ucd(e))
5dd470
+        return solver_errors
5dd470
+
5dd470
+    def _enable_dependencies(self, module_dicts):
5dd470
+        error_spec = []
5dd470
         for spec, (nsvcap, moduleDict) in module_dicts.items():
5dd470
             for streamDict in moduleDict.values():
5dd470
                 for modules in streamDict.values():
5dd470
@@ -357,6 +364,17 @@ class ModuleBase(object):
5dd470
                         error_spec.append(spec)
5dd470
                         logger.error(ucd(e))
5dd470
                         logger.error(_("Unable to resolve argument {}").format(spec))
5dd470
+        return error_spec
5dd470
+
5dd470
+    def _resolve_specs_enable_update_sack(self, module_specs):
5dd470
+        no_match_specs, error_spec, module_dicts = self._resolve_specs_enable(module_specs)
5dd470
+
5dd470
+        solver_errors = self._update_sack()
5dd470
+
5dd470
+        dependency_error_spec = self._enable_dependencies(module_dicts)
5dd470
+        if dependency_error_spec:
5dd470
+            error_spec.extend(dependency_error_spec)
5dd470
+
5dd470
         return no_match_specs, error_spec, solver_errors, module_dicts
5dd470
 
5dd470
     def _modules_reset_or_disable(self, module_specs, to_state):
5dd470
@@ -379,14 +397,7 @@ class ModuleBase(object):
5dd470
                 if to_state == STATE_DISABLED:
5dd470
                     self.base._moduleContainer.disable(name)
5dd470
 
5dd470
-        hot_fix_repos = [i.id for i in self.base.repos.iter_enabled() if i.module_hotfixes]
5dd470
-        try:
5dd470
-            solver_errors = self.base.sack.filter_modules(
5dd470
-                self.base._moduleContainer, hot_fix_repos, self.base.conf.installroot,
5dd470
-                self.base.conf.module_platform_id, update_only=True,
5dd470
-                debugsolver=self.base.conf.debug_solver)
5dd470
-        except hawkey.Exception as e:
5dd470
-            raise dnf.exceptions.Error(ucd(e))
5dd470
+        solver_errors = self._update_sack()
5dd470
         return no_match_specs, solver_errors
5dd470
 
5dd470
     def _get_package_name_set_and_remove_profiles(self, module_list, nsvcap, remove=False):
5dd470
-- 
5dd470
2.26.2
5dd470
5dd470
5dd470
From e6473f4e6f17bb635e023b8905f29b318b8795bf Mon Sep 17 00:00:00 2001
5dd470
From: Jaroslav Mracek <jmracek@redhat.com>
5dd470
Date: Wed, 11 Nov 2020 17:09:16 +0100
5dd470
Subject: [PATCH 2/5] Add module switch-to support (RhBug:1792020)
5dd470
5dd470
It is a combination of module rpm distrosync, module profile switch and
5dd470
module stream switch.
5dd470
5dd470
= changelog =
5dd470
msg:           Add new `module switch-to` command for switching content
5dd470
of module streams
5dd470
type:          enhancement
5dd470
resolves:      https://bugzilla.redhat.com/show_bug.cgi?id=1792020
5dd470
---
5dd470
 VERSION.cmake              |   2 +-
5dd470
 dnf.spec                   |   2 +-
5dd470
 dnf/cli/commands/module.py |  24 ++++-
5dd470
 dnf/module/module_base.py  | 182 ++++++++++++++++++++++++++++++++-----
5dd470
 4 files changed, 185 insertions(+), 25 deletions(-)
5dd470
5dd470
diff --git a/dnf/cli/commands/module.py b/dnf/cli/commands/module.py
5dd470
index 5a6c0069..4cdc915e 100644
5dd470
--- a/dnf/cli/commands/module.py
5dd470
+++ b/dnf/cli/commands/module.py
5dd470
@@ -271,6 +271,28 @@ class ModuleCommand(commands.Command):
5dd470
 
5dd470
             logger.error(dnf.exceptions.MarkingErrors(no_match_group_specs=skipped_groups))
5dd470
 
5dd470
+    class SwitchToSubCommand(SubCommand):
5dd470
+
5dd470
+        aliases = ('switch-to',)
5dd470
+        summary = _('switch a module to a stream and distrosync rpm packages')
5dd470
+
5dd470
+        def configure(self):
5dd470
+            demands = self.cli.demands
5dd470
+            demands.available_repos = True
5dd470
+            demands.sack_activation = True
5dd470
+            demands.resolving = True
5dd470
+            demands.root_user = True
5dd470
+            self.base.conf.module_stream_switch = True
5dd470
+
5dd470
+        def run_on_module(self):
5dd470
+            try:
5dd470
+                self.module_base.switch_to(self.opts.module_spec, strict=self.base.conf.strict)
5dd470
+            except dnf.exceptions.MarkingErrors as e:
5dd470
+                if self.base.conf.strict:
5dd470
+                    if e.no_match_group_specs or e.error_group_specs:
5dd470
+                        raise e
5dd470
+                logger.error(str(e))
5dd470
+
5dd470
     class ProvidesSubCommand(SubCommand):
5dd470
 
5dd470
         aliases = ("provides", )
5dd470
@@ -319,7 +341,7 @@ class ModuleCommand(commands.Command):
5dd470
 
5dd470
     SUBCMDS = {ListSubCommand, InfoSubCommand, EnableSubCommand,
5dd470
                DisableSubCommand, ResetSubCommand, InstallSubCommand, UpdateSubCommand,
5dd470
-               RemoveSubCommand, ProvidesSubCommand, RepoquerySubCommand}
5dd470
+               RemoveSubCommand, SwitchToSubCommand, ProvidesSubCommand, RepoquerySubCommand}
5dd470
 
5dd470
     SUBCMDS_NOT_REQUIRED_ARG = {ListSubCommand}
5dd470
 
5dd470
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
5dd470
index 0da4fab1..03d54f72 100644
5dd470
--- a/dnf/module/module_base.py
5dd470
+++ b/dnf/module/module_base.py
5dd470
@@ -140,31 +140,140 @@ class ModuleBase(object):
5dd470
         if fail_safe_repo_used:
5dd470
             raise dnf.exceptions.Error(_(
5dd470
                 "Installing module from Fail-Safe repository is not allowed"))
5dd470
-        #  Remove source packages they cannot be installed or upgraded
5dd470
-        base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
5dd470
-        install_base_query = base_no_source_query.filter(nevra_strict=install_set_artefacts)
5dd470
+        __, profiles_errors = self._install_profiles_internal(
5dd470
+            install_set_artefacts, install_dict, strict)
5dd470
+        if profiles_errors:
5dd470
+            error_specs.extend(profiles_errors)
5dd470
 
5dd470
-        # add hot-fix packages
5dd470
-        hot_fix_repos = [i.id for i in self.base.repos.iter_enabled() if i.module_hotfixes]
5dd470
-        hotfix_packages = base_no_source_query.filter(
5dd470
-            reponame=hot_fix_repos, name=install_dict.keys())
5dd470
-        install_base_query = install_base_query.union(hotfix_packages)
5dd470
+        if no_match_specs or error_specs or solver_errors:
5dd470
+            raise dnf.exceptions.MarkingErrors(no_match_group_specs=no_match_specs,
5dd470
+                                               error_group_specs=error_specs,
5dd470
+                                               module_depsolv_errors=solver_errors)
5dd470
 
5dd470
-        for pkg_name, set_specs in install_dict.items():
5dd470
-            query = install_base_query.filter(name=pkg_name)
5dd470
-            if not query:
5dd470
-                # package can also be non-modular or part of another stream
5dd470
-                query = base_no_source_query.filter(name=pkg_name)
5dd470
-                if not query:
5dd470
-                    for spec in set_specs:
5dd470
-                        logger.error(_("Unable to resolve argument {}").format(spec))
5dd470
-                    logger.error(_("No match for package {}").format(pkg_name))
5dd470
-                    error_specs.extend(set_specs)
5dd470
-                    continue
5dd470
-            self.base._goal.group_members.add(pkg_name)
5dd470
+    def switch_to(self, module_specs, strict=True):
5dd470
+        # :api
5dd470
+        no_match_specs, error_specs, module_dicts = self._resolve_specs_enable(module_specs)
5dd470
+        # collect name of artifacts from new modules for distrosync
5dd470
+        new_artifacts_names = set()
5dd470
+        # collect name of artifacts from active modules for distrosync before sack update
5dd470
+        active_artifacts_names = set()
5dd470
+        src_arches = {"nosrc", "src"}
5dd470
+        for spec, (nsvcap, moduledict) in module_dicts.items():
5dd470
+            for name in moduledict.keys():
5dd470
+                for module in self.base._moduleContainer.query(name, "", "", "", ""):
5dd470
+                    if self.base._moduleContainer.isModuleActive(module):
5dd470
+                        for artifact in module.getArtifacts():
5dd470
+                            arch = artifact.rsplit(".", 1)[1]
5dd470
+                            if arch in src_arches:
5dd470
+                                continue
5dd470
+                            pkg_name = artifact.rsplit("-", 2)[0]
5dd470
+                            active_artifacts_names.add(pkg_name)
5dd470
+
5dd470
+        solver_errors = self._update_sack()
5dd470
+
5dd470
+        dependency_error_spec = self._enable_dependencies(module_dicts)
5dd470
+        if dependency_error_spec:
5dd470
+            error_specs.extend(dependency_error_spec)
5dd470
+
5dd470
+        # <package_name, set_of_spec>
5dd470
+        fail_safe_repo = hawkey.MODULE_FAIL_SAFE_REPO_NAME
5dd470
+        install_dict = {}
5dd470
+        install_set_artifacts = set()
5dd470
+        fail_safe_repo_used = False
5dd470
+
5dd470
+        # list of name: [profiles] for module profiles being removed
5dd470
+        removed_profiles = self.base._moduleContainer.getRemovedProfiles()
5dd470
+
5dd470
+        for spec, (nsvcap, moduledict) in module_dicts.items():
5dd470
+            for name, streamdict in moduledict.items():
5dd470
+                for stream, module_list in streamdict.items():
5dd470
+                    install_module_list = [x for x in module_list
5dd470
+                                           if self.base._moduleContainer.isModuleActive(x.getId())]
5dd470
+                    if not install_module_list:
5dd470
+                        "No active matches for argument '{0}' in module '{1}:{2}'"
5dd470
+                        logger.error(_("No active matches for argument '{0}' in module "
5dd470
+                                       "'{1}:{2}'").format(spec, name, stream))
5dd470
+                        error_specs.append(spec)
5dd470
+                        continue
5dd470
+                    profiles = []
5dd470
+                    latest_module = self._get_latest(install_module_list)
5dd470
+                    if latest_module.getRepoID() == fail_safe_repo:
5dd470
+                        msg = _(
5dd470
+                            "Installing module '{0}' from Fail-Safe repository {1} is not allowed")
5dd470
+                        logger.critical(msg.format(latest_module.getNameStream(), fail_safe_repo))
5dd470
+                        fail_safe_repo_used = True
5dd470
+                    if nsvcap.profile:
5dd470
+                        profiles.extend(latest_module.getProfiles(nsvcap.profile))
5dd470
+                        if not profiles:
5dd470
+                            available_profiles = latest_module.getProfiles()
5dd470
+                            if available_profiles:
5dd470
+                                profile_names = ", ".join(sorted(
5dd470
+                                    [profile.getName() for profile in available_profiles]))
5dd470
+                                msg = _("Unable to match profile for argument {}. Available "
5dd470
+                                        "profiles for '{}:{}': {}").format(
5dd470
+                                    spec, name, stream, profile_names)
5dd470
+                            else:
5dd470
+                                msg = _("Unable to match profile for argument {}").format(spec)
5dd470
+                            logger.error(msg)
5dd470
+                            no_match_specs.append(spec)
5dd470
+                            continue
5dd470
+                    elif name in removed_profiles:
5dd470
+
5dd470
+                        for profile in removed_profiles[name]:
5dd470
+                            module_profiles = latest_module.getProfiles(profile)
5dd470
+                            if not module_profiles:
5dd470
+                                logger.warning(
5dd470
+                                    _("Installed profile '{0}' is not available in module "
5dd470
+                                      "'{1}' stream '{2}'").format(profile, name, stream))
5dd470
+                                continue
5dd470
+                            profiles.extend(module_profiles)
5dd470
+                    for profile in profiles:
5dd470
+                        self.base._moduleContainer.install(latest_module, profile.getName())
5dd470
+                        for pkg_name in profile.getContent():
5dd470
+                            install_dict.setdefault(pkg_name, set()).add(spec)
5dd470
+                    for module in install_module_list:
5dd470
+                        artifacts = module.getArtifacts()
5dd470
+                        install_set_artifacts.update(artifacts)
5dd470
+                        for artifact in artifacts:
5dd470
+                            arch = artifact.rsplit(".", 1)[1]
5dd470
+                            if arch in src_arches:
5dd470
+                                continue
5dd470
+                            pkg_name = artifact.rsplit("-", 2)[0]
5dd470
+                            new_artifacts_names.add(pkg_name)
5dd470
+        if fail_safe_repo_used:
5dd470
+            raise dnf.exceptions.Error(_(
5dd470
+                "Installing module from Fail-Safe repository is not allowed"))
5dd470
+        install_base_query, profiles_errors = self._install_profiles_internal(
5dd470
+            install_set_artifacts, install_dict, strict)
5dd470
+        if profiles_errors:
5dd470
+            error_specs.extend(profiles_errors)
5dd470
+
5dd470
+        # distrosync module name
5dd470
+        all_names = set()
5dd470
+        all_names.update(new_artifacts_names)
5dd470
+        all_names.update(active_artifacts_names)
5dd470
+        remove_query = self.base.sack.query().filterm(empty=True)
5dd470
+        for pkg_name in all_names:
5dd470
+            query = self.base.sack.query().filterm(name=pkg_name)
5dd470
+            installed = query.installed()
5dd470
+            if not installed:
5dd470
+                continue
5dd470
+            available = query.available()
5dd470
+            if not available:
5dd470
+                logger.warning(_("No packages available to distrosync for package name "
5dd470
+                                 "'{}'").format(pkg_name))
5dd470
+                if pkg_name not in new_artifacts_names:
5dd470
+                    remove_query = remove_query.union(query)
5dd470
+                continue
5dd470
+
5dd470
+            only_new_module = query.intersection(install_base_query)
5dd470
+            if only_new_module:
5dd470
+                query = only_new_module
5dd470
             sltr = dnf.selector.Selector(self.base.sack)
5dd470
             sltr.set(pkg=query)
5dd470
-            self.base._goal.install(select=sltr, optional=(not strict))
5dd470
+            self.base._goal.distupgrade(select=sltr)
5dd470
+        self.base._remove_if_unneeded(remove_query)
5dd470
+
5dd470
         if no_match_specs or error_specs or solver_errors:
5dd470
             raise dnf.exceptions.MarkingErrors(no_match_group_specs=no_match_specs,
5dd470
                                                error_group_specs=error_specs,
5dd470
@@ -183,7 +292,7 @@ class ModuleBase(object):
5dd470
         fail_safe_repo = hawkey.MODULE_FAIL_SAFE_REPO_NAME
5dd470
         fail_safe_repo_used = False
5dd470
 
5dd470
-        #  Remove source packages they cannot be installed or upgraded
5dd470
+        #  Remove source packages because they cannot be installed or upgraded
5dd470
         base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
5dd470
 
5dd470
         for spec in module_specs:
5dd470
@@ -694,6 +803,35 @@ class ModuleBase(object):
5dd470
     def _format_repoid(self, repo_name):
5dd470
         return "{}\n".format(self.base.output.term.bold(repo_name))
5dd470
 
5dd470
+    def _install_profiles_internal(self, install_set_artifacts, install_dict, strict):
5dd470
+        #  Remove source packages because they cannot be installed or upgraded
5dd470
+        base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
5dd470
+        install_base_query = base_no_source_query.filter(nevra_strict=install_set_artifacts)
5dd470
+        error_specs = []
5dd470
+
5dd470
+        # add hot-fix packages
5dd470
+        hot_fix_repos = [i.id for i in self.base.repos.iter_enabled() if i.module_hotfixes]
5dd470
+        hotfix_packages = base_no_source_query.filter(
5dd470
+            reponame=hot_fix_repos, name=install_dict.keys())
5dd470
+        install_base_query = install_base_query.union(hotfix_packages)
5dd470
+
5dd470
+        for pkg_name, set_specs in install_dict.items():
5dd470
+            query = install_base_query.filter(name=pkg_name)
5dd470
+            if not query:
5dd470
+                # package can also be non-modular or part of another stream
5dd470
+                query = base_no_source_query.filter(name=pkg_name)
5dd470
+                if not query:
5dd470
+                    for spec in set_specs:
5dd470
+                        logger.error(_("Unable to resolve argument {}").format(spec))
5dd470
+                    logger.error(_("No match for package {}").format(pkg_name))
5dd470
+                    error_specs.extend(set_specs)
5dd470
+                    continue
5dd470
+            self.base._goal.group_members.add(pkg_name)
5dd470
+            sltr = dnf.selector.Selector(self.base.sack)
5dd470
+            sltr.set(pkg=query)
5dd470
+            self.base._goal.install(select=sltr, optional=(not strict))
5dd470
+        return install_base_query, error_specs
5dd470
+
5dd470
 
5dd470
 def format_modular_solver_errors(errors):
5dd470
     msg = dnf.util._format_resolve_problems(errors)
5dd470
-- 
5dd470
2.26.2
5dd470
5dd470
5dd470
From df8c74679193bf27db584b3ad225997b2f5f4b87 Mon Sep 17 00:00:00 2001
5dd470
From: Jaroslav Mracek <jmracek@redhat.com>
5dd470
Date: Thu, 12 Nov 2020 13:51:02 +0100
5dd470
Subject: [PATCH 3/5] [minor] Rename all variables with artefact to artifact
5dd470
5dd470
---
5dd470
 dnf/module/module_base.py | 10 +++++-----
5dd470
 1 file changed, 5 insertions(+), 5 deletions(-)
5dd470
5dd470
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
5dd470
index 03d54f72..7298c9a3 100644
5dd470
--- a/dnf/module/module_base.py
5dd470
+++ b/dnf/module/module_base.py
5dd470
@@ -73,7 +73,7 @@ class ModuleBase(object):
5dd470
         # <package_name, set_of_spec>
5dd470
         fail_safe_repo = hawkey.MODULE_FAIL_SAFE_REPO_NAME
5dd470
         install_dict = {}
5dd470
-        install_set_artefacts = set()
5dd470
+        install_set_artifacts = set()
5dd470
         fail_safe_repo_used = False
5dd470
         for spec, (nsvcap, moduledict) in module_dicts.items():
5dd470
             for name, streamdict in moduledict.items():
5dd470
@@ -136,12 +136,12 @@ class ModuleBase(object):
5dd470
                         for pkg_name in profile.getContent():
5dd470
                             install_dict.setdefault(pkg_name, set()).add(spec)
5dd470
                     for module in install_module_list:
5dd470
-                        install_set_artefacts.update(module.getArtifacts())
5dd470
+                        install_set_artifacts.update(module.getArtifacts())
5dd470
         if fail_safe_repo_used:
5dd470
             raise dnf.exceptions.Error(_(
5dd470
                 "Installing module from Fail-Safe repository is not allowed"))
5dd470
         __, profiles_errors = self._install_profiles_internal(
5dd470
-            install_set_artefacts, install_dict, strict)
5dd470
+            install_set_artifacts, install_dict, strict)
5dd470
         if profiles_errors:
5dd470
             error_specs.extend(profiles_errors)
5dd470
 
5dd470
@@ -326,8 +326,8 @@ class ModuleBase(object):
5dd470
                     else:
5dd470
                         for profile in latest_module.getProfiles():
5dd470
                             upgrade_package_set.update(profile.getContent())
5dd470
-                        for artefact in latest_module.getArtifacts():
5dd470
-                            subj = hawkey.Subject(artefact)
5dd470
+                        for artifact in latest_module.getArtifacts():
5dd470
+                            subj = hawkey.Subject(artifact)
5dd470
                             for nevra_obj in subj.get_nevra_possibilities(
5dd470
                                     forms=[hawkey.FORM_NEVRA]):
5dd470
                                 upgrade_package_set.add(nevra_obj.name)
5dd470
-- 
5dd470
2.26.2
5dd470
5dd470
5dd470
From 0818bb80fc0846f602f338a2119671be97c47217 Mon Sep 17 00:00:00 2001
5dd470
From: Jaroslav Mracek <jmracek@redhat.com>
5dd470
Date: Thu, 12 Nov 2020 15:11:29 +0100
5dd470
Subject: [PATCH 4/5] [doc] Add description of dnf module switch-to
5dd470
5dd470
---
5dd470
 doc/command_ref.rst | 30 ++++++++++++++++++++++--------
5dd470
 1 file changed, 22 insertions(+), 8 deletions(-)
5dd470
5dd470
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
5dd470
index 83879013..c12837ea 100644
5dd470
--- a/doc/command_ref.rst
5dd470
+++ b/doc/command_ref.rst
5dd470
@@ -979,15 +979,31 @@ Module subcommands take :ref:`\<module-spec>\ <specifying_modules-label>`... arg
5dd470
     In case no profile was provided, all default profiles get installed.
5dd470
     Module streams get enabled accordingly.
5dd470
 
5dd470
-    This command cannot be used for switching module streams. It is recommended to remove all
5dd470
-    installed content from the module and reset the module using the
5dd470
-    :ref:`reset <module_reset_command-label>` command. After you reset the module, you can install
5dd470
-    the other stream.
5dd470
+    This command cannot be used for switching module streams. Use the
5dd470
+    :ref:`dnf module switch-to <module_switch_to_command-label>` command for that.
5dd470
 
5dd470
 ``dnf [options] module update <module-spec>...``
5dd470
     Update packages associated with an active module stream, optionally restricted to a profile.
5dd470
     If the `profile_name` is provided, only the packages referenced by that profile will be updated.
5dd470
 
5dd470
+.. _module_switch_to_command-label:
5dd470
+
5dd470
+``dnf [options] module switch-to <module-spec>...``
5dd470
+    Switch to or enable a module stream, change versions of installed packages to versions provided
5dd470
+    by the new stream, and remove packages from the old stream that are no longer available. It also
5dd470
+    updates installed profiles if they are available for the new stream. When a profile was
5dd470
+    provided, it installs that profile and does not update any already installed profiles.
5dd470
+
5dd470
+    This command can be used as a stronger version of the
5dd470
+    :ref:`dnf module enable <module_enable_command-label>` command, which not only enables modules,
5dd470
+    but also does a `distrosync` to all modular packages in the enabled modules.
5dd470
+
5dd470
+    It can also be used as a stronger version of the
5dd470
+    :ref:`dnf module install <module_install_command-label>` command, but it requires to specify
5dd470
+    profiles that are supposed to be installed, because `switch-to` command does not use `default
5dd470
+    profiles`. The `switch-to` command doesn't only install profiles, it also makes a `distrosync`
5dd470
+    to all modular packages in the installed module.
5dd470
+
5dd470
 ``dnf [options] module remove <module-spec>...``
5dd470
     Remove installed module profiles, including packages that were installed with the
5dd470
     :ref:`dnf module install <module_install_command-label>` command. Will not remove packages
5dd470
@@ -1010,10 +1026,8 @@ Module subcommands take :ref:`\<module-spec>\ <specifying_modules-label>`... arg
5dd470
     of modular dependency issue the operation will be rejected. To perform the action anyway please use
5dd470
     \-\ :ref:`-skip-broken <skip-broken_option-label>` option.
5dd470
 
5dd470
-    This command cannot be used for switching module streams. It is recommended to remove all
5dd470
-    installed content from the module, and reset the module using the
5dd470
-    :ref:`reset <module_reset_command-label>` command. After you reset the module, you can enable
5dd470
-    the other stream.
5dd470
+    This command cannot be used for switching module streams. Use the
5dd470
+    :ref:`dnf module switch-to <module_switch_to_command-label>` command for that.
5dd470
 
5dd470
 .. _module_disable_command-label:
5dd470
 
5dd470
-- 
5dd470
2.26.2
5dd470
5dd470
5dd470
From 6b0b2b99e40c20706145e774626658825f5bc55d Mon Sep 17 00:00:00 2001
5dd470
From: Jaroslav Mracek <jmracek@redhat.com>
5dd470
Date: Wed, 25 Nov 2020 12:34:30 +0100
5dd470
Subject: [PATCH 5/5] Do not use source rpms for module switch
5dd470
5dd470
It prevents misleading message from libsolv that it tries to install
5dd470
source rpm.
5dd470
---
5dd470
 dnf/module/module_base.py | 4 +++-
5dd470
 1 file changed, 3 insertions(+), 1 deletion(-)
5dd470
5dd470
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
5dd470
index 7298c9a3..02d5d5a3 100644
5dd470
--- a/dnf/module/module_base.py
5dd470
+++ b/dnf/module/module_base.py
5dd470
@@ -253,8 +253,10 @@ class ModuleBase(object):
5dd470
         all_names.update(new_artifacts_names)
5dd470
         all_names.update(active_artifacts_names)
5dd470
         remove_query = self.base.sack.query().filterm(empty=True)
5dd470
+        base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
5dd470
+
5dd470
         for pkg_name in all_names:
5dd470
-            query = self.base.sack.query().filterm(name=pkg_name)
5dd470
+            query = base_no_source_query.filter(name=pkg_name)
5dd470
             installed = query.installed()
5dd470
             if not installed:
5dd470
                 continue
5dd470
-- 
5dd470
2.26.2
5dd470