Bug 383032

Summary: Can't get installed package information when it's not in mirror
Product: [Unmaintained] libqapt Reporter: sbw <sbw>
Component: generalAssignee: Harald Sitter <sitter>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description sbw 2017-08-02 05:54:28 UTC
When install a .deb file which not in any mirror. there is no way to get this package installed information (even no way to test this package is installed or not).

because any package information is getting from Package class, if some package is installed but not in mirror, we can't get this Package object from Backend.
Comment 1 Harald Sitter 2017-08-02 08:26:28 UTC
works just fine.

$ cat src/main.cpp 
#include <QApplication>

#include <QApt/Backend>
#include <QDebug>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QApt::Backend backend;
    backend.init();
    auto pkg = backend.package("discord");
    Q_ASSERT(pkg);
    qDebug() << pkg->isInstalled();
    qDebug() << pkg->version();
}

$ ./build/src/test      
test(18175)/(default) main: true
test(18175)/(default) main: "0.0.1"


$ apt policy discord
discord:
  Installed: 0.0.1
  Candidate: 0.0.1
  Version table:
 *** 0.0.1 100
        100 /var/lib/dpkg/status
Comment 2 sbw 2017-08-03 10:24:48 UTC
Okey, I checked my code and find some reason.

I'm install a 32-bit deb file in 64-bit system, and call backend.package("somename") will return a null pointer, but backend.package("somename:i386") will get right info.