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
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.
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?
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.
Bug fixed in version of dnf-2.0.1-1.
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?
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.
(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.
(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
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.