Bug 2036434 - dnf swap with local rpm produces Error: Cannot add local packages, because transaction job already exists
Summary: dnf swap with local rpm produces Error: Cannot add local packages, because tr...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 35
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
Assignee: Marek Blaha
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-01 14:25 UTC by Jan Pazdziora
Modified: 2022-03-14 13:09 UTC (History)
10 users (show)

Fixed In Version: dnf-4.11.1-1.fc37
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-14 13:09:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora 2022-01-01 14:25:04 UTC
Description of problem:

The dnf man page says:

       dnf [options] swap <remove-spec> <install-spec>
          Remove  spec and install spec in one transaction. Each <spec> can be
          either a <package-spec>, which specifies a package  directly,  or  a
          @<group-spec>, which specifies an (environment) group which contains
          it. Automatic conflict solving is provided in DNF  by  the  --allow‐
          erasing  option  that provides the functionality of the swap command
          automatically.

It is not clear if <package-spec> is just N(E(V(R(A)))) or if it can also be local rpm file. The man page also says

       For an explanation of <package-spec>,  <package-file-spec>  and
       <package-name-spec> see Specifying Packages.

and

  SPECIFYING PACKAGES
       Many  commands  take  a <package-spec> parameter that selects a package
       for the operation. The <package-spec> argument is matched against pack‐
       age NEVRAs, provides and file provides.

which would suggest local rpm cannot be used as <package-spec> ... but then

       dnf [options] install <spec>...
              Makes  sure  that  the given packages and their dependencies are
              installed  on  the  system.  Each  <spec>  can   be   either   a
              <package-spec>,  or  a  @<module-spec>, or a @<group-spec>.  See
              Install Examples.

and

   Install Examples
       dnf install tito
              Install the tito package (tito is the package name).

       dnf install ~/Downloads/tito-0.6.2-1.fc22.noarch.rpm
              Install a local rpm file tito-0.6.2-1.fc22.noarch.rpm  from  the
              ~/Downloads/ directory.

show that ~/Downloads/tito-0.6.2-1.fc22.noarch.rpm is accepted by install's <package-spec>, leading to conclusion that dnf swap should accept local rpm file as well.

However, attempt to use local rpm file for swap's <install-spec> fails.

Version-Release number of selected component (if applicable):

dnf-4.9.0-1.fc35.noarch

How reproducible:

Deterministic.

Steps to Reproduce:
1. Check that swap in general works:

# dnf swap tar apr
Dependencies resolved.
================================================================================
 Package      Architecture    Version                  Repository          Size
================================================================================
Installing:
 apr          x86_64          1.7.0-14.fc35            fedora             123 k
Removing:
 tar          x86_64          2:1.34-2.fc35            @anaconda          3.0 M

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

Total size: 123 k
Is this ok [y/N]: n
Operation aborted.

2. Download the package as local rpm:

# dnf install --downloadonly -y apr
[...]

DNF will only download packages for the transaction.
Downloading Packages:
apr-1.7.0-14.fc35.x86_64.rpm                    2.1 MB/s | 123 kB     00:00    
--------------------------------------------------------------------------------
Total                                           818 kB/s | 123 kB     00:00     
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.

3. find /var/cache/dnf -name 'apr*.rpm'
/var/cache/dnf/fedora-37d3cae0527b6391/packages/apr-1.7.0-14.fc35.x86_64.rpm

4. Check that installing local rpm in general works:

# dnf install /var/cache/dnf/fedora-37d3cae0527b6391/packages/apr-1.7.0-14.fc35.x86_64.rpm
[...]
Dependencies resolved.
================================================================================
 Package     Architecture   Version                  Repository            Size
================================================================================
Installing:
 apr         x86_64         1.7.0-14.fc35            @commandline         123 k

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

Total size: 123 k
Installed size: 289 k
Is this ok [y/N]: n
Operation aborted.

5. Now try to swap with local rpm file:

# dnf swap tar /var/cache/dnf/fedora-37d3cae0527b6391/packages/apr-1.7.0-14.fc35.x86_64.rpm

Actual results:

Error: Cannot add local packages, because transaction job already exists

Expected results:

Dependencies resolved.
================================================================================
 Package      Architecture    Version                  Repository          Size
================================================================================
Installing:
 apr          x86_64          1.7.0-14.fc35            @commandline       123 k
Removing:
 tar          x86_64          2:1.34-2.fc35            @anaconda          3.0 M

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

Total size: 123 k
Is this ok [y/N]: n
Operation aborted.

Additional info:

Of course the real use-case is to use something like

# dnf swap 'centos-*' ./redhat-release-8.5-0.8.el8.x86_64.rpm

on CentOS Linux 8 but the above reproducer shows that swap acts weird on Fedora as well.

Comment 3 Jan Pazdziora 2022-01-04 09:13:30 UTC
Would it make sense to also update the man page to clarify in which situations <package-spec> can be a local rpm file?

Comment 4 Marek Blaha 2022-01-04 09:48:52 UTC
It definitely would. I'll take a look.

Comment 5 Fedora Update System 2022-03-14 13:07:23 UTC
FEDORA-2022-e119fcc7d5 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-e119fcc7d5

Comment 6 Fedora Update System 2022-03-14 13:09:49 UTC
FEDORA-2022-e119fcc7d5 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.


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