Bug 1138096
Summary: | [doc] add examples on install, resolve, do_transaction api usage | ||||||
---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Parag Nemade <pnemade> | ||||
Component: | dnf | Assignee: | Radek Holy <rholy> | ||||
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
Severity: | unspecified | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | 21 | CC: | akozumpl, jfilak, jsilhan, jzeleny, packaging-team-maint, pnemade, rholy, tim.lauridsen | ||||
Target Milestone: | --- | Keywords: | Reopened | ||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | hawkey-0.5.3-2.fc21 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2015-02-20 08:32:43 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 1156485 | ||||||
Attachments: |
|
Description
Parag Nemade
2014-09-04 05:12:32 UTC
e.g. its not clear to me what api's one need to install a set of packages. Good to give examples in documentation. another thing install api does not return control back to calling program. If I am using following in my plugin code then code gets exit after executing install call and will not continue further in the calling program. <snippet> for pkg in pkgs: print(pkg) try: ######################################################## self.base.install(pkg) ######################################################## except dnf.exceptions.MarkingError: msg = _("No matching package to install: '%s'") % pkg raise dnf.exceptions.Error(msg) <snippet> Hi, thanks for the report. I don't know what's going on in your snippet, it should work if pkg is string object. IMO resolve and do_transaction is clear from the doc. We could write small dnf tutorial from sack loading, package installing, resolve and do_transaction. Created attachment 934398 [details]
sample code that fails
I do have one more query for same install function. attached sample code. Appreciate your help to make it work. @Parag: Look like you are missing the part there download the packages to install https://github.com/timlau/dnf-apiex/blob/master/dnf-install.py#L82 @Tim: Thanks for the pointer. I thought install function call used to take care of downloading the packages. After correcting db.conf.releasever and using download_package() function I got the individual api sample code working now. But now I am trying to understand why same sample code not working in a dnf plugin. self.base.install(pkg) is not working there. Just take an example of builddep.py where also there is this function call self.base.install(reldep_str) this install() in plugins directly do all the steps like resolve, download_packages and do_transaction. Is there any other function for dnf.cli.Command class that will only mark packages for installation and not execute other steps? Further deep analysis reveals that self.base.install() when called from non-plugin code then it goes to --- modulename: base, funcname: install but the same function when called in plugin code its passing through --- modulename: __init__, funcname: base __init__.py(154): return self.cli.base and then both the code pass through dnf/base.py install() function but plugin code execute all the functions automatically like resolve, do_transaction.... I got the install, resolve, do_transaction functions working in an individual code. Therefore closing this bug. *** Bug 1159255 has been marked as a duplicate of this bug. *** It seems that the examples are still needed. Especially during the YUM->DNF porting efforts. I'll take a look. Think that the misunderstanding here is the difference from plugin with a new command [1] to a standalone api program. I a plugin using the dnf.cli.Command many actions like sack setup & execution of the transaction, will be done by the dnf cli, depended of that is set in the dnf.cli.demand.DemandSheet for the new cmd. I a standalone api program, the user need to do everything self. [1] : http://rpm-software-management.github.io/dnf/api_cli.html Tim, thank you for the notice. Nevertheless I think that originally this report concerned the general lack of examples in the documentation. This was the root cause of the Parag's concrete problem. I will emphasise the difference between extensions and plugins in the examples. Some examples have been added by an upstream commit 435b9acb74b71f8deb045a05df8a9c852c828538. dnf-plugins-core-0.1.5-1.fc21,hawkey-0.5.3-2.fc21,dnf-0.6.4-1.fc21 has been submitted as an update for Fedora 21. https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.5-1.fc21,hawkey-0.5.3-2.fc21,dnf-0.6.4-1.fc21 Package hawkey-0.5.3-2.fc21, dnf-plugins-core-0.1.5-1.fc21, dnf-0.6.4-1.fc21: * should fix your issue, * was pushed to the Fedora 21 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing hawkey-0.5.3-2.fc21 dnf-plugins-core-0.1.5-1.fc21 dnf-0.6.4-1.fc21' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2015-2139/dnf-plugins-core-0.1.5-1.fc21,hawkey-0.5.3-2.fc21,dnf-0.6.4-1.fc21 then log in and leave karma (feedback). hawkey-0.5.3-2.fc21, dnf-plugins-core-0.1.5-1.fc21, dnf-0.6.4-1.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report. |