Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions libs/linglong/src/linglong/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,6 @@ int Cli::run(const RunOptions &options)
opts.cdiDevices = std::move(*autoDetectedCdiDevices);
}

// 调整日志输出,打印扩展列表(用逗号拼接)
std::string extStr =
opts.extensionRefs ? linglong::common::strings::join(*opts.extensionRefs, ',') : "null";
LogD("start resolve run context with base {}, runtime {}, extensions {}",
opts.baseRef.value_or("null"),
opts.runtimeRef.value_or("null"),
extStr);

auto res = runContext.resolve(*curAppRef, opts);
if (!res) {
handleCommonError(res.error());
Expand Down
39 changes: 33 additions & 6 deletions libs/linglong/src/linglong/runtime/run_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,39 @@ utils::error::Result<void> RunContext::resolve(const api::types::v1::RunContextC
if (extLayer.getCachedItem().info.kind != "extension") {
return LINGLONG_ERR("invalid extension kind in config.extensions");
}

api::types::v1::ExtensionDefine extDef;
const auto &targetInfo = targetLayer->get().getCachedItem().info;
const auto *matchedDef = [&]() -> const api::types::v1::ExtensionDefine * {
if (!targetInfo.extensions) {
return nullptr;
}
for (const auto &def : *targetInfo.extensions) {
std::string name = def.name;
auto ext = extension::ExtensionFactory::makeExtension(name);
if (ext->shouldEnable(name) && name == extLayer.getReference().id) {
Comment thread
reddevillg marked this conversation as resolved.
return &def;
}
}
return nullptr;
}();
Comment thread
reddevillg marked this conversation as resolved.

if (matchedDef) {
extDef = *matchedDef;
} else {
LogW("extension {} not found in target layer {}'s extensions, "
"using manual extension define",
extLayer.getReference().toString(),
targetLayer->get().getReference().toString());
auto manualDefs = makeManualExtensionDefine({ extensionRefStr });
if (!manualDefs) {
return LINGLONG_ERR(manualDefs);
}
extDef = std::move(manualDefs->front());
}

extLayer.setExtensionInfo(RuntimeLayer::ExtensionRuntimeLayerInfo{
.extensionInfo =
api::types::v1::ExtensionDefine{
.directory = "/opt/extensions/" + extLayer.getReference().id,
.name = extLayer.getReference().id,
.version = extLayer.getReference().version.toString(),
},
.extensionInfo = std::move(extDef),
.extensionLayer = std::ref(extLayer),
.forRef = targetRefStr,
});
Expand Down Expand Up @@ -545,6 +571,7 @@ utils::error::Result<void> RunContext::resolveLayer(bool depsBinaryOnly,

const auto &extensionOf = ext.getExtensionInfo();
if (!extensionOf) {
LogW("failed getExtensionInfo, skip");
continue;
}

Expand Down
Loading