Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1403465 - [RFE] Transaction modifiers for "dnf install" and "dnf remove"
Summary: [RFE] Transaction modifiers for "dnf install" and "dnf remove"
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: dnf-community
TreeView+ depends on / blocked
 
Reported: 2016-12-10 14:32 UTC by Neal Gompa
Modified: 2021-03-03 22:59 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-23 17:50:42 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Neal Gompa 2016-12-10 14:32:23 UTC
Description of problem:
Zypper supports using transaction modifiers in "zypper install" and "zypper remove" so that you can have both installs and removes in the same transaction.

For example, you can do "zypper install emacs-nox -vim" or "zypper remove +vim emacs-nox" to swap between emacs and vim. 

I'd like to propose that DNF supports a similar syntax:

dnf install <inpkg> -<rmpkg>

dnf remove +<inpkg> <rmpkg>

These args can be stacked and used in any order, though special handling has to be done for -<rmpkg>, as it *could* look like an argument. Zypper has to do something like that as well, see the man page: https://en.opensuse.org/SDB:Zypper_manual_(plain)

This would be a superior alternative to "yum swap" because you can have multiple changes specified at once. For example:

dnf install nginx -httpd php-fpm -php
dnf remove +python3-nikola wordpress +python3-nikola-extras

Version-Release number of selected component (if applicable):
2.0.0-0.rc2.5.fc26

Comment 1 Michal Luscon 2016-12-12 12:41:45 UTC
Hi Neal,

as you probably know, there will be a DNF swap command implemented soon which will provide the same capabilities. We think that the development and the maintenance cost of this feature is not worth it.

Comment 2 Neal Gompa 2016-12-13 20:54:08 UTC
But the swap command doesn't let you specify more than one single package swap. Do you plan to extend swap to support defining a full transaction via the swap command?

Comment 3 Jaroslav Mracek 2016-12-15 13:43:47 UTC
Here is the PR (https://github.com/rpm-software-management/dnf/pull/679) that provides swap command. We support only syntax "dnf [options] swap <remove-spec> <install-spec>" . If user wants to do something more complicated, it will be possible to use dnf shell from PR: https://github.com/rpm-software-management/dnf/pull/658.

Comment 4 Jaroslav Mracek 2017-02-10 16:03:52 UTC
Bug fixed in version of dnf-2.0.1-1.

Comment 5 Neal Gompa 2017-04-13 09:54:12 UTC
How does this help for the scripting use case? Is there a way to pass a set of "dnf shell" commands to make it happen as one transaction?

Comment 6 Ian.Arkver 2017-04-13 10:30:30 UTC
It would still be useful to have the ability to install, upgrade or remove packages all in one command. Ideally this would work at least for dnf upgrade and dnf distro-sync.

In the past "smart upgrade" accepted a +package (and was supposed to accept -package, though this was broken), as part of a list of packages, for example...

smart upgrade emacs -vim +vile

would upgrade emacs, remove vim and install vile.

This is useful for example, in scenarios where the package processing list comes from somewhere remote via some non-interactive mechanism.

Comment 7 Honza Silhan 2017-04-13 11:04:56 UTC
(In reply to Neal Gompa from comment #5)
> How does this help for the scripting use case? Is there a way to pass a set
> of "dnf shell" commands to make it happen as one transaction?

hmm, even "bashism" using "<<<" does not work for dnf shell.

FTR this behavior is supported in yum and could be considered as part of DNF-yum compatibility and even implementing this would be relatively easy. PR from contributors on this issue will be welcomed and guidance provided.

Otherwise considering the capacity of reduced DNF team and priorities, this could be implemented by DNF team in 6 - 12 months.

Comment 8 Jaroslav Rohel 2017-04-13 15:09:51 UTC
(In reply to Neal Gompa from comment #5)
> How does this help for the scripting use case? Is there a way to pass a set
> of "dnf shell" commands to make it happen as one transaction?

Yes there is a way. At least with the current version dnf (2.3.x). User can create file with dnf commands - one command per line. Example of removing and installing more packages in one transaction:

Content of prepared file:
# cat dnf_shell_script.txt 
remove iftop
install iptstate
install htop
remove tcpdump
transaction run

Start dnf shell with prepared file:
# dnf shell dnf_shell_script.txt

User can add -y or --assumeyes option to dnf shell for automatically answer yes for questions:
# dnf -y shell dnf_shell_script.txt

------------
Another approach:
echo -e 'remove iftop \n install iptstate \n install htop \n remove tcpdump \n ts run' | dnf -y shell

Comment 9 Jaroslav Mracek 2017-05-23 17:50:42 UTC
Another possibility with "dnf shell" is write directly script in terminal. As it was mentioned, the request is solved by "dnf shell" command that was implemented in dnf-2.3.x that was released into rawhide or Fedora 26.


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