diff --git a/source/dub/dub.d b/source/dub/dub.d index 59794b7..d2c814e 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -167,7 +167,7 @@ assert(a.pack !is null, "No package specified for removal."); remove(a.pack); } - foreach(Action a; filter!((Action a) => a.type == Action.Type.get)(actions)) { + foreach(Action a; filter!((Action a) => a.type == Action.Type.fetch)(actions)) { fetch(a.packageId, a.vers, a.location, (options & UpdateOptions.Upgrade) != 0); // never update the same package more than once masterVersionUpgrades[a.packageId] = true; diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 88e118d..f20693b 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -139,6 +139,21 @@ return ret; } + /** Determines if a package is managed by DUB. + + Managed packages can be upgraded and uninstalled. + */ + bool isManagedPackage(Package pack) + const { + auto ppath = pack.basePackage.path; + foreach (rep; m_repositories) { + auto rpath = rep.packagePath; + if (ppath.startsWith(rpath)) + return true; + } + return false; + } + int delegate(int delegate(ref Package)) getPackageIterator() { int iterator(int delegate(ref Package) del) diff --git a/source/dub/project.d b/source/dub/project.d index 98751a5..a5b09a2 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -431,7 +431,7 @@ /// Actions which can be performed to update the application. - Action[] determineActions(PackageSupplier[] packageSuppliers, int option) + Action[] determineActions(PackageSupplier[] packageSuppliers, UpdateOptions option) { scope(exit) writeDubJson(); @@ -491,9 +491,10 @@ else logDiagnostic("Triggering retrieval of required package '"~basepkg~"', which doesn't match the required versionh. Required '%s', available '%s'.", d.dependency, p.vers); actions ~= Action.get(basepkg, PlacementLocation.userWide, d.dependency, d.packages); } else { - if( option & UpdateOptions.Upgrade ) { + if (option & UpdateOptions.Upgrade) { + auto existing = m_packageManager.getBestPackage(basepkg, d.dependency); // Only add one upgrade action for each package. - if(basepkg !in upgradePackages) { + if(basepkg !in upgradePackages && m_packageManager.isManagedPackage(existing)) { logDiagnostic("Required package '"~basepkg~"' found with version '"~p.vers~"', upgrading."); upgradePackages[basepkg] = 1; actions ~= Action.get(basepkg, PlacementLocation.userWide, d.dependency, d.packages); @@ -662,7 +663,7 @@ /// Actions to be performed by the dub struct Action { enum Type { - get, + fetch, remove, conflict, failure @@ -679,7 +680,7 @@ static Action get(string pkg, PlacementLocation location, in Dependency dep, Dependency[string] context) { - return Action(Type.get, pkg, location, dep, context); + return Action(Type.fetch, pkg, location, dep, context); } static Action remove(Package pkg, Dependency[string] context)