Bug 1677253

Summary: Provide a way of removing all packages belonging to a stream
Product: Red Hat Enterprise Linux 8 Reporter: Petr Pisar <ppisar>
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 8.0CC: amatej, emrakova, james.antill, jblazek, jmracek, jorton, ksrot, kwalker, lkuprova, mdomonko, tbaeder, tbowling, vslavik
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: 8.1Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.2.17-1.el8 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:47:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1681084    
Bug Blocks: 1755139    

Description Petr Pisar 2019-02-14 11:34:46 UTC
This request is forked from <https://bugzilla.redhat.com/show_bug.cgi?id=1669491#c27>.

DNF is going print this message:

> It is recomended to remove all installed content from the module and then
> reset the module using 'dnf module reset <module_name>' command.

How can I "remove all installed content from the module" using DNF? "dnf module remove STREAM" does not do that. It can maybe remove profiles, but it cannot clean up all packages belonging to a module: Example:

I have perl:5.24 enabled:

# dnf -q module list --enabled
Red Hat Enterprise Linux 8 AppStream - x86_64
Name      Stream       Profiles                   Summary                                 
httpd     2.4 [d][e]   common [d], devel, minimal Apache HTTP Server                      
perl      5.24 [e]     common [d], minimal        Practical Extraction and Report Language
python27  2.7 [d][e]   common [d]                 Python programming language, version 2.7
python36  3.6 [d][e]   common [d], build          Python programming language, version 3.6
virt      rhel [d][e]  common [d]                 Virtualization module                   

And some packages from perl:5.24 installed:

# rpm -q perl --qf '%{NEVRA}\n'
perl-4:5.24.4-403.module+el8+2770+c759b41a.x86_64
# dnf -q module info perl:5.24 |grep 'perl-4:5.24.4-403.module+el8+2770+c759b41a.x86_64'
Artifacts        : perl-4:5.24.4-403.module+el8+2770+c759b41a.x86_64

# dnf -q module remove perl:5.24
Unable to match profile in argument perl:5.24

If we recommend users to "remove all installed content from the module", we need to provide a tool for it.

Tested with dnf-4.0.9.2-4.el8.

Comment 1 Jaroslav Mracek 2019-02-20 09:37:49 UTC
To delivery the feature we suggest to use name of packages from artifact according to available metadata.

Comment 2 Petr Pisar 2019-02-20 09:57:43 UTC
I agree.

Comment 4 Kyle Walker 2019-06-12 12:27:52 UTC
A resounding +1 for this functionality. However, what is the plan for empty modules?


> To delivery the feature we suggest to use name of packages from artifact according to available metadata.

If a user leverages this functionality and removes a populated module stream[/profile], they would have the content removed. In the empty-module instance, you would get no effect:

  Name             : perl
  Stream           : 5.26 [d][e][a]
  Version          : 820181219174508
  Context          : 9edba152
  Profiles         : common [d] [i], minimal
  Default profiles : common
  Repo             : rhel-8-for-x86_64-appstream-rpms
  Summary          : Practical Extraction and Report Language
  Description      : Perl is a high-level programming language with roots in C, sed, awk and shell scripting. Perl is good at handling processes and files, and is especially good at handling text. Perl's hallmark>

  Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled, [a]ctive]


Though, the installation of the above module resulted in 155 packages being installed from the two primary repos:

 # yum history info last | awk '/Install/ {counts[$NF]++} END {for(idx in counts) {printf("%3d - %s\n", counts[idx], idx)}}'
  37 - @rhel-8-for-x86_64-baseos-rpms
 118 - @rhel-8-for-x86_64-appstream-rpms

Comment 5 Petr Pisar 2019-06-12 13:14:42 UTC
Are we going to uninstall a profile content or a module content? The first case calls for removing the packages listed in a profile no matter what module or a non-module they come from; the second case calls for removing artifacts belonging to the module.

However, uninstalling profiles is not easy. A package can belong to multiple profiles. A package can be installed directly by a package name (or a RPM provide or a file name), not by a profile. And should keep removing transitively dependent packages from foreign modules or non-modules? And if not, why should we stop at a border of one module? Also uninstalling profiles is not enough for purging a module content. There can be artifacts not listed in any profile.

I believe we should follow the rule that uninstalls all artifacts. Because if not, how deeply should we follow the dependency tree? Up to glibc? I woulnd't complicated this feature. It's goal is removing artifacts after resetting a stream. Nothing more. Actually DNF could simply ask after resetting a stream whether a user wants to uninstall the former stream content, so that the user does not have to issue yet another command just to follow recommendation of the same tool.

Comment 10 Jaroslav Mracek 2019-11-21 07:56:18 UTC
I created a pull request (https://github.com/rpm-software-management/dnf/pull/1536) that adds --all option for module remove command. It also adds `module repoquery` command that can be used with --available and --installed options.

Comment 12 Jaroslav Mracek 2019-11-22 07:57:32 UTC
Tests: https://github.com/rpm-software-management/ci-dnf-stack/pull/698

Comment 17 errata-xmlrpc 2020-04-28 16:47:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1823