Skip to content

Commit

Permalink
rpm-ostree: Fix version checks for container path
Browse files Browse the repository at this point in the history
Starting with rpm-ostree v2024.3, the version is only set with the
'org.opencontainers.image.version' label and no longer with the
'version' one.

Check the new label first and the old one second to be compatible with
all images.

See:
- https://github.com/coreos/rpm-ostree/releases/tag/v2024.3
- coreos/rpm-ostree#4794
- ostreedev/ostree-rs-ext#581
  • Loading branch information
travier committed Mar 18, 2024
1 parent 759593a commit 48adb8f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions libdiscover/backends/RpmOstreeBackend/RpmOstreeTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,17 @@ void RpmOstreeTransaction::processCommand(int exitCode, QProcess::ExitStatus exi
return;
}

// Get the version stored in .Labels.version
const QString newVersion = jsonDocument.object().value("Labels").toObject().value("version").toString();
// Get the version stored in 'org.opencontainers.image.version' label
QString newVersion =
jsonDocument.object().value(QLatin1String("Labels")).toObject().value(QLatin1String("org.opencontainers.image.version")).toString();
if (newVersion.isEmpty()) {
qInfo() << "rpm-ostree-backend: Could not get the version from the container labels";
setStatus(Status::DoneWithErrorStatus);
return;
// Check the 'version' label for compatibility with older rpm-ostree releases (< v2024.03)
newVersion = jsonDocument.object().value(QLatin1String("Labels")).toObject().value(QLatin1String("version")).toString();
if (newVersion.isEmpty()) {
qWarning() << "rpm-ostree-backend: Could not get the version from the container labels";
setStatus(Status::DoneWithErrorStatus);
return;
}
}

QVersionNumber newVersionNumber = QVersionNumber::fromString(newVersion);
Expand Down

0 comments on commit 48adb8f

Please sign in to comment.