RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1682969 - [RFE] - equivalent of yumdb for RHEL 8 dnf
Summary: [RFE] - equivalent of yumdb for RHEL 8 dnf
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.0
Assignee: Daniel Mach
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-26 00:51 UTC by Ryan Mullett
Modified: 2019-12-03 15:55 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-08 08:19:06 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3939111 0 Install None Missing yumdb functionality on RHEL 8 2019-02-26 01:09:19 UTC

Description Ryan Mullett 2019-02-26 00:51:46 UTC
Description of problem:
- Would like to be able to modify their dnf database by marking a package as non-userinstalled
- This is important for government customers that have requirements to ensure there are no packages left on the system that were manually installed

Version-Release number of selected component (if applicable):
- All versions of dnf on RHEL 8

How reproducible:
Always

Steps to Reproduce:
Assuming that we needed to install package-b, it is a common scenario that a sysadmin may fulfill the dependencies manually (especially for third-party packages). If it is later determined that package-b is not needed, and we remove it, there is no way to mark package-a as not user-installed, because the functionality from yumdb in previous RHEL versions is not available for RHEL 8

1. Install package-a manually using rpm or even dnf to fulfill a dependency
2. Install package-b which requires package-a

Another example, provided by a customer:
1. User A needs "libZ" for testing.  It is installed by the admin.
2. User B needs "ProjectY" which depends on "libZ"
3. User A concludes that "libZ" does not meet his need and no longer requires it.  It can't be removed at this time due to dependency of "ProjectY"
4. User B decides that "ProjectX" meets his need better than "ProjectY".  Admin removes "ProjectY" with 'yum autoremove', but "libZ" stays because it was previously requested explicitly.

There is a dangling leaf node "libZ" that we could have eliminated if at Step 3, we'd marked it as no longer required.  We do this today on RHEL 7 with 'yumdb set reason dep "libZ"'

Actual results:
- No functional replacement for yumdb on RHEL 8

Expected results:
- Need some functional equivalent of yumdb to modify the rpmdb/dnf database in a way similar to this. For example if you wanted to change the installed reason for tzdata from userinstalled to dependency:
   # 'yumdb set reason dep tzdata ; yum autoremove'

Additional info:

Comment 2 Kyle Walker 2019-03-15 19:17:23 UTC
Based on the example operation above, I believe that the YUM4/DNF workflow for accomplishing that operation is to make use of the "mark" command. 

   Mark Command
       dnf mark install <package-specs>...
              Marks  the specified packages as installed by user. This can be useful if any package was installed as
              a dependency and is desired to stay on the system when Auto Remove Command  or  Remove  Command  along
              with clean_requirements_on_remove configuration option set to True is executed.

       dnf mark remove <package-specs>...
              Unmarks  the  specified  packages  as  installed by user. Whenever you as a user don't need a specific
              package you can mark it for removal. The package stays installed on the system  but  will  be  removed
              when  Auto  Remove  Command  or  Remove  Command along with clean_requirements_on_remove configuration
              option set to True is executed. You should use this operation instead of Remove Command if you're  not
              sure whether the package is a requirement of other user installed packages on the system.

       dnf mark group <package-specs>...
              Marks the specified packages as installed by group. This can be useful if any package was installed as
              a dependency or a user and is desired to be protected and handled as a group member like during  group
              remove.


Using the example given:

    Making the following package dependency tree:


    Legend:
        -------------
        req = Requires
        pro = Provides
        rec = Recommends
        sup = Supplements
        sug = Suggests
        enh = Enhances
        -------------

        +----------+  +----------+
        | ProjectY |  | ProjectX |
        +----------+  +----------+
             |
            req
             v
        +---------+
        |  libZ   |
        +---------+

    Moving YUM repositoriy created in /tmp/tmp376bqsfv to /root/repos/test-repo
    Cleaning up the temporary directory
    Use the following command to test:

    sudo yum --nogpgcheck --disablerepo=* --repofrompath=test,file:///root/repos/test-repo


Following the process outlined:

1. User A needs "libZ" for testing.  It is installed by the admin.

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck install libZ
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Last metadata expiration check: 0:08:00 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    =======================================================================================================================
     Package                    Arch                         Version                      Repository                  Size
    =======================================================================================================================
    Installing:
     libZ                       x86_64                       0.1-1                        test                       6.0 k

    Transaction Summary
    =======================================================================================================================
    Install  1 Package

    Total size: 6.0 k
    Installed size: 0
    Is this ok [y/N]: y
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                               1/1
      Installing       : libZ-0.1-1.x86_64                                                                             1/1
      Verifying        : libZ-0.1-1.x86_64                                                                             1/1
    Installed products updated.

    Installed:
      libZ-0.1-1.x86_64

    Complete!

2. User B needs "ProjectY" which depends on "libZ"

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck install ProjectY
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Last metadata expiration check: 0:09:02 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    =======================================================================================================================
     Package                       Arch                        Version                     Repository                 Size
    =======================================================================================================================
    Installing:
     ProjectY                      x86_64                      0.1-1                       test                      6.0 k

    Transaction Summary
    =======================================================================================================================
    Install  1 Package

    Total size: 6.0 k
    Installed size: 0
    Is this ok [y/N]: y
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                               1/1
      Installing       : ProjectY-0.1-1.x86_64                                                                         1/1
      Verifying        : ProjectY-0.1-1.x86_64                                                                         1/1
    Installed products updated.

    Installed:
      ProjectY-0.1-1.x86_64

    Complete!


3. User A concludes that "libZ" does not meet his need and no longer requires it.  It can't be removed at this time due to dependency of "ProjectY"

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck remove libZ
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Dependencies resolved.
    =======================================================================================================================
     Package                       Arch                        Version                    Repository                  Size
    =======================================================================================================================
    Removing:
     libZ                          x86_64                      0.1-1                      @test                        0
    Removing dependent packages:
     ProjectY                      x86_64                      0.1-1                      @test                        0

    Transaction Summary
    =======================================================================================================================
    Remove  2 Packages

    Freed space: 0
    Is this ok [y/N]: n
    Operation aborted.


4. User B decides that "ProjectX" meets his need better than "ProjectY".  Admin removes "ProjectY" with 'yum autoremove', but "libZ" stays because it was previously requested explicitly.

To demonstrate the above, I am using the "swap" command as it shows the intended behaviour of moving from ProjectY to ProjectX:

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck swap ProjectY ProjectX
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Last metadata expiration check: 0:11:51 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    =======================================================================================================================
     Package                       Arch                        Version                    Repository                  Size
    =======================================================================================================================
    Installing:
     ProjectX                      x86_64                      0.1-1                      test                       6.0 k
    Removing:
     ProjectY                      x86_64                      0.1-1                      @test                        0

    Transaction Summary
    =======================================================================================================================
    Install  1 Package
    Remove   1 Package

    Total size: 6.0 k
    Is this ok [y/N]: y
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                               1/1
      Installing       : ProjectX-0.1-1.x86_64                                                                         1/2
      Erasing          : ProjectY-0.1-1.x86_64                                                                         2/2
      Verifying        : ProjectX-0.1-1.x86_64                                                                         1/2
      Verifying        : ProjectY-0.1-1.x86_64                                                                         2/2
    Installed products updated.

    Installed:
      ProjectX-0.1-1.x86_64

    Removed:
      ProjectY-0.1-1.x86_64

    Complete!

Though the above swap operation doesn't remove libZ in this first step, due to the indicated dangling leaf behaviour. It will not be removed with an autoremove either.

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck autoremove                                                                                                         
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Last metadata expiration check: 0:24:21 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    Nothing to do.
    Complete!


It is easily rectified with mark:

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck mark remove libZ
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    libZ-0.1-1.x86_64 unmarked as user installed.

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck autoremove
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo 
    Last metadata expiration check: 0:13:10 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    =======================================================================================================================
     Package                    Arch                         Version                     Repository                   Size
    =======================================================================================================================
    Removing:               
     libZ                       x86_64                       0.1-1                       @test                         0
    
    Transaction Summary
    =======================================================================================================================
    Remove  1 Package
    
    Freed space: 0
    Is this ok [y/N]: y
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction                                                                                            
      Preparing        :                                                                                               1/1
      Erasing          : libZ-0.1-1.x86_64                                                                             1/1
      Verifying        : libZ-0.1-1.x86_64                                                                             1/1
    Installed products updated.
    
    Removed:
      libZ-0.1-1.x86_64
    
    Complete!


Note, this can also be done prior to the swap and libZ will be removed in the same operation due to the behaviour of the clean_requirements_on_remove configuration option.

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck mark remove libZ
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    libZ-0.1-1.x86_64 unmarked as user installed.

    # yum --disablerepo=* --repofrompath=test,file:///root/repos/test-repo --nogpgcheck swap ProjectY ProjectX                                                                                                                               
    Updating Subscription Management repositories.
    Added test repo from file:///root/repos/test-repo
    Last metadata expiration check: 0:16:56 ago on Fri 15 Mar 2019 02:52:27 PM EDT.
    Dependencies resolved.
    =======================================================================================================================
     Package                       Arch                        Version                    Repository                  Size
    =======================================================================================================================
    Installing:
     ProjectX                      x86_64                      0.1-1                      test                       6.0 k
    Removing:
     ProjectY                      x86_64                      0.1-1                      @test                        0
    Removing unused dependencies:
     libZ                          x86_64                      0.1-1                      @test                        0

    Transaction Summary
    =======================================================================================================================
    Install  1 Package
    Remove   2 Packages

    Total size: 6.0 k
    Is this ok [y/N]: y
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                               1/1
      Installing       : ProjectX-0.1-1.x86_64                                                                         1/3
      Erasing          : ProjectY-0.1-1.x86_64                                                                         2/3
      Erasing          : libZ-0.1-1.x86_64                                                                             3/3
      Verifying        : ProjectX-0.1-1.x86_64                                                                         1/3
      Verifying        : ProjectY-0.1-1.x86_64                                                                         2/3
      Verifying        : libZ-0.1-1.x86_64                                                                             3/3
    Installed products updated.

    Installed:
      ProjectX-0.1-1.x86_64

    Removed:
      ProjectY-0.1-1.x86_64                                        libZ-0.1-1.x86_64

    Complete!


I would recommend using that command set to implement this behaviour as opposed to altering the underlying database itself. Are there any other operations that the "yumdb" command is needed for?

- Kyle Walker

Comment 4 Daniel Mach 2019-07-08 08:18:45 UTC
The yumdb functionality is not intended to be forward-ported to the DNF project. Per comment #2, the end goal can be achieved via other supported commands. In the event that there is further usability issues identified as missing, and needing yumdb functionality, please reopen this bug report with that need identified.

Comment 5 Daniel Mach 2019-07-08 08:19:06 UTC
The yumdb functionality is not intended to be forward-ported to the DNF project. Per comment #2, the end goal can be achieved via other supported commands. In the event that there is further usability issues identified as missing, and needing yumdb functionality, please reopen this bug report with that need identified.


Note You need to log in before you can comment on or make changes to this bug.