Commit 222122cb authored by Alessandro Astone's avatar Alessandro Astone Committed by Aleix Pol Gonzalez
Browse files

pk: Consider multiple package ids for one upgradeable resource

One package may be installed with multiple architectures, and thus
the package name shall not be considered unique for the update
transaction.

There are a few ways to achieve that, but this is the one that
requires the less refactoring of the packagekit backend.

BUG: 444600


(cherry picked from commit 4907ad07)
parent 6e26b05f
Pipeline #159133 passed with stage
in 1 minute and 32 seconds
......@@ -755,14 +755,15 @@ static QStringRef TransactionpackageName(const QString &packageID)
return ret;
}
QString PackageKitBackend::upgradeablePackageId(const PackageKitResource *res) const
QSet<QString> PackageKitBackend::upgradeablePackageId(const PackageKitResource *res) const
{
QSet<QString> ids;
const QString name = res->packageName();
for (const QString &pkgid : m_updatesPackageId) {
if (TransactionpackageName(pkgid) == name)
return pkgid;
ids.insert(pkgid);
}
return QString();
return ids;
}
void PackageKitBackend::fetchDetails(const QSet<QString> &pkgid)
......
......@@ -52,7 +52,7 @@ public:
bool isFetching() const override;
bool isPackageNameUpgradeable(const PackageKitResource *res) const;
QString upgradeablePackageId(const PackageKitResource *res) const;
QSet<QString> upgradeablePackageId(const PackageKitResource *res) const;
QVector<AppPackageKitResource *> extendedBy(const QString &id) const;
void resolvePackages(const QStringList &packageNames);
......
......@@ -51,9 +51,9 @@ QStringList PackageKitResource::allPackageNames() const
QString PackageKitResource::availablePackageId() const
{
// First we check if it's upgradeable and use this version to display
const QString pkgid = backend()->upgradeablePackageId(this);
if (!pkgid.isEmpty())
return pkgid;
const QSet<QString> pkgids = backend()->upgradeablePackageId(this);
if (!pkgids.isEmpty())
return *pkgids.constBegin();
const auto it = m_packages.constFind(PackageKit::Transaction::InfoAvailable);
if (it != m_packages.constEnd())
......
......@@ -113,9 +113,9 @@ public:
QSet<QString> donePkgs;
for (auto res : qAsConst(m_resources)) {
PackageKitResource *app = qobject_cast<PackageKitResource *>(res);
QString pkgid = m_backend->upgradeablePackageId(app);
if (!donePkgs.contains(pkgid)) {
donePkgs.insert(pkgid);
QString pkgname = app->packageName();
if (!donePkgs.contains(pkgname)) {
donePkgs.insert(pkgname);
ret += app;
}
}
......@@ -336,13 +336,13 @@ QSet<QString> PackageKitUpdater::involvedPackages(const QSet<AbstractResource *>
}
PackageKitResource *app = qobject_cast<PackageKitResource *>(res);
const QString pkgid = m_backend->upgradeablePackageId(app);
if (pkgid.isEmpty()) {
const QSet<QString> ids = m_backend->upgradeablePackageId(app);
if (ids.isEmpty()) {
qWarning() << "no upgradeablePackageId for" << app;
continue;
}
packageIds.insert(pkgid);
packageIds.unite(ids);
}
return packageIds;
}
......@@ -739,9 +739,9 @@ double PackageKitUpdater::updateSize() const
}
PackageKitResource *app = qobject_cast<PackageKitResource *>(res);
QString pkgid = m_backend->upgradeablePackageId(app);
if (!donePkgs.contains(pkgid)) {
donePkgs.insert(pkgid);
QString pkgname = app->packageName();
if (!donePkgs.contains(pkgname)) {
donePkgs.insert(pkgname);
ret += app->size();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment