@@ -1713,27 +1713,13 @@ bool ProjMgrWorker::AddPackRequirements(ContextItem& context, const vector<PackI
17131713 if (!specifiedMetadata.empty ()) {
17141714 m_packMetadata[RteUtils::ExtractPrefix (packageEntry.pack , " +" )] = specifiedMetadata;
17151715 }
1716- // System wide package
1717- vector<string> matchedPackIds = FindMatchingPackIdsInCbuildPack (packageEntry, resolvedPacks);
1718- if (matchedPackIds.size ()) {
1719- // Cbuild pack content matches, so use it
1720- for (const auto & resolvedPackId : matchedPackIds) {
1721- PackageItem package;
1722- package.origin = packageEntry.origin ;
1723- package.selectedBy = packageEntry.pack ;
1724- ProjMgrUtils::ConvertToPackInfo (resolvedPackId, package.pack );
1725- context.userInputToResolvedPackIdMap [packageEntry.pack ].insert (make_pair (resolvedPackId, package));
1726- context.packRequirements .push_back (package);
1727- }
1728- } else {
1729- // Not matching cbuild pack, add it unless a wildcard entry
1730- PackageItem package;
1731- ProjMgrUtils::ConvertToPackInfo (packageEntry.pack , package.pack );
1732- package.selectedBy = packageEntry.pack ;
1733- // Store pack entries in separated vectors for later resolution in the right order
1734- if (!package.pack .name .empty () && !WildCards::IsWildcardPattern (package.pack .name )) {
1735- packEntries[ProjMgrUtils::GetVersionType (package.pack .version )].push_back (packageEntry);
1736- }
1716+ // Store pack entries in separated vectors for later resolution in the right order, unless a wildcard entry
1717+ // TODO: store also the wildcard entries, expanding them but preserving origin and selectedBy for each resolved pack
1718+ PackageItem package;
1719+ ProjMgrUtils::ConvertToPackInfo (packageEntry.pack , package.pack );
1720+ package.selectedBy = packageEntry.pack ;
1721+ if (!package.pack .name .empty () && !WildCards::IsWildcardPattern (package.pack .name )) {
1722+ packEntries[ProjMgrUtils::GetVersionType (package.pack .version )].push_back (packageEntry);
17371723 }
17381724 } else {
17391725 // Project local pack - add as-is
@@ -1762,7 +1748,7 @@ bool ProjMgrWorker::AddPackRequirements(ContextItem& context, const vector<PackI
17621748 for (const auto & versionType : { VersionType::FIXED, VersionType::EQUIVALENT, VersionType::COMPATIBLE,
17631749 VersionType::MINIMUM, VersionType::ANY }) {
17641750 for (const auto & packEntry : packEntries[versionType]) {
1765- ResolvePackRequirement (context, packEntry);
1751+ ResolvePackRequirement (context, packEntry, ignoreCBuildPack );
17661752 }
17671753 }
17681754
@@ -1792,7 +1778,7 @@ bool ProjMgrWorker::AddPackRequirements(ContextItem& context, const vector<PackI
17921778 return true ;
17931779}
17941780
1795- void ProjMgrWorker::ResolvePackRequirement (ContextItem& context, const PackItem& packageEntry) {
1781+ void ProjMgrWorker::ResolvePackRequirement (ContextItem& context, const PackItem& packageEntry, bool ignoreCBuildPack ) {
17961782 // Resolve version range using installed/local packs
17971783 // Reuse already resolved pack when possible
17981784 PackageItem package;
@@ -1815,13 +1801,29 @@ void ProjMgrWorker::ResolvePackRequirement(ContextItem& context, const PackItem&
18151801 {" vendor" , package.pack .vendor },
18161802 {" version" , versionRange}
18171803 });
1818- auto pdsc = m_kernel->GetEffectivePdscFile (attributes);
1804+ auto [packId, _] = m_kernel->GetEffectivePdscFile (attributes);
18191805 // Only remember the version of the pack if we had it installed or local
18201806 // Will be used when serializing the cbuild-pack.yml file later
1821- if (!pdsc. first .empty ()) {
1822- string installedVersion = RtePackage::VersionFromId (pdsc. first );
1807+ if (!packId .empty ()) {
1808+ string installedVersion = RtePackage::VersionFromId (packId );
18231809 package.pack .version = VersionCmp::RemoveVersionMeta (installedVersion);
1824- context.userInputToResolvedPackIdMap [packageEntry.pack ].insert (make_pair (pdsc.first , package));
1810+
1811+ // Check whether the packageEntry is already locked in cbuild-pack
1812+ if (!ignoreCBuildPack) {
1813+ vector<string> locked = FindMatchingPackIdsInCbuildPack (packageEntry, context.csolution ->cbuildPack .packs );
1814+ if (!locked.empty ()) {
1815+ // TODO: When wildcards will be fully stored in cbuild-pack there may be multiple matches
1816+ const auto & lockedId = locked.front ();
1817+ if (lockedId != packId) {
1818+ // Save available version if different from locked
1819+ context.availablePackVersions [lockedId] = package.pack .version ;
1820+ // Keep the locked pack
1821+ packId = lockedId;
1822+ package.pack .version = RtePackage::VersionFromId (lockedId);
1823+ }
1824+ }
1825+ }
1826+ context.userInputToResolvedPackIdMap [packageEntry.pack ].insert (make_pair (packId, package));
18251827 } else {
18261828 // Remember that we had the user input, but it does not match any installed pack
18271829 context.userInputToResolvedPackIdMap [packageEntry.pack ] = {};
@@ -3989,8 +3991,9 @@ bool ProjMgrWorker::ProcessContext(ContextItem& context, bool loadGenFiles, bool
39893991 return ret;
39903992}
39913993
3992- bool ProjMgrWorker::ListPacks (vector<string>&packs, bool bListMissingPacksOnly, const string& filter) {
3994+ bool ProjMgrWorker::ListPacks (vector<string>&packs, bool bListMissingPacksOnly, bool bLocked, const string& filter) {
39933995 map<string, string, RtePackageComparator> packsMap;
3996+ StrMap availablePackVersions;
39943997 list<string> pdscFiles;
39953998 if (!InitializeModel ()) {
39963999 return false ;
@@ -4052,6 +4055,13 @@ bool ProjMgrWorker::ListPacks(vector<string>&packs, bool bListMissingPacksOnly,
40524055 // check if additional dependencies must be added
40534056 CheckMissingPackRequirements (RteUtils::EMPTY_STRING);
40544057 }
4058+ // get available updates for locked packs
4059+ if (bLocked) {
4060+ for (const auto & selectedContext : m_selectedContexts) {
4061+ ContextItem& context = m_contexts[selectedContext];
4062+ availablePackVersions.merge (context.availablePackVersions );
4063+ }
4064+ }
40554065 }
40564066
40574067 if (!m_contextErrMap.empty ()) {
@@ -4066,7 +4076,11 @@ bool ProjMgrWorker::ListPacks(vector<string>&packs, bool bListMissingPacksOnly,
40664076 packsVec.reserve (packsMap.size ());
40674077 for (auto [id, fileName] : packsMap) {
40684078 string s = id;
4069- if (!fileName.empty ()) {
4079+ if (bLocked) {
4080+ if (!availablePackVersions[id].empty ()) {
4081+ s += " (locked) available update " + availablePackVersions[id];
4082+ }
4083+ } else if (!fileName.empty ()) {
40704084 string str = fileName;
40714085 if (m_relativePaths) {
40724086 if (str.find (m_packRoot) == 0 ) {
0 commit comments