Skip to content

Commit

Permalink
fix: not compare the arch during install layer/uab
Browse files Browse the repository at this point in the history
-

Log:
  • Loading branch information
kamiyadm committed Oct 24, 2024
1 parent ca6551e commit 41dd7ea
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions libs/linglong/src/linglong/package_manager/package_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ QVariantMap PackageManager::installFromLayer(const QDBusUnixFileDescriptor &fd)
}

const auto &packageInfo = *packageInfoRet;

auto architectureRet = package::Architecture::parse(packageInfo.arch[0]);
if (!architectureRet) {
return toDBusReply(architectureRet);
}

auto currentArch = package::Architecture::currentCPUArchitecture();
Q_ASSERT(currentArch.has_value());
if (*architectureRet != *currentArch) {
return toDBusReply(-1,
"app arch:" + architectureRet->toString()
+ " not match host architecture");
}

auto versionRet = package::Version::parse(QString::fromStdString(packageInfo.version));
if (!versionRet) {
return toDBusReply(versionRet);
Expand All @@ -201,11 +215,6 @@ QVariantMap PackageManager::installFromLayer(const QDBusUnixFileDescriptor &fd)
}
}

auto architectureRet = package::Architecture::parse(packageInfo.arch[0]);
if (!architectureRet) {
return toDBusReply(architectureRet);
}

auto packageRefRet = package::Reference::create(QString::fromStdString(packageInfo.channel),
QString::fromStdString(packageInfo.id),
*versionRet,
Expand Down Expand Up @@ -331,6 +340,14 @@ QVariantMap PackageManager::installFromUAB(const QDBusUnixFileDescriptor &fd) no
return toDBusReply(architectureRet);
}

auto currentArch = package::Architecture::currentCPUArchitecture();
Q_ASSERT(currentArch.has_value());
if (*architectureRet != *currentArch) {
return toDBusReply(-1,
"app arch:" + architectureRet->toString()
+ " not match host architecture");
}

auto appRefRet = package::Reference::create(QString::fromStdString(appLayer.info.channel),
QString::fromStdString(appLayer.info.id),
*versionRet,
Expand Down

0 comments on commit 41dd7ea

Please sign in to comment.