Bug 1008287

Summary: PackageKit: zypp backend needs implementation for GetDetailsLocal
Product: [openSUSE] openSUSE Tumbleweed Reporter: Dominique Leuenberger <dimstar>
Component: GNOMEAssignee: Jonathan Kang <songchuan.kang>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Enhancement    
Priority: P3 - Medium CC: ma
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 941862, 1012272, 1079825    
Attachments: patch implementing GetDetailsLocal
Implement GetDetailsLocal method in zypp backend

Description Dominique Leuenberger 2016-11-03 10:49:58 UTC
In order to make use of gnome-software's capability to install local files, it requires the PackageKit backend in use to support GetDetailsLocal

The zypp backend exposes the role get-details and this works 'just fine' when querying remote info, but it's not possible to call:

pkcon get-details filename.rpm, e.g.

kcon get-details gnome-software-3.22.1-215.1.0.x86_64.rpm
Getting details               [=========================]         
Finished                      [=========================]         
Fatal error: GetDetailsLocal not supported by backend

For this reason, the RPM handler for gnome-software does not work
Comment 1 Dominique Leuenberger 2016-11-03 11:02:10 UTC
The ROLE would be PK_ROLE_ENUM_GET_DETAILS_LOCAL
Comment 2 Jonathan Kang 2017-04-12 06:38:47 UTC
Created attachment 720884 [details]
patch implementing GetDetailsLocal

Can anyone help review this patch?
Comment 3 Dominique Leuenberger 2017-05-30 20:19:49 UTC
Jonathan - this seems ok-ish; are other backends also copying all RPMs to a temp dir to extract the info from the rpm? No way zypp can read the file directly?
Comment 4 Jonathan Kang 2017-05-31 08:37:11 UTC
(In reply to Dominique Leuenberger from comment #3)
> Jonathan - this seems ok-ish; are other backends also copying all RPMs to a
> temp dir to extract the info from the rpm?
Nope. In dnf backend, they use a function called dnf_sack_add_cmdline_package()
to implement this. This function accepts full path of the rpm file.

> No way zypp can read the file directly?

I'm not quite sure about it, as I am not quite familiar with libzypp atm. The
way I implemented it is learned from the implementation of
backend_install_files_thread() in pk-backend-zypp.cpp.

I admit that it's not a very good solution.
Comment 5 Jonathan Kang 2018-02-09 07:05:32 UTC
@Michael

Could you please help review the patch in comment#2?

Thanks.
Comment 7 Michael Andres 2018-02-21 11:54:28 UTC
(In reply to Dominique Leuenberger from comment #3)
> Jonathan - this seems ok-ish; are other backends also copying all RPMs to a
> temp dir to extract the info from the rpm? No way zypp can read the file
> directly?

https://github.com/openSUSE/libzypp/blob/master/zypp/target/rpm/RpmHeader.h

If you have the header, you can extract the data
Comment 8 Jonathan Kang 2018-02-23 09:10:09 UTC
Created attachment 761391 [details]
Implement GetDetailsLocal method in zypp backend

I've updated the patch according to Michael's advice. But there is still one
issue that I'm aware of how to fix. That is tag_name() function returns NULL for
all the local rpms I tested.

@Michael

Could you please help check what's wrong in this patch?

Thanks
Comment 9 Michael Andres 2018-02-23 11:25:14 UTC
@Jonathan: I can't spot a problem.

Line 2179 (after target::rpm::RpmHeader::constPtr rpmHeader = ...) please add:
> DBG << rpmHeader << endl;
and check the output in /var/log/pk_backend_zypp.
> ReferenceCounted(@0x22ea140<=1){0x23000b0}{sqldeveloper-2.1.1.64.45-1}
It prints `tag_name()-tag_version()-tag_release()`. Works for me as expected.

If you get a nupllptr, I'll need one of the failing rpms and the libzypp version.
Comment 10 Jonathan Kang 2018-02-24 07:56:54 UTC
(In reply to Michael Andres from comment #9)
> @Jonathan: I can't spot a problem.
> 
> Line 2179 (after target::rpm::RpmHeader::constPtr rpmHeader = ...) please
> add:
> > DBG << rpmHeader << endl;
> and check the output in /var/log/pk_backend_zypp.
> > ReferenceCounted(@0x22ea140<=1){0x23000b0}{sqldeveloper-2.1.1.64.45-1}
> It prints `tag_name()-tag_version()-tag_release()`. Works for me as expected.
> 
After adding that line and checking the output in /var/log/pk_backend_zypp, I
found that it works for me as well. It seems that it's the fault of
> pk_backend_job_details ().
Even if I set the second parameter(which is the package id) of this function to
a constant string, for example "testing". The output of "pkcon get-details ..."
is still like this:

> Package description
>   package:     (null)
>   summary:     Simple software installation management software
>   license:     GPL-2.0-or-later
>   ...

I'll investigate more about this.

Thanks for the review.
Comment 11 Jonathan Kang 2018-03-01 02:21:29 UTC
PR created: https://github.com/hughsie/PackageKit/pull/242
Comment 12 Jonathan Kang 2018-03-06 09:37:06 UTC
RESOLVED FIXED.
Comment 14 Swamp Workflow Management 2018-03-08 15:00:07 UTC
This is an autogenerated message for OBS integration:
This bug (1008287) was mentioned in
https://build.opensuse.org/request/show/584461 Factory / PackageKit