Bug 1403465 - [RFE] Transaction modifiers for "dnf install" and "dnf remove"
[RFE] Transaction modifiers for "dnf install" and "dnf remove"
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
rawhide
Unspecified Unspecified
medium Severity unspecified
: ---
: ---
Assigned To: rpm-software-management
Fedora Extras Quality Assurance
: FutureFeature, Reopened, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-12-10 09:32 EST by Neal Gompa
Modified: 2017-05-23 13:50 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-05-23 13:50:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Neal Gompa 2016-12-10 09:32:23 EST
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 07:41:45 EST
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 15:54:08 EST
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 08:43:47 EST
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 11:03:52 EST
Bug fixed in version of dnf-2.0.1-1.
Comment 5 Neal Gompa 2017-04-13 05:54:12 EDT
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 06:30:30 EDT
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 07:04:56 EDT
(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 11:09:51 EDT
(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 13:50:42 EDT
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.