Bug 1073859 - [api][rfe] access to dnf.Base.goal_parameters.allow_uninstall
[api][rfe] access to dnf.Base.goal_parameters.allow_uninstall
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
20
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 1066869
  Show dependency treegraph
 
Reported: 2014-03-07 06:08 EST by Tim Lauridsen
Modified: 2014-05-31 19:58 EDT (History)
4 users (show)

See Also:
Fixed In Version: dnf-plugins-core-0.0.8-2.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-05-31 19:58:44 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 Tim Lauridsen 2014-03-07 06:08:44 EST
Description of problem:

If I want to install a package named "foobar" it is pretty simple
using dnf.base.Base.install('foobar') to add it to current Hawkey.Goal object.

But if I allready have a package object for the "foobar" package it not possible
with public api.

I could use dnf.base.Base._goal.install(po), but the it is not public api

the dnf.transaction.Transaction.add_install() is not very useful, because it is
first defined after the depsolve.

Possible solutions
 - make the current Hawkey.Goal available 
 - add a install(po=package_object) option to Base.instal(), upgrade(), etc

The use-case in a package gui like yumex, the user select a number of packages and the actions to perform on them. so we know the exact package object and the action to perform, so we just want to fill up the Hawkey.Goal and the depsolve, download, run transaction


Version-Release number of selected component (if applicable):
0.4.17
Comment 1 Ales Kozumplik 2014-03-07 07:58:38 EST
Indeed, we need to enable this, thanks for the report.
Comment 2 Radek Holy 2014-03-07 08:17:15 EST
I would be careful with making Base._goal public. If we did, I would rewrite Base.install (and friends) to just return packages (instead of modifying the goal object), because it then might become not clear whether an API user should use Base.install or Base.goal.install. On the other hand, I would appreciate possibility to query the content of the goal.

I also did not like the Yum's approach of using keyword arguments in Base.install where in fact, it wasn't possible to use both arguments at once. I would prefer two different methods.
Comment 3 Ales Kozumplik 2014-03-07 08:20:10 EST
(In reply to Radek Holy from comment #2)
> I would be careful with making Base._goal public. If we did, I would rewrite
> Base.install (and friends) to just return packages (instead of modifying the
> goal object), 

Also it would need to return selectors.

> because it then might become not clear whether an API user
> should use Base.install or Base.goal.install. On the other hand, I would
> appreciate possibility to query the content of the goal.
> 
> I also did not like the Yum's approach of using keyword arguments in
> Base.install where in fact, it wasn't possible to use both arguments at
> once. I would prefer two different methods.

The fact is it's tricky. We don't want to end up with what Yum had in YumBase.install() for arguments, that's for sure.
Comment 4 Tim Lauridsen 2014-03-07 08:23:31 EST
(In reply to Radek Holy from comment #2)
> I would be careful with making Base._goal public. If we did, I would rewrite
> Base.install (and friends) to just return packages (instead of modifying the
> goal object), because it then might become not clear whether an API user
> should use Base.install or Base.goal.install. On the other hand, I would
> appreciate possibility to query the content of the goal.
> 
> I also did not like the Yum's approach of using keyword arguments in
> Base.install where in fact, it wasn't possible to use both arguments at
> once. I would prefer two different methods.

What about extending install(pkgspec) (and friend) to check if pkgspec is a string or a pkg object.
Comment 5 Ales Kozumplik 2014-03-07 08:25:34 EST
Alternatively, it would be sufficient to expose 'reponame' argument of install() et. al.
Comment 6 Radek Holy 2014-03-07 08:37:49 EST
For the record, I had two ideas:

1) a possibility to inject own instance of the goal (then both sets of methods will be available)

2) change the argument of Base methods to a Query/Selector type, which provides much more possibilities to specify a package (however, it won't help Tim with his use case)
Comment 7 Tim Lauridsen 2014-03-07 08:39:44 EST
(In reply to Ales Kozumplik from comment #5)
> Alternatively, it would be sufficient to expose 'reponame' argument of
> install() et. al.

po = some package obj
base.install(str(po),reponame=po.reponame)

could be a workaround for my use case
Comment 8 Tim Lauridsen 2014-03-07 08:45:24 EST
(In reply to Radek Holy from comment #6)
> For the record, I had two ideas:
> 
> 1) a possibility to inject own instance of the goal (then both sets of
> methods will be available)
> 

Could be a way to go

> 2) change the argument of Base methods to a Query/Selector type, which
> provides much more possibilities to specify a package (however, it won't
> help Tim with his use case)

This will make the use of the API more complex, I like the possibility
to do simple actions like

bas.install('foobar')

or 

base.install('foobar.x86_64')
Comment 9 Radek Holy 2014-03-07 08:58:38 EST
Or add a possibility to specify a repo via the pkg_spec.
Comment 10 Tim Lauridsen 2014-03-07 09:49:47 EST
(In reply to Radek Holy from comment #9)
> Or add a possibility to specify a repo via the pkg_spec.

pkgspec = 'spring-88.0-2.fc17.x86_64@updates'
base.install(pkgspec)

when we are talking about it

what about local file .rpm file support

currently the Base.*_local methods is not public api
Comment 11 Tim Lauridsen 2014-03-12 07:41:24 EDT
Another related issue.

dnf.Base.goal_parameters should be public api

without setting 
dnf.Base.goal_parameters.allow_uninstall = True

then remove is kind of useless, because you can't remove a package, something else is depending on.

Example
https://github.com/timlau/dnf-apiex/blob/master/dnf-remove.py
try without  
self.goal_parameters.allow_uninstall = True and it will fail
Comment 12 Tim Lauridsen 2014-03-15 03:34:09 EDT
After getting a little futher with my implemention, I will sum it up:

1. the current install, upgrade ... API will solve my need, if the reponame parameter is made public API.[1]

2. install_local is needed as public API, to support installation of local .rpm [1]

3. need to read the dnf.Base._goal object to get the content of the Hawkay.Goal.

This would be enough for my usecase



[1] : https://github.com/timlau/dnf-daemon/blob/master/dnfdaemon/dnfdaemon-system.py#L537

[2] : https://github.com/timlau/dnf-daemon/blob/master/dnfdaemon/dnfdaemon-system.py#L1012
Comment 13 Tim Lauridsen 2014-03-15 11:40:48 EDT
3. need to read the dnf.Base._goal object to get the content of the Hawkay.Goal.
is not needed anyway, have to call resolve() for be able to read the result from the Goal object and then the transaction will be populated anyway, so I can get the results from the transaction.

So the list is down to:

1. the current install, upgrade ... API will solve my need, if the reponame parameter is made public API

2. install_local is needed as public API, to support installation of local .rpm 

and dnf.Base.goal_parameters (comment 11)
Comment 14 Tim Lauridsen 2014-03-21 14:43:48 EDT
Updated the title of the report, to match the outstanding issues
Comment 15 Tim Lauridsen 2014-03-28 09:16:18 EDT
Looks like most of my usecase is fixed upstream

https://github.com/akozumpl/dnf/commit/64bd3c27fe2e8b946794beab59f3a7f2c3f9dd66

The only outstanding issue is

dnf.Base.goal_parameters.allow_uninstall = True

is need to remove packages with deps.

maybe it should be True by default
Comment 16 Ales Kozumplik 2014-03-28 10:24:58 EDT
Thanks for the quick feedback Tim, updated the bugzilla title.
Comment 17 Ales Kozumplik 2014-04-03 10:07:53 EDT
Fulfilled by 162d881, the clients can now tell Base.resolve() via a parameter whether they want to allow the solver to remove packages:

   base.resolve(allow_erasing=True)
Comment 18 Tim Lauridsen 2014-04-03 11:23:01 EDT
Nice, Thanks
Comment 19 Fedora Update System 2014-05-02 04:32:21 EDT
dnf-0.5.1-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-0.5.1-1.fc20
Comment 20 Fedora Update System 2014-05-02 17:04:54 EDT
Package dnf-0.5.1-1.fc20, hawkey-0.4.14-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.5.1-1.fc20 hawkey-0.4.14-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-5937/hawkey-0.4.14-1.fc20,dnf-0.5.1-1.fc20
then log in and leave karma (feedback).
Comment 21 Fedora Update System 2014-05-28 08:10:12 EDT
dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/libsolv-0.6.1-1.git6d968f1.fc20,hawkey-0.4.16-1.fc20,dnf-0.5.2-1.fc20,dnf-plugins-core-0.0.8-2.fc20
Comment 22 Fedora Update System 2014-05-28 19:50:10 EDT
Package dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.0.8-2.fc20 libsolv-0.6.1-1.git6d968f1.fc20 hawkey-0.4.16-1.fc20 dnf-0.5.2-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-6789/libsolv-0.6.1-1.git6d968f1.fc20,hawkey-0.4.16-1.fc20,dnf-0.5.2-1.fc20,dnf-plugins-core-0.0.8-2.fc20
then log in and leave karma (feedback).
Comment 23 Fedora Update System 2014-05-31 19:58:44 EDT
dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, 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.