diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index b54500ab7..303d0badd 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -1801,31 +1801,32 @@ void ProjMgrWorker::ResolvePackRequirement(ContextItem& context, const PackItem& {"vendor", package.pack.vendor}, {"version", versionRange} }); - auto [packId, _] = m_kernel->GetEffectivePdscFile(attributes); - // Only remember the version of the pack if we had it installed or local - // Will be used when serializing the cbuild-pack.yml file later + auto packId = get<0>(m_kernel->GetEffectivePdscFile(attributes)); + + // Get installed pack version without meta-data if (!packId.empty()) { - string installedVersion = RtePackage::VersionFromId(packId); - package.pack.version = VersionCmp::RemoveVersionMeta(installedVersion); - - // Check whether the packageEntry is already locked in cbuild-pack - if (!ignoreCBuildPack) { - vector locked = FindMatchingPackIdsInCbuildPack(packageEntry, context.csolution->cbuildPack.packs); - if (!locked.empty()) { - // TODO: When wildcards will be fully stored in cbuild-pack there may be multiple matches - const auto& lockedId = locked.front(); - if (lockedId != packId) { - // Save available version if different from locked - context.availablePackVersions[lockedId] = package.pack.version; - // Keep the locked pack - packId = lockedId; - package.pack.version = RtePackage::VersionFromId(lockedId); - } + package.pack.version = VersionCmp::RemoveVersionMeta(RtePackage::VersionFromId(packId)); + } + // Check whether the packageEntry is already locked in cbuild-pack + if (!ignoreCBuildPack) { + vector locked = FindMatchingPackIdsInCbuildPack(packageEntry, context.csolution->cbuildPack.packs); + if (!locked.empty()) { + // TODO: When wildcards will be fully stored in cbuild-pack there may be multiple matches + const auto& lockedId = locked.front(); + if (lockedId != packId) { + // Save available version if different from locked + context.availablePackVersions[lockedId] = package.pack.version; + // Keep the locked pack + packId = lockedId; + package.pack.version = RtePackage::VersionFromId(lockedId); } } + } + if (!packId.empty()) { + // Remember the version of the pack if we had it installed, local or locked in cbuild-pack context.userInputToResolvedPackIdMap[packageEntry.pack].insert(make_pair(packId, package)); } else { - // Remember that we had the user input, but it does not match any installed pack + // Remember that we had the user input, but it does not match any installed nor locked pack context.userInputToResolvedPackIdMap[packageEntry.pack] = {}; } package.origin = packageEntry.origin; diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 883ed5490..9403070b6 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -6672,6 +6672,19 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_pack_version_not_available) { EXPECT_NE(string::npos, errStr.find(errExpected)); } +TEST_F(ProjMgrUnitTests, ListMissingPacks_LockedNotInstalled) { + char* argv[5]; + StdStreamRedirect streamRedirect; + const string& csolution = testinput_folder + "/TestSolution/PackLocking/pack_version_not_available.csolution.yml"; + argv[1] = (char*)"list"; + argv[2] = (char*)"packs"; + argv[3] = (char*)"-m"; + argv[4] = (char*)csolution.c_str(); + EXPECT_EQ(0, RunProjMgr(5, argv, 0)); + auto outStr = streamRedirect.GetOutString(); + EXPECT_EQ("ARM::RteTest_DFP@0.1.0\n", outStr); +} + TEST_F(ProjMgrUnitTests, ReportPacksUnused) { char* argv[5]; const string& csolution = testinput_folder + "/TestSolution/PacksUnused/packs.csolution.yml";